diff options
author | Jonathan Chambers <jonathan@unity3d.com> | 2014-05-16 13:46:54 -0400 |
---|---|---|
committer | Lucas Meijer <lucas@unity3d.com> | 2014-07-03 21:00:46 +0200 |
commit | 7d2905e01d7f9831353e1f034aea3692e71f96fc (patch) | |
tree | 97bb74678ea6aac9eff3a46ac345cd6689b551c1 | |
parent | 6c5a455c722172f0defcfb77aa28b2709a191e7c (diff) | |
download | bdwgc-7d2905e01d7f9831353e1f034aea3692e71f96fc.tar.gz |
Add support for emscripten platform
-rw-r--r-- | alloc.c | 8 | ||||
-rw-r--r-- | include/private/gcconfig.h | 14 | ||||
-rw-r--r-- | mach_dep.c | 5 | ||||
-rw-r--r-- | mark_rts.c | 2 | ||||
-rw-r--r-- | misc.c | 3 |
5 files changed, 30 insertions, 2 deletions
@@ -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" @@ -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 */ @@ -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. */ @@ -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]; |