Index: vm/port/src/encoder/ia32_em64t/enc_prvt.h =================================================================== --- vm/port/src/encoder/ia32_em64t/enc_prvt.h (revision 587470) +++ vm/port/src/encoder/ia32_em64t/enc_prvt.h (working copy) @@ -156,6 +156,11 @@ #define RDX { OpndKind_GPReg, OpndSize_64, RegName_RDX } #endif +#define ESI {OpndKind_GPReg, OpndSize_32, RegName_ESI} +#ifdef _EM64T_ + #define RSI { OpndKind_GPReg, OpndSize_64, RegName_RSI } +#endif + #define EDI {OpndKind_GPReg, OpndSize_32, RegName_EDI} #ifdef _EM64T_ #define RDI { OpndKind_GPReg, OpndSize_64, RegName_RDI } Index: vm/port/src/encoder/ia32_em64t/enc_tabl.cpp =================================================================== --- vm/port/src/encoder/ia32_em64t/enc_tabl.cpp (revision 587470) +++ vm/port/src/encoder/ia32_em64t/enc_tabl.cpp (working copy) @@ -1439,22 +1439,22 @@ BEGIN_MNEMONIC(CMPSB, MF_AFFECTS_FLAGS, DU_DU_DU) BEGIN_OPCODES() - {OpcodeInfo::ia32, {0xA6}, {r32,r32,ECX}, DU_DU_DU }, - {OpcodeInfo::em64t, {0xA6}, {r64,r64,RCX}, DU_DU_DU }, + {OpcodeInfo::ia32, {0xA6}, {ESI,EDI,ECX}, DU_DU_DU }, + {OpcodeInfo::em64t, {0xA6}, {RSI,RDI,RCX}, DU_DU_DU }, END_OPCODES() END_MNEMONIC() BEGIN_MNEMONIC(CMPSW, MF_AFFECTS_FLAGS, DU_DU_DU) BEGIN_OPCODES() - {OpcodeInfo::ia32, {Size16, 0xA7}, {r32,r32,ECX}, DU_DU_DU }, - {OpcodeInfo::em64t, {Size16, 0xA7}, {r64,r64,RCX}, DU_DU_DU }, + {OpcodeInfo::ia32, {Size16, 0xA7}, {EDI,ESI,ECX}, DU_DU_DU }, + {OpcodeInfo::em64t, {Size16, 0xA7}, {RDI,RSI,RCX}, DU_DU_DU }, END_OPCODES() END_MNEMONIC() BEGIN_MNEMONIC(CMPSD, MF_AFFECTS_FLAGS, DU_DU_DU) BEGIN_OPCODES() - {OpcodeInfo::ia32, {0xA7}, {r32,r32,ECX}, DU_DU_DU }, - {OpcodeInfo::em64t, {0xA7}, {r64,r64,RCX}, DU_DU_DU }, + {OpcodeInfo::ia32, {0xA7}, {ESI,EDI,ECX}, DU_DU_DU }, + {OpcodeInfo::em64t, {0xA7}, {RSI,RDI,RCX}, DU_DU_DU }, END_OPCODES() END_MNEMONIC() Index: vm/jitrino/config/em64t/server_static.emconf =================================================================== --- vm/jitrino/config/em64t/server_static.emconf (revision 587470) +++ vm/jitrino/config/em64t/server_static.emconf (working copy) @@ -24,7 +24,7 @@ -XX:jit.SS_OPT.path=opt_init,translator,optimizer,hir2lir,codegen --XX:jit.SS_OPT.path.optimizer=ssa,simplify,dce,uce,statprof,devirt,inline,purge,simplify,dce,uce,hvn,dce,uce,dessa,statprof,peel,ssa,hvn,simplify,dce,uce,lower,dce,uce,memopt,reassoc,dce,uce,hvn,dce,uce,classic_abcd,dce,uce,gcm,dessa,statprof +-XX:jit.SS_OPT.path.optimizer=ssa,simplify,dce,uce,statprof,devirt,hlo_api_magic,inline,purge,simplify,dce,uce,hvn,dce,uce,dessa,statprof,peel,ssa,hvn,simplify,dce,uce,lower,dce,uce,memopt,reassoc,dce,uce,hvn,dce,uce,classic_abcd,dce,uce,gcm,dessa,statprof -XX:jit.SS_OPT.path.codegen=lock_method,bbp,gcpoints,cafl,dce1,i8l-,early_prop-,itrace-,native,constraints,dce2,regalloc,spillgen,layout,copy,rce-,stack,break-,iprof-,emitter!,si_insts,gcmap,info,unlock_method -XX:jit.SS_OPT.path.dce1=cg_dce -XX:jit.SS_OPT.path.dce2=cg_dce @@ -34,7 +34,7 @@ #inliner configuration -XX:jit.SS_OPT.SS_OPT_inliner_pipeline.filter=- --XX:jit.SS_OPT.SS_OPT_inliner_pipeline.path=ssa,simplify,dce,uce,statprof,devirt +-XX:jit.SS_OPT.SS_OPT_inliner_pipeline.path=ssa,simplify,dce,uce,statprof,devirt,hlo_api_magic -XX:jit.SS_OPT.arg.optimizer.inline.pipeline=SS_OPT_inliner_pipeline -XX:jit.SS_OPT.arg.codegen.dce1.early=yes Index: vm/jitrino/config/em64t/opt.emconf =================================================================== --- vm/jitrino/config/em64t/opt.emconf (revision 587470) +++ vm/jitrino/config/em64t/opt.emconf (working copy) @@ -24,8 +24,8 @@ -XX:jit.CS_OPT.path=opt_init,translator,optimizer,hir2lir,codegen --XX:jit.CS_OPT.path.optimizer=ssa,devirt,inline,purge,simplify,dce,uce,escape,dce,uce,memopt,simplify,dce,uce,lower,dessa,statprof --XX:jit.CS_OPT.path.codegen=lock_method,bbp,gcpoints,cafl,dce1,i8l-,early_prop-,itrace-,native,constraints,dce2,regalloc,spillgen,layout,copy,rce-,stack,break-,iprof-,emitter!,si_insts,gcmap,info,unlock_method +-XX:jit.CS_OPT.path.optimizer=ssa,devirt,hlo_api_magic,inline,purge,simplify,dce,uce,escape,dce,uce,memopt,simplify,dce,uce,lower,dessa,statprof +-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 -XX:jit.CS_OPT.path.dce1=cg_dce -XX:jit.CS_OPT.path.dce2=cg_dce -XX:jit.CS_OPT.path.regalloc=bp_regalloc1,bp_regalloc2 @@ -34,7 +34,7 @@ #inliner configuration -XX:jit.CS_OPT.CS_OPT_inliner_pipeline.filter=- --XX:jit.CS_OPT.CS_OPT_inliner_pipeline.path=ssa,devirt +-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 Index: vm/jitrino/config/em64t/server.emconf =================================================================== --- vm/jitrino/config/em64t/server.emconf (revision 587470) +++ vm/jitrino/config/em64t/server.emconf (working copy) @@ -69,7 +69,7 @@ -XX:jit.SD1_OPT.arg.optimizer.vp_instrument.profile_abstract=true --XX:jit.SD2_OPT.path.optimizer=ssa,simplify,dce,uce,devirt_virtual,edge_annotate,unguard,devirt_intf,inline,purge,simplify,dce,uce,so2-,simplify,dce,uce,escape,dce,uce,hvn,dce,uce,inline_helpers,purge,simplify,uce,dce,dessa,statprof,peel,ssa,hvn,simplify,dce,uce,lower,dce,uce,memopt,reassoc,dce,uce,hvn,dce,uce,classic_abcd,dce,uce,gcm,dessa,fastArrayFill,statprof +-XX:jit.SD2_OPT.path.optimizer=ssa,simplify,dce,uce,devirt_virtual,edge_annotate,unguard,devirt_intf,hlo_api_magic,inline,purge,simplify,dce,uce,so2-,simplify,dce,uce,escape,dce,uce,hvn,dce,uce,inline_helpers,purge,simplify,uce,dce,dessa,statprof,peel,ssa,hvn,simplify,dce,uce,lower,dce,uce,memopt,reassoc,dce,uce,hvn,dce,uce,classic_abcd,dce,uce,gcm,dessa,fastArrayFill,statprof -XX:jit.SD2_OPT.path.codegen=lock_method,bbp,gcpoints,cafl,dce1,i8l-,early_prop-,itrace-,native,cg_fastArrayFill,constraints,dce2,regalloc,spillgen,layout,copy,rce-,stack,break-,iprof-,emitter!,si_insts,gcmap,info,unlock_method -XX:jit.SD2_OPT.path.dce1=cg_dce -XX:jit.SD2_OPT.path.dce2=cg_dce @@ -83,7 +83,7 @@ #inliner configuration -XX:jit.SD2_OPT.SD2_OPT_inliner_pipeline.filter=- --XX:jit.SD2_OPT.SD2_OPT_inliner_pipeline.path=ssa,simplify,dce,uce,devirt_virtual,edge_annotate,unguard,devirt_intf +-XX:jit.SD2_OPT.SD2_OPT_inliner_pipeline.path=ssa,simplify,dce,uce,devirt_virtual,edge_annotate,unguard,devirt_intf,hlo_api_magic -XX:jit.SD2_OPT.arg.optimizer.inline.pipeline=SD2_OPT_inliner_pipeline -XX:jit.SD2_OPT.arg.optimizer.inline.connect_early=false #devirt configuration for inliner pipeline Index: vm/jitrino/src/codegenerator/ia32/Ia32APIMagics.cpp =================================================================== --- vm/jitrino/src/codegenerator/ia32/Ia32APIMagics.cpp (revision 587470) +++ vm/jitrino/src/codegenerator/ia32/Ia32APIMagics.cpp (working copy) @@ -60,7 +60,8 @@ virtual void run()=0; protected: - Opnd* addElemIndexWithLEA(Opnd* array, Opnd* index, Node* node); + void convertIntToInt(Opnd* dst, Opnd* src, Node* node); + Opnd* addElemIndexWithLEA(Opnd* array, Opnd* index, Node* node); IRManager* irm; CallInst* callInst; @@ -108,6 +109,7 @@ continue; }; if( ri->getKind() == Opnd::RuntimeInfo::Kind_MethodDirectAddr ){ +#ifndef _EM64T_ MethodDesc * md = (MethodDesc*)ri->getValue(0); const char* className = md->getParentType()->getName(); const char* methodName = md->getName(); @@ -125,6 +127,7 @@ handlers.push_back(new (tmpMM) Long_numberOfTrailingZeros_Handler_x_J_x_I(irm, callInst, md)); } } +#endif } else if( ri->getKind() == Opnd::RuntimeInfo::Kind_InternalHelperAddress ) { if( strcmp((char*)ri->getValue(0),"String_compareTo")==0 ) { if(getBoolArg("String_compareTo_as_magic", true)) @@ -363,7 +366,7 @@ // prepare counter Opnd* counter = irm->newRegOpnd(counterType,counterRegName); - node->appendInst(irm->newCopyPseudoInst(Mnemonic_MOV, counter, valForCounter)); + convertIntToInt(counter, valForCounter, node); // prepare this position Opnd* thisAddr = addElemIndexWithLEA(thisArr,thisIdx,node); @@ -451,7 +454,7 @@ // prepare counter Opnd* counter = irm->newRegOpnd(counterType,counterRegName); - node->appendInst(irm->newCopyPseudoInst(Mnemonic_MOV, counter, valForCounter)); + convertIntToInt(counter, valForCounter, node); // prepare this position Opnd* thisAddr = addElemIndexWithLEA(thisArr,thisIdx,node); @@ -491,6 +494,25 @@ callInst->unlink(); } +// this intends for indexes and counters conversion +// ATTENTION !!! Zero Extention is used for this +void APIMagicHandler::convertIntToInt(Opnd* dst, Opnd* src, Node* node) +{ + Type* dstType = dst->getType(); + Type* srcType = src->getType(); + + // this works only for equal types + // or Int32 into Int64 conversion + assert(srcType == dstType || (srcType == irm->getTypeManager().getInt32Type() && + dstType == irm->getTypeManager().getInt64Type())); + + if(srcType != dstType) { + node->appendInst(irm->newInstEx(Mnemonic_MOVZX, 1, dst, src)); + } else { + node->appendInst(irm->newCopyPseudoInst(Mnemonic_MOV, dst, src)); + } +} + // Compute address of the array element given // address of the first element and index // using 'LEA' instruction @@ -520,22 +542,14 @@ } Opnd * elemSizeOpnd = irm->newImmOpnd(indexType, elemSize); - Opnd * indexOpnd = index; - assert(index->getType() == indexType); //when this assertion fails 'convert' should be implemented -// indexOpnd = convert(indexOpnd, indexType); - - if ( indexOpnd->isPlacedIn(OpndKind_Imm) ) { - // we need to put index operand on a register to satisfy LEA constraint - int64 immValue = indexOpnd->getImmValue(); - if (immValue == 0) { + Opnd * indexOpnd = NULL; + if ( index->isPlacedIn(OpndKind_Imm) && index->getImmValue() == 0 ) { indexOpnd = NULL; elemSizeOpnd = NULL; - } else { - Opnd * indexReg = irm->newOpnd(indexType); - node->appendInst(irm->newCopyPseudoInst(Mnemonic_MOV, indexReg, indexOpnd)); - indexOpnd = indexReg; - } - } + } else { + indexOpnd = irm->newOpnd(indexType); + convertIntToInt(indexOpnd,index,node); + } Opnd * arrOffset = irm->newImmOpnd(offType, arrayType->getArrayElemOffset()); Opnd * addr = irm->newMemOpnd(dstType,(Opnd*)array, indexOpnd, elemSizeOpnd, arrOffset); Opnd * dst = irm->newOpnd(dstType);