Index: include/open/hythread.h =================================================================== --- include/open/hythread.h (revision 571361) +++ include/open/hythread.h (working copy) @@ -383,6 +383,8 @@ */ void *thread_local_storage[10]; + uint8 gc_required; //wjw + } HyThread_public; Index: vmcore/src/jni/jni.cpp =================================================================== --- vmcore/src/jni/jni.cpp (revision 571361) +++ vmcore/src/jni/jni.cpp (working copy) @@ -506,11 +506,11 @@ // Attaches main thread to TM. { - IDATA jtstatus = jthread_attach(jni_env, java_thread, daemon); - if (jtstatus != TM_ERROR_NONE) { - status = JNI_ERR; - goto done; - } + //wjw IDATA jtstatus = jthread_attach(jni_env, java_thread, daemon); + // if (jtstatus != TM_ERROR_NONE) { + // status = JNI_ERR; + // goto done; + // } } assert(jthread_self() != NULL); *p_jni_env = jni_env; @@ -1463,8 +1463,8 @@ status = vm_attach_internal(&jni_env, &java_thread, java_vm, NULL, name, daemon); if (status != JNI_OK) return status; - IDATA jtstatus = jthread_attach(jni_env, java_thread, daemon); - if (jtstatus != TM_ERROR_NONE) return JNI_ERR; + ///wjw IDATA jtstatus = jthread_attach(jni_env, java_thread, daemon); + ///wjw if (jtstatus != TM_ERROR_NONE) return JNI_ERR; // Now JVMTIThread keeps global reference. Discared temporary global reference. jni_env->DeleteGlobalRef(java_thread); @@ -1526,7 +1526,7 @@ *p_jni_env = jni_env; // Attaches current thread to TM. - status = jthread_attach(jni_env, java_thread, daemon); + //wjw status = jthread_attach(jni_env, java_thread, daemon); assert(jthread_self() != NULL); // Now JVMTIThread keeps global reference. Discared temporary global reference. Index: vmcore/src/gc/stop_the_world_root_set_enum.cpp =================================================================== --- vmcore/src/gc/stop_the_world_root_set_enum.cpp (revision 571361) +++ vmcore/src/gc/stop_the_world_root_set_enum.cpp (working copy) @@ -107,7 +107,7 @@ VM_thread *thread = get_vm_thread(tm_thread); //assert(thread); if (thread && thread != current_vm_thread) { - vm_enumerate_thread(thread); + if ( ((HyThread_public*)tm_thread)->gc_required) vm_enumerate_thread(thread); // Enumeration for this thread is complete. //thread->gc_status = gc_enumeration_done; //assert(thread->gc_status==gc_enumeration_done); @@ -115,9 +115,9 @@ } tm_thread = hythread_iterator_next(&iterator); } + HyThread_public * self = (HyThread_public *)hythread_self(); //wjw + if (self->gc_required) vm_enumerate_the_current_thread(current_vm_thread); - vm_enumerate_the_current_thread(current_vm_thread); - // finally, process all the global refs vm_enumerate_root_set_global_refs(); Index: vmcore/src/init/parse_arguments.cpp =================================================================== --- vmcore/src/init/parse_arguments.cpp (revision 571361) +++ vmcore/src/init/parse_arguments.cpp (working copy) @@ -236,8 +236,10 @@ #endif } else if (strcmp(option, "-version") == 0) { // Print the version number and exit - LECHO_VERSION; - LOGGER_EXIT(0); + //LECHO_VERSION; + //LOGGER_EXIT(0); + __asm {int 3} ; //wjw + } else if (strcmp(option, "-showversion") == 0) { if (!version_printed) { // Print the version number and continue Index: vmcore/src/init/vm_init.cpp =================================================================== --- vmcore/src/init/vm_init.cpp (revision 571361) +++ vmcore/src/init/vm_init.cpp (working copy) @@ -22,6 +22,7 @@ #include #include #include +#include #include "port_dso.h" #include "open/gc.h" @@ -543,6 +544,7 @@ // Allocate new j.l.Thread object. thread_handle = oh_allocate_global_handle(); thread_handle->object = class_alloc_new_object(thread_class); + if (thread_handle->object == NULL) { assert(!hythread_is_suspend_enabled()); assert(exn_raised() && p_TLS_vmthread->thread_exception.exc_object == vm_env->java_lang_OutOfMemoryError->object); @@ -550,6 +552,14 @@ } *thread_object = thread_handle; + //wjw + // IDATA jthread_attach(JNIEnv *jni_env, jthread java_thread, jboolean daemon) + hythread_suspend_enable(); + IDATA jtstatus = jthread_attach(jni_env, thread_handle, daemon); + hythread_suspend_disable(); + if (jtstatus != TM_ERROR_NONE) return JNI_ERR; + //wjw + if (constructor == NULL) { // Initialize created thread object. constructor = thread_class->lookup_method(vm_env->Init_String, @@ -576,6 +586,8 @@ args[5].i = (jint)hythread_get_priority(native_thread); args[6].z = daemon; + ((HyThread_public *)native_thread)->gc_required = 1; /*true*/ //wjw + vm_execute_java_method_array((jmethodID) constructor, 0, args); if (exn_raised()) { TRACE("Failed to initialize new thread object, exception = " << exn_get_name()); Index: vmcore/src/thread/thread_java_basic.cpp =================================================================== --- vmcore/src/thread/thread_java_basic.cpp (revision 571474) +++ vmcore/src/thread/thread_java_basic.cpp (working copy) @@ -84,6 +84,8 @@ jvmti_send_thread_start_end_event(1); jthread_start_count(); + ((HyThread_public *)native_thread)->gc_required = 1; /*true*/ //wjw + if (data.proc != NULL) { data.proc(data.jvmti_env, jni_env, (void*)data.arg); } else { Index: thread/src/thread_private.h =================================================================== --- thread/src/thread_private.h (revision 571361) +++ thread/src/thread_private.h (working copy) @@ -163,7 +163,9 @@ */ void *thread_local_storage[10]; + uint8 gc_required; //wjw + // Private fields /** Index: thread/src/thread_native_basic.c =================================================================== --- thread/src/thread_native_basic.c (revision 571474) +++ thread/src/thread_native_basic.c (working copy) @@ -271,6 +271,7 @@ // No actions required in case the specified thread is detached already. if (thread->group != NULL) { + ((HyThread *)thread)->gc_required = 0; //wjw // The thread can be detached from the other thread in case // of forceful termination by hythread_cancel(), but thread // local storage can be zeroed only for current thread. @@ -541,6 +542,9 @@ assert(thread == tm_self_tls); thread->state |= TM_THREAD_STATE_ALIVE | TM_THREAD_STATE_RUNNABLE; + + // wjw this will be set to true just before the very first java method is called + thread->gc_required = 0 /*false*/ ; if (!thread->thread_id) { U_32 i;