harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfur...@apache.org
Subject svn commit: r571484 [3/3] - in /harmony/enhanced/drlvm/trunk: src/test/regression/H2084/ vm/jitrino/src/codegenerator/ia32/ vm/jitrino/src/main/ vm/jitrino/src/optimizer/ vm/jitrino/src/shared/ vm/jitrino/src/translator/ vm/jitrino/src/translator/java/
Date Fri, 31 Aug 2007 14:48:21 GMT
Propchange: harmony/enhanced/drlvm/trunk/src/test/regression/H2084/Test.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/drlvm/trunk/src/test/regression/H2084/run.test.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/src/test/regression/H2084/run.test.xml?rev=571484&view=auto
==============================================================================
--- harmony/enhanced/drlvm/trunk/src/test/regression/H2084/run.test.xml (added)
+++ harmony/enhanced/drlvm/trunk/src/test/regression/H2084/run.test.xml Fri Aug 31 07:48:19 2007
@@ -0,0 +1,9 @@
+<project name="RUN HARMONY-2084 Regression Test">
+    <target name="run-test">
+        <run-junit-test 
+             test="org.apache.harmony.drlvm.tests.regression.h2084.Test"
+             vmarg="-Xem:opt">
+        </run-junit-test>
+    </target>
+</project>
+

Propchange: harmony/enhanced/drlvm/trunk/src/test/regression/H2084/run.test.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32CodeEmitter.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32CodeEmitter.cpp?rev=571484&r1=571483&r2=571484&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32CodeEmitter.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32CodeEmitter.cpp Fri Aug 31 07:48:19 2007
@@ -371,6 +371,7 @@
                     IRPrinter::printIndent(Log::out(), parentEntry->getInlineDepth()+1);
                     IRPrinter::printInst(Log::out(), inst);
                     Log::out()<<" native-offset="<<nativeInstEndOffset<<" bc-offset="<<inst->getBCOffset();
+                    Log::out().flush();
                 }
                 uint16 bcOffset = inst->getBCOffset();
                 globalBCMapOffset = getTopLevelEntryOffset(parentEntry);

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32IRManager.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32IRManager.cpp?rev=571484&r1=571483&r2=571484&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32IRManager.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32IRManager.cpp Fri Aug 31 07:48:19 2007
@@ -1908,6 +1908,7 @@
                        )){
                         Node* throwBasicBlock = fg->createBlockNode();
                         Inst* throwInst = newRuntimeHelperCallInst(CompilationInterface::Helper_NullPtrException, 0, NULL, NULL);
+                        assert(lastInst->getBCOffset()!=ILLEGAL_BC_MAPPING_VALUE);
                         throwInst->setBCOffset(lastInst->getBCOffset());
                         throwBasicBlock->appendInst(throwInst);
 #ifndef _EM64T_

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.cpp?rev=571484&r1=571483&r2=571484&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.cpp Fri Aug 31 07:48:19 2007
@@ -129,7 +129,7 @@
 // FP remainder internal helpers (temp solution to be optimized)
 float   __stdcall   remF4   (float v0, float v1)stdcall__;
 float   __stdcall   remF4   (float v0, float v1)   { 
-    return fmod((double)v0,(double)v1);
+    return (float)fmod((double)v0,(double)v1);
 }
 
 double  __stdcall   remF8   (double v0, double v1)stdcall__;

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/main/CompilationContext.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/main/CompilationContext.cpp?rev=571484&r1=571483&r2=571484&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/main/CompilationContext.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/main/CompilationContext.cpp Fri Aug 31 07:48:19 2007
@@ -122,7 +122,7 @@
  */
 LogStreams& LogStreams::current(JITInstanceContext* jitContext) {
 
-    CompilationContext* ccp = CompilationContext::getCurrentContext();
+    CompilationContext* ccp = CompilationContext::getCurrentContext()->getVMCompilationInterface()->getCompilationContext();
     LogStreams* cls = ccp->getCurrentLogs();
     if (cls != 0) 
         return *cls;

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/main/PMF.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/main/PMF.cpp?rev=571484&r1=571483&r2=571484&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/main/PMF.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/main/PMF.cpp Fri Aug 31 07:48:19 2007
@@ -24,6 +24,7 @@
 #include "PMFAction.h"
 #include "FixFileName.h"
 #include "JITInstanceContext.h"
+#include "CompilationContext.h"
 #include <ctype.h>
 #include <errno.h>
 #include <stdlib.h>
@@ -2583,7 +2584,13 @@
 #ifndef _NOLOG
 LogStream& IAction::log (LogStream::SID sid) const
 {
-    return (step->logs == 0) ? LogStream::log_sink() : step->logs->log(sid);
+    CompilationContext* currentCC = CompilationContext::getCurrentContext();
+    CompilationContext* topLevelCC = CompilationContext::getCurrentContext()->getVMCompilationInterface()->getCompilationContext();
+    const IAction* action = this;
+    if (currentCC != topLevelCC) {
+        action = topLevelCC->getCurrentSessionAction();
+    }
+    return (action!=NULL && action->step->logs == 0) ? LogStream::log_sink() : action->step->logs->log(sid);
 }
 #endif
 

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/IRBuilder.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/IRBuilder.cpp?rev=571484&r1=571483&r2=571484&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/IRBuilder.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/IRBuilder.cpp Fri Aug 31 07:48:19 2007
@@ -1259,7 +1259,8 @@
                                 Opnd* args[],
                                 ObjectType* ch,
                                 JavaByteCodes bc,
-                                uint32 cpIndex
+                                uint32 cpIndex,
+                                MethodSignature* sig
                                 )
 {
     assert(!returnType->isNullObject());
@@ -1299,7 +1300,7 @@
             break;
         default: assert(0);
         }
-        callAddrOpnd = genVMHelperCall(vmHelperId, typeManager->getUnresolvedMethodPtrType(ch, cpIndex), numHelperArgs, helperArgs);
+        callAddrOpnd = genVMHelperCall(vmHelperId, typeManager->getUnresolvedMethodPtrType(ch, cpIndex, sig), numHelperArgs, helperArgs);
         insertHash(Op_VMHelperCall, bc, cpIndex, numArgs>0?args[0]->getId() : 0, callAddrOpnd->getInst());
     }
 

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/IRBuilder.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/IRBuilder.h?rev=571484&r1=571483&r2=571484&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/IRBuilder.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/IRBuilder.h Fri Aug 31 07:48:19 2007
@@ -131,7 +131,8 @@
                                     Opnd* args[],
                                     ObjectType* ch,
                                     JavaByteCodes bc,
-                                    uint32 cpIndex
+                                    uint32 cpIndex,
+                                    MethodSignature* sig
                                     );
     
     Opnd* genDirectCall(MethodDesc* methodDesc, // TR //SI

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Loop.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Loop.cpp?rev=571484&r1=571483&r2=571484&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Loop.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Loop.cpp Fri Aug 31 07:48:19 2007
@@ -794,6 +794,7 @@
         Inst* labelInst = (Inst*)header->getFirstInst();
         assert(labelInst->isLabel() && !labelInst->isCatchLabel());
         newPreHeader->appendInst(instFactory.makeLabel());
+        newPreHeader->getFirstInst()->setBCOffset(labelInst->getBCOffset());
         if (numEdges > 1 ) {
             for (Inst* phi = labelInst->getNextInst();phi!=NULL && phi->isPhi(); phi = phi->getNextInst()) {
                 Opnd *orgDst = phi->getDst();

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/devirtualizer.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/devirtualizer.cpp?rev=571484&r1=571483&r2=571484&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/devirtualizer.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/devirtualizer.cpp Fri Aug 31 07:48:19 2007
@@ -190,6 +190,7 @@
     ControlFlowGraph &regionFG = regionIRM.getFlowGraph();
     assert(!methodDesc->isStatic());
     assert(call == node->getLastInst());
+    uint16 bcOffset = call->getBCOffset();
 
     Log::out() << "Generating guarded direct call to " << objectType->getName()
         << "." << methodDesc->getName() << ::std::endl;
@@ -214,6 +215,9 @@
     Node* guard = node;
     Node* directCallBlock = regionFG.createBlockNode(_instFactory.makeLabel());
     Node* virtualCallBlock = regionFG.createBlockNode(_instFactory.makeLabel());
+    directCallBlock->getFirstInst()->setBCOffset(bcOffset);
+    virtualCallBlock->getFirstInst()->setBCOffset(bcOffset);
+
     Node* merge = next;
 
     //
@@ -289,12 +293,14 @@
         VarOpnd* returnVar = _opndManager.createVarOpnd(dst->getType(), false);
         
         Node* directStVarBlock = regionFG.createBlockNode(_instFactory.makeLabel());
+        directStVarBlock->getFirstInst()->setBCOffset(bcOffset);
         directStVarBlock->setExecCount(directCallBlock->getExecCount());
         regionFG.addEdge(directCallBlock, directStVarBlock)->setEdgeProb(1.0);
         Inst* stVar1 = _instFactory.makeStVar(returnVar, ssaTmp1);
         directStVarBlock->appendInst(stVar1);
         
         Node* virtualStVarBlock = regionFG.createBlockNode(_instFactory.makeLabel());
+        virtualStVarBlock->getFirstInst()->setBCOffset(bcOffset);
         regionFG.addEdge(virtualCallBlock, virtualStVarBlock);
         Inst* stVar2 = _instFactory.makeStVar(returnVar, ssaTmp2);
         virtualStVarBlock->appendInst(stVar2);
@@ -319,6 +325,7 @@
         bool needPhiBlock = (merge->getInDegree() > 0);
         if (needPhiBlock) {
             Node* phiBlock = regionFG.createBlockNode(_instFactory.makeLabel());
+            phiBlock->getFirstInst()->setBCOffset(bcOffset);
             regionFG.addEdge(phiBlock, merge);
             regionFG.addEdge(directStVarBlock, phiBlock)->setEdgeProb(1.0);
             regionFG.addEdge(virtualStVarBlock, phiBlock);

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/helper_inliner.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/helper_inliner.cpp?rev=571484&r1=571483&r2=571484&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/helper_inliner.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/helper_inliner.cpp Fri Aug 31 07:48:19 2007
@@ -24,6 +24,7 @@
 #include "inliner.h"
 #include "LoopTree.h"
 #include "Dominator.h"
+#include "StlPriorityQueue.h"
 
 namespace Jitrino {
 
@@ -35,7 +36,7 @@
 
 #define DECLARE_STANDARD_HELPER_FLAGS(name) \
     bool  name##_doInlining;\
-    int   name##_hotnessPercentToInline;\
+    uint32   name##_hotnessPercentToInline;\
     const char* name##_className;\
     const char* name##_methodName;\
     const char* name##_signature;\
@@ -114,10 +115,11 @@
 
 class HelperInliner {
 public:
-    HelperInliner(HelperInlinerSession* _sessionAction, MemoryManager& tmpMM, CompilationContext* _cc, Inst* _inst)  
+    HelperInliner(HelperInlinerSession* _sessionAction, MemoryManager& tmpMM, CompilationContext* _cc, Inst* _inst, uint32 _hotness)  
         : flags(((HelperInlinerAction*)_sessionAction->getAction())->getFlags()), localMM(tmpMM), 
         cc(_cc), inst(_inst), session(_sessionAction), method(NULL)
     {
+        hotness=_hotness;
         irm = cc->getHIRManager();
         instFactory = &irm->getInstFactory();
         opndManager = &irm->getOpndManager();
@@ -128,6 +130,9 @@
     virtual ~HelperInliner(){};
     
     virtual void run()=0;
+
+    uint32 hotness;
+
 protected:
     MethodDesc* ensureClassIsResolvedAndInitialized(const char* className,  const char* methodName, const char* signature);
     virtual void doInline() = 0;
@@ -147,13 +152,19 @@
     OpndManager* opndManager;
     TypeManager* typeManager;
     ControlFlowGraph* cfg;
+};
 
+class HelperInlinerCompare {
+public:
+    bool operator()(const HelperInliner* hi1, const HelperInliner* hi2) { return hi1->hotness < hi2->hotness; }
 };
+
+
 #define DECLARE_HELPER_INLINER(name, flagPrefix)\
 class name : public HelperInliner {\
 public:\
-    name (HelperInlinerSession* session, MemoryManager& tmpMM, CompilationContext* cc, Inst* inst)\
-        : HelperInliner(session, tmpMM, cc, inst){}\
+    name (HelperInlinerSession* session, MemoryManager& tmpMM, CompilationContext* cc, Inst* inst, uint32 hotness)\
+        : HelperInliner(session, tmpMM, cc, inst, hotness){}\
     \
     virtual void run() { \
         if (Log::isEnabled())  {\
@@ -188,53 +199,57 @@
     //finding all helper calls
     ControlFlowGraph& fg = irm.getFlowGraph();
     double entryExecCount = fg.hasEdgeProfile() ? fg.getEntryNode()->getExecCount(): 1;
-    StlVector<HelperInliner*> helperInliners(tmpMM);
+    uint32 maxNodeCount = irm.getOptimizerFlags().hir_node_threshold;
+    StlPriorityQueue<HelperInliner*, StlVector<HelperInliner*>, HelperInlinerCompare> *helperInlineCandidates = 
+        new (tmpMM) StlPriorityQueue<HelperInliner*, StlVector<HelperInliner*>, HelperInlinerCompare>(tmpMM);
     const Nodes& nodes = fg.getNodesPostOrder();//process checking only reachable nodes.
     for (Nodes::const_iterator it = nodes.begin(), end = nodes.end(); it!=end; ++it) {
         Node* node = *it;
-        int nodePercent = fg.hasEdgeProfile() ? (int)(node->getExecCount()*100/entryExecCount) : 0;
+        double execCount = node->getExecCount();
+        assert (execCount >= 0);
+        uint32 nodePercent = fg.hasEdgeProfile() ? (uint32)(execCount*100/entryExecCount) : 0;
         if (node->isBlockNode()) {
             for (Inst* inst = (Inst*)node->getFirstInst(); inst!=NULL; inst = inst->getNextInst()) {
                 Opcode opcode = inst->getOpcode();
                 switch(opcode) {
                     case Op_NewObj:
                         if (flags.newObj_doInlining && nodePercent >= flags.newObj_hotnessPercentToInline) {
-                            helperInliners.push_back(new (tmpMM) NewObjHelperInliner(this, tmpMM, cc, inst));
+                            helperInlineCandidates->push(new (tmpMM) NewObjHelperInliner(this, tmpMM, cc, inst, nodePercent));
                         }
                         break;
                     case Op_NewArray:
                         if (flags.newArray_doInlining && nodePercent >= flags.newArray_hotnessPercentToInline) {
-                            helperInliners.push_back(new (tmpMM) NewArrayHelperInliner(this, tmpMM, cc, inst));
+                            helperInlineCandidates->push(new (tmpMM) NewArrayHelperInliner(this, tmpMM, cc, inst, nodePercent));
                         }
                         break;
                     case Op_TauMonitorEnter:
                         if (flags.objMonEnter_doInlining && nodePercent >= flags.objMonEnter_hotnessPercentToInline) {
-                            helperInliners.push_back(new (tmpMM) ObjMonitorEnterHelperInliner(this, tmpMM, cc, inst));
+                            helperInlineCandidates->push(new (tmpMM) ObjMonitorEnterHelperInliner(this, tmpMM, cc, inst, nodePercent));
                         }
                         break;
                     case Op_TauMonitorExit:
                         if (flags.objMonExit_doInlining && nodePercent >= flags.objMonExit_hotnessPercentToInline) {
-                            helperInliners.push_back(new (tmpMM) ObjMonitorExitHelperInliner(this, tmpMM, cc, inst));
+                            helperInlineCandidates->push(new (tmpMM) ObjMonitorExitHelperInliner(this, tmpMM, cc, inst, nodePercent));
                         }
                         break;
                     case Op_TauStRef:
                         if (flags.wb_doInlining && nodePercent >= flags.wb_hotnessPercentToInline) {
-                            helperInliners.push_back(new (tmpMM) WriteBarrierHelperInliner(this, tmpMM, cc, inst));
+                            helperInlineCandidates->push(new (tmpMM) WriteBarrierHelperInliner(this, tmpMM, cc, inst, nodePercent));
                         }
                         break;
                     case Op_TauLdIntfcVTableAddr:
                         if (flags.ldInterface_doInlining && nodePercent >= flags.ldInterface_hotnessPercentToInline) {
-                            helperInliners.push_back(new (tmpMM) LdInterfaceHelperInliner(this, tmpMM, cc, inst));
+                            helperInlineCandidates->push(new (tmpMM) LdInterfaceHelperInliner(this, tmpMM, cc, inst, nodePercent));
                         }
                         break;
                     case Op_TauCheckCast:
                         if (flags.checkCast_doInlining && nodePercent >= flags.checkCast_hotnessPercentToInline) {
-                            helperInliners.push_back(new (tmpMM) CheckCastHelperInliner(this, tmpMM, cc, inst));
+                            helperInlineCandidates->push(new (tmpMM) CheckCastHelperInliner(this, tmpMM, cc, inst, nodePercent));
                         }
                         break;
                     case Op_TauInstanceOf:
                         if (flags.instanceOf_doInlining && nodePercent >= flags.instanceOf_hotnessPercentToInline) {
-                            helperInliners.push_back(new (tmpMM) InstanceOfHelperInliner(this, tmpMM, cc, inst));
+                            helperInlineCandidates->push(new (tmpMM) InstanceOfHelperInliner(this, tmpMM, cc, inst, nodePercent));
                         }
                         break;
                     default: break;
@@ -244,10 +259,10 @@
     }
 
     //running all inliners
-    //TODO: set inline limit!
-    for (StlVector<HelperInliner*>::const_iterator it = helperInliners.begin(), end = helperInliners.end(); it!=end; ++it) {
-        HelperInliner* inliner = *it;
+    while(!helperInlineCandidates->empty() && (fg.getNodeCount() < maxNodeCount)) {
+        HelperInliner* inliner = helperInlineCandidates->top();
         inliner->run();
+        helperInlineCandidates->pop();
     }
 }
 
@@ -348,6 +363,7 @@
     instFactory->makeLdConst(allocationHandleOpnd, allocationHandle)->insertBefore(inst);
     Opnd* args[2] = {objSizeOpnd, allocationHandleOpnd};
     MethodCallInst* call = instFactory->makeDirectCall(callResOpnd, tauSafeOpnd, tauSafeOpnd, 2, args, method)->asMethodCallInst();
+    assert(inst->getBCOffset()!=ILLEGAL_BC_MAPPING_VALUE);
     call->setBCOffset(inst->getBCOffset());
     call->insertBefore(inst);
     inst->unlink();
@@ -407,6 +423,7 @@
     Opnd* args[3] = {numElements, elemSizeOpnd, allocationHandleOpnd};
     Opnd* callResOpnd = opndManager->createSsaTmpOpnd(typeManager->getUnmanagedPtrType(typeManager->getInt8Type()));
     MethodCallInst* call = instFactory->makeDirectCall(callResOpnd, tauSafeOpnd, tauSafeOpnd, 3, args, method)->asMethodCallInst();
+    assert(inst->getBCOffset()!=ILLEGAL_BC_MAPPING_VALUE);
     call->setBCOffset(inst->getBCOffset());
     call->insertBefore(inst);
     inst->unlink();
@@ -439,6 +456,7 @@
     instFactory->makeTauSafe(tauSafeOpnd)->insertBefore(inst);
     Opnd* args[1] = {objOpnd};
     MethodCallInst* call = instFactory->makeDirectCall(opndManager->getNullOpnd(), tauSafeOpnd, tauSafeOpnd, 1, args, method)->asMethodCallInst();
+    assert(inst->getBCOffset()!=ILLEGAL_BC_MAPPING_VALUE);
     call->setBCOffset(inst->getBCOffset());
     call->insertBefore(inst);
     inst->unlink();
@@ -474,6 +492,7 @@
     instFactory->makeTauSafe(tauSafeOpnd)->insertBefore(inst);
     Opnd* args[1] = {objOpnd};
     MethodCallInst* call = instFactory->makeDirectCall(opndManager->getNullOpnd(), tauSafeOpnd, tauSafeOpnd, 1, args, method)->asMethodCallInst();
+    assert(inst->getBCOffset()!=ILLEGAL_BC_MAPPING_VALUE);
     call->setBCOffset(inst->getBCOffset());
     call->insertBefore(inst);
     inst->unlink();
@@ -501,6 +520,7 @@
     instFactory->makeTauSafe(tauSafeOpnd)->insertBefore(inst);
     Opnd* args[3] = {objBaseOpnd, ptrOpnd, srcOpnd};
     MethodCallInst* call = instFactory->makeDirectCall(opndManager->getNullOpnd(), tauSafeOpnd, tauSafeOpnd, 3, args, method)->asMethodCallInst();
+    assert(inst->getBCOffset()!=ILLEGAL_BC_MAPPING_VALUE);
     call->setBCOffset(inst->getBCOffset());
     call->insertBefore(inst);
     inst->unlink();
@@ -550,6 +570,7 @@
     instFactory->makeTauSafe(tauSafeOpnd)->insertBefore(inst);
     Opnd* args[2] = {baseOpnd, typeOpnd};
     MethodCallInst* call = instFactory->makeDirectCall(resOpnd, tauSafeOpnd, tauSafeOpnd, 2, args, method)->asMethodCallInst();
+    assert(inst->getBCOffset()!=ILLEGAL_BC_MAPPING_VALUE);
     call->setBCOffset(inst->getBCOffset());
     call->insertBefore(inst);
     inst->unlink();
@@ -609,6 +630,7 @@
 
     Opnd* args[6] = {objOpnd, typeOpnd, isArrayOpnd, isInterfaceOpnd, isFinalOpnd, fastCheckDepthOpnd};
     MethodCallInst* call = instFactory->makeDirectCall(opndManager->getNullOpnd(), tauSafeOpnd, tauSafeOpnd, 6, args, method)->asMethodCallInst();
+    assert(inst->getBCOffset()!=ILLEGAL_BC_MAPPING_VALUE);
     call->setBCOffset(inst->getBCOffset());
     
     call->insertBefore(inst);
@@ -670,6 +692,7 @@
 
     Opnd* args[6] = {objOpnd, typeOpnd, isArrayOpnd, isInterfaceOpnd, isFinalOpnd, fastCheckDepthOpnd};
     MethodCallInst* call = instFactory->makeDirectCall(inst->getDst(), tauSafeOpnd, tauSafeOpnd, 6, args, method)->asMethodCallInst();
+    assert(inst->getBCOffset()!=ILLEGAL_BC_MAPPING_VALUE);
     call->setBCOffset(inst->getBCOffset());
 
     call->insertBefore(inst);

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/inliner.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/inliner.cpp?rev=571484&r1=571483&r2=571484&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/inliner.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/inliner.cpp Fri Aug 31 07:48:19 2007
@@ -111,6 +111,8 @@
     _inlineExactArgBonus = argSource->getIntArg("exact_single_parameter_bonus", INLINE_EXACT_ARG_BONUS);
     _inlineExactAllBonus = argSource->getIntArg("exact_all_parameter_bonus", INLINE_EXACT_ALL_BONUS);
 
+    _inlineMaxNodeThreshold = irm.getOptimizerFlags().hir_node_threshold * irm.getOptimizerFlags().inline_node_quota / 100;
+
     _inlineSkipExceptionPath = argSource->getBoolArg("skip_exception_path", INLINE_SKIP_EXCEPTION_PATH);
 #if defined  (_EM64T_) || defined (_IPF_)
     _inlineSkipApiMagicMethods  = false;
@@ -160,7 +162,7 @@
     if (inlinePragma!=NULL && methodDesc.hasAnnotation(inlinePragma)) {
         //methods marked with inline pragma processed separately and are always inlined
         //regardless of it benefits and size limitations.
-        return -1;
+        assert(0);
     }
     if (_inlineBonusMethodTable!=NULL && _inlineBonusMethodTable->accept_this_method(methodDesc)) {
         benefit+=1000;
@@ -894,13 +896,12 @@
         // Find new candidate.
         callNode = _inlineCandidates.top().callNode;
         inlineParentNode = _inlineCandidates.top().inlineNode;
-        int benefit = _inlineCandidates.top().benefit;
         _inlineCandidates.pop();
 
         call = ((Inst*)callNode->getLastInst())->asMethodCallInst();
         assert(call != NULL);
         methodDesc = call->getMethodDesc();
-        bool isPragmaInline = benefit == PRAGMA_INLINE_BENEFIT;
+        bool isPragmaInline = methodDesc->hasAnnotation(inlinePragma);;
 
         // If candidate would cause top level method to exceed size threshold, throw away.
         
@@ -944,7 +945,8 @@
     MethodDesc *methodDesc = call->getMethodDesc();
     IRManager* inlinedIRM = new (_tmpMM) IRManager(_tmpMM, _toplevelIRM, *methodDesc, NULL);
     // Augment inline tree
-    InlineNode *inlineNode = new (_tmpMM) InlineNode(*inlinedIRM, call, call->getNode());
+    bool forceInline = methodDesc->hasAnnotation(inlinePragma);
+    InlineNode *inlineNode = new (_tmpMM) InlineNode(*inlinedIRM, call, call->getNode(), forceInline);
     
     inlineCC.setHIRManager(inlinedIRM);
     
@@ -993,6 +995,7 @@
                 assert(size > 0);
                 Log::out() << "Inline benefit " << methodDesc->getParentType()->getName() << "." << methodDesc->getName() << " == " << (int) benefit << ::std::endl;
                 if(0 < size && benefit > _minBenefitThreshold) {
+                    assert(benefit < PRAGMA_INLINE_BENEFIT);
                     // Inline candidate
                     Log::out() << "Add to queue" << std::endl;
                     _inlineCandidates.push(CallSite(benefit, node, inlineNode));
@@ -1155,6 +1158,10 @@
         }
         //inline current region
         inlineRegion(regionNode);
+        // Limit inlining by node count. All @Inline methods still must be inlined.
+        if (!regionNode->isForced() && _toplevelIRM.getFlowGraph().getNodeCount() > _inlineMaxNodeThreshold) {
+            break;
+        }
     } while (true);
 
 

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/inliner.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/inliner.h?rev=571484&r1=571483&r2=571484&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/inliner.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/inliner.h Fri Aug 31 07:48:19 2007
@@ -61,19 +61,22 @@
 
 class InlineNode : public TreeNode {
 public:
-    InlineNode(IRManager& irm, Inst *callInst, Node *callNode) : _irm(irm), _callInst(callInst), _callNode(callNode) {}
+    InlineNode(IRManager& irm, Inst *callInst, Node *callNode, bool forced = false)
+        : _irm(irm), _callInst(callInst), _callNode(callNode), _forceInline(forced) {}
     InlineNode* getChild()    {return (InlineNode*) child;}
     InlineNode* getSiblings() {return (InlineNode*) siblings;}
     InlineNode* getParent()   {return (InlineNode*) parent;}
     IRManager&  getIRManager()      { return _irm; }
     Inst*       getCallInst() { return _callInst; }
-    Node*    getCallNode() { return _callNode; }
+    Node*       getCallNode() { return _callNode; }
+    bool        isForced() { return _forceInline; }
     void print(::std::ostream& os);
     void printTag(::std::ostream& os);
 private:
     IRManager&  _irm;
     Inst*       _callInst;
-    Node*    _callNode;
+    Node*       _callNode;
+    bool        _forceInline;
 };
 
 class InlineTree : public Tree {
@@ -193,7 +196,9 @@
     int32 _inlineRecursionPenalty;
     int32 _inlineExactArgBonus;
     int32 _inlineExactAllBonus;
-    
+
+    uint32 _inlineMaxNodeThreshold;
+
     bool _inlineSkipExceptionPath;
     bool _inlineSkipApiMagicMethods;
     Method_Table* _inlineSkipMethodTable;

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/optimizer.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/optimizer.cpp?rev=571484&r1=571483&r2=571484&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/optimizer.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/optimizer.cpp Fri Aug 31 07:48:19 2007
@@ -63,6 +63,9 @@
 
 namespace Jitrino {
 
+#define HIR_NODE_THRESHOLD 1300
+#define INLINE_NODE_QUOTA 60  // percents
+
 class OptInitAction : public Action {
 public:
     void init() {readFlags();}
@@ -105,6 +108,8 @@
     memset( &optimizerFlags, 0, sizeof(OptimizerFlags));
 
     optimizerFlags.dumpdot= getBoolArg("dumpdot", false);
+    optimizerFlags.hir_node_threshold = getIntArg("hir_node_threshold", HIR_NODE_THRESHOLD);
+    optimizerFlags.inline_node_quota = getIntArg("inline_node_quota", INLINE_NODE_QUOTA);
 
     optimizerFlags.cse_final = getBoolArg("cse_final", true);
 
@@ -196,6 +201,7 @@
 void showFlags(std::ostream& os) {
     os << "\n"<<OPT_INIT_NAME<<std::endl;
     os << "  global optimizer flags:"<<std::endl;
+    os << "    hir_node_threshold=<n>      - max number of CFG nodes for inlining" << std::endl;
     os << "    elim_cmp3[={ON|off}]        - eliminate cmp3 tests" << std::endl;
     os << "    elim_checks[={ON|off}]      - try to eliminate some checks using branch conditions" << std::endl;
     os << "    use_mulhi{ON|off}]          - use MulHi opcode" << std::endl;

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/optimizer.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/optimizer.h?rev=571484&r1=571483&r2=571484&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/optimizer.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/optimizer.h Fri Aug 31 07:48:19 2007
@@ -39,6 +39,11 @@
     //global optimizer flags
     bool dumpdot;
 
+    // Max number of nodes HIR would grow up to during various inlinings
+    uint32 hir_node_threshold;
+    // A share of node limit inlining may use (in percents), the remaining share is for helper inlining
+    uint32 inline_node_quota;
+
     bool cse_final;
 
     uint32 hash_init_factor;

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/ControlFlowGraph.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/ControlFlowGraph.cpp?rev=571484&r1=571483&r2=571484&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/ControlFlowGraph.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/ControlFlowGraph.cpp Fri Aug 31 07:48:19 2007
@@ -191,6 +191,30 @@
 
 }
 
+uint16 Node::getNodeStartBCOffset() const {
+    if (!isBlockNode()) {
+        return ILLEGAL_BC_MAPPING_VALUE;
+    }
+    CFGInst* inst = getFirstInst();
+    while (inst!=NULL && inst->getBCOffset()==ILLEGAL_BC_MAPPING_VALUE) {
+        inst = inst->next();
+    }
+    return inst==NULL ? ILLEGAL_BC_MAPPING_VALUE : inst->getBCOffset();
+}
+
+uint16 Node::getNodeEndBCOffset() const {
+    if (!isBlockNode()) {
+        return ILLEGAL_BC_MAPPING_VALUE;
+    }
+    CFGInst* inst = getLastInst();
+    while (inst!=NULL && inst->getBCOffset()==ILLEGAL_BC_MAPPING_VALUE) {
+        inst = inst->prev();
+    }
+    return inst==NULL ? ILLEGAL_BC_MAPPING_VALUE : inst->getBCOffset();
+}
+
+
+
 //////////////////////////////////////////////////////////////////////////
 // CFG methods
 
@@ -817,6 +841,9 @@
 Node* ControlFlowGraph::splitEdge(Edge *edge, CFGInst* inst, bool keepOldEdge) {
     Node* target = edge->getTargetNode();
     Node* newNode = createBlockNode(inst);
+    if (inst!=NULL && target->getFirstInst()!=NULL) {
+        inst->setBCOffset(target->getFirstInst()->getBCOffset());
+    }
 
     replaceEdgeTarget(edge, newNode, keepOldEdge);
     addEdge(newNode, target);

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/ControlFlowGraph.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/ControlFlowGraph.h?rev=571484&r1=571483&r2=571484&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/ControlFlowGraph.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/ControlFlowGraph.h Fri Aug 31 07:48:19 2007
@@ -887,6 +887,22 @@
    */
     CFGInst* getLabelInst() const {CFGInst* first = getFirstInst(); assert(first==NULL || first->isLabel()); return first;}
 
+
+    /** 
+    * Gets bytecode offset of the first inst with bc-mapping in the node
+    * 
+    * @return  bytecode offset of the first inst with bc-mapping in the node
+    */
+    uint16 getNodeStartBCOffset() const;
+
+    /** 
+    * Gets bytecode offset of the last inst with bc-mapping in the node
+    * 
+    * @return  bytecode offset of the last inst with bc-mapping in the node
+    */
+    uint16 getNodeEndBCOffset() const;
+
+
 protected:
   /** 
    * The constructor of Node.

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/Type.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/Type.cpp?rev=571484&r1=571483&r2=571484&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/Type.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/Type.cpp Fri Aug 31 07:48:19 2007
@@ -526,7 +526,7 @@
 }
 
 UnresolvedMethodPtrType*    
-TypeManager::getUnresolvedMethodPtrType(ObjectType* enclosingClass, uint32 cpIndex) {
+TypeManager::getUnresolvedMethodPtrType(ObjectType* enclosingClass, uint32 cpIndex, MethodSignature* sig) {
     PtrHashTable<UnresolvedMethodPtrType>* methodsPerClass = unresMethodPtrTypes.lookup(enclosingClass);
     if (!methodsPerClass) {
         methodsPerClass = new (memManager) PtrHashTable<UnresolvedMethodPtrType>(memManager, 32);
@@ -534,7 +534,8 @@
     }
     UnresolvedMethodPtrType* methType = methodsPerClass->lookup((void*)(POINTER_SIZE_INT)cpIndex);
     if (!methType) {
-        methType = new (memManager) UnresolvedMethodPtrType(enclosingClass, cpIndex, *this);
+        methType = new (memManager) UnresolvedMethodPtrType(enclosingClass, cpIndex, *this, 
+            sig->getNumParams(), sig->getParamTypes(), sig->getRetType());
         methodsPerClass->insert((void*)(POINTER_SIZE_INT)cpIndex, methType);
     }
     return methType;
@@ -1008,6 +1009,7 @@
 }
 
 void UnresolvedMethodPtrType::print(::std::ostream& os) {
+    //TODO: think about caching signature string as a separate field to avoid VM calls here
     Class_Handle ch = (Class_Handle)enclosingClass->getVMTypeHandle();
     const char* method_class = const_pool_get_method_class_name(ch, (unsigned short)cpIndex);
     const char* method_name = const_pool_get_method_name(ch, (unsigned short)cpIndex);

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/Type.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/Type.h?rev=571484&r1=571483&r2=571484&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/Type.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/Type.h Fri Aug 31 07:48:19 2007
@@ -50,7 +50,7 @@
 class TypeManager;
 class TypeFailStream;
 class TypeFactsManager;
-
+class MethodSignature;
 typedef SsaOpnd* ValueName;
 
 class Type {
@@ -422,27 +422,6 @@
     virtual bool isInstance() = 0;
 };
 
-class UnresolvedMethodPtrType : public FunctionPtrType {
-public:
-    UnresolvedMethodPtrType(ObjectType* _enclosingClass, uint32 _cpIndex, TypeManager& tm, bool isCompressed=false, ValueName obj=NULL) 
-        : FunctionPtrType(isCompressed), enclosingClass(_enclosingClass), cpIndex(_cpIndex), typeManager(tm), object(obj) {}
-        virtual ~UnresolvedMethodPtrType() {}
-
-        UnresolvedMethodPtrType* asUnresolvedMethodPtrType() { return this; }
-        uint32 getNumParams() {assert(0); return 0;}
-        Type* getParamType(uint32 n){assert(0); return NULL;}
-        Type* getReturnType() {assert(0); return NULL;}
-        bool isInstance() { assert(0); return false;}
-        void print(::std::ostream& os);
-        virtual bool    isUnresolvedType() {return true;}
-private:
-    ObjectType* enclosingClass;
-    uint32      cpIndex;
-    TypeManager& typeManager;
-    ValueName object;
-
-};
-
 class MethodPtrType : public FunctionPtrType {
 public:
     MethodPtrType(MethodDesc* md, TypeManager& tm, bool isCompressed=false, ValueName obj=NULL) 
@@ -454,7 +433,7 @@
     Type* getParamType(uint32 i);
     Type* getReturnType() { return methodDesc->getReturnType(); }
     bool isInstance() { return methodDesc->isInstance(); }
-    MethodDesc*     getMethodDesc()         {return methodDesc;}
+    virtual MethodDesc*     getMethodDesc()         {return methodDesc;}
     void print(::std::ostream& os);
     ValueName getThisValueName() { return object; }
 private:
@@ -463,6 +442,40 @@
     ValueName object;
 };
 
+
+class UnresolvedMethodPtrType : public MethodPtrType {
+public:
+    UnresolvedMethodPtrType(ObjectType* _enclosingClass, uint32 _cpIndex, TypeManager& tm, 
+        uint32 _nParams, Type** _paramTypes, Type* _returnType, 
+        bool isCompressed=false, ValueName obj=NULL) 
+        : MethodPtrType(NULL, tm, isCompressed, obj), 
+        enclosingClass(_enclosingClass), cpIndex(_cpIndex),
+        nParams(_nParams), paramTypes(_paramTypes), returnType(_returnType)
+    {}
+
+    virtual ~UnresolvedMethodPtrType() {}
+
+    UnresolvedMethodPtrType* asUnresolvedMethodPtrType() { return this; }
+    uint32 getNumParams() {return nParams;}
+    Type* getParamType(uint32 n){ assert(n<nParams); return paramTypes[n];}
+    Type* getReturnType() {return returnType;}
+    bool isInstance() { assert(0); return false;}
+    virtual MethodDesc* getMethodDesc() {assert(0); return NULL;}
+
+    void print(::std::ostream& os);
+    virtual bool isUnresolvedType() {return true;}
+private:
+    void initSignature();
+    ObjectType* enclosingClass;
+    uint32      cpIndex;
+    
+    uint32 nParams;
+    Type** paramTypes;
+    Type* returnType;
+};
+
+
+
 class VTablePtrType : public Type {
 public:
     VTablePtrType(Type* t, bool isCompressed=false) : Type(isCompressed? CompressedVTablePtr : VTablePtr), 
@@ -722,7 +735,7 @@
 
     MethodPtrType*    getMethodPtrType(MethodDesc* methodDesc);
 
-    UnresolvedMethodPtrType*    getUnresolvedMethodPtrType(ObjectType* enclosingClass, uint32 cpIndex);
+    UnresolvedMethodPtrType*    getUnresolvedMethodPtrType(ObjectType* enclosingClass, uint32 cpIndex, MethodSignature* sig);
         
     MethodPtrType* getMethodPtrObjType(ValueName obj, MethodDesc* methodDesc);
         
@@ -832,6 +845,15 @@
     bool         lazyResolutionMode;
 };
 
+class MethodSignature {
+public:
+    MethodSignature(){}
+    virtual ~MethodSignature(){}
+
+    virtual uint32 getNumParams() const = 0;
+    virtual Type** getParamTypes() const = 0;
+    virtual Type* getRetType() const = 0;
+};
 } //namespace Jitrino 
 
 #endif // _TYPE_H_

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/TranslatorIntfc.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/TranslatorIntfc.cpp?rev=571484&r1=571483&r2=571484&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/TranslatorIntfc.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/TranslatorIntfc.cpp Fri Aug 31 07:48:19 2007
@@ -42,10 +42,15 @@
     TranslatorAction* action = (TranslatorAction*)getAction();
     flags = action->getFlags();
 #ifdef _DEBUG
+/*
+    TODO: to avoid recursive compilation with OPT we need to finish this task
+    1) Fix lazy exceptions opt
+    2) Ia32CodeEmmitter forces creation of interned strings during compilation -> fix it.
     if (flags.assertOnRecursion) {
         int rec = Jitrino::getCompilationRecursionLevel();
         assert( rec == 1);
     }
+*/
 #endif
     translate();
     postTranslatorCleanup();

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeParser.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeParser.cpp?rev=571484&r1=571483&r2=571484&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeParser.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeParser.cpp Fri Aug 31 07:48:19 2007
@@ -23,9 +23,48 @@
 
 #include <stdio.h>
 #include "JavaByteCodeParser.h"
+#include "Log.h"
 
 namespace Jitrino {
 
+static const char *opcode_names[256] = {
+    "NOP", "ACONST_NULL", "ICONST_M1", "ICONST_0", "ICONST_1", "ICONST_2",
+    "ICONST_3", "ICONST_4", "ICONST_5", "LCONST_0", "LCONST_1", "FCONST_0",
+    "FCONST_1", "FCONST_2", "DCONST_0", "DCONST_1", "BIPUSH", "SIPUSH",
+    "LDC", "LDC_W", "LDC2_W", "ILOAD", "LLOAD", "FLOAD", "DLOAD", "ALOAD",
+    "ILOAD_0", "ILOAD_1", "ILOAD_2", "ILOAD_3", "LLOAD_0", "LLOAD_1",
+    "LLOAD_2",
+    "LLOAD_3", "FLOAD_0", "FLOAD_1", "FLOAD_2", "FLOAD_3", "DLOAD_0",
+    "DLOAD_1",
+    "DLOAD_2", "DLOAD_3", "ALOAD_0", "ALOAD_1", "ALOAD_2", "ALOAD_3",
+    "IALOAD",
+    "LALOAD", "FALOAD", "DALOAD", "AALOAD", "BALOAD", "CALOAD", "SALOAD",
+    "ISTORE", "LSTORE", "FSTORE", "DSTORE", "ASTORE", "ISTORE_0", "ISTORE_1",
+    "ISTORE_2", "ISTORE_3", "LSTORE_0", "LSTORE_1", "LSTORE_2", "LSTORE_3",
+    "FSTORE_0", "FSTORE_1", "FSTORE_2", "FSTORE_3", "DSTORE_0", "DSTORE_1",
+    "DSTORE_2", "DSTORE_3", "ASTORE_0", "ASTORE_1", "ASTORE_2", "ASTORE_3",
+    "IASTORE", "LASTORE", "FASTORE", "DASTORE", "AASTORE", "BASTORE",
+    "CASTORE",
+    "SASTORE", "POP", "POP2", "DUP", "DUP_X1", "DUP_X2", "DUP2", "DUP2_X1",
+    "DUP2_X2", "SWAP", "IADD", "LADD", "FADD", "DADD", "ISUB", "LSUB", "FSUB",
+    "DSUB", "IMUL", "LMUL", "FMUL", "DMUL", "IDIV", "LDIV", "FDIV", "DDIV",
+    "IREM", "LREM", "FREM", "DREM", "INEG", "LNEG", "FNEG", "DNEG", "ISHL",
+    "LSHL", "ISHR", "LSHR", "IUSHR", "LUSHR", "IAND", "LAND", "IOR", "LOR",
+    "IXOR", "LXOR", "IINC", "I2L", "I2F", "I2D", "L2I", "L2F", "L2D", "F2I",
+    "F2L", "F2D", "D2I", "D2L", "D2F", "I2B", "I2C", "I2S", "LCMP", "FCMPL",
+    "FCMPG", "DCMPL", "DCMPG", "IFEQ", "IFNE", "IFLT", "IFGE", "IFGT", "IFLE",
+    "IF_ICMPEQ", "IF_ICMPNE", "IF_ICMPLT", "IF_ICMPGE", "IF_ICMPGT",
+    "IF_ICMPLE", "IF_ACMPEQ", "IF_ACMPNE", "GOTO", "JSR", "RET",
+    "TABLESWITCH",
+    "LOOKUPSWITCH", "IRETURN", "LRETURN", "FRETURN", "DRETURN", "ARETURN",
+    "RETURN", "GETSTATIC", "PUTSTATIC", "GETFIELD", "PUTFIELD",
+    "INVOKEVIRTUAL",
+    "INVOKESPECIAL", "INVOKESTATIC", "INVOKEINTERFACE", "_OPCODE_UNDEFINED",
+    "NEW", "NEWARRAY", "ANEWARRAY", "ARRAYLENGTH", "ATHROW", "CHECKCAST",
+    "INSTANCEOF", "MONITORENTER", "MONITOREXIT", "WIDE", "MULTIANEWARRAY",
+    "IFNULL", "IFNONNULL", "GOTO_W", "JSR_W",
+};
+
 static char bytecodelength[] = { 
     1, // 0x00:    nop                          
     1, // 0x01:    aconst_null                  
@@ -283,6 +322,11 @@
     uint32 len = 0; 
     const uint8  opcode = *bcp;
     assert (opcode <= 0xc9);
+    if (Log::isEnabled()) {
+        Log::out()<<"---------------------PARSING BYTECODE: "<<opcode_names[opcode]<<"        bc-offset="<<off<<std::endl;
+    }
+
+
     len = bytecodelength[opcode];
     if (len == 0) { // variable length cases
         switch (opcode) {

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeTranslator.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeTranslator.cpp?rev=571484&r1=571483&r2=571484&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeTranslator.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeTranslator.cpp Fri Aug 31 07:48:19 2007
@@ -1445,6 +1445,37 @@
     return srcOpnds;
 }
 
+class JavaMethodSignature : public MethodSignature {
+public:
+    JavaMethodSignature(MemoryManager& mm, CompilationInterface ci, Class_Handle cl, const char* sigStr){
+        nParams = JavaLabelPrepass::getNumArgsBySignature(sigStr);
+        const char* sigSuffix = sigStr;
+        if (nParams > 0) {
+            sigSuffix++;
+            paramTypes = new (mm) Type*[nParams];
+            for (uint32 i=0;i<nParams;i++) {
+                uint32 len = 0;
+                Type* type = JavaLabelPrepass::getTypeByDescriptorString(ci, cl, sigSuffix, len);
+                assert(type!=NULL);
+                paramTypes[i] = type;
+                sigSuffix+=len;
+            }
+        } else {
+            paramTypes = NULL;
+        }
+        retType = JavaLabelPrepass::getRetTypeBySignature(ci, cl, sigSuffix);
+    }
+    
+    virtual ~JavaMethodSignature(){};
+    virtual uint32 getNumParams() const { return nParams;}
+    virtual Type** getParamTypes() const { return paramTypes;}
+    virtual Type* getRetType() const {return retType;}
+private:
+    uint32 nParams;
+    Type** paramTypes;
+    Type* retType;
+
+};
 
 void JavaByteCodeTranslator::genCallWithResolve(JavaByteCodes bc, unsigned cpIndex) {
     assert(bc == OPCODE_INVOKESPECIAL || bc == OPCODE_INVOKESTATIC || bc == OPCODE_INVOKEVIRTUAL || bc == OPCODE_INVOKEINTERFACE);
@@ -1455,11 +1486,13 @@
     assert(enclosingClass!=NULL);
     const char* methodSig = methodSignatureString(cpIndex);
     assert(methodSig);
-    uint32 numArgs = JavaLabelPrepass::getNumArgsBySignature(methodSig) + (isStatic ? 0 : 1); 
+    JavaMethodSignature* sig = new (memManager) JavaMethodSignature(irBuilder.getIRManager()->getMemoryManager(),
+        compilationInterface, (Class_Handle)enclosingClass->getVMTypeHandle(), methodSig);
+    uint32 numArgs = sig->getNumParams() + (isStatic ? 0 : 1); 
     assert(numArgs > 0 || isStatic);
 
     Opnd** args = popArgs(numArgs);
-    Type* returnType = JavaLabelPrepass::getRetTypeBySignature(compilationInterface, methodToCompile.getParentHandle(), methodSig);
+    Type* returnType = sig->getRetType();
     
 
     if (bc != OPCODE_INVOKEINTERFACE) {
@@ -1483,7 +1516,7 @@
     Opnd* tauTypesChecked = NULL;// let IRBuilder handle types
 
     Opnd* dst = irBuilder.genIndirectCallWithResolve(returnType, tauNullCheckedFirstArg, tauTypesChecked, 
-                                numArgs, args, enclosingClass, bc, cpIndex);
+                                numArgs, args, enclosingClass, bc, cpIndex, sig);
     if (returnType->tag != Type::Void) {
         pushOpnd(dst);
     }

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaLabelPrepass.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaLabelPrepass.cpp?rev=571484&r1=571483&r2=571484&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaLabelPrepass.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaLabelPrepass.cpp Fri Aug 31 07:48:19 2007
@@ -1349,7 +1349,7 @@
     }
 }
 
-uint32 JavaLabelPrepass::getNumArgsBySignature(const char*& methodSig) 
+uint32 JavaLabelPrepass::getNumArgsBySignature(const char* methodSig) 
 {
     assert(methodSig);
     assert(*methodSig == '(');
@@ -1391,76 +1391,87 @@
 Type* JavaLabelPrepass::getRetTypeBySignature(CompilationInterface& ci, Class_Handle enclClass, const char* origSig) 
 {
     assert(*origSig== '(' || *origSig == ')');
-    while( *(origSig++) != ')' ); // in case getNumArgsBySignature was not run earlier
-
-    Type* retType = NULL;
-    uint32 arrayDim = 0;
-    const char* methodSig = origSig;
+    while( *(origSig++) != ')' ); 
 
+    uint32 stub=0;
+    return getTypeByDescriptorString(ci, enclClass, origSig, stub);
+}
 
+Type* JavaLabelPrepass::getTypeByDescriptorString(CompilationInterface& ci, Class_Handle enclClass, const char* descriptorString, uint32& len) {
+    uint32 arrayDim = 0;
+    len=1;
+    Type* resType = NULL;
     // collect array dimension if any
-    while( *(methodSig) == '[' ) {
+    while( *(descriptorString) == '[' ) {
         arrayDim++;
-        methodSig++;
+        descriptorString++;
+        len++;
     }
 
     bool arrayIsWrapped = false;
     TypeManager& typeManager = ci.getTypeManager();
-    switch( *methodSig ) 
+    switch( *descriptorString ) 
     {
-    case 'L': {
+    case 'L': 
+        {
+            //TODO: check by name if type is already resolved!!!
             if (!typeManager.isLazyResolutionMode()) {
-                retType = typeManager.getUnresolvedObjectType();
+                resType = typeManager.getUnresolvedObjectType();
             } else {
-                retType = ci.getTypeFromDescriptor(enclClass, origSig);
+                resType = ci.getTypeFromDescriptor(enclClass, descriptorString);
                 //in lazy resolution mode retType is already valid array type
                 arrayIsWrapped = true;
             }
+            while( *(++descriptorString) != ';' ) {
+                len++;
+                assert(*descriptorString);
+            }
+            len++; //';' char
         }
         break;
     case 'B':
-        retType = typeManager.getInt8Type();
+        resType = typeManager.getInt8Type();
         break;
     case 'C':
-        retType = typeManager.getCharType();
+        resType = typeManager.getCharType();
         break;
     case 'D':
-        retType = typeManager.getDoubleType();
+        resType = typeManager.getDoubleType();
         break;
     case 'F':
-        retType = typeManager.getSingleType();
+        resType = typeManager.getSingleType();
         break;
     case 'I':
-        retType = typeManager.getInt32Type();
+        resType = typeManager.getInt32Type();
         break;
     case 'J':
-        retType = typeManager.getInt64Type();
+        resType = typeManager.getInt64Type();
         break;
     case 'S':
-        retType = typeManager.getInt16Type();
+        resType = typeManager.getInt16Type();
         break;
     case 'Z':
-        retType = typeManager.getBooleanType();
+        resType = typeManager.getBooleanType();
         break;
     case 'V':
-        retType = typeManager.getVoidType();
+        resType = typeManager.getVoidType();
         break; // leave stack as is
     case '[': // all '[' are already skipped
     case '(': // we have already pass it
     case ')': // we have just leave it back
     default: // impossible! Verifier must check and catch this
         assert(0);
-        retType = typeManager.getUnresolvedObjectType();
+        resType = typeManager.getUnresolvedObjectType();
         break;
     }
-    assert(retType);
+    assert(resType);
 
     if (!arrayIsWrapped && arrayDim > 0) {
         for (;arrayDim > 0; arrayDim--) {
-            retType = typeManager.getArrayType(retType, false);
+            resType = typeManager.getArrayType(resType, false);
         }
     }
-    return retType;
+    return resType;
 }
 
 void JavaLabelPrepass::invoke(MethodDesc* methodDesc) {
@@ -1950,7 +1961,7 @@
                     << "][index=" << index << "] is empty" << ::std::endl;
     } else {
         Log::out() << "localVars[offset=" << offset << "][index=" << index << "].var->declT = "; 
-        (*iter).second->getDeclaredType()->print(::std::cout); 
+        (*iter).second->getDeclaredType()->print(Log::out()); 
         Log::out() << ::std::endl;
     }
 }

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaLabelPrepass.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaLabelPrepass.h?rev=571484&r1=571483&r2=571484&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaLabelPrepass.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaLabelPrepass.h Fri Aug 31 07:48:19 2007
@@ -312,8 +312,9 @@
     void genCompare   (Type *type);
     void invoke       (MethodDesc *mdesc);
     void pseudoInvoke (const char* mdesc);
-    static  uint32  getNumArgsBySignature(const char*& methodSig);
-    static  Type*   getRetTypeBySignature(CompilationInterface& ci, Class_Handle enclClass, const char* methodSig);
+    static uint32  getNumArgsBySignature(const char* methodSig);
+    static Type*   getRetTypeBySignature(CompilationInterface& ci, Class_Handle enclClass, const char* methodSig);
+    static Type*   getTypeByDescriptorString(CompilationInterface& ci, Class_Handle enclClass, const char* descriptorString, uint32& len);
 
     // remaining instructions
 



Mime
View raw message