From: Jonathan Chambers Date: Fri, 16 May 2014 17:46:54 +0000 (-0400) Subject: Add support for emscripten platform X-Git-Tag: gc7_6_0~218^2~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7d2905e01d7f9831353e1f034aea3692e71f96fc;p=gc Add support for emscripten platform --- diff --git a/alloc.c b/alloc.c index 25bb31ea..d8fb954f 100644 --- a/alloc.c +++ b/alloc.c @@ -202,11 +202,15 @@ GC_API GC_stop_func GC_CALL GC_get_stop_func(void) static word min_bytes_allocd(void) { word result; -# ifdef STACK_GROWS_UP +# ifdef __EMSCRIPTEN__ + word stack_size = 0; +# else +# ifdef STACK_GROWS_UP word stack_size = GC_approx_sp() - GC_stackbottom; /* GC_stackbottom is used only for a single-threaded case. */ -# else +# else word stack_size = GC_stackbottom - GC_approx_sp(); +# endif # endif word total_root_size; /* includes double stack size, */ diff --git a/include/private/gcconfig.h b/include/private/gcconfig.h index 7d0fc0df..4eed1842 100644 --- a/include/private/gcconfig.h +++ b/include/private/gcconfig.h @@ -558,6 +558,12 @@ # define mach_type_known # endif +# if defined(__EMSCRIPTEN__) +# define I386 +# define ALIGNMENT 4 +# define mach_type_known +# endif + /* Feel free to add more clauses here */ /* Or manually define the machine type here. A machine type is */ @@ -754,6 +760,14 @@ # define DATAEND NULL # endif +# ifdef __EMSCRIPTEN__ +# define OS_TYPE "EMSCRIPTEN" +# define CPP_WORDSZ 32 +# define ALIGNMENT 4 +# define DATASTART NULL +# define DATAEND NULL +# endif + # define STACK_GRAN 0x1000000 # ifdef M68K # define MACH_TYPE "M68K" diff --git a/mach_dep.c b/mach_dep.c index 9c95e698..a882c76d 100644 --- a/mach_dep.c +++ b/mach_dep.c @@ -181,6 +181,11 @@ } # define HAVE_PUSH_REGS # endif /* __MWERKS__ */ +# elif defined(EMSCRIPTEN) + void GC_push_regs(void) + { + } +# define HAVE_PUSH_REGS # endif /* MACOS */ #endif /* !USE_ASM_PUSH_REGS */ diff --git a/mark_rts.c b/mark_rts.c index a8dc04a2..53341586 100644 --- a/mark_rts.c +++ b/mark_rts.c @@ -810,7 +810,9 @@ GC_INNER void GC_push_roots(GC_bool all, ptr_t cold_gc_frame) * This is usually done by saving the current context on the * stack, and then just tracing from the stack. */ +#ifndef __EMSCRIPTEN__ GC_push_regs_and_stack(cold_gc_frame); +#endif if (GC_push_other_roots != 0) (*GC_push_other_roots)(); /* In the threads case, this also pushes thread stacks. */ diff --git a/misc.c b/misc.c index 68667eef..526eb989 100644 --- a/misc.c +++ b/misc.c @@ -349,6 +349,9 @@ GC_INNER void GC_extend_size_map(size_t i) /* another frame. */ GC_API void * GC_CALL GC_clear_stack(void *arg) { +#ifdef __EMSCRIPTEN__ + return arg; +#endif ptr_t sp = GC_approx_sp(); /* Hotter than actual sp */ # ifdef THREADS word volatile dummy[SMALL_CLEAR_SIZE];