Index: vm/jitrino/src/optimizer/escanalyzer.cpp =================================================================== --- vm/jitrino/src/optimizer/escanalyzer.cpp (revision 523676) +++ vm/jitrino/src/optimizer/escanalyzer.cpp (working copy) @@ -111,6 +111,7 @@ ec_mult = ( execCountMultiplier_string==NULL ? 0 : atof(execCountMultiplier_string) ); do_scalar_repl_only_final_fields = argSource->getBoolArg("do_scalar_repl_only_final_fields",false); scalarize_final_fields = argSource->getBoolArg("scalarize_final_fields",false); + compressedReferencesArg = argSource->getBoolArg("compressedReferences", false); const char* translatorName = argSource->getStringArg("translatorActionName", "translator"); translatorAction = (TranslatorAction*)PMF::getAction(argSource->getPipeline(), translatorName); @@ -2120,7 +2121,7 @@ dominatorTree = irManager.getDominatorTree(); } if (dominatorTree && dominatorTree->isValid()) { - OptPass::computeLoops(irManager); + OptPass::computeLoops(irManager,false); LoopTree* ltree = irManager.getLoopTree(); if (ltree->isValid()) for (it = cngNodes->begin( ); it != cngNodes->end( ); it++ ) { @@ -2592,7 +2593,6 @@ void EscAnalyzer::scanCnGNodeRefsGE(CnGNode* cgn, bool check_var_src, bool check_field_elem) { -// CnGEdges* cge = cngEdges; CnGEdges::iterator it; CnGRefs::iterator it1; CnGNode* next_node; @@ -2604,18 +2604,29 @@ if (_setState) { Log::out() <<"--scanGE 1: node "<cngNodeId <<" opndId "<opndId<<" state "; - if (Log::isEnabled()) - printState(cgn); + printState(cgn); Log::out() <<" " << nodeTypeToString(cgn) <nodeType <<" check_var_src " << check_var_src <<" check_field_elem " << check_field_elem << std::endl; } #endif - if (cgn->nodeType == NT_LDVAL) + if (cgn->nodeType == NT_LDVAL) { +#ifdef _DEBUG + if (_setState) { + Log::out() <<"--scanGE > 1: primitive type " << std::endl; + } +#endif return; + } if (scObjs->size()!=0) { - if (checkScanned(scObjs,cgn->cngNodeId)) + if (checkScanned(scObjs,cgn->cngNodeId)) { +#ifdef _DEBUG + if (_setState) { + Log::out() <<"--scanGE > 1: was scanned earlier " << std::endl; + } +#endif return; + } } if (cgn->nodeType&NT_OBJS) { if (initNodeType!=NT_EXITVAL && initNodeType!=NT_DEFARG) { // @@ -2624,8 +2635,7 @@ if (_setState) { Log::out() <<"--scanGE 2: node " <cngNodeId<<" opndId "<opndId <<" state "; - if (Log::isEnabled()) - printState(cgn); + printState(cgn); Log::out() <<" to gl.esc."<< std::endl; Log::out() <<"--scanGE 2: "<< nodeTypeToString(cgn) << cgn->nodeType <<" initNode "<cngNodeId<<" opndId "<opndId <<" state "; - if (Log::isEnabled()) - printState(cgn); + printState(cgn); Log::out() <<" to callee.esc."<< std::endl; Log::out() <<"--scanGE 3: "<< nodeTypeToString(cgn) << cgn->nodeType <<" initNode "<cngNodeId<<" opndId "<opndId <<" state "; - if (Log::isEnabled()) - printState(cgn); + printState(cgn); Log::out() <<" to callee.esc."<< std::endl; Log::out() <<"--scanGE 4: "<< nodeTypeToString(cgn) << cgn->nodeType <<" initNode "<push_back(cgn->cngNodeId); + scObjs->push_back(cgn->cngNodeId); if (cgn->outEdges != NULL) { bool to_check_var_src = check_var_src; @@ -2688,6 +2696,12 @@ } #endif scanCnGNodeRefsGE(next_node,to_check_var_src,to_check_field_elem); +#ifdef _DEBUG + if (_setState) { + Log::out() <<"--scanGE ret 1 for node: " << next_node->cngNodeId + <<" opndId " << next_node->opndId << std::endl; + } +#endif if ((*it1)->edgeType!=ET_POINT) nscan++; } @@ -2705,6 +2719,12 @@ } #endif scanCnGNodeRefsGE(next_node,check_var_src); +#ifdef _DEBUG + if (_setState) { + Log::out() <<"--scanGE ret 2 for node: " << next_node->cngNodeId + <<" opndId " << next_node->opndId << std::endl; + } +#endif } } } @@ -2713,7 +2733,7 @@ Log::out()<<"--scanGE: nscan "<opndId<nodeType==NT_ARRELEM) { + if (cgn->nodeType==NT_ARRELEM && !check_field_elem) { Inst* inst_ldbase = cgn->nInst; if (inst_ldbase->getOpcode()==Op_AddScaledIndex) inst_ldbase = ((Opnd*)(cgn->refObj))->getInst()->getSrc(0)->getInst(); @@ -2721,8 +2741,7 @@ #ifdef _DEBUG if (_setState) { Log::out() <<"--scanGE 7 arrElem: "; - if (Log::isEnabled()) - inst_ldbase->print(Log::out()); + inst_ldbase->print(Log::out()); Log::out() << std::endl; Log::out() <<"--scanGE 7 next: " << cgnode->cngNodeId << " - " << cgnode->opndId << std::endl; @@ -2740,6 +2759,12 @@ } #endif scanCnGNodeRefsGE(next_node,check_var_src,false); +#ifdef _DEBUG + if (_setState) { + Log::out() <<"--scanGE ret 3 for node: " << next_node->cngNodeId + <<" opndId " << next_node->opndId << std::endl; + } +#endif } } } @@ -2753,11 +2778,9 @@ if (_setState) { Log::out() << "--scanGE 8 TO FIND 1 for opnd " << cgn->opndId << std::endl; - if (Log::isEnabled()) - ldinst->print(Log::out()); + ldinst->print(Log::out()); Log::out() << std::endl; - if (Log::isEnabled()) - inst_fldaddr->print(Log::out()); + inst_fldaddr->print(Log::out()); Log::out() << std::endl; Log::out() << cgn->cngNodeId << "-" << cgn->opndId << " -> "; @@ -2766,6 +2789,13 @@ } #endif scanCnGNodeRefsGE(cgnode,check_var_src,false); +#ifdef _DEBUG + if (_setState) { + Log::out() <<"--scanGE ret 4 for node: " << cgnode->cngNodeId + <<" opndId " << cgnode->opndId << std::endl; + } +#endif + } else { uint32 oc = inst_fldaddr->getOpcode(); if (oc==Op_AddScaledIndex || oc == Op_LdArrayBaseAddr) { @@ -2774,11 +2804,9 @@ if (_setState) { Log::out() << "--scanGE 8 TO FIND 2 for opnd " << cgn->opndId << std::endl; - if (Log::isEnabled()) - ldinst->print(Log::out()); + ldinst->print(Log::out()); Log::out() << std::endl; - if (Log::isEnabled()) - inst_fldaddr->print(Log::out()); + inst_fldaddr->print(Log::out()); Log::out() << std::endl; Log::out() << cgn->cngNodeId << "-" << cgn->opndId << " -> "; @@ -2787,6 +2815,12 @@ } #endif scanCnGNodeRefsGE(cgnode,check_var_src,false); +#ifdef _DEBUG + if (_setState) { + Log::out() <<"--scanGE ret 5 for node: " << cgnode->cngNodeId + <<" opndId " << cgnode->opndId << std::endl; + } +#endif } } } @@ -2807,8 +2841,7 @@ if (_setState) { Log::out() <<"--scanAE < 1: node "<cngNodeId <<" opndId "<opndId<<" state "; - if (Log::isEnabled()) - printState(cgn); + printState(cgn); Log::out() <<" " << nodeTypeToString(cgn) <nodeType <<" check_var_src " << check_var_src <<" check_field_elem " << check_field_elem << std::endl; @@ -2856,8 +2889,7 @@ if (_setState) { Log::out() <<"--scanAE 2: node "<cngNodeId <<" opndId "<opndId<<" state "; - if (Log::isEnabled()) - printState(cgn); + printState(cgn); Log::out() <<" to arg.esc."<< std::endl; } #endif @@ -2917,8 +2949,7 @@ #ifdef _DEBUG if (_setState) { Log::out() <<"--scanAE 5 check1: "; - if (Log::isEnabled()) - inst_ldbase->print(Log::out()); + inst_ldbase->print(Log::out()); Log::out() << std::endl; Log::out() <<"--scanAE 5 check2: "; if (cgnode==NULL) @@ -2951,11 +2982,9 @@ if (_setState) { Log::out() <<"--scanAE 6 TO FIND 1 for opnd " << cgn->opndId << std::endl; - if (Log::isEnabled()) - ldinst->print(Log::out()); + ldinst->print(Log::out()); Log::out() << std::endl; - if (Log::isEnabled()) - inst_fldaddr->print(Log::out()); + inst_fldaddr->print(Log::out()); Log::out() << std::endl; Log::out() << cgn->cngNodeId << "-" << cgn->opndId << " -> "; @@ -2972,11 +3001,9 @@ if (_setState) { Log::out() << "--scanAE 6 TO FIND 2 for opnd " << cgn->opndId << std::endl; - if (Log::isEnabled()) - ldinst->print(Log::out()); + ldinst->print(Log::out()); Log::out() << std::endl; - if (Log::isEnabled()) - inst_fldaddr->print(Log::out()); + inst_fldaddr->print(Log::out()); Log::out() << std::endl; Log::out() << cgn->cngNodeId << "-" << cgn->opndId << " -> "; @@ -3276,15 +3303,8 @@ cgnode->nodeRefType = NR_PRIM; } cngNodes->push_back(cgnode); -#ifdef _DEBUG - if (_cngnodes) { - Log::out() <<"++++ addNode "<cngNodeId - <<" opndId "<opndId; printCnGNode(cgnode,Log::out()); - Log::out() << std::endl; - } -#endif return cgnode; -} // addCnGNode(MemoryManager& mm, Type* type, Inst* inst, uint32 ntype) +} // addCnGNode(Inst* inst, Type* type, uint32 ntype) EscAnalyzer::CnGNode* @@ -3294,8 +3314,14 @@ cgnode->opndId = opnd->getId(); cgnode->refObj = opnd; +#ifdef _DEBUG + if (_cngnodes) { + Log::out() <<"++++ addNode "; printCnGNode(cgnode,Log::out()); + Log::out() << std::endl; + } +#endif return cgnode; -} // addCnGNode_op(MemoryManager& mm, Inst* inst, Type* type, uint32 ntype) +} // addCnGNode_op(Inst* inst, Type* type, uint32 ntype) EscAnalyzer::CnGNode* @@ -3306,19 +3332,31 @@ cgnode->opndId = 0; cgnode->argNumber = narg; cgnode->refObj = md; +#ifdef _DEBUG + if (_cngnodes) { + Log::out() <<"++++ addNode "; printCnGNode(cgnode,Log::out()); + Log::out() << std::endl; + } +#endif return cgnode; -} // addCnGNode_mp(MemoryManager& mm, Inst* inst, MethodDesc* md, uint32 ntype, uint32 narg) +} // addCnGNode_mp(Inst* inst, MethodDesc* md, uint32 ntype, uint32 narg) EscAnalyzer::CnGNode* -EscAnalyzer::addCnGNode_ex( Inst* inst, uint32 ntype) { +EscAnalyzer::addCnGNode_ex(Inst* inst, uint32 ntype) { Type* type = inst->getSrc(0)->getType(); CnGNode* cgnode = addCnGNode(inst, type, ntype); // new CG node cgnode->opndId = 0; cgnode->refObj = inst->getSrc(0); // returned or thrown operand +#ifdef _DEBUG + if (_cngnodes) { + Log::out() <<"++++ addNode "; printCnGNode(cgnode,Log::out()); + Log::out() << std::endl; + } +#endif return cgnode; -} // addCnGNode_ex(MemoryManager& mm, Inst* inst, uint32 ntype) +} // addCnGNode_ex(Inst* inst, uint32 ntype) EscAnalyzer::CnGNode* @@ -3328,8 +3366,14 @@ cgnode->opndId = 0; cgnode->refObj = inst; // returned or thrown operand +#ifdef _DEBUG + if (_cngnodes) { + Log::out() <<"++++ addNode "; printCnGNode(cgnode,Log::out()); + Log::out() << std::endl; + } +#endif return cgnode; -} // addCnGNode_fl(MemoryManager& mm, Inst* inst, uint32 ntype) +} // addCnGNode_fl(Inst* inst, uint32 ntype) void @@ -4862,11 +4906,14 @@ } if (do_fld_sc) { Type* fl_type = NULL; + Type* fl_type1 = NULL; Inst* ii = sco->ls_insts->front(); if (ii->getOpcode()==Op_TauStInd) { - fl_type = ii->getSrc(1)->getType()->asPtrType()->getPointedToType(); + fl_type1 = ii->getSrc(1)->getType()->asPtrType()->getPointedToType(); + fl_type = ii->getSrc(0)->getType(); } else { - fl_type = ii->getSrc(0)->getType()->asPtrType()->getPointedToType(); + fl_type1 = ii->getSrc(0)->getType()->asPtrType()->getPointedToType(); + fl_type = ii->getDst()->getType(); } VarOpnd* fl_var_opnd = _opndManager.createVarOpnd(fl_type, false); SsaTmpOpnd* fl_init_opnd = _opndManager.createSsaTmpOpnd(fl_type); @@ -4875,7 +4922,8 @@ sco->fldVarOpnd = fl_var_opnd; if (_scinfo) { - os_sc<<" PoitedType "; fl_type->print(os_sc); os_sc <print(os_sc); os_sc <print(os_sc); os_sc <isReference()) { ld_init_val_inst = _instFactory.makeLdNull(fl_init_opnd); @@ -5170,14 +5218,17 @@ if (sco->ls_insts->size()==0) continue; Type* fl_type = NULL; + Type* fl_type1 = NULL; Inst* ii = sco->ls_insts->front(); Inst* iadr = NULL; if (ii->getOpcode()==Op_TauStInd) { iadr=ii->getSrc(1)->getInst(); - fl_type = ii->getSrc(1)->getType()->asPtrType()->getPointedToType(); + fl_type1 = ii->getSrc(1)->getType()->asPtrType()->getPointedToType(); + fl_type = ii->getSrc(0)->getType(); } else { iadr=ii->getSrc(0)->getInst(); - fl_type = ii->getSrc(0)->getType()->asPtrType()->getPointedToType(); + fl_type1 = ii->getSrc(0)->getType()->asPtrType()->getPointedToType(); + fl_type = ii->getDst()->getType(); } VarOpnd* fl_var_opnd = _opndManager.createVarOpnd(fl_type, false); SsaTmpOpnd* fl_init_opnd = _opndManager.createSsaTmpOpnd(fl_type); @@ -5186,7 +5237,8 @@ sco->fldVarOpnd = fl_var_opnd; if (_scinfo) { - os_sc<<" PoitedType "; fl_type->print(os_sc); os_sc <print(os_sc); os_sc <print(os_sc); os_sc <isReference()) { ld_init_val_inst = _instFactory.makeLdNull(fl_init_opnd); @@ -5209,7 +5261,9 @@ } if (lobj_opt) { // - Modifier mod = ii->getModifier(); + bool comprRefs = compressedReferencesArg + || (compInterface.areReferencesCompressed()); + Modifier mod1 = comprRefs ? AutoCompress_Yes : AutoCompress_No; Opnd* ld_tau_op = _opndManager.createSsaTmpOpnd(_typeManager.getTauType()); Inst* itau = _instFactory.makeTauUnsafe(ld_tau_op); itau->insertAfter(lobj_inst); @@ -5219,7 +5273,7 @@ Inst* lda = _instFactory.makeLdFieldAddr(dst_ld,ob_opnd,fd); lda->insertAfter(itau); SsaTmpOpnd* fl_tmp_opnd_ld = _opndManager.createSsaTmpOpnd(fl_type); - Inst* ldf = _instFactory.makeTauLdInd(mod,fl_var_opnd->getType()->tag, + Inst* ldf = _instFactory.makeTauLdInd(mod1,fl_var_opnd->getType()->tag, fl_tmp_opnd_ld,dst_ld,ld_tau_op,ld_tau_op); ldf->insertAfter(lda); Inst* stv = _instFactory.makeStVar(fl_var_opnd,fl_tmp_opnd_ld); @@ -5942,19 +5996,19 @@ return r; } #ifdef _DEBUG - if (_scinfo) { +/* if (_scinfo) { os_sc << text << " From node : "; FlowGraph::printLabel(os_sc,node); os_sc << " id." << node->getId() << " execCount " << node->getExecCount() << " in prob " << cprob << std::endl; - } + }*/ #endif if (scannedObjs->size()!=0) { if (checkScannedObjs(node->getId())) { #ifdef _DEBUG - if (_scinfo) { +/* if (_scinfo) { os_sc << text << " . . . " << std::endl; - } + }*/ #endif if (scannedSucNodes->size()!=0) { if (checkScannedSucNodes(node->getId())) @@ -5968,7 +6022,7 @@ } } #ifdef _DEBUG - const Edges &out_edges = node->getOutEdges(); +/* const Edges &out_edges = node->getOutEdges(); if (_scinfo) { for (eit = out_edges.begin(); eit != out_edges.end(); ++eit) { double ecount = (*eit)->getTargetNode()->getExecCount(); @@ -5978,7 +6032,7 @@ << " execCount " << ecount << " edgeProb " << prob << " edgeKind " << (*eit)->getKind() << std::endl; } - } + }*/ #endif for (Inst* inst=headInst->getNextInst();inst!=NULL;inst=inst->getNextInst()) { if (inst->getOpcode()==Op_IndirectMemoryCall || inst->getOpcode()==Op_DirectCall) { @@ -6005,31 +6059,31 @@ if ((tn1=node->getUnconditionalEdgeTarget())!=NULL) { r0 = checkNextNodes(tn1,obId,r,text+" "); #ifdef _DEBUG - if (_scinfo) { +/* if (_scinfo) { os_sc << text << " "; FlowGraph::printLabel(os_sc,node); os_sc << " id." << node->getId() << " uncon. returned prob " << r0 << std::endl; - } + }*/ #endif } else { if ((tn1=node->getTrueEdgeTarget())!=NULL) { r1 = checkNextNodes(tn1,obId,r,text+" "); #ifdef _DEBUG - if (_scinfo) { +/* if (_scinfo) { os_sc << text << " "; FlowGraph::printLabel(os_sc,node); os_sc << " id." << node->getId() << " true returned prob " << r1 << std::endl; - } + }*/ #endif } if ((tn2=node->getFalseEdgeTarget())!=NULL) { r2 = checkNextNodes(tn2,obId,r,text+" "); #ifdef _DEBUG - if (_scinfo) { +/* if (_scinfo) { os_sc << text << " "; FlowGraph::printLabel(os_sc,node); os_sc << " id." << node->getId() << " false returned prob " << r2 << std::endl; - } + }*/ #endif } if (r1==-1 && r2==-1) @@ -6138,28 +6192,32 @@ continue; } Type* fl_type = NULL; + Type* type = NULL; Inst* ii = sco->ls_insts->front(); Inst* iadr = NULL; if (ii->getOpcode()==Op_TauStInd) { iadr=ii->getSrc(1)->getInst(); fl_type = ii->getSrc(1)->getType()->asPtrType()->getPointedToType(); + type = ii->getSrc(0)->getType(); } else { iadr=ii->getSrc(0)->getInst(); fl_type = ii->getSrc(0)->getType()->asPtrType()->getPointedToType(); + type = ii->getDst()->getType(); } assert(iadr->getOpcode()==Op_LdFieldAddr); // only esc.objects may be optimized - Type* type = sco->fldVarOpnd->getType(); bool compress = (fl_type->isCompressedReference() && !type->isCompressedReference()); Modifier compressMod = Modifier(compress ? AutoCompress_Yes : AutoCompress_No); - Modifier mod = Modifier(Store_NoWriteBarrier)|compressMod; + Modifier mod = (compInterface.insertWriteBarriers())? + (Modifier(Store_WriteBarrier)|compressMod) : (Modifier(Store_NoWriteBarrier)|compressMod); - SsaTmpOpnd* fl_tmp_opnd_st = _opndManager.createSsaTmpOpnd(fl_type); + SsaTmpOpnd* fl_tmp_opnd_st = _opndManager.createSsaTmpOpnd(type); _instFactory.makeLdVar(fl_tmp_opnd_st, sco->fldVarOpnd)->insertBefore(stvobj); Opnd* dst = _opndManager.createSsaTmpOpnd(iadr->getDst()->getType()); FieldDesc* fd = iadr->asFieldAccessInst()->getFieldDesc(); _instFactory.makeLdFieldAddr(dst,nob_opnd,fd)->insertBefore(stvobj); + Inst* nstind=_instFactory.makeTauStInd(mod,type->tag, fl_tmp_opnd_st,dst,st_tau_op,st_tau_op,st_tau_op); nstind->insertBefore(stvobj); @@ -6178,8 +6236,11 @@ Inst* lda = _instFactory.makeLdFieldAddr(dst_ld,ob_opnd,fd); node_after1->appendInst(lda); // loading field value - SsaTmpOpnd* fl_tmp_opnd_ld = _opndManager.createSsaTmpOpnd(fl_type); - Inst* ldf = _instFactory.makeTauLdInd(mod,type->tag,fl_tmp_opnd_ld,dst_ld, + SsaTmpOpnd* fl_tmp_opnd_ld = _opndManager.createSsaTmpOpnd(type); + bool comprRefs = compressedReferencesArg + || (compInterface.areReferencesCompressed()); + Modifier mod1 = comprRefs ? AutoCompress_Yes : AutoCompress_No; + Inst* ldf = _instFactory.makeTauLdInd(mod1,type->tag,fl_tmp_opnd_ld,dst_ld, ld_tau_op,ld_tau_op); node_after1->appendInst(ldf); // storing field value in field var opnd @@ -6595,24 +6656,33 @@ continue; } Type* fl_type = NULL; + Type* fl_type1 = NULL; Inst* ii = sco->ls_insts->front(); Inst* iadr = NULL; if (ii->getOpcode()==Op_TauStInd) { iadr=ii->getSrc(1)->getInst(); - fl_type = ii->getSrc(1)->getType()->asPtrType()->getPointedToType(); + fl_type1 = ii->getSrc(1)->getType()->asPtrType()->getPointedToType(); + fl_type = ii->getSrc(0)->getType(); } else { iadr=ii->getSrc(0)->getInst(); - fl_type = ii->getSrc(0)->getType()->asPtrType()->getPointedToType(); + fl_type1 = ii->getSrc(0)->getType()->asPtrType()->getPointedToType(); + fl_type = ii->getDst()->getType(); } VarOpnd* fl_var_opnd = _opndManager.createVarOpnd(fl_type, false); sco->fldVarOpnd = fl_var_opnd; + if (_scinfo) { + os_sc<<" PoitedType "; fl_type1->print(os_sc); os_sc <print(os_sc); os_sc <nInst->getNode()); os_sc << "++++ old newobj: before end" << std::endl; } - Modifier mod = ii->getModifier(); + bool comprRefs = compressedReferencesArg + || (compInterface.areReferencesCompressed()); + Modifier mod1 = comprRefs ? AutoCompress_Yes : AutoCompress_No; Opnd* ld_tau_op = _opndManager.createSsaTmpOpnd(_typeManager.getTauType()); Inst* itau = _instFactory.makeTauUnsafe(ld_tau_op); itau->insertAfter(onode->nInst); @@ -6622,7 +6692,7 @@ Inst* lda = _instFactory.makeLdFieldAddr(dst_ld,ob_opnd,fd); lda->insertAfter(itau); SsaTmpOpnd* fl_tmp_opnd_ld = _opndManager.createSsaTmpOpnd(fl_type); - Inst* ldf = _instFactory.makeTauLdInd(mod,fl_var_opnd->getType()->tag, + Inst* ldf = _instFactory.makeTauLdInd(mod1,fl_var_opnd->getType()->tag, fl_tmp_opnd_ld,dst_ld,ld_tau_op,ld_tau_op); ldf->insertAfter(lda); Inst* stv = _instFactory.makeStVar(fl_var_opnd,fl_tmp_opnd_ld); Index: vm/jitrino/src/optimizer/escanalyzer.h =================================================================== --- vm/jitrino/src/optimizer/escanalyzer.h (revision 523676) +++ vm/jitrino/src/optimizer/escanalyzer.h (working copy) @@ -162,6 +162,7 @@ bool scalarize_final_fields; const char* execCountMultiplier_string; double ec_mult; + bool compressedReferencesArg; // for makeTauLdInd private: static const int maxMethodExamLevel_default = 0;