diff -u'rNF^function' gcv5_r0.10/src/common/gc_for_vm.cpp gc/src/common/gc_for_vm.cpp --- gcv5_r0.10/src/common/gc_for_vm.cpp 2006-10-05 22:08:58.000000000 +0800 +++ gc/src/common/gc_for_vm.cpp 2006-10-08 15:56:56.185872400 +0800 @@ -27,7 +27,7 @@ void gc_init() { assert(p_global_gc == NULL); - GC* gc = (GC*)STD_MALLOC(sizeof(GC)); + GC* gc = (GC*)STD_MALLOC(sizeof(GC_Gen)); assert(gc); memset(gc, 0, sizeof(GC)); p_global_gc = gc; diff -u'rNF^function' gcv5_r0.10/src/common/gc_platform.h gc/src/common/gc_platform.h --- gcv5_r0.10/src/common/gc_platform.h 2006-10-05 22:13:58.000000000 +0800 +++ gc/src/common/gc_platform.h 2006-10-08 15:42:04.405771600 +0800 @@ -22,11 +22,48 @@ #define _GC_PLATFORM_H_ -#include -#include +#include +#include + +#include #define USEC_PER_SEC INT64_C(1000000) +#define VmThreadHandle (void*) +#define VmEventHandle hysem_t +#define THREAD_OK TM_ERROR_NONE + +inline int vm_wait_event(VmEventHandle event) +{ IDATA stat = hysem_wait(event); + assert(stat == TM_ERROR_NONE); return stat; +} + +inline int vm_set_event(VmEventHandle event) +{ IDATA stat = hysem_post(event); + assert(stat == TM_ERROR_NONE); return stat; +} + +inline int vm_reset_event(VmEventHandle event) +{ IDATA stat = hysem_set(event,0); + assert(stat == TM_ERROR_NONE); return stat; +} + +inline int vm_create_event(VmEventHandle* event, unsigned int initial_count, unsigned int max_count) +{ + return hysem_create(event, initial_count, max_count); +} + +inline void vm_thread_yield() +{ + hythread_yield(); +} + +inline int vm_create_thread(void* ret_thread, unsigned int stacksize, unsigned int priority, unsigned int suspend, int (*func)(void*), void *data) +{ + return hythread_create((hythread_t*)ret_thread, (UDATA)stacksize, (UDATA)priority, (UDATA)suspend, + (hythread_entrypoint_t)func, data); +} + inline void *atomic_casptr(volatile void **mem, void *with, const void *cmp) { return apr_atomic_casptr(mem, with, cmp); } diff -u'rNF^function' gcv5_r0.10/src/thread/collector.cpp gc/src/thread/collector.cpp --- gcv5_r0.10/src/thread/collector.cpp 2006-10-06 10:46:36.000000000 +0800 +++ gc/src/thread/collector.cpp 2006-10-08 15:44:25.952128000 +0800 @@ -37,8 +37,7 @@ static void wait_collector_to_finish(Collector *collector) { - int wstat = vm_wait_for_single_object(collector->task_finished_event, INFINITE); - assert(wstat != WAIT_FAILED); + vm_wait_event(collector->task_finished_event); } static void notify_collector_to_work(Collector* collector) @@ -48,8 +47,7 @@ static void collector_wait_for_task(Collector *collector) { - int wstat = vm_wait_for_single_object(collector->task_assigned_event, INFINITE); - assert(wstat != WAIT_FAILED); + vm_wait_event(collector->task_assigned_event); } static void collector_notify_work_done(Collector *collector) @@ -89,7 +87,7 @@ } -static unsigned int __stdcall collector_thread_func(void *arg) +static int collector_thread_func(void *arg) { Collector *collector = (Collector *)arg; assert(collector); @@ -123,22 +121,18 @@ collector->this_cycle_remset->reserve(GC_NUM_ROOTS_HINT); collector->this_cycle_remset->clear(); - collector->task_assigned_event = vm_create_event(NULL,FALSE,FALSE,NULL); - assert(collector->task_assigned_event); - vm_reset_event(collector->task_assigned_event); - - collector->task_finished_event = vm_create_event(NULL,FALSE,FALSE,NULL); - assert(collector->task_finished_event); - vm_reset_event(collector->task_finished_event); + int status = vm_create_event(&collector->task_assigned_event,0,1); + assert(status == THREAD_OK); - collector->thread_handle = vm_beginthreadex(NULL, - 0, + status = vm_create_event(&collector->task_finished_event,0,1); + assert(status == THREAD_OK); + + status = (unsigned int)vm_create_thread(NULL, + 0, 0, 0, collector_thread_func, - (LPVOID) collector, - 0, - NULL); + (void*)collector); - assert(collector->thread_handle); + assert(status == THREAD_OK); return; } @@ -147,7 +141,7 @@ { collector->task_func = NULL; /* NULL to notify thread exit */ notify_collector_to_work(collector); - vm_yield(); /* give collector time to die */ + vm_thread_yield(); /* give collector time to die */ delete collector->trace_stack; delete collector->last_cycle_remset;