diff --git a/Makefile b/Makefile index 50dfb4d27..1baad9215 100644 --- a/Makefile +++ b/Makefile @@ -29,7 +29,11 @@ STD = src/std/array.o src/std/buffer.o src/std/bytes.o src/std/cast.o src/std/da src/std/socket.o src/std/string.o src/std/sys.o src/std/types.o src/std/ucs2.o src/std/thread.o src/std/process.o \ src/std/track.o -HL = src/code.o src/jit.o src/main.o src/module.o src/debugger.o src/profile.o +HL_COMMON = src/code.o src/jit.o src/module.o src/debugger.o src/profile.o + +HL = src/main.o $(HL_COMMON) + +LIBHL_JIT = $(HL_COMMON) FMT = libs/fmt/fmt.o libs/fmt/sha1.o include/mikktspace/mikktspace.o libs/fmt/mikkt.o libs/fmt/dxt.o @@ -133,6 +137,9 @@ libs: $(LIBS) libhl: ${LIB} ${CC} -o libhl.$(LIBEXT) -m${MARCH} ${LIBFLAGS} -shared ${LIB} -lpthread -lm +libhl-jit: ${LIBHL_JIT} libhl + ${CC} -o libhl-jit.$(LIBEXT) -m${MARCH} ${LIBFLAGS} -shared ${LIBHL_JIT} ${LFLAGS} ${HLFLAGS} + hlc: ${BOOT} ${CC} ${CFLAGS} -o hlc ${BOOT} ${LFLAGS} ${EXTRA_LFLAGS} @@ -224,9 +231,9 @@ codesign_osx: ${CC} ${CFLAGS} -o $@ -c $< clean_o: - rm -f ${STD} ${BOOT} ${RUNTIME} ${PCRE} ${HL} ${FMT} ${SDL} ${SSL} ${OPENAL} ${UI} ${UV} ${HL_DEBUG} + rm -f ${STD} ${BOOT} ${RUNTIME} ${PCRE} ${HL} ${LIBHL_JIT} ${FMT} ${SDL} ${SSL} ${OPENAL} ${UI} ${UV} ${HL_DEBUG} clean: clean_o - rm -f hl hl.exe libhl.$(LIBEXT) *.hdll + rm -f hl hl.exe libhl-jit.$(LIBEXT) libhl.$(LIBEXT) *.hdll -.PHONY: libhl hl hlc fmt sdl libs release +.PHONY: libhl libhl-jit hl hlc fmt sdl libs release diff --git a/src/gc.c b/src/gc.c index 9be3613da..b84112332 100644 --- a/src/gc.c +++ b/src/gc.c @@ -325,6 +325,15 @@ HL_API void hl_unregister_thread() { hl_mutex_release(gc_threads.global_lock); } +/** + * When the calling language doesn't have a C-style stack + * that is scannable for GC references, this method can be called to + * reset the GC thread top to something C can understand. + */ +HL_API void hl_enter_thread_stack( int dummy ) { + current_thread->stack_top = &dummy; +} + HL_API void *hl_gc_threads_info() { return &gc_threads; } diff --git a/src/hl.h b/src/hl.h index 05e92cbb4..87c60e961 100644 --- a/src/hl.h +++ b/src/hl.h @@ -584,6 +584,8 @@ HL_API char *hl_to_utf8( const uchar *bytes ); HL_API uchar *hl_to_utf16( const char *str ); HL_API vdynamic *hl_virtual_make_value( vvirtual *v ); HL_API hl_obj_field *hl_obj_field_fetch( hl_type *t, int fid ); +HL_API hl_field_lookup *hl_obj_resolve_field( hl_type_obj *o, int hfield ); +HL_API void *hl_obj_lookup( vdynamic *d, int hfield, hl_type **t ); HL_API int hl_hash( vbyte *name ); HL_API int hl_hash_utf8( const char *str ); // no cache @@ -681,6 +683,7 @@ HL_API hl_thread *hl_thread_current( void ); HL_API void hl_thread_yield(void); HL_API void hl_register_thread( void *stack_top ); HL_API void hl_unregister_thread( void ); +HL_API void hl_enter_thread_stack( int dummy ); HL_API hl_mutex *hl_mutex_alloc( bool gc_thread ); HL_API void hl_mutex_acquire( hl_mutex *l ); diff --git a/src/std/obj.c b/src/std/obj.c index f611c6301..094fdf4c4 100644 --- a/src/std/obj.c +++ b/src/std/obj.c @@ -71,6 +71,10 @@ static hl_field_lookup *obj_resolve_field( hl_type_obj *o, int hfield ) { return NULL; } +HL_PRIM hl_field_lookup *hl_obj_resolve_field( hl_type_obj *o, int hfield ) { + return obj_resolve_field(o, hfield); +} + static int hl_cache_count = 0; static int hl_cache_size = 0; static hl_mutex *hl_cache_lock = NULL; @@ -739,7 +743,7 @@ static hl_field_lookup *hl_dynobj_add_field( vdynobj *o, int hfield, hl_type *t // -------------------- DYNAMIC GET ------------------------------------ -static void *hl_obj_lookup( vdynamic *d, int hfield, hl_type **t ) { +HL_API void *hl_obj_lookup( vdynamic *d, int hfield, hl_type **t ) { switch( d->t->kind ) { case HDYNOBJ: {