Index: vm/include/jit_import.h =================================================================== --- vm/include/jit_import.h (revision 614816) +++ vm/include/jit_import.h (working copy) @@ -533,12 +533,7 @@ /** * @return The address where the interned version of the string - * is stored. - * - * Calling class_get_const_string_intern_addr has - * a side-effect of interning the string, so that the JIT can - * load a reference to the interned string without checking if - * it is null. + * is stored or NULL if string isn't interned yet. */ VMEXPORT void *class_get_const_string_intern_addr(Class_Handle ch, unsigned idx); @@ -549,9 +544,14 @@ * The idx parameter is interpreted as a constant pool index for JVM. */ - VMEXPORT VM_Data_Type class_get_const_type(Class_Handle ch, unsigned idx); +VMEXPORT VM_Data_Type class_get_const_type(Class_Handle ch, unsigned idx); /** + * @return address of java.lang.Class handle for the specified class. + */ +VMEXPORT void * class_get_class_handle(Class_Handle cl); + +/** * @return The signature for field or (interface) method in constant pool entry. * The cp_index parameter is interpreted as a constant pool index * for JVM. @@ -576,7 +576,7 @@ * The idx parameter is interpreted as a constant pool index for JVM. * This function shouldn't be called for constant strings. Instead, either:
* */ Index: vm/include/jit_runtime_support.h =================================================================== --- vm/include/jit_runtime_support.h (revision 614816) +++ vm/include/jit_runtime_support.h (working copy) @@ -90,7 +90,7 @@ * Create a multidimensional Java array. */ - VM_RT_LDC_STRING=103, + VM_RT_LDC_REF=103, /** * @param The parameters are the following: * \arg Class handle of the class owning the const pool Index: vm/jitrino/config/em64t/opt.emconf =================================================================== --- vm/jitrino/config/em64t/opt.emconf (revision 614816) +++ vm/jitrino/config/em64t/opt.emconf (working copy) @@ -24,7 +24,7 @@ -XX:jit.CS_OPT.path=opt_init,translator,optimizer,hir2lir,codegen --XX:jit.CS_OPT.path.optimizer=ssa,devirt,hlo_api_magic,inline,purge,osr_path-,escape_path,dce,uce,memopt,simplify,dce,uce,lower,dessa,statprof +-XX:jit.CS_OPT.path.optimizer=ssa,devirt,hlo_api_magic,inline,purge,osr_path-,escape_path,dce,uce,inline_helpers,purge,simplify,uce,dce,uce,memopt,lower,dce,uce,dessa,statprof -XX:jit.CS_OPT.path.osr_path=simplify,dce,uce,gcm,osr -XX:jit.CS_OPT.path.escape_path=hvn,simplify,dce,uce,escape -XX:jit.CS_OPT.path.codegen=lock_method,bbp,gcpoints,cafl,dce1,i8l-,api_magic,early_prop-,itrace-,native,constraints,dce2,regalloc,spillgen,layout,copy,rce-,stack,break-,iprof-,emitter!,si_insts,gcmap,info,unlock_method @@ -39,7 +39,14 @@ -XX:jit.CS_OPT.CS_OPT_inliner_pipeline.path=ssa,devirt,hlo_api_magic -XX:jit.CS_OPT.arg.optimizer.inline.pipeline=CS_OPT_inliner_pipeline +#helper inliner configuration +-XX:jit.CS_OPT.CS_OPT_helper_inliner_pipeline.filter=- +-XX:jit.CS_OPT.CS_OPT_helper_inliner_pipeline.path=ssa,simplify,dce,uce +-XX:jit.CS_OPT.arg.optimizer.inline_helpers.pipeline=CS_OPT_helper_inliner_pipeline +-XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_LDC_REF=on +-XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_LDC_REF_hotnessPercent=0.5 + -XX:jit.CS_OPT.arg.codegen.dce1.early=yes -XX:jit.CS_OPT.arg.codegen.regalloc.bp_regalloc1.regs=ALL_GP -XX:jit.CS_OPT.arg.codegen.regalloc.bp_regalloc2.regs=ALL_XMM Index: vm/jitrino/config/em64t/server.emconf =================================================================== --- vm/jitrino/config/em64t/server.emconf (revision 614816) +++ vm/jitrino/config/em64t/server.emconf (working copy) @@ -107,7 +107,7 @@ #helper inliner configuration -XX:jit.SD2_OPT.SD2_OPT_helper_inliner_pipeline.filter=- --XX:jit.SD2_OPT.SD2_OPT_helper_inliner_pipeline.path=ssa +-XX:jit.SD2_OPT.SD2_OPT_helper_inliner_pipeline.path=ssa,simplify,dce,uce -XX:jit.SD2_OPT.arg.optimizer.inline_helpers.pipeline=SD2_OPT_helper_inliner_pipeline -XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_NEW_RESOLVED_USING_VTABLE_AND_SIZE=off @@ -131,6 +131,9 @@ -XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_INSTANCEOF=off -XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_INSTANCEOF_hotnessPercent=1 +-XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_LDC_REF=on +-XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_LDC_REF_hotnessPercent=0.5 + -XX:jit.SD2_OPT.arg.codegen.dce1.early=yes -XX:jit.arg.codegen.emitter.align=0 Index: vm/jitrino/config/em64t/server_static.emconf =================================================================== --- vm/jitrino/config/em64t/server_static.emconf (revision 614816) +++ vm/jitrino/config/em64t/server_static.emconf (working copy) @@ -62,7 +62,7 @@ #helper inliner configuration -XX:jit.SS_OPT.SS_OPT_helper_inliner_pipeline.filter=- --XX:jit.SS_OPT.SS_OPT_helper_inliner_pipeline.path=ssa +-XX:jit.SS_OPT.SS_OPT_helper_inliner_pipeline.path=ssa,simplify,dce,uce -XX:jit.SS_OPT.arg.optimizer.inline_helpers.pipeline=SS_OPT_helper_inliner_pipeline -XX:jit.SS_OPT.arg.optimizer.inline_helpers.VM_RT_NEW_RESOLVED_USING_VTABLE_AND_SIZE=off @@ -86,6 +86,9 @@ -XX:jit.SS_OPT.arg.optimizer.inline_helpers.VM_RT_INSTANCEOF=off -XX:jit.SS_OPT.arg.optimizer.inline_helpers.VM_RT_INSTANCEOF_hotnessPercent=1 +-XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_LDC_REF=on +-XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_LDC_REF_hotnessPercent=0.5 + -XX:jit.SS_OPT.arg.codegen.dce1.early=yes -XX:jit.arg.codegen.emitter.align=0 Index: vm/jitrino/config/ia32/opt.emconf =================================================================== --- vm/jitrino/config/ia32/opt.emconf (revision 614816) +++ vm/jitrino/config/ia32/opt.emconf (working copy) @@ -24,7 +24,7 @@ -XX:jit.CS_OPT.path=opt_init,lock_method,translator,optimizer,hir2lir,codegen,unlock_method --XX:jit.CS_OPT.path.optimizer=ssa,devirt,hlo_api_magic,inline,purge,osr_path-,simplify,dce,uce,lazyexc,throwopt,escape_path,dce,uce,memopt,simplify,dce,uce,lower,statprof,unroll,ssa,simplify,dce,uce,dessa,statprof +-XX:jit.CS_OPT.path.optimizer=ssa,devirt,hlo_api_magic,inline,purge,osr_path-,simplify,dce,uce,lazyexc,throwopt,escape_path,dce,uce,inline_helpers,purge,simplify,uce,dce,uce,memopt,lower,dce,uce,statprof,unroll,ssa,simplify,dce,uce,dessa,statprof -XX:jit.CS_OPT.path.osr_path=simplify,dce,uce,gcm,osr -XX:jit.CS_OPT.path.escape_path=hvn,simplify,dce,uce,escape -XX:jit.CS_OPT.path.codegen=bbp,btr,gcpoints,cafl,dce1,i8l,api_magic,early_prop,peephole,itrace-,native,constraints,dce2,regalloc,spillgen,copy,i586,layout,rce+,stack,break-,iprof-,peephole,emitter!,si_insts,gcmap,info @@ -39,7 +39,15 @@ -XX:jit.CS_OPT.CS_OPT_inliner_pipeline.path=ssa,devirt,hlo_api_magic -XX:jit.CS_OPT.arg.optimizer.inline.pipeline=CS_OPT_inliner_pipeline +#helper inliner configuration +-XX:jit.CS_OPT.CS_OPT_helper_inliner_pipeline.filter=- +-XX:jit.CS_OPT.CS_OPT_helper_inliner_pipeline.path=ssa,simplify,dce,uce +-XX:jit.CS_OPT.arg.optimizer.inline_helpers.pipeline=CS_OPT_helper_inliner_pipeline +-XX:jit.CS_OPT.arg.optimizer.inline_helpers.VM_RT_LDC_REF=on +-XX:jit.CS_OPT.arg.optimizer.inline_helpers.VM_RT_LDC_REF_hotnessPercent=0.5 + + -XX:jit.CS_OPT.arg.codegen.dce1.early=yes -XX:jit.CS_OPT.arg.codegen.regalloc.bp_regalloc1.regs=ALL_GP -XX:jit.CS_OPT.arg.codegen.regalloc.bp_regalloc2.regs=ALL_XMM Index: vm/jitrino/config/ia32/server.emconf =================================================================== --- vm/jitrino/config/ia32/server.emconf (revision 614816) +++ vm/jitrino/config/ia32/server.emconf (working copy) @@ -109,7 +109,7 @@ #helper inliner configuration -XX:jit.SD2_OPT.SD2_OPT_helper_inliner_pipeline.filter=- --XX:jit.SD2_OPT.SD2_OPT_helper_inliner_pipeline.path=ssa +-XX:jit.SD2_OPT.SD2_OPT_helper_inliner_pipeline.path=ssa,simplify,dce,uce -XX:jit.SD2_OPT.arg.optimizer.inline_helpers.pipeline=SD2_OPT_helper_inliner_pipeline -XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_NEW_RESOLVED_USING_VTABLE_AND_SIZE=on @@ -133,6 +133,9 @@ -XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_INSTANCEOF=on -XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_INSTANCEOF_hotnessPercent=1 +-XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_LDC_REF=on +-XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_LDC_REF_hotnessPercent=0.5 + -XX:jit.SD2_OPT.arg.codegen.dce1.early=yes -XX:jit.SD2_OPT.arg.codegen.btr.insertCMOVs=no -XX:jit.SD2_OPT.arg.codegen.btr.removeConstCompare=yes Index: vm/jitrino/config/ia32/server_aggressive.emconf =================================================================== --- vm/jitrino/config/ia32/server_aggressive.emconf (revision 614816) +++ vm/jitrino/config/ia32/server_aggressive.emconf (working copy) @@ -103,7 +103,7 @@ #helper inliner configuration -XX:jit.SD2_OPT.SD2_OPT_helper_inliner_pipeline.filter=- --XX:jit.SD2_OPT.SD2_OPT_helper_inliner_pipeline.path=ssa +-XX:jit.SD2_OPT.SD2_OPT_helper_inliner_pipeline.path=ssa,simplify,dce,uce -XX:jit.SD2_OPT.arg.optimizer.inline_helpers.pipeline=SD2_OPT_helper_inliner_pipeline -XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_NEW_RESOLVED_USING_VTABLE_AND_SIZE=on @@ -127,6 +127,9 @@ -XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_INSTANCEOF=on -XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_INSTANCEOF_hotnessPercent=1 +-XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_LDC_REF=on +-XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_LDC_REF_hotnessPercent=0.5 + -XX:jit.SD2_OPT.arg.codegen.dce1.early=yes -XX:jit.SD2_OPT.arg.codegen.btr.insertCMOVs=no -XX:jit.SD2_OPT.arg.codegen.btr.removeConstCompare=yes Index: vm/jitrino/config/ia32/server_static.emconf =================================================================== --- vm/jitrino/config/ia32/server_static.emconf (revision 614816) +++ vm/jitrino/config/ia32/server_static.emconf (working copy) @@ -62,7 +62,7 @@ #helper inliner configuration -XX:jit.SS_OPT.SS_OPT_helper_inliner_pipeline.filter=- --XX:jit.SS_OPT.SS_OPT_helper_inliner_pipeline.path=ssa +-XX:jit.SS_OPT.SS_OPT_helper_inliner_pipeline.path=ssa,simplify,dce,uce -XX:jit.SS_OPT.arg.optimizer.inline_helpers.pipeline=SS_OPT_helper_inliner_pipeline -XX:jit.SS_OPT.arg.optimizer.inline_helpers.VM_RT_NEW_RESOLVED_USING_VTABLE_AND_SIZE=on @@ -86,6 +86,9 @@ -XX:jit.SS_OPT.arg.optimizer.inline_helpers.VM_RT_INSTANCEOF=on -XX:jit.SS_OPT.arg.optimizer.inline_helpers.VM_RT_INSTANCEOF_hotnessPercent=1 +-XX:jit.SS_OPT.arg.optimizer.inline_helpers.VM_RT_LDC_REF=on +-XX:jit.SS_OPT.arg.optimizer.inline_helpers.VM_RT_LDC_REF_hotnessPercent=0.5 + -XX:jit.SS_OPT.arg.codegen.dce1.early=yes -XX:jit.SS_OPT.arg.codegen.btr.insertCMOVs=no -XX:jit.SS_OPT.arg.codegen.btr.removeConstCompare=yes Index: vm/jitrino/src/codegenerator/CodeGenIntfc.h =================================================================== --- vm/jitrino/src/codegenerator/CodeGenIntfc.h (revision 614816) +++ vm/jitrino/src/codegenerator/CodeGenIntfc.h (working copy) @@ -290,6 +290,7 @@ virtual CG_OpndHandle* ldc_i8(int64 val) = 0; virtual CG_OpndHandle* ldc_s(float val) = 0; virtual CG_OpndHandle* ldc_d(double val) = 0; + virtual CG_OpndHandle* ldc_unmanagedptr(Type* t, void* val) = 0; virtual CG_OpndHandle* ldnull(bool compressed) = 0; // result of each of these is now a tau Index: vm/jitrino/src/codegenerator/ia32/Ia32Inst.h =================================================================== --- vm/jitrino/src/codegenerator/ia32/Ia32Inst.h (revision 614816) +++ vm/jitrino/src/codegenerator/ia32/Ia32Inst.h (working copy) @@ -136,8 +136,6 @@ Kind_HelperAddress, /** The value of the operand is irManager.getInternalHelperInfo((const char*)[0]).pfn */ Kind_InternalHelperAddress, - /** The value of the operand is the address where the interned version of the string is stored*/ - Kind_StringAddress, /** The value of the operand is [0]->FieldDesc::getAddress() */ Kind_StaticFieldAddress, /** The value of the operand is [0]->FieldDesc::getOffset() */ Index: vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.cpp =================================================================== --- vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.cpp (revision 614816) +++ vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.cpp (working copy) @@ -1482,6 +1482,10 @@ #endif } +CG_OpndHandle* InstCodeSelector::ldc_unmanagedptr(Type* t, void* val) { + return irManager.newImmOpnd(t, (POINTER_SIZE_INT)val); +} + //_______________________________________________________________________________________________________________ // Load Null @@ -2187,72 +2191,27 @@ bool uncompress) { assert(dstType->isSystemString() || dstType->isSystemClass()); - Opnd * retOpnd=irManager.newOpnd(dstType); - if (codeSelector.methodCodeSelector.slowLdString || dstType->isSystemClass()) { - NamedType * parentType=enclosingMethod->getParentType(); - #ifdef _EM64T_ - Opnd * tp = irManager.getRegOpnd(RegName_RDI); - appendInsts(irManager.newCopyPseudoInst(Mnemonic_MOV, tp,irManager.newImmOpnd(getRuntimeIdType(), Opnd::RuntimeInfo::Kind_TypeRuntimeId, parentType))); - Opnd * st = irManager.getRegOpnd(RegName_RSI); - appendInsts(irManager.newCopyPseudoInst(Mnemonic_MOV, st, irManager.newImmOpnd(typeManager.getInt64Type(), refToken))); - Opnd * helperOpnds[] = { - tp, - st - }; - #else - Opnd * helperOpnds[] = { - irManager.newImmOpnd(getRuntimeIdType(), Opnd::RuntimeInfo::Kind_TypeRuntimeId, parentType), - irManager.newImmOpnd(typeManager.getInt32Type(), refToken) - }; - #endif - - CallInst * callInst = irManager.newRuntimeHelperCallInst(VM_RT_LDC_STRING, 2, helperOpnds, retOpnd); - appendInsts(callInst); - } else { - // this optimized version is based on determinig item address at compile time. - // Respective compile time helper (class_get_const_string_intern_addr) is available for strings. - // Similar function for literal constants is not ready. - // TODO: rewrite this as soon as the helper for loading ref addr at compile time is ready. - - Type* objectType = irManager.getTypeFromTag(Type::Object); - if(irManager.refsAreCompressed()) { - Opnd * base = irManager.newOpnd(objectType); - copyOpnd(base, irManager.newImmOpnd(objectType, (POINTER_SIZE_INT)VMInterface::getHeapBase())); - Opnd * tmp = irManager.newImmOpnd(irManager.getTypeFromTag(Type::UInt64), - Opnd::RuntimeInfo::Kind_StringAddress, - enclosingMethod, (void*)(POINTER_SIZE_INT)refToken); - Opnd * ptr; - if (uncompress) { - ptr = irManager.newOpnd(objectType); - copyOpnd(ptr,tmp); - } else { - ptr = simpleOp_I8(Mnemonic_ADD, objectType,base,tmp); - } - - Opnd* memOpnd = irManager.newMemOpnd(typeManager.getSystemStringType(), MemOpndKind_Heap, - ptr, NULL, NULL, NULL); - retOpnd = simpleOp_I8(Mnemonic_ADD, memOpnd->getType(), memOpnd, base); - } else { -#ifdef _EM64T_ // in uncompressed mode the ptr can be greater than MAX_INT32 so it can not be an immediate - Opnd * tmp = irManager.newImmOpnd(irManager.getTypeFromTag(Type::UInt64), - Opnd::RuntimeInfo::Kind_StringAddress, - enclosingMethod, (void*)(POINTER_SIZE_INT)refToken); - Opnd* ptr = irManager.newOpnd(objectType); - // Opnd* ptr = irManager.newOpnd(typeManager.getUnmanagedPtrType(typeManager.getSystemStringType())); - copyOpnd(ptr,tmp); - Opnd* memOpnd = irManager.newMemOpnd(typeManager.getSystemStringType(), MemOpndKind_Heap, - ptr, NULL, NULL, NULL); + Opnd * retOpnd = irManager.newOpnd(dstType); + NamedType * parentType = enclosingMethod->getParentType(); +#ifdef _EM64T_ + Opnd * tp = irManager.getRegOpnd(RegName_RDI); + appendInsts(irManager.newCopyPseudoInst(Mnemonic_MOV, tp, irManager.newImmOpnd(getRuntimeIdType(), Opnd::RuntimeInfo::Kind_TypeRuntimeId, parentType))); + Opnd * st = irManager.getRegOpnd(RegName_RSI); + appendInsts(irManager.newCopyPseudoInst(Mnemonic_MOV, st, irManager.newImmOpnd(typeManager.getInt64Type(), refToken))); + Opnd * helperOpnds[] = { + tp, + st + }; #else - Opnd* ptr = irManager.newImmOpnd(objectType, Opnd::RuntimeInfo::Kind_StringAddress, - enclosingMethod, (void*)(POINTER_SIZE_INT)refToken); - Opnd* memOpnd = irManager.newMemOpnd(typeManager.getSystemStringType(), MemOpndKind_Heap, - NULL, NULL, NULL, ptr); + Opnd * helperOpnds[] = { + irManager.newImmOpnd(getRuntimeIdType(), Opnd::RuntimeInfo::Kind_TypeRuntimeId, parentType), + irManager.newImmOpnd(typeManager.getInt32Type(), refToken) + }; #endif - copyOpnd(retOpnd, memOpnd); - } - } + CallInst * callInst = irManager.newRuntimeHelperCallInst(VM_RT_LDC_REF, 2, helperOpnds, retOpnd); + appendInsts(callInst); return retOpnd; } @@ -2852,6 +2811,7 @@ case VM_RT_GET_INTERFACE_VTABLE_VER0: case VM_RT_CHECKCAST: case VM_RT_INSTANCEOF: + case VM_RT_LDC_REF: //helpers used by JIT in lazy resolution mode case VM_RT_NEWOBJ_WITHRESOLVE: Index: vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.h =================================================================== --- vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.h (revision 614816) +++ vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.h (working copy) @@ -123,6 +123,7 @@ CG_OpndHandle* ldc_i8(int64 val); CG_OpndHandle* ldc_s(float val); CG_OpndHandle* ldc_d(double val); + CG_OpndHandle* ldc_unmanagedptr(Type* t, void* val); CG_OpndHandle* ldnull(bool compressed); CG_OpndHandle* tau_checkNull(CG_OpndHandle* base, bool checksThisForInlinedMethod); Index: vm/jitrino/src/codegenerator/ia32/Ia32IRManager.cpp =================================================================== --- vm/jitrino/src/codegenerator/ia32/Ia32IRManager.cpp (revision 614816) +++ vm/jitrino/src/codegenerator/ia32/Ia32IRManager.cpp (working copy) @@ -2021,13 +2021,6 @@ /* The value of the operand is [0]->ObjectType::getObjectSize() */ value=(POINTER_SIZE_INT)((ObjectType*)info->getValue(0))->getObjectSize(); break; - case Opnd::RuntimeInfo::Kind_StringAddress: - /** The value of the operand is the address where the interned version of the string is stored*/ - { - MethodDesc* mDesc = (MethodDesc*)info->getValue(0); - uint32 token = (uint32)(POINTER_SIZE_INT)info->getValue(1); - value = (POINTER_SIZE_INT) compilationInterface.loadStringObject(mDesc,token); - }break; case Opnd::RuntimeInfo::Kind_StaticFieldAddress: /** The value of the operand is [0]->FieldDesc::getAddress() */ value=(POINTER_SIZE_INT)((FieldDesc*)info->getValue(0))->getAddress(); @@ -2225,9 +2218,9 @@ Type * type=subOpnd->getType(); if (type->isManagedPtr() || type->isObject() || type->isMethodPtr() || type->isVTablePtr() || type->isUnmanagedPtr() #ifdef _EM64T_ - || subOpnd->getRegName() == RegName_RSP/*SOE handler*/ + || subOpnd->getRegName() == RegName_RSP//SOE handler #else - || subOpnd->getRegName() == RegName_ESP/*SOE handler*/ + || subOpnd->getRegName() == RegName_ESP//SOE handler #endif ){ if (properTypeSubOpnd!=NULL){ Index: vm/jitrino/src/codegenerator/ia32/Ia32Printer.cpp =================================================================== --- vm/jitrino/src/codegenerator/ia32/Ia32Printer.cpp (revision 614816) +++ vm/jitrino/src/codegenerator/ia32/Ia32Printer.cpp (working copy) @@ -461,12 +461,6 @@ { os<<"sz:"; printType((ObjectType*)info->getValue(0)); }break; - case Opnd::RuntimeInfo::Kind_StringAddress: - /** The value of the operand is the address where the interned version of the string is stored*/ - { - os<<"&str:"; - os<<(POINTER_SIZE_INT)info->getValue(1); // string token - }break; case Opnd::RuntimeInfo::Kind_StaticFieldAddress: /** The value of the operand is [0]->FieldDesc::getAddress() */ { Index: vm/jitrino/src/codegenerator/ipf/IpfInstCodeSelector.cpp =================================================================== --- vm/jitrino/src/codegenerator/ipf/IpfInstCodeSelector.cpp (revision 614816) +++ vm/jitrino/src/codegenerator/ipf/IpfInstCodeSelector.cpp (working copy) @@ -1700,7 +1700,7 @@ }; RegOpnd *retOpnd = opndManager->newRegOpnd(OPND_G_REG, DATA_BASE); - VM_RT_SUPPORT hId = VM_RT_LDC_STRING; + VM_RT_SUPPORT hId = VM_RT_LDC_REF; uint64 address = (uint64) compilationInterface.getRuntimeHelperAddress(hId); Opnd *helperAddress = opndManager->newImm(address); @@ -2942,7 +2942,7 @@ opndManager->newImm(refToken), opndManager->newImm((int64) enclosingMethod->getParentType()->getRuntimeIdentifier()) }; - VM_RT_SUPPORT hId = VM_RT_LDC_STRING; + VM_RT_SUPPORT hId = VM_RT_LDC_REF; uint64 address = (uint64) compilationInterface.getRuntimeHelperAddress(hId); Opnd *helperAddress = opndManager->newImm(address); Index: vm/jitrino/src/jet/cg_stk.cpp =================================================================== --- vm/jitrino/src/jet/cg_stk.cpp (revision 614816) +++ vm/jitrino/src/jet/cg_stk.cpp (working copy) @@ -67,7 +67,7 @@ return; } assert(m_curr_inst->opcode != OPCODE_LDC2_W); - gen_call_vm(ci_helper_oi, rt_helper_ldc_string, 0, m_klass, m_curr_inst->op0); + gen_call_vm(ci_helper_oi, rt_helper_ldc_ref, 0, m_klass, m_curr_inst->op0); gen_save_ret(jobj); vstack(0).set(VA_NZ); m_bbstate->seen_gcpt = true; Index: vm/jitrino/src/jet/compiler.cpp =================================================================== --- vm/jitrino/src/jet/compiler.cpp (revision 614816) +++ vm/jitrino/src/jet/compiler.cpp (working copy) @@ -1462,8 +1462,8 @@ // rt_helper_init_class = (char*)vm_get_rt_support_addr(VM_RT_INITIALIZE_CLASS); - rt_helper_ldc_string = - (char*)vm_get_rt_support_addr(VM_RT_LDC_STRING); + rt_helper_ldc_ref = + (char*)vm_get_rt_support_addr(VM_RT_LDC_REF); rt_helper_new = (char*)vm_get_rt_support_addr(VM_RT_NEW_RESOLVED_USING_VTABLE_AND_SIZE); Index: vm/jitrino/src/jet/sconsts.cpp =================================================================== --- vm/jitrino/src/jet/sconsts.cpp (revision 614816) +++ vm/jitrino/src/jet/sconsts.cpp (working copy) @@ -42,7 +42,7 @@ char * StaticConsts::rt_helper_monitor_enter_static = NULL; char * StaticConsts::rt_helper_monitor_exit_static = NULL; -char * StaticConsts::rt_helper_ldc_string = NULL; +char * StaticConsts::rt_helper_ldc_ref = NULL; char * StaticConsts::rt_helper_new = NULL; char * StaticConsts::rt_helper_new_array = NULL; char * StaticConsts::rt_helper_init_class = NULL; Index: vm/jitrino/src/jet/sconsts.h =================================================================== --- vm/jitrino/src/jet/sconsts.h (revision 614816) +++ vm/jitrino/src/jet/sconsts.h (working copy) @@ -62,7 +62,7 @@ static char * rt_helper_monitor_enter_static; static char * rt_helper_monitor_exit_static; - static char * rt_helper_ldc_string; + static char * rt_helper_ldc_ref; static char * rt_helper_init_class; static char * rt_helper_multinewarray; static char * rt_helper_get_vtable; Index: vm/jitrino/src/optimizer/CodeSelectors.cpp =================================================================== --- vm/jitrino/src/optimizer/CodeSelectors.cpp (revision 614816) +++ vm/jitrino/src/optimizer/CodeSelectors.cpp (working copy) @@ -987,10 +987,12 @@ if (!genConsts) break; ConstInst* constInst = (ConstInst*)inst; switch (inst->getType()) { + case Type::UnmanagedPtr: + cgInst = instructionCallback.ldc_unmanagedptr(inst->getDst()->getType(), constInst->getValue().i); + break; #ifdef _IA32_ case Type::UIntPtr: case Type::IntPtr: - case Type::UnmanagedPtr: #endif case Type::Int32: cgInst = instructionCallback.ldc_i4(constInst->getValue().i4); @@ -998,7 +1000,6 @@ #ifdef _EM64T_ case Type::UIntPtr: case Type::IntPtr: - case Type::UnmanagedPtr: #endif case Type::Int64: cgInst = instructionCallback.ldc_i8(constInst->getValue().i8); Index: vm/jitrino/src/optimizer/escanalyzer.cpp =================================================================== --- vm/jitrino/src/optimizer/escanalyzer.cpp (revision 614816) +++ vm/jitrino/src/optimizer/escanalyzer.cpp (working copy) @@ -427,6 +427,11 @@ case ClassGetArrayClass: case ClassIsFinalizable: case ClassGetFastCheckDepth: + case IsString: + case IsStringInterned: + case GetStringAddress: + case IsResolvedClass: + case GetClassObjectAddress: break; default: assert(0); Index: vm/jitrino/src/optimizer/helper_inliner.cpp =================================================================== --- vm/jitrino/src/optimizer/helper_inliner.cpp (revision 614816) +++ vm/jitrino/src/optimizer/helper_inliner.cpp (working copy) @@ -72,6 +72,7 @@ registerHelper(Op_TauLdIntfcVTableAddr, VM_RT_GET_INTERFACE_VTABLE_VER0); registerHelper(Op_TauCheckCast, VM_RT_CHECKCAST); registerHelper(Op_TauInstanceOf, VM_RT_INSTANCEOF); + registerHelper(Op_LdRef, VM_RT_LDC_REF); } void HelperInlinerAction::registerHelper(Opcode opcode, VM_RT_SUPPORT helperId) { @@ -211,7 +212,7 @@ //Convert all inst params into helper params uint32 numHelperArgs = method->getNumParams(); uint32 numInstArgs = inst->getNumSrcOperands(); - Opnd** helperArgs =new (irm->getMemoryManager()) Opnd*[numHelperArgs]; + Opnd** helperArgs = new (irm->getMemoryManager()) Opnd*[numHelperArgs]; #ifdef _DEBUG std::fill(helperArgs, helperArgs + numHelperArgs, (Opnd*)NULL); #endif @@ -224,6 +225,22 @@ ldconst->insertBefore(inst); helperArgs[currentHelperArg] = typeOpnd; currentHelperArg++; + } else if (inst->isToken()) { + TokenInst* tokenInst = inst->asTokenInst(); + MethodDesc* methDesc = tokenInst->getEnclosingMethod(); + uint32 cpIndex = tokenInst->getToken(); + Opnd* classHandleOpnd = opndManager->createSsaTmpOpnd(typeManager->getUnmanagedPtrType(typeManager->getIntPtrType())); + Opnd* cpIndexOpnd = opndManager->createSsaTmpOpnd(typeManager->getUInt32Type()); + Inst* ldMethDesc = instFactory->makeLdConst(classHandleOpnd, (POINTER_SIZE_SINT)methDesc->getParentHandle()); + Inst* ldCpIndex = instFactory->makeLdConst(cpIndexOpnd, (int32)cpIndex); + + ldMethDesc->insertBefore(inst); + helperArgs[currentHelperArg] = classHandleOpnd; + currentHelperArg++; + + ldCpIndex->insertBefore(inst); + helperArgs[currentHelperArg] = cpIndexOpnd; + currentHelperArg++; } for (uint32 i = 0; i < numInstArgs; i++) { Opnd* instArg = inst->getSrc(i); Index: vm/jitrino/src/optimizer/Inst.cpp =================================================================== --- vm/jitrino/src/optimizer/Inst.cpp (revision 614816) +++ vm/jitrino/src/optimizer/Inst.cpp (working copy) @@ -502,6 +502,16 @@ os << "ClassGetArrayClass"; break; case ClassGetFastCheckDepth: os << "ClassGetFastCheckDepth"; break; + case IsString: + os << "IsString"; break; + case IsStringInterned: + os << "IsStringInterned"; break; + case GetStringAddress: + os << "GetStringAddress"; break; + case IsResolvedClass: + os << "IsResolvedClass"; break; + case GetClassObjectAddress: + os << "GetClassObjectAddress"; break; default: assert(0); break; } Index: vm/jitrino/src/optimizer/memoryopt.cpp =================================================================== --- vm/jitrino/src/optimizer/memoryopt.cpp (revision 614816) +++ vm/jitrino/src/optimizer/memoryopt.cpp (working copy) @@ -681,6 +681,11 @@ case ClassGetArrayClass: case ClassIsFinalizable: case ClassGetFastCheckDepth: + case IsString: + case IsStringInterned: + case GetStringAddress: + case IsResolvedClass: + case GetClassObjectAddress: break; default: assert(0); @@ -1420,6 +1425,7 @@ case Op_ConvZE: case Op_ConvUnmanaged: case Op_TauLdInd: // the result of static field load + case Op_LdConstant: break; case Op_VMHelperCall: { Index: vm/jitrino/src/optimizer/Opcode.h =================================================================== --- vm/jitrino/src/optimizer/Opcode.h (revision 614816) +++ vm/jitrino/src/optimizer/Opcode.h (working copy) @@ -289,7 +289,12 @@ ClassIsFinal, ClassGetArrayClass, ClassIsFinalizable, - ClassGetFastCheckDepth + ClassGetFastCheckDepth, + IsString, + IsStringInterned, + GetStringAddress, + IsResolvedClass, + GetClassObjectAddress }; enum Opcode { Index: vm/jitrino/src/optimizer/simplifier.cpp =================================================================== --- vm/jitrino/src/optimizer/simplifier.cpp (revision 614816) +++ vm/jitrino/src/optimizer/simplifier.cpp (working copy) @@ -4479,11 +4479,19 @@ return ch; } +static uint32 getCPIndex(Opnd* opnd) { + assert(opnd->getType()->isInt4()); + Inst* inst = opnd->getInst(); + assert(inst->isConst()); + return (uint32)inst->asConstInst()->getValue().i4; +} + Inst* Simplifier::simplifyJitHelperCall(JitHelperCallInst* inst) { Inst* res = inst; Class_Handle ch = NULL; TypeManager& tm = irManager.getTypeManager(); - switch(inst->getJitHelperId()) { + JitHelperCallId helperId = inst->getJitHelperId(); + switch(helperId) { case ClassIsArray: ch = getClassHandle(inst->getSrc(0)); if (ch) { @@ -4495,7 +4503,7 @@ if (ch) { ConstInst::ConstValue v; v.i8 = (POINTER_SIZE_SINT)class_get_allocation_handle(ch); - res = genLdConstant(tm.getUnmanagedPtrType(tm.getInt8Type()), v); + res = genLdConstant(tm.getInt32Type(), v); } break; case ClassGetTypeSize: @@ -4546,6 +4554,50 @@ res = genLdConstant(depth); } break; + case IsString: { + Class_Handle classHandle = getClassHandle(inst->getSrc(0)); + uint32 cpIndex = getCPIndex(inst->getSrc(1)); + Type* type = irManager.getCompilationInterface().getConstantType(classHandle, cpIndex); + res = genLdConstant((int32)type->isSystemString()); + break; + } + case IsStringInterned: { + Class_Handle classHandle = getClassHandle(inst->getSrc(0)); + uint32 cpIndex = getCPIndex(inst->getSrc(1)); + void * stringAddr = irManager.getCompilationInterface().getStringInternAddr(classHandle, cpIndex); + res = genLdConstant((int32)(*(POINTER_SIZE_INT *)stringAddr) != 0); + break; + } + case GetStringAddress: { + ConstInst::ConstValue v; + Class_Handle classHandle = getClassHandle(inst->getSrc(0)); + uint32 cpIndex = getCPIndex(inst->getSrc(1)); + v.i = irManager.getCompilationInterface().getStringInternAddr(classHandle, cpIndex); + res = genLdConstant(tm.getUnmanagedPtrType(tm.getManagedPtrType(tm.getSystemStringType())), v); + break; + } + case IsResolvedClass: { + Class_Handle classHandle = getClassHandle(inst->getSrc(0)); + uint32 cpIndex = getCPIndex(inst->getSrc(1)); + if (tm.getSystemClassType() == + irManager.getCompilationInterface().getConstantType(classHandle, cpIndex)) { + NamedType* type = irManager.getCompilationInterface().getNamedType(classHandle, cpIndex); + res = genLdConstant((int32)!(type->isUnresolvedType())); + } else { + res = genLdConstant((int32)0); + } + break; + } + case GetClassObjectAddress: { + ConstInst::ConstValue v; + Class_Handle classHandle = getClassHandle(inst->getSrc(0)); + uint32 cpIndex = getCPIndex(inst->getSrc(1)); + NamedType* type = irManager.getCompilationInterface().getNamedType(classHandle, cpIndex); + v.i = irManager.getCompilationInterface().getClassHandle((Class_Handle)type->getVMTypeHandle()); + res = genLdConstant(tm.getUnmanagedPtrType(tm.getManagedPtrType(tm.getSystemClassType())), v); + break; + } + default: break; } return res; Index: vm/jitrino/src/translator/java/JavaByteCodeTranslator.cpp =================================================================== --- vm/jitrino/src/translator/java/JavaByteCodeTranslator.cpp (revision 614816) +++ vm/jitrino/src/translator/java/JavaByteCodeTranslator.cpp (working copy) @@ -378,7 +378,7 @@ const char* JavaByteCodeTranslator::methodSignatureString(uint32 cpIndex) { - return compilationInterface.getSignatureString(&methodToCompile,cpIndex); + return compilationInterface.getSignatureString(methodToCompile.getParentHandle(),cpIndex); } uint32 @@ -604,7 +604,7 @@ JavaByteCodeTranslator::ldc(uint32 constPoolIndex) { // load 32-bit quantity or string from constant pool Type* constantType = - compilationInterface.getConstantType(&methodToCompile,constPoolIndex); + compilationInterface.getConstantType(methodToCompile.getParentHandle(),constPoolIndex); Opnd* opnd = NULL; if (constantType->isSystemString()) { opnd = irBuilder.genLdRef(&methodToCompile,constPoolIndex,constantType); @@ -616,7 +616,7 @@ opnd = irBuilder.genLdRef(&methodToCompile,constPoolIndex,constantType); } else { const void* constantAddress = - compilationInterface.getConstantValue(&methodToCompile,constPoolIndex); + compilationInterface.getConstantValue(methodToCompile.getParentHandle(),constPoolIndex); if (constantType->isInt4()) { int32 value = *(int32*)constantAddress; opnd = irBuilder.genLdConstant(value); @@ -635,10 +635,10 @@ JavaByteCodeTranslator::ldc2(uint32 constPoolIndex) { // load 64-bit quantity from constant pool Type* constantType = - compilationInterface.getConstantType(&methodToCompile,constPoolIndex); + compilationInterface.getConstantType(methodToCompile.getParentHandle(),constPoolIndex); const void* constantAddress = - compilationInterface.getConstantValue(&methodToCompile,constPoolIndex); + compilationInterface.getConstantValue(methodToCompile.getParentHandle(),constPoolIndex); Opnd *opnd = NULL; if (constantType->isInt8()) { int64 value = *(int64*)constantAddress; @@ -3282,14 +3282,14 @@ if (off >= byteCodeLength) return 0; uint32 constPoolIndex = su8(byteCodes + (off++)); // load 32-bit quantity from constant pool - Type* constantType = compilationInterface.getConstantType(&methodToCompile,constPoolIndex); + Type* constantType = compilationInterface.getConstantType(methodToCompile.getParentHandle(),constPoolIndex); if ( !(constantType->isInt4() || constantType->isSingle()) ) { // only integer and floating-point types // are implemented for streamed array loads return 0; } const void* constantAddress = - compilationInterface.getConstantValue(&methodToCompile,constPoolIndex); + compilationInterface.getConstantValue(methodToCompile.getParentHandle(),constPoolIndex); value = *(uint32*)constantAddress; } break; @@ -3298,14 +3298,14 @@ if ((off + 1) >= byteCodeLength) return 0; uint32 constPoolIndex = su16(byteCodes + off); // load 32-bit quantity from constant pool - Type* constantType = compilationInterface.getConstantType(&methodToCompile,constPoolIndex); + Type* constantType = compilationInterface.getConstantType(methodToCompile.getParentHandle(),constPoolIndex); if ( !(constantType->isInt4() || constantType->isSingle()) ) { // only integer and floating-point types // are implemented for streamed array loads return 0; } const void* constantAddress = - compilationInterface.getConstantValue(&methodToCompile,constPoolIndex); + compilationInterface.getConstantValue(methodToCompile.getParentHandle(),constPoolIndex); value = *(uint32*)constantAddress; } off += 2; @@ -3315,14 +3315,14 @@ if ((off + 1) >= byteCodeLength) return 0; uint32 constPoolIndex = su16(byteCodes + off); // load 64-bit quantity from constant pool - Type* constantType = compilationInterface.getConstantType(&methodToCompile,constPoolIndex); + Type* constantType = compilationInterface.getConstantType(methodToCompile.getParentHandle(),constPoolIndex); if ( !(constantType->isInt8() || constantType->isDouble()) ) { // only integer and floating-point types // are implemented for streamed array loads return 0; } const void* constantAddress = - compilationInterface.getConstantValue(&methodToCompile,constPoolIndex); + compilationInterface.getConstantValue(methodToCompile.getParentHandle(),constPoolIndex); value = *(uint64*)constantAddress; } off += 2; @@ -3652,6 +3652,12 @@ return true; } + if (!strcmp(mname,"loadRef")) { + assert(numArgs == 2); + Opnd* res = irBuilder.genVMHelperCall(VM_RT_LDC_REF, resType, numArgs, srcOpnds); + pushOpnd(res); + return true; + } //no VMHelpers exist for these magics -> use internal JIT helpers @@ -3718,6 +3724,41 @@ return true; } + if (!strcmp(mname,"isString")) { + assert(numArgs == 2 && srcOpnds[0]->getType()->isUnmanagedPtr() && srcOpnds[1]->getType()->isInt4()); + Opnd* res = irBuilder.genJitHelperCall(IsString, resType, numArgs, srcOpnds); + pushOpnd(res); + return true; + } + + if (!strcmp(mname,"isStringInterned")) { + assert(numArgs == 2 && srcOpnds[0]->getType()->isUnmanagedPtr() && srcOpnds[1]->getType()->isInt4()); + Opnd* res = irBuilder.genJitHelperCall(IsStringInterned, resType, numArgs, srcOpnds); + pushOpnd(res); + return true; + } + + if (!strcmp(mname,"getStringAddress")) { + assert(numArgs == 2 && srcOpnds[0]->getType()->isUnmanagedPtr() && srcOpnds[1]->getType()->isInt4()); + Opnd* res = irBuilder.genJitHelperCall(GetStringAddress, resType, numArgs, srcOpnds); + pushOpnd(res); + return true; + } + + if (!strcmp(mname, "isResolvedClass")) { + assert(numArgs == 2 && srcOpnds[0]->getType()->isUnmanagedPtr() && srcOpnds[1]->getType()->isInt4()); + Opnd* res = irBuilder.genJitHelperCall(IsResolvedClass, resType, numArgs, srcOpnds); + pushOpnd(res); + return true; + + } + if (!strcmp(mname, "getClassObjectAddress")) { + assert(numArgs == 2 && srcOpnds[0]->getType()->isUnmanagedPtr() && srcOpnds[1]->getType()->isInt4()); + Opnd* res = irBuilder.genJitHelperCall(GetClassObjectAddress, resType, numArgs, srcOpnds); + pushOpnd(res); + return true; + } + return false; } Index: vm/jitrino/src/translator/java/JavaLabelPrepass.cpp =================================================================== --- vm/jitrino/src/translator/java/JavaLabelPrepass.cpp (revision 614816) +++ vm/jitrino/src/translator/java/JavaLabelPrepass.cpp (working copy) @@ -1235,7 +1235,7 @@ void JavaLabelPrepass::ldc(uint32 constPoolIndex) { // load 32-bit quantity or string from constant pool Type* constantType = - compilationInterface.getConstantType(&methodDesc,constPoolIndex); + compilationInterface.getConstantType(methodDesc.getParentHandle(),constPoolIndex); if (constantType->isSystemString() || constantType->isSystemClass()) { pushType(constantType); } else if (constantType->isInt4()) { @@ -1249,7 +1249,7 @@ void JavaLabelPrepass::ldc2(uint32 constPoolIndex) { // load 64-bit quantity from constant pool Type* constantType = - compilationInterface.getConstantType(&methodDesc,constPoolIndex); + compilationInterface.getConstantType(methodDesc.getParentHandle(),constPoolIndex); if (constantType->isInt8()) { pushType(int64Type); } else if (constantType->isDouble()) { @@ -1760,7 +1760,7 @@ const char* JavaLabelPrepass::methodSignatureString(uint32 cpIndex) { - return compilationInterface.getSignatureString(&methodDesc,cpIndex); + return compilationInterface.getSignatureString(methodDesc.getParentHandle(),cpIndex); } void StateTable::copySlotInfo(StateInfo::SlotInfo& to, StateInfo::SlotInfo& from) { Index: vm/jitrino/src/vm/VMInterface.cpp =================================================================== --- vm/jitrino/src/vm/VMInterface.cpp (revision 614816) +++ vm/jitrino/src/vm/VMInterface.cpp (working copy) @@ -330,9 +330,8 @@ } const char* -CompilationInterface::getSignatureString(MethodDesc* enclosingMethodDesc, uint32 methodToken) { - Class_Handle enclosingDrlVMClass = enclosingMethodDesc->getParentHandle(); - return class_get_cp_entry_signature(enclosingDrlVMClass, (unsigned short)methodToken); +CompilationInterface::getSignatureString(Class_Handle classHandle, uint32 methodToken) { + return class_get_cp_entry_signature(classHandle, (unsigned short)methodToken); } Method_Side_Effects @@ -542,20 +541,15 @@ return res == JIT_SUCCESS ? true : false; } - - void* -CompilationInterface::loadStringObject(MethodDesc* enclosingMethodDesc, - uint32 stringToken) { - Class_Handle enclosingDrlVMClass = enclosingMethodDesc->getParentHandle(); - return class_get_const_string_intern_addr(enclosingDrlVMClass,stringToken); +CompilationInterface::getStringInternAddr(Class_Handle classHandle, uint32 stringToken) { + return class_get_const_string_intern_addr(classHandle, stringToken); } Type* -CompilationInterface::getConstantType(MethodDesc* enclosingMethodDesc, - uint32 constantToken) { - Class_Handle enclosingDrlVMClass = enclosingMethodDesc->getParentHandle(); - Java_Type drlType = (Java_Type)class_get_const_type(enclosingDrlVMClass,constantToken); +CompilationInterface::getConstantType(Class_Handle classHandle, + uint32 constantToken) { + Java_Type drlType = (Java_Type)class_get_const_type(classHandle, constantToken); switch (drlType) { case JAVA_TYPE_STRING: return typeManager.getSystemStringType(); case JAVA_TYPE_CLASS: return typeManager.getSystemClassType(); @@ -569,11 +563,15 @@ return NULL; } +void* +CompilationInterface::getClassHandle(Class_Handle classHandle){ + return class_get_class_handle(classHandle); +} + const void* -CompilationInterface::getConstantValue(MethodDesc* enclosingMethodDesc, - uint32 constantToken) { - Class_Handle enclosingDrlVMClass = enclosingMethodDesc->getParentHandle(); - return class_get_const_addr(enclosingDrlVMClass,constantToken); +CompilationInterface::getConstantValue(Class_Handle classHandle, + uint32 constantToken) { + return class_get_const_addr(classHandle, constantToken); } MethodDesc* Index: vm/jitrino/src/vm/VMInterface.h =================================================================== --- vm/jitrino/src/vm/VMInterface.h (revision 614816) +++ vm/jitrino/src/vm/VMInterface.h (working copy) @@ -352,10 +352,11 @@ ClassHierarchyMethodIterator* getClassHierarchyMethodIterator(ObjectType* baseType, MethodDesc* methodDesc); - void* loadStringObject(MethodDesc* enclosingMethodDesc, uint32 stringToken); - Type* getConstantType(MethodDesc* enclosingMethodDesc, uint32 constantToken); - const void* getConstantValue(MethodDesc* enclosingMethodDesc, uint32 constantToken); - const char* getSignatureString(MethodDesc* enclosingMethodDesc, uint32 methodToken); + void* getStringInternAddr(Class_Handle classHandle, uint32 stringToken); + Type* getConstantType(Class_Handle classHandle, uint32 constantToken); + const void* getConstantValue(Class_Handle classHandle, uint32 constantToken); + const char* getSignatureString(Class_Handle classHandle, uint32 methodToken); + void* getClassHandle(Class_Handle classHandle); // Memory allocation API // all of these are for the method being compiled Index: vm/vmcore/build/vmcore.exp =================================================================== --- vm/vmcore/build/vmcore.exp (revision 614816) +++ vm/vmcore/build/vmcore.exp (working copy) @@ -18,6 +18,7 @@ class_get_boxed_data_size; class_get_class_loader; class_get_class_of_primitive_type; + class_get_class_handle; class_get_const_addr; class_get_const_string; class_get_const_string_intern_addr; Index: vm/vmcore/src/class_support/C_Interface.cpp =================================================================== --- vm/vmcore/src/class_support/C_Interface.cpp (revision 614816) +++ vm/vmcore/src/class_support/C_Interface.cpp (working copy) @@ -789,45 +789,15 @@ // Returns the address where the interned version of the string is stored: this will be the address -// of a slot containing a Java_java_lang_String* or a uint32 compressed reference. Also interns the -// string so that the JIT can load a reference to the interned string without checking if it is null. +// of a slot containing a Java_java_lang_String* or a uint32 compressed reference. void *class_get_const_string_intern_addr(Class_Handle cl, unsigned index) { assert(cl); Global_Env* env = VM_Global_State::loader_env; String* str = cl->get_constant_pool().get_string(index); assert(str); - - bool must_instantiate; - REFS_RUNTIME_SWITCH_IF -#ifdef REFS_RUNTIME_OR_COMPRESSED - must_instantiate = (str->intern.compressed_ref == 0 /*NULL*/); -#endif // REFS_RUNTIME_OR_COMPRESSED - REFS_RUNTIME_SWITCH_ELSE -#ifdef REFS_RUNTIME_OR_UNCOMPRESSED - must_instantiate = (str->intern.raw_ref == NULL); -#endif // REFS_RUNTIME_OR_UNCOMPRESSED - REFS_RUNTIME_SWITCH_ENDIF - - if (must_instantiate) { - BEGIN_RAISE_AREA; - // vm_instantiate_cp_string_resolved assumes that GC is disabled - tmn_suspend_disable(); - // Discard the result. We are only interested in the side-effect of setting str->intern. - vm_instantiate_cp_string_resolved(str); - tmn_suspend_enable(); - END_RAISE_AREA; - } - - REFS_RUNTIME_SWITCH_IF -#ifdef REFS_RUNTIME_OR_COMPRESSED - return &(str->intern.compressed_ref); -#endif // REFS_RUNTIME_OR_COMPRESSED - REFS_RUNTIME_SWITCH_ELSE -#ifdef REFS_RUNTIME_OR_UNCOMPRESSED - return &(str->intern.raw_ref); -#endif // REFS_RUNTIME_OR_UNCOMPRESSED - REFS_RUNTIME_SWITCH_ENDIF + assert((void *)(&(str->intern.raw_ref)) == (void *)(&(str->intern.compressed_ref))); + return &(str->intern.raw_ref); } //class_get_const_string_intern_addr @@ -918,8 +888,10 @@ return (VM_Data_Type)jt; } //class_get_const_type +void * class_get_class_handle(Class_Handle ch) { + return (void *)((Class*)ch)->get_class_handle(); +} - const void *class_get_const_addr(Class_Handle cl, unsigned index) { assert(cl); Index: vm/vmcore/src/jit/jit_runtime_support.cpp =================================================================== --- vm/vmcore/src/jit/jit_runtime_support.cpp (revision 614816) +++ vm/vmcore/src/jit/jit_runtime_support.cpp (working copy) @@ -2434,7 +2434,7 @@ switch(f) { case VM_RT_MULTIANEWARRAY_RESOLVED: return rth_get_lil_multianewarray(dyn_count); - case VM_RT_LDC_STRING: + case VM_RT_LDC_REF: return rth_get_lil_ldc_ref(dyn_count); // Exceptions case VM_RT_THROW: Index: vm/vmcore/src/jit/rt_helper_info.cpp =================================================================== --- vm/vmcore/src/jit/rt_helper_info.cpp (revision 614816) +++ vm/vmcore/src/jit/rt_helper_info.cpp (working copy) @@ -51,10 +51,10 @@ {VM_RT_MULTIANEWARRAY_RESOLVED, "VM_RT_MULTIANEWARRAY_RESOLVED", INTERRUPTIBLE_ALWAYS, CALLING_CONVENTION_CDECL, 8, NULL, NULL, NULL, NULL}, - {VM_RT_LDC_STRING, "VM_RT_LDC_STRING", + {VM_RT_LDC_REF, "VM_RT_LDC_REF", INTERRUPTIBLE_ALWAYS, CALLING_CONVENTION_STDCALL, 2, - NULL, NULL, NULL, NULL}, - + "org/apache/harmony/drlvm/VMHelperFastPath", "loadRef", + "(Lorg/vmmagic/unboxed/Address;I)Ljava/lang/Object;", NULL}, {VM_RT_THROW, "VM_RT_THROW", INTERRUPTIBLE_ALWAYS, CALLING_CONVENTION_STDCALL, 1, NULL, NULL, NULL, NULL}, Index: vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/drlvm/VMHelper.java =================================================================== --- vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/drlvm/VMHelper.java (revision 614816) +++ vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/drlvm/VMHelper.java (working copy) @@ -87,6 +87,7 @@ public static boolean instanceOf(Object obj, Address castTypePtr) {fail(); return false;} + public static Object loadRef(Address classHandle, int cpIndex) {fail(); return null;} @@ -110,6 +111,16 @@ public static int getFastTypeCheckDepth(Address classHandle) {VMHelper.fail(); return 0;} + public static boolean isString(Address classHandle, int cpIndex) {VMHelper.fail(); return false;} + + public static boolean isStringInterned(Address classHandle, int cpIndex) {VMHelper.fail(); return false;} + + public static Address getStringAddress(Address classHandle, int cpIndex) {VMHelper.fail(); return null;} + + public static boolean isResolvedClass(Address classHandle, int cpIndex) {VMHelper.fail(); return false;} + + public static Address getClassObjectAddress(Address classHandle, int cpIndex) {VMHelper.fail(); return null;} + protected static void fail() {throw new RuntimeException("Not supported!");} Index: vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/drlvm/VMHelperFastPath.java =================================================================== --- vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/drlvm/VMHelperFastPath.java (revision 614816) +++ vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/drlvm/VMHelperFastPath.java (working copy) @@ -178,6 +178,34 @@ } + @Inline + public static Object loadRef(Address classHandle, int cpIndex) { + if (VMHelper.isString(classHandle, cpIndex)) { + Address stringLocation = VMHelper.getStringAddress(classHandle, cpIndex); + if (VMHelper.COMPRESSED_REFS_MODE) { + int compressedRef = stringLocation.loadInt(); + if (VMHelper.isStringInterned(classHandle, cpIndex) || + compressedRef != 0) { + Address addr = Address.fromLong(compressedRef + + VMHelper.COMPRESSED_REFS_OBJ_BASE_OFFSET); + return addr.toObjectReference().toObject(); + } + } else { + Object theString = stringLocation.loadObjectReference().toObject(); + if (VMHelper.isStringInterned(classHandle, cpIndex) || + theString != null) { + return theString; + } + } + } else if (VMHelper.isResolvedClass(classHandle, cpIndex)) { + Address vmClass = VMHelper.getClassObjectAddress(classHandle, cpIndex); + return vmClass.loadObjectReference().toObject(); + + } + + return VMHelper.loadRef(classHandle, cpIndex); + } + private static native int getObjectVtableOffset(); private static native int getVtableIntfTypeOffset(int n); private static native int getVtableIntfTableOffset(int n); Index: vm/vmcore/src/util/ia32/base/jit_runtime_support_ia32.cpp =================================================================== --- vm/vmcore/src/util/ia32/base/jit_runtime_support_ia32.cpp (revision 614816) +++ vm/vmcore/src/util/ia32/base/jit_runtime_support_ia32.cpp (working copy) @@ -749,7 +749,7 @@ -static void *getaddress__vm_instantiate_cp_string_naked() +static void *getaddress__vm_instantiate_cp_ref_naked() { static void *addr = 0; if (addr) { @@ -778,10 +778,10 @@ jvmti_send_dynamic_code_generated_event("vm_instantiate_cp_string_naked", stub, stub_size); } - DUMP_STUB(stub, "getaddress__vm_instantiate_cp_string_naked", ss - stub); + DUMP_STUB(stub, "getaddress__vm_instantiate_cp_ref_naked", ss - stub); return addr; -} //getaddress__vm_instantiate_cp_string_naked +} //getaddress__vm_instantiate_cp_ref_naked @@ -1192,8 +1192,8 @@ return exn_get_rth_throw(); case VM_RT_THROW_LAZY: return exn_get_rth_throw_lazy(); - case VM_RT_LDC_STRING: - return getaddress__vm_instantiate_cp_string_naked(); + case VM_RT_LDC_REF: + return getaddress__vm_instantiate_cp_ref_naked(); case VM_RT_NEW_RESOLVED_USING_VTABLE_AND_SIZE: return getaddress__vm_alloc_java_object_resolved_using_vtable_and_size_naked(); case VM_RT_MULTIANEWARRAY_RESOLVED: Index: vm/vmcore/src/util/ipf/base/jit_runtime_support_ipf.cpp =================================================================== --- vm/vmcore/src/util/ipf/base/jit_runtime_support_ipf.cpp (revision 614816) +++ vm/vmcore/src/util/ipf/base/jit_runtime_support_ipf.cpp (working copy) @@ -262,7 +262,7 @@ -static void *get_vm_rt_ldc_string_address() +static void *get_vm_rt_ldc_ref_address() { static void *addr = 0; if(addr) { @@ -275,7 +275,7 @@ /*num_rets*/ MPR_Gr, /*translate_returned_ref*/ true); return addr; -} //get_vm_rt_ldc_string_address +} //get_vm_rt_ldc_ref_address static void update_allocation_stats(int64 size, @@ -2585,8 +2585,8 @@ switch(f) { - case VM_RT_LDC_STRING: - fptr = get_vm_rt_ldc_string_address(); + case VM_RT_LDC_REF: + fptr = get_vm_rt_ldc_ref_address(); dereference_fptr = false; break; case VM_RT_MULTIANEWARRAY_RESOLVED: