Index: vmcore/src/thread/object_generic.cpp =================================================================== --- vmcore/src/thread/object_generic.cpp £¨revision 442796£© +++ vmcore/src/thread/object_generic.cpp £¨working copy£© @@ -141,6 +141,10 @@ exn_throw(VM_Global_State::loader_env->java_lang_OutOfMemoryError); return NULL; } + +if( gc_requires_barriers()) + gc_heap_wrote_object(result); + memcpy(result, h->object, size); result->set_obj_info(0); ObjectHandle new_handle = oh_allocate_local_handle(); Index: vmcore/src/util/ia32/base/jit_runtime_support_ia32.cpp =================================================================== --- vmcore/src/util/ia32/base/jit_runtime_support_ia32.cpp £¨revision 442796£© +++ vmcore/src/util/ia32/base/jit_runtime_support_ia32.cpp £¨working copy£© @@ -1120,6 +1120,71 @@ } //getaddress__gc_write_barrier_fastcall + +void * getaddress__gc_heap_slot_write_ref_in_lil() +{ + assert(VM_Global_State::loader_env->use_lil_stubs); + static void *addr = NULL; + if (addr != NULL) { + return addr; + } + + LilCodeStub* cs = lil_parse_code_stub( + "entry 0:platform:ref,ref,ref:void; // The args are the element ref to store, the index, and the array to store into\n" + "in2out platform:pint; " + "call %0i;" // vm_rt_aastore either returns NULL or the ClassHandle of an exception to throw \n" + "ret ;", + (void *)gc_heap_slot_write_ref); + assert(lil_is_valid(cs)); + addr = LilCodeGenerator::get_platform()->compile(cs, "gc_write_barrier", dump_stubs); + lil_free_code_stub(cs); + return addr; +}//getaddress__gc_write_barrier + + +void * getaddress__gc_heap_slot_write_ref() +{ + static void *addr = 0; + if (addr) { + return addr; + } + + const int stub_size = 25; + char *stub = (char *)malloc_fixed_code_for_jit(stub_size, DEFAULT_CODE_ALIGNMENT, CODE_BLOCK_HEAT_DEFAULT, CAA_Allocate); +#ifdef _DEBUG + memset(stub, 0xcc /*int 3*/, stub_size); +#endif + char *ss = stub; + + ss = push(ss, M_Base_Opnd(esp_reg,+12)); + ss = push(ss, M_Base_Opnd(esp_reg,+12)); + ss = push(ss, M_Base_Opnd(esp_reg,+12)); + + ss = call(ss, (char *)gc_heap_slot_write_ref); + + ss = alu(ss, add_opc, esp_opnd, Imm_Opnd(12)); + + ss = ret(ss); + + addr = stub; + + assert((ss - stub) < stub_size); + + if (VM_Global_State::loader_env->TI->isEnabled()) + { + jvmti_add_dynamic_generated_code_chunk("getaddress__gc_heap_slot_write_ref", stub, stub_size); + jvmti_send_dynamic_code_generated_event("getaddress__gc_heap_slot_write_ref", stub, stub_size); + } + +#ifndef NDEBUG + if (dump_stubs) + dump(stub, "getaddress__gc_heap_slot_write_ref", ss - stub); +#endif + return addr; +} + + + static int64 __stdcall vm_lrem(int64 m, int64 n) stdcall__; static int64 __stdcall vm_lrem(int64 m, int64 n) @@ -1289,6 +1354,14 @@ case VM_RT_WRITE_BARRIER_FASTCALL: return getaddress__gc_write_barrier_fastcall(); + case VM_RT_GC_HEAP_WRITE_REF: + if(VM_Global_State::loader_env->use_lil_stubs){ + return getaddress__gc_heap_slot_write_ref_in_lil(); + }else{ + return getaddress__gc_heap_slot_write_ref(); + } + + case VM_RT_CHECKCAST: return getaddress__vm_checkcast_naked(); Index: jitrino/src/jet/cg_ia32.cpp =================================================================== --- jitrino/src/jet/cg_ia32.cpp £¨revision 442796£© +++ jitrino/src/jet/cg_ia32.cpp £¨working copy£© @@ -2084,6 +2084,34 @@ pfield.scale(), pfield.disp() + 4); voper(typeInfo[jt].mov, phi, vstack(1)); } + + if(gc_requires_barriers() && jt == jobj) + { + void * helper = vm_get_rt_support_addr(VM_RT_GC_HEAP_WRITE_REF); + gen_mem(MEM_STACK|MEM_VARS|MEM_TO_MEM|MEM_UPDATE); + + int iarg = 0; + for( ; iarg < 2 ; iarg++ ) + { + const JFrame::Slot& s = m_jframe->dip(iarg); + if( s.swapped() ){ + voper(Mnemonic_PUSH,vstack_mem_slot(iarg)); + }else{ + voper(Mnemonic_PUSH,vstack(iarg)); + } + if( iarg == 0 ) + { + EncoderBase::Operand imm_v(OpndSize_32,fld_offset); + voper(Mnemonic_ADD,rref,imm_v); + voper(Mnemonic_PUSH,rref); + } + } + vcall(helper); + + EncoderBase::Operand restore_stack(OpndSize_32,12); + voper(Mnemonic_ADD,RegName_ESP,restore_stack); + } + // vpop(jt); vpop(jobj);