Index: vm/jitrino/src/optimizer/escanalyzer.cpp =================================================================== --- vm/jitrino/src/optimizer/escanalyzer.cpp (revision 541352) +++ vm/jitrino/src/optimizer/escanalyzer.cpp (working copy) @@ -40,7 +40,7 @@ const char* help = " escape flags:\n" " escape.max_level[=0] - max level callee method analysis\n" - " escape.do_sync_removal[={on,OFF}] - do synchronization removal optimization\n" + " escape.do_sync_removal[={ON,off}] - do synchronization removal optimization\n" " escape.do_sync_removal_vc[={ON,off}] - do synchronization removal optimization\n" " for virtual call escaped operands\n" " escape.do_sync_removal_sm[={ON,off}] - do synchronization removal optimization\n" @@ -48,8 +48,9 @@ " escape.do_scalar_repl[={ON,off}] - do scalar replacement optimization for\n" " local and escaped objects\n" " escape.do_esc_scalar_repl[={ON,off}] - scalar replacement for escaped objects\n" - " escape.do_scalar_repl_only_final_fields[={on,OFF}] \n" - " escape.scalarize_final_fields[={on,OFF}] - scalarize final field usage when\n" + " escape.do_scalar_repl_only_final_fields_in_use[={on,OFF}] \n" + " escape.do_scalar_repl_final_fields[={on,OFF}] \n" + " - scalarize final field usage when\n" " escaped object wasn't optimized\n" " escape.exec_count_mult[=0] - entry node execCount multiplier\n"; @@ -101,8 +102,8 @@ print_scinfo = argSource->getBoolArg("sc_info",false); execCountMultiplier_string = argSource->getStringArg("exec_count_mult", NULL); 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); + do_scalar_repl_only_final_fields_in_use = argSource->getBoolArg("do_scalar_repl_only_final_fields_in_use",false); + do_scalar_repl_final_fields = argSource->getBoolArg("do_scalar_repl_final_fields",false); compressedReferencesArg = argSource->getBoolArg("compressedReferences", false); const char* translatorName = argSource->getStringArg("translatorActionName", "translator"); @@ -198,7 +199,7 @@ EscAnalyzer::showFlags(std::ostream& os) { os << " escape flags:"<nodeMDs = NULL; if (type->isReference()) { if (type->isArray()) { @@ -1200,6 +1202,12 @@ } else { cgnode->nodeRefType = NR_PRIM; } + if (cgnode->nodeType==NT_OBJECT && cgnode->nodeRefType == NR_REF) { + NamedType* nt = (NamedType*)(inst->getDst())->getType(); + if (nt->isFinalizable()) { // finalized objects cannot be removed + setOutEscaped(cgnode); + } + } cngNodes->push_back(cgnode); return cgnode; } // addCnGNode(Inst* inst, Type* type, uint32 ntype) @@ -1915,7 +1923,7 @@ } } if (initNodeType==NT_EXITVAL) { - if (getCalleeEscaped(cgn) == 0) { + if (getOutEscaped(cgn) == 0) { #ifdef _DEBUG if (_setState) { Log::out() <<"--scanGE 3: nodeId " @@ -1926,12 +1934,12 @@ << cgn->nodeType <<" initNode "<nodeType == NT_OBJECT ) { setEscState(cgn,GLOBAL_ESCAPE); //objects escaped through defarg - global escape } else { - setCalleeEscaped(cgn); + setOutEscaped(cgn); } } } @@ -2185,7 +2193,7 @@ continue; } } - if (getCalleeEscaped(node) == 0 && getCalleeEscaped(cgn) != 0) { + if (getOutEscaped(node) == 0 && getOutEscaped(cgn) != 0) { calle = true; continue; } @@ -2445,7 +2453,7 @@ uint32 escstate = 3, bitstate = 0; for (it = cngNodes->begin( ); it != cngNodes->end( ); it++) { if ((*it)->nodeType==NT_EXITVAL) { - bitstate = bitstate|getCalleeEscaped(*it); + bitstate = bitstate|getOutEscaped(*it); if (escstate > getEscState(*it)) escstate=getEscState(*it); } @@ -2507,7 +2515,8 @@ typedef ::std::pair intPair; for (it = cngNodes->begin( ); it != cngNodes->end( ); it++ ) { - if ((*it)->nodeType == NT_OBJECT && getEscState(*it) > GLOBAL_ESCAPE) { + if ((*it)->nodeType == NT_OBJECT && getEscState(*it) > GLOBAL_ESCAPE && getVirtualCall(*it) == 0 + && getOutEscaped(*it) == 0) { nonEscInsts.insert(intPair((*it)->instrId,getFullState(*it))); } } @@ -4156,7 +4165,7 @@ for (it = cngNodes->begin( ); it != cngNodes->end( ); it++ ) { if ((*it)->nodeType == NT_OBJECT && getEscState(*it)==NO_ESCAPE - && getCalleeEscaped(*it) == 0 && !((*it)->nInst->getOpcode()==Op_LdRef)) { + && getOutEscaped(*it) == 0 && !((*it)->nInst->getOpcode()==Op_LdRef)) { if (prTitle) { if (_scinfo) { os_sc << "================ Local Object States < "; @@ -4284,7 +4293,7 @@ for (it = cngNodes->begin( ); it != cngNodes->end( ); it++ ) { // if ((*it)->nodeType == NT_OBJECT && getEscState(*it)!=NO_ESCAPE if ((*it)->nodeType == NT_OBJECT - && getCalleeEscaped(*it) == 0 && !((*it)->nInst->getOpcode()==Op_LdRef)) { + && getOutEscaped(*it) == 0 && !((*it)->nInst->getOpcode()==Op_LdRef)) { if ((*it)->nInst->getNode() == NULL && getEscState(*it)==NO_ESCAPE) { continue; // already scalarized } @@ -4604,7 +4613,7 @@ os_sc<<"* " << (path_prob < entryNode_execCount*ec_mult || path_prob==0)<refObj)->printWithType(os_sc); + NamedType* nt = (NamedType*)((Opnd*)scnode->refObj)->getType(); + if (nt->isFinalizable()) { + os_sc << " - finalizable "; + } os_sc << std::endl; os_sc << " =="; ((Opnd*)scnode->refObj)->getInst()->print(os_sc); os_sc << std::endl; @@ -5503,7 +5516,7 @@ goto MM; } // to optimize escaped object - if (do_scalar_repl_only_final_fields) { + if (do_scalar_repl_only_final_fields_in_use) { if (ob_fin_fld_count==ob_fld_usage_count) { storeId = true; } else { Index: vm/jitrino/src/optimizer/escanalyzer.h =================================================================== --- vm/jitrino/src/optimizer/escanalyzer.h (revision 541352) +++ vm/jitrino/src/optimizer/escanalyzer.h (working copy) @@ -107,7 +107,7 @@ static const uint32 ESC_MASK = 3; static const uint32 BIT_MASK = 56; static const uint32 LOOP_CREATED = 8; - static const uint32 CALLEE_ESCAPED = 16; + static const uint32 OUT_ESCAPED = 16; static const uint32 VIRTUAL_CALL = 32; @@ -198,8 +198,8 @@ bool do_sync_removal_sm; bool do_scalar_repl; bool do_esc_scalar_repl; - bool do_scalar_repl_only_final_fields; - bool scalarize_final_fields; + bool do_scalar_repl_only_final_fields_in_use; + bool do_scalar_repl_final_fields; const char* execCountMultiplier_string; double ec_mult; bool print_scinfo; @@ -609,14 +609,14 @@ void remLoopCreated(CnGNode* n) { n->state = (n->state|LOOP_CREATED)^LOOP_CREATED; } - uint32 getCalleeEscaped(CnGNode* n) { - return (n->state)&CALLEE_ESCAPED; + uint32 getOutEscaped(CnGNode* n) { + return (n->state)&OUT_ESCAPED; } - void setCalleeEscaped(CnGNode* n) { - n->state = n->state|CALLEE_ESCAPED; + void setOutEscaped(CnGNode* n) { + n->state = n->state|OUT_ESCAPED; } - void remCalleeEscaped(CnGNode* n) { - n->state = (n->state|CALLEE_ESCAPED)^CALLEE_ESCAPED; + void remOutEscaped(CnGNode* n) { + n->state = (n->state|OUT_ESCAPED)^OUT_ESCAPED; } uint32 getVirtualCall(CnGNode* n) { return (n->state)&VIRTUAL_CALL;