Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 47535 invoked from network); 15 Mar 2007 10:27:47 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 15 Mar 2007 10:27:47 -0000 Received: (qmail 85135 invoked by uid 500); 15 Mar 2007 10:27:55 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 85104 invoked by uid 500); 15 Mar 2007 10:27:54 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 85093 invoked by uid 99); 15 Mar 2007 10:27:54 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 15 Mar 2007 03:27:54 -0700 X-ASF-Spam-Status: No, hits=-99.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 15 Mar 2007 03:27:45 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 6EB661A984A; Thu, 15 Mar 2007 03:27:25 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r518565 [3/3] - in /harmony/enhanced/drlvm/trunk: src/test/microbenchmark/harmony-2874/ vm/jitrino/config/em64t/ vm/jitrino/config/ia32/ vm/jitrino/src/optimizer/ Date: Thu, 15 Mar 2007 10:27:24 -0000 To: commits@harmony.apache.org From: varlax@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070315102725.6EB661A984A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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=518565&r1=518564&r2=518565 ============================================================================== --- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/escanalyzer.h (original) +++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/escanalyzer.h Thu Mar 15 03:27:22 2007 @@ -59,8 +59,10 @@ static const uint32 NT_ACTARG = 128; // Op_DirectCall,Op_IndirectMemoryCall static const uint32 NT_EXITVAL = 256; // returned value - Op_Return static const uint32 NT_THRVAL = NT_EXITVAL+1; // thrown value - Op_Throw - static const uint32 NT_OBJS = NT_OBJECT|NT_RETVAL|NT_LDOBJ; //for findCnGNode_op + static const uint32 NT_LDVAL = 512; // Op_TauLdInd, Op_TauStInd + static const uint32 NT_OBJS = NT_OBJECT|NT_RETVAL|NT_LDOBJ; //for findCnGNode_op // CnG node reference types + static const uint32 NR_PRIM = 0; static const uint32 NR_REF = 1; static const uint32 NR_ARR = 2; static const uint32 NR_REFARR = 3; @@ -153,9 +155,16 @@ uint32 allProps; const char* debug_method; + bool do_sync_removal; + bool do_scalar_repl; + bool do_esc_scalar_repl; + bool do_scalar_repl_only_final_fields; + bool scalarize_final_fields; + const char* execCountMultiplier_string; + double ec_mult; private: - static const int maxMethodExamLevel_default = 5; + static const int maxMethodExamLevel_default = 0; struct CnGEdge { CnGNode* cngNodeFrom; @@ -187,6 +196,7 @@ int defArgNumber; uint32 method_ea_level; ObjIds *scannedObjs; + ObjIds *scannedObjsRev; ObjIds *scannedInsts; ObjIds *scannedSucNodes; uint32 initNodeType; // type of initial scanned node @@ -194,7 +204,20 @@ SsaTmpOpnd* i32_0; SsaTmpOpnd* i32_1; TranslatorAction* translatorAction; + Insts* methodEndInsts; + Insts* checkInsts; + std::ostream& os_sc; + bool print_scinfo; + + struct ScObjFld { + VarOpnd* fldVarOpnd; + Insts* ls_insts; + FieldDesc* fd; + bool isFinalFld; + }; + + typedef StlList ScObjFlds; #ifdef _DEBUG void prPrN(cfgNode pr_n[],int maxInd) { @@ -210,6 +233,8 @@ #endif //common method for both EscAnalyzer constructors void init(); + void showFlags(std::ostream& os); + void eaFixupVars(IRManager& irm); void instrExam(cfgNode* node); void instrExam2(cfgNode* node); void addEdge(CnGNode* cgnfrom, CnGNode* cgnto, uint32 etype, Inst* inst); @@ -235,14 +260,15 @@ void printCnGNodeRefs(CnGNode* cgn, std::string text,::std::ostream& os); void printRefInfo(::std::ostream& os); void addInst(cfgNode* cfgn, Inst* inst); - void scanCnGNodeRefsGE(CnGNode* cgn); - void scanCnGNodeRefsEV(CnGNode* cgn); - void scanCnGNodeRefsDA(CnGNode* cgn); - void scanCnGNodeRefsAE(CnGNode* cgn); + void scanCnGNodeRefsGE(CnGNode* cgn, bool check_var_src, bool check_field_elem=true); +// void scanCnGNodeRefsEV(CnGNode* cgn); +// void scanCnGNodeRefsDA(CnGNode* cgn); + void scanCnGNodeRefsAE(CnGNode* cgn, bool check_var_src, bool check_field_elem=true); void scanCalleeMethod(Inst* call); void optimizeTranslatedCode(IRManager& irManager); void setCreatedObjectStates(); void printCreatedObjectsInfo(::std::ostream& os); +// void printLocalObjectsInfo(::std::ostream& os); //nvg void printMethodInfos(); //? void printMethodInfo(CalledMethodInfo* mi); CalledMethodInfo* getMethodInfo(const char* ch1,const char* ch2,const char* ch3); @@ -250,9 +276,7 @@ void saveScannedMethodInfo(); uint32 getMethodParamState(CalledMethodInfo* mi, uint32 np); void markNotEscInsts(); - bool checkScannedObjs(uint32 id); - bool checkScannedInsts(uint32 id); - bool checkScannedSucNodes(uint32 id); + void createdObjectInfo(); void addMonInst(Inst* inst); void addMonUnitVCall(MonUnit* mu, Inst* inst); @@ -279,6 +303,23 @@ void lObjectHistory(Inst* inst,std::string text,::std::ostream& os); uint32 getSubobjectStates(CnGNode* node); + bool checkScanned(ObjIds* ids, uint32 id) { + ObjIds::iterator it; + if (ids == NULL) { + return false; + } + for (it = ids->begin( ); it != ids->end( ); it++ ) { + if ((*it)==id) { + return true; + } + } + return false; + } + bool checkScannedObjs(uint32 id) {return checkScanned(scannedObjs, id);} + bool checkScannedObjsRev(uint32 id) {return checkScanned(scannedObjsRev, id);} + bool checkScannedInsts(uint32 id) {return checkScanned(scannedInsts, id);} + bool checkScannedSucNodes(uint32 id) {return checkScanned(scannedSucNodes, id);} + uint32 getEscState(CnGNode* n) { return (n->state)&ESC_MASK; } @@ -331,6 +372,201 @@ } void runTranslatorSession(CompilationContext& inlineCC); + + // Scalar replacement optimization +/** + * Performs scalar replacement optimization for local objects + * (class instances and arrays). + */ + void scanLocalObjects(); + +/** + * Performs scalar replacement optimization for method escaped class instances. + */ + void scanEscapedObjects(); + +/** + * Performs scalar replacement optimization for local objects from the specified list. + * @param loids - list of local objects CnG nodes Ids + * @param os - output stream + */ + void doLOScalarReplacement(ObjIds* loids); + +/** + * Performs scalar replacement optimization for method escaped objects from the specified list. + * @param loids - list of local objects CnG nodes Ids + */ + void doEOScalarReplacement(ObjIds* loids); + +/** + * Collects (using connection graph) information of onode object fields usage. + * @param onode - connection graph node fields usage of which is collected + * @param scObjFlds - list to collect onode fields usage + */ + void collectStLdInsts(CnGNode* onode, ScObjFlds* scObjFlds); + +/** + * Collects (using connection graph) call instructions which use optimized object + * as a parameter. + * @param n - optimized obgect connection graph node Id; + * @param vc_insts - list of call instructions; + * @param vcids - list of call instructions ids. + */ + void collectCallInsts(uint32 n, Insts* vc_insts, ObjIds* vcids); + +/** + * Performs scalar replacement optimization for optimized object field usage. + * @param scfld - optimized object scalarizable field + */ + void scalarizeOFldUsage(ScObjFld* scfld); + +/** + * Checks if an object from the specified list can be removed and its fields/elements scalarized. + * If an object cannot be optimized it is removed from the list. + * @param loids - list of local object CnG nodes Ids + * @param check_loc - if true checks for local objects, + * if false checks for virtual call escaped objects. + */ + void checkOpndUsage(ObjIds* lnoids, ObjIds* lloids, bool check_loc); + +/** + * Checks if an object can be removed and its fields/elements scalarized. + * @param lobjid - object CnG nodes Ids + * @return true if an object is used only in ldflda or ldbase instructions; + * false otherwise. + */ + bool checkOpndUsage(uint32 lobjid); + +/** + * Performs checks for CnGNode operand using connection graph. + * @param scnode - CnG node of optimized operand + * @param check_loc - * @param check_loc - if true checks for local objects, + * if false checks for virtual call escaped objects. + * @return CnGNode* for operand that may be optimized; + * NULL otherwise. + */ + CnGNode* checkCnG(CnGNode* scnode, bool check_loc); + +/** + * Checks if there is a path in CFG from node where object created by a nob_inst instruction + * to EXIT node and this object is not escaped to any method call. + * @param nob_inst - object creation instruction. + * @return execCount of this path execution; + * 0 otherwise. + */ + double checkLocalPath(Inst* nob_inst); + +/** + * Checks if there is a path in CFG from node where object created by a nob_inst instruction + * to EXIT node and this object is not escaped to any method call. + * @param n - CFG node to scan + * @param obId - escaped optimized object Id + * @param cExecCount - current execCount + * @return execCount the most value of execCount and + * checkNextNodes execution for next after n node; + */ + double checkNextNodes(Node* n, uint32 obId, double cExecCount, std::string text=""); + +/** + * Checks flag and creates object before call instruction (if it was not created yet). + * @param vc_insts - list of call instructions optimized object is escaped to + * @param objs - list of optimized object fields + * @param ob_var_opnd - varOpnd replacing optimized object + * @param ob_flag_var_opnd - sign if optimized object was created + * @param tnode - target CFG node for newobj instruction exception edge + * @param oid - escaped optimized object Id + */ + void restoreEOCreation(Insts* vc_insts, ScObjFlds* objs, VarOpnd* ob_var_opnd, + VarOpnd* ob_flag_var_opnd, Node* tnode, uint32 oid); + +/** + * Removes specified instruction from ControlFlowGraph. + * If instruction can throw exception removes corresponding CFGEdge. + * @param reminst - removed instruction + */ + void removeInst(Inst* reminst); + +/** + * Returns MethodDesc* for Op_IndirectMemoryCall and Op_DirectCall instructions. + * @param inst - call instruction. + * @return MethodDesc for Op_IndirectMemoryCall and Op_DirectCall; + * NULL otherwise. + */ + MethodDesc* getMD(Inst* inst); + +/** + * Replaces first source operand of Op_MethodEnd instruction by NULL + * for scalar replacement optimized object. + * @param ob_id - optimized object Id + */ + void fixMethodEndInsts(uint32 ob_id); + +/** + * Finds (using connection graph) load varOpnd that should be optimized with + * new object operand. + * @param vval - CnG node of target stvar instruction varOpnd + * @return CnGNode* - found optimized load varOpnd CnG node + * NULL otherwise. + */ + CnGNode* getLObj(CnGNode* vval); + +/** + * Checks that all sources of optimized load varOpnd aren't null and + * satisfy to specified conditions. + * @param inst - ldvar instruction created optimized load varOpnd. + * @return true if satisfied; + * false otherwise. + */ + bool checkVVarSrcs(Inst* inst); + +/** + * Checks that optimized object type satisfied to specified types. + * @param otn - object type name. + * @return true if satisfied; + * false otherwise. + */ + bool checkObjectType(const char* otn); + +/** + * Checks that all load varOpnd fields are in new object field usage list. + * @param nscObjFlds - list of used fields of optimized new object + * @param lscObjFlds - list of used fields of optimized load varOpnd + * @return true if list of new object used field contains all + * load varOpnd used field; + * false otherwise. + */ + bool checkObjFlds(ScObjFlds* nscObjFlds, ScObjFlds* lscObjFlds); + +/** + * Removes check instructions for optimized load varOpnd. + * @param ob_id - optimized load variable operand Id + */ + void fixCheckInsts(uint32 opId); + +/** + * Checks (using connection graph) if CnGNode operand has final fields and adds it to + * the list of posible optimized final fields operands. + * @param onode - CnG node of optimized operand + * @param scObjFlds - list to collect onode operand field usage + */ + void checkToScalarizeFinalFiels(CnGNode* onode, ScObjFlds* scObjFlds); + + + // BCMap support +/** + * Sets bcmap offset in bc2HIRMapHandler. + * @param new_i - instruction to set offset + * @param old_i - offset of old_i instruction is set to new_i instruction + */ + void setNewBCMap(Inst* new_i, Inst* old_i); + +/** + * Removes bcmap offset in bc2HIRMapHandler. + * @param inst - instruction to remove offset + */ + void remBCMap(Inst* inst); + + int _cfgirun; int _instrInfo; int _instrInfo2; @@ -341,8 +577,14 @@ int _printstat; int _eainfo; int _seinfo; + int _scinfo; #define prsNum 10 int prsArr[prsNum]; + + CompilationInterface &compInterface; + // Byte code map info + bool isBCmapRequired; + VectorHandler* bc2HIRMapHandler; }; } //namespace Jitrino