You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by va...@apache.org on 2007/05/31 12:44:18 UTC
svn commit: r543108 - in
/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer: escanalyzer.cpp
escanalyzer.h
Author: varlax
Date: Thu May 31 03:44:18 2007
New Revision: 543108
URL: http://svn.apache.org/viewvc?view=rev&rev=543108
Log:
Applied HARMONY-3984 [drlvm][jit]Finalizable object should not be scalarized
Modified:
harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/escanalyzer.cpp
harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/escanalyzer.h
Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/escanalyzer.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/escanalyzer.cpp?view=diff&rev=543108&r1=543107&r2=543108
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/escanalyzer.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/escanalyzer.cpp Thu May 31 03:44:18 2007
@@ -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:"<<std::endl;
os << " escape.max_level[=0] - max level callee method analysis" << std::endl;
- os << " escape.do_sync_removal[={On,off}] - do synchronization removal optimization" << std::endl;
+ os << " escape.do_sync_removal[={ON,off}] - do synchronization removal optimization" << std::endl;
os << " escape.do_sync_removal_vc[={ON,off}] - do synchronization removal optimization" << std::endl;
os << " for virtual call escaped operands" << std::endl;
os << " escape.do_sync_removal_sm[={ON,off}] - do synchronization removal optimization" << std::endl;
@@ -206,8 +207,9 @@
os << " escape.do_scalar_repl[={ON,off}] - do scalar replacement optimization for" << std::endl;
os << " local and escaped objects" << std::endl;
os << " escape.do_esc_scalar_repl[={ON,off}] - scalar replacement for escaped objects" << std::endl;
- os << " escape.do_scalar_repl_only_final_fields[={on,OFF}] " << std::endl;
- os << " escape.scalarize_final_fields[={on,OFF}] - scalarize final field usage when" << std::endl;
+ os << " escape.do_scalar_repl_only_final_fields_in_use[={on,OFF}] " << std::endl;
+ os << " escape.do_scalar_repl_final_fields[={on,OFF}] " << std::endl;
+ os << " - scalarize final field usage when" << std::endl;
os << " escaped object wasn't optimized" << std::endl;
os << " escape.exec_count_mult[=0] - entry node execCount multiplier" << std::endl;
}
@@ -1184,7 +1186,7 @@
setFullState(cgnode,NO_ESCAPE);
}
if (ntype==NT_EXITVAL)
- setCalleeEscaped(cgnode);
+ setOutEscaped(cgnode);
cgnode->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 "<<initNodeType<< std::endl;
}
#endif
- setCalleeEscaped(cgn);
+ setOutEscaped(cgn);
}
// The objects created in the method are not global escaped through return
}
if (initNodeType==NT_DEFARG) {
- if (getCalleeEscaped(cgn) == 0) {
+ if (getOutEscaped(cgn) == 0) {
#ifdef _DEBUG
if (_setState) {
Log::out() <<"--scanGE 4: nodeId "
@@ -1949,7 +1957,7 @@
if (cgn->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 <uint32,uint32> 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)<<std::endl;
}
if (path_prob < entryNode_execCount*ec_mult || path_prob==0) {
- if (scalarize_final_fields) {
+ if (do_scalar_repl_final_fields) {
checkToScalarizeFinalFiels(onode, scObjFlds);
}
continue;
@@ -5320,6 +5329,10 @@
if (_scinfo) {
os_sc << "=="; printCnGNode(scnode,os_sc);
((Opnd*)scnode->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 {
Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/escanalyzer.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/escanalyzer.h?view=diff&rev=543108&r1=543107&r2=543108
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/escanalyzer.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/escanalyzer.h Thu May 31 03:44:18 2007
@@ -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;