Index: vm/vmcore/src/lil/em64t/m2n_em64t.cpp =================================================================== --- vm/vmcore/src/lil/em64t/m2n_em64t.cpp (revision 638937) +++ vm/vmcore/src/lil/em64t/m2n_em64t.cpp (working copy) @@ -323,9 +323,10 @@ buf = m2n_gen_ts_to_register(buf, &rax_opnd, num_callee_saves, LcgEM64TContext::MAX_GR_LOCALS, num_std_need_to_save, 0); - + // shift to the last_m2n_frame field - int32 last_m2n_frame_offset = (int32)(int64)&((VM_thread*)0)->last_m2n_frame; + VM_thread* zero_vmthread = NULL; // For field offset calculation + int32 last_m2n_frame_offset = (int32)(int64)&zero_vmthread->last_m2n_frame; buf = alu(buf, add_opc, rax_opnd, Imm_Opnd(size_32, last_m2n_frame_offset), size_64); // store pointer to pointer to last m2n frame bytes_to_m2n_top -= LcgEM64TContext::GR_SIZE; Index: vm/vmcore/src/lil/ia32/m2n_ia32.cpp =================================================================== --- vm/vmcore/src/lil/ia32/m2n_ia32.cpp (revision 638937) +++ vm/vmcore/src/lil/ia32/m2n_ia32.cpp (working copy) @@ -208,8 +208,9 @@ //MVM APN 20050513 work with frame_type set up current_frame_type to NULL //int frame_type_offset = (int)&((VM_thread*)0)->current_frame_type; buf = push(buf, Imm_Opnd(current_frame_type)); - - int last_m2n_frame_offset = (int)&((VM_thread*)0)->last_m2n_frame; + + VM_thread* zero_vmthread = NULL; // For field offset calculation + int last_m2n_frame_offset = (int)&zero_vmthread->last_m2n_frame; Imm_Opnd imm1(last_m2n_frame_offset); buf = alu(buf, add_opc, eax_opnd, imm1); Index: vm/vmcore/src/lil/ipf/m2n_ipf.cpp =================================================================== --- vm/vmcore/src/lil/ipf/m2n_ipf.cpp (revision 638937) +++ vm/vmcore/src/lil/ipf/m2n_ipf.cpp (working copy) @@ -323,7 +323,8 @@ emitter->ipf_mtap(AR_rsc, OLD_RSE_MODE); // Link M2nFrame into list of current thread - size_t offset_lm2nf = (size_t)&((VM_thread*)0)->last_m2n_frame; + VM_thread* zero_vmthread = NULL; // For field offset calculation + size_t offset_lm2nf = (size_t)&zero_vmthread->last_m2n_frame; emitter->ipf_adds(SCRATCH_GENERAL_REG2, (int)offset_lm2nf, THREAD_PTR_REG); emitter->ipf_ld(int_mem_size_8, mem_ld_none, mem_none, M2N_SAVED_M2NFL, SCRATCH_GENERAL_REG2); emitter->ipf_mfap(SCRATCH_GENERAL_REG7, AR_bsp); @@ -403,7 +404,8 @@ } // Unlink the M2nFrame from the list of the current thread - size_t offset_lm2nf = (size_t)&((VM_thread*)0)->last_m2n_frame; + VM_thread* zero_vmthread = NULL; // For field offset calculation + size_t offset_lm2nf = (size_t)&zero_vmthread->last_m2n_frame; emitter->ipf_adds(SCRATCH_GENERAL_REG2, (int)offset_lm2nf, THREAD_PTR_REG); emitter->ipf_st(int_mem_size_8, mem_st_none, mem_none, SCRATCH_GENERAL_REG2, M2N_SAVED_M2NFL); Index: vm/vmcore/src/jit/jit_runtime_support.cpp =================================================================== --- vm/vmcore/src/jit/jit_runtime_support.cpp (revision 638937) +++ vm/vmcore/src/jit/jit_runtime_support.cpp (working copy) @@ -747,6 +747,7 @@ static NativeCodePtr rth_get_lil_initialize_class(int* dyn_count) { static NativeCodePtr addr = NULL; + VM_thread* zero_vmthread = NULL; // For field offset calculation if (!addr) { POINTER_SIZE_INT (*p_is_inited)(Class*) = is_class_initialized; @@ -781,8 +782,8 @@ "out platform::void;" "call.noret %5i;", p_is_inited, (POINTER_SIZE_INT)(FRAME_JNI | FRAME_POPABLE), p_init, - OFFSET(VM_thread, thread_exception.exc_object), - OFFSET(VM_thread, thread_exception.exc_class), + &zero_vmthread->thread_exception.exc_object, + &zero_vmthread->thread_exception.exc_class, p_rethrow); assert(cs && lil_is_valid(cs)); addr = LilCodeGenerator::get_platform()->compile(cs); @@ -2766,6 +2767,8 @@ */ VMEXPORT void * vm_create_helper_for_function(void* (*fptr)(void*)) { + VM_thread* zero_vmthread = NULL; // For field offset calculation + static const char * lil_stub = "entry 0:stdcall:pint:pint;" // the single argument is 'void*' "push_m2n 0, %0i;" // create m2n frame @@ -2796,8 +2799,8 @@ LilCodeStub* cs = lil_parse_code_stub( lil_stub, (FRAME_COMPILATION | FRAME_POPABLE), fptr_suspend_enable, (void*)fptr, fptr_suspend_disable, - OFFSET(VM_thread, thread_exception.exc_object), - OFFSET(VM_thread, thread_exception.exc_class), + &zero_vmthread->thread_exception.exc_object, + &zero_vmthread->thread_exception.exc_class, fptr_rethrow); assert(lil_is_valid(cs)); void * addr = LilCodeGenerator::get_platform()->compile(cs); Index: vm/vmcore/src/jit/compile.cpp =================================================================== --- vm/vmcore/src/jit/compile.cpp (revision 638937) +++ vm/vmcore/src/jit/compile.cpp (working copy) @@ -326,6 +326,8 @@ //***** Part 5: Set up arguments + VM_thread* zero_vmthread = NULL; // For field offset calculation + // Setup outputs, set JNIEnv, set class/this handle cs = lil_parse_onto_end(cs, "out jni:%0j;" @@ -333,7 +335,7 @@ "ld o0,[l1 + %1i:pint];" "o1=l0+%2i;", method, - (POINTER_SIZE_INT)APR_OFFSETOF(VM_thread, jni_env), + (POINTER_SIZE_INT)&zero_vmthread->jni_env, oh_get_handle_offset(0)); assert(cs); @@ -416,8 +418,8 @@ assert(cs); // Exception offsets - POINTER_SIZE_INT eoo = (POINTER_SIZE_INT)&((VM_thread*)0)->thread_exception.exc_object; - POINTER_SIZE_INT eco = (POINTER_SIZE_INT)&((VM_thread*)0)->thread_exception.exc_class; + POINTER_SIZE_INT eoo = (POINTER_SIZE_INT)&zero_vmthread->thread_exception.exc_object; + POINTER_SIZE_INT eco = (POINTER_SIZE_INT)&zero_vmthread->thread_exception.exc_class; //***** Call JVMTI MethodExit if (ti->isEnabled() && Index: vm/vmcore/src/thread/thread_manager.cpp =================================================================== --- vm/vmcore/src/thread/thread_manager.cpp (revision 638937) +++ vm/vmcore/src/thread/thread_manager.cpp (working copy) @@ -106,8 +106,9 @@ suspend_lock->_unlock(); // zero VM_thread structure + VM_thread* zero_vmthread = NULL; memset(&vm_thread->java_thread, 0, - sizeof(VM_thread) - offsetof(VM_thread, java_thread)); + sizeof(VM_thread) - (size_t)&zero_vmthread->java_thread); } vm_thread_t jthread_get_vm_thread_ptr_safe(jobject thread_obj) Index: vm/vmcore/src/util/em64t/base/jit_runtime_support_em64t.cpp =================================================================== --- vm/vmcore/src/util/em64t/base/jit_runtime_support_em64t.cpp (revision 638937) +++ vm/vmcore/src/util/em64t/base/jit_runtime_support_em64t.cpp (working copy) @@ -50,7 +50,8 @@ */ static LilCodeStub * rth_get_lil_new_generic(LilCodeStub * cs, void * fast_alloc, void * slow_alloc) { - POINTER_SIZE_INT ts_gc_offset = APR_OFFSETOF(VM_thread, _gc_private_information); + VM_thread* zero_vmthread = NULL; // For field offset calculation + POINTER_SIZE_INT ts_gc_offset = (POINTER_SIZE_INT)&zero_vmthread->_gc_private_information; return lil_parse_onto_end(cs, "locals 1;" Index: vm/vmcore/src/util/ia32/base/jit_runtime_support_ia32.cpp =================================================================== --- vm/vmcore/src/util/ia32/base/jit_runtime_support_ia32.cpp (revision 638937) +++ vm/vmcore/src/util/ia32/base/jit_runtime_support_ia32.cpp (working copy) @@ -230,6 +230,8 @@ return addr; } + VM_thread* zero_vmthread = NULL; // For field offset calculation + if (VM_Global_State::loader_env->use_lil_stubs) { LilCodeStub* cs = lil_parse_code_stub( "entry 0:stdcall:pint:void; // The single argument is a Class_Handle \n" @@ -255,8 +257,8 @@ (void *)is_class_initialized, (FRAME_JNI | FRAME_POPABLE), (void *)class_initialize, - APR_OFFSETOF(VM_thread, thread_exception.exc_object), - APR_OFFSETOF(VM_thread, thread_exception.exc_class), + &zero_vmthread->thread_exception.exc_object, + &zero_vmthread->thread_exception.exc_class, (void*)exn_rethrow); assert(lil_is_valid(cs)); addr = LilCodeGenerator::get_platform()->compile(cs);