harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfur...@apache.org
Subject svn commit: r565339 - in /harmony/enhanced/drlvm/trunk: src/test/regression/H4292/ src/test/regression/excludes/ vm/jitrino/src/codegenerator/ vm/jitrino/src/codegenerator/ia32/ vm/jitrino/src/jet/ vm/jitrino/src/main/ vm/jitrino/src/optimizer/ vm/jitr...
Date Mon, 13 Aug 2007 13:16:04 GMT
Author: mfursov
Date: Mon Aug 13 06:16:03 2007
New Revision: 565339

URL: http://svn.apache.org/viewvc?view=rev&rev=565339
Log:
Fix for HARMONY-4292 "[drlvm][jit][opt] Jitrino.OPT craches instead of throwing SOE when synchronized
method is invoked recursively" + regression test

Fix for HARMONY-4561 "[drlvm][jit] Code regions reachable by exception paths only are ignred
by inliner"

Fix for HARMONY-2115 "[drlvm][jit][opt] syncopt optimization pass crashes because expects
old CFG structure"

Fix for HARMONY-4622 "[drlvm][jit][opt] Duplicated functionality in Loop.cpp and loop_unroll.cpp"


Added:
    harmony/enhanced/drlvm/trunk/src/test/regression/H4292/
    harmony/enhanced/drlvm/trunk/src/test/regression/H4292/Test.java   (with props)
    harmony/enhanced/drlvm/trunk/src/test/regression/H4292/run.test.xml   (with props)
Modified:
    harmony/enhanced/drlvm/trunk/src/test/regression/excludes/exclude.linux.x86_64
    harmony/enhanced/drlvm/trunk/src/test/regression/excludes/exclude.windows.x86_64
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/CodeGenIntfc.h
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32RuntimeInterface.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32RuntimeInterface.h
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/jet.h
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/rt.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/main/Jitrino.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/main/Jitrino.h
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Loop.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Loop.h
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/inliner.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/syncopt.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/drl/DrlJITInterface.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/include/dll_jit_intf.h
    harmony/enhanced/drlvm/trunk/vm/vmcore/include/jit_intf_cpp.h
    harmony/enhanced/drlvm/trunk/vm/vmcore/include/thread_manager.h
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions_jit.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/dll_jit.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/mon_enter_exit.cpp

Added: harmony/enhanced/drlvm/trunk/src/test/regression/H4292/Test.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/src/test/regression/H4292/Test.java?view=auto&rev=565339
==============================================================================
--- harmony/enhanced/drlvm/trunk/src/test/regression/H4292/Test.java (added)
+++ harmony/enhanced/drlvm/trunk/src/test/regression/H4292/Test.java Mon Aug 13 06:16:03 2007
@@ -0,0 +1,37 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+
+package org.apache.harmony.drlvm.tests.regression.h4292;
+import junit.framework.*;
+
+public class Test extends TestCase {
+
+    synchronized void _testSyncRec1() {
+        _testSyncRec1();
+    }
+
+    public void testSyncRec1() {
+        try {
+            _testSyncRec1();
+        } catch (StackOverflowError e) {
+            System.out.println("PASSED!");
+            return;
+        }
+        fail("FAILED:No SOE was thrown!");
+    }
+}

Propchange: harmony/enhanced/drlvm/trunk/src/test/regression/H4292/Test.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/drlvm/trunk/src/test/regression/H4292/run.test.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/src/test/regression/H4292/run.test.xml?view=auto&rev=565339
==============================================================================
--- harmony/enhanced/drlvm/trunk/src/test/regression/H4292/run.test.xml (added)
+++ harmony/enhanced/drlvm/trunk/src/test/regression/H4292/run.test.xml Mon Aug 13 06:16:03
2007
@@ -0,0 +1,13 @@
+<project name="RUN HARMONY-4292 Regression Test">
+    <target name="run-test">
+        <run-junit-test 
+            test="org.apache.harmony.drlvm.tests.regression.h4292.Test"
+            vmarg="-Xem:jet">
+        </run-junit-test>
+        <run-junit-test 
+            test="org.apache.harmony.drlvm.tests.regression.h4292.Test"
+            vmarg="-Xem:opt">
+        </run-junit-test>
+    </target>
+</project>
+

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

Modified: harmony/enhanced/drlvm/trunk/src/test/regression/excludes/exclude.linux.x86_64
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/src/test/regression/excludes/exclude.linux.x86_64?view=diff&rev=565339&r1=565338&r2=565339
==============================================================================
--- harmony/enhanced/drlvm/trunk/src/test/regression/excludes/exclude.linux.x86_64 (original)
+++ harmony/enhanced/drlvm/trunk/src/test/regression/excludes/exclude.linux.x86_64 Mon Aug
13 06:16:03 2007
@@ -22,3 +22,4 @@
 H3341
 # Exclude this test because SOE handling is not ready for x86_64 in JIT/VM yet
 H4265
+H4292

Modified: harmony/enhanced/drlvm/trunk/src/test/regression/excludes/exclude.windows.x86_64
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/src/test/regression/excludes/exclude.windows.x86_64?view=diff&rev=565339&r1=565338&r2=565339
==============================================================================
--- harmony/enhanced/drlvm/trunk/src/test/regression/excludes/exclude.windows.x86_64 (original)
+++ harmony/enhanced/drlvm/trunk/src/test/regression/excludes/exclude.windows.x86_64 Mon Aug
13 06:16:03 2007
@@ -21,3 +21,4 @@
 H3341
 # Exclude this test because SOE handling is not ready for x86_64 in JIT/VM yet
 H4265
+H4292

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/CodeGenIntfc.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/CodeGenIntfc.h?view=diff&rev=565339&r1=565338&r2=565339
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/CodeGenIntfc.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/CodeGenIntfc.h Mon Aug 13 06:16:03
2007
@@ -576,6 +576,7 @@
     virtual void  fixHandlerContext(MethodDesc* methodDesc, ::JitFrameContext* context, bool
isFirst) = 0;
 
     virtual void* getAddressOfThis(MethodDesc* methodDesc, const ::JitFrameContext* context,
bool isFirst) = 0;
+    virtual bool  isSOEArea(MethodDesc* methodDesc, const ::JitFrameContext* context, bool
isFirst) {return false;}
 
     virtual bool getBcLocationForNative(MethodDesc* method, POINTER_SIZE_INT native_pc, uint16
*bc_pc) = 0;
     virtual bool getNativeLocationForBc(MethodDesc* method,  uint16 bc_pc, POINTER_SIZE_INT
*native_pc) = 0;

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32RuntimeInterface.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32RuntimeInterface.cpp?view=diff&rev=565339&r1=565338&r2=565339
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32RuntimeInterface.cpp
(original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32RuntimeInterface.cpp
Mon Aug 13 06:16:03 2007
@@ -39,6 +39,19 @@
     stackInfo.unwind(methodDesc, context, isFirst);
 }
 
+bool RuntimeInterface::isSOEArea(MethodDesc* methodDesc, const ::JitFrameContext* context,
bool isFirst) {
+#ifdef _EM64T_
+    POINTER_SIZE_INT eip = *context->p_rip;
+#else
+    POINTER_SIZE_INT eip = *context->p_eip;
+#endif
+    StackInfo stackInfo;
+    stackInfo.read(methodDesc, eip, isFirst);
+    POINTER_SIZE_INT eipOffset = eip - (POINTER_SIZE_INT)methodDesc->getCodeBlockAddress(0);
+    assert(fit32(eipOffset) && eipOffset >= 0);
+    return eipOffset<=stackInfo.getSOECheckAreaOffset();
+}
+
 void* RuntimeInterface::getAddressOfThis(MethodDesc * methodDesc, const JitFrameContext*
context, bool isFirst) {
     assert(!methodDesc->isStatic());
     if (!methodDesc->isSynchronized() &&  !methodDesc->isParentClassIsLikelyExceptionType())
{
@@ -54,9 +67,7 @@
 #else
     stackInfo.read(methodDesc, *context->p_eip, isFirst);
     assert(isFirst || (uint32)context->p_eip+4 == context->esp);
-    if (stackInfo.getStackDepth() == 0) { //stack overflow exception
-        return NULL;
-    }
+    assert(stackInfo.getStackDepth()==0 || !isFirst);
     return (void *)(context->esp + stackInfo.getStackDepth() + stackInfo.getOffsetOfThis());
 #endif
 }

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32RuntimeInterface.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32RuntimeInterface.h?view=diff&rev=565339&r1=565338&r2=565339
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32RuntimeInterface.h
(original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32RuntimeInterface.h
Mon Aug 13 06:16:03 2007
@@ -53,6 +53,7 @@
 
     virtual void* getAddressOfThis(MethodDesc* methodDesc, const JitFrameContext* context,
bool isFirst);
 
+    virtual bool isSOEArea(MethodDesc* methodDesc, const ::JitFrameContext* context, bool
isFirst);
 
     virtual void* getAddressOfSecurityObject(MethodDesc* methodDesc, const JitFrameContext*
context) { assert(0); return NULL; }
 

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/jet.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/jet.h?view=diff&rev=565339&r1=565338&r2=565339
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/jet.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/jet.h Mon Aug 13 06:16:03 2007
@@ -110,6 +110,11 @@
                             JitFrameContext * context);
 
 /**
+* @brief Returns 'TRUE' if EIP referenced by context points to SOE checking area of the method
+*/
+Boolean rt_is_soe_area(JIT_Handle jit, Method_Handle method, const JitFrameContext * context);
+
+/**
  * @brief Returns address of 'this' argument for the given method.
  *
  * Returns an address where the 'this' pointer is stored. This is normally 

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/rt.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/rt.cpp?view=diff&rev=565339&r1=565338&r2=565339
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/rt.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/rt.cpp Mon Aug 13 06:16:03 2007
@@ -417,6 +417,25 @@
     *psp = sp_val;
 }
 
+Boolean rt_is_soe_area(JIT_Handle jit, Method_Handle method, const JitFrameContext * context)
{
+    char * pinfo = (char*)method_get_info_block_jit(method, jit);
+
+    assert(MethodInfoBlock::is_valid_data(pinfo));
+    
+    MethodInfoBlock infoBlock(pinfo);
+    assert(!(infoBlock.get_flags() & JMF_SP_FRAME)); // not yet 
+
+    void *** pip = (void***)((char*)context + ip_off);
+    char * where = (char*)**pip;
+    char * meth_start = infoBlock.get_code_start();
+    unsigned whereLen = (unsigned)(where - meth_start);
+    if (whereLen<infoBlock.get_warmup_len()) {
+        return 1;
+    }
+    return 0;
+
+}
+
 void * rt_get_address_of_this(JIT_Handle jit, Method_Handle method,
                               const JitFrameContext * context)
 {

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/main/Jitrino.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/main/Jitrino.cpp?view=diff&rev=565339&r1=565338&r2=565339
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/main/Jitrino.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/main/Jitrino.cpp Mon Aug 13 06:16:03 2007
@@ -326,6 +326,12 @@
     return runtimeInterface->getAddressOfThis(methodDesc, context, isFirst);
 }
 
+bool
+Jitrino::IsSOEArea(MethodDesc* methodDesc, const ::JitFrameContext* context, bool isFirst)
{
+    return runtimeInterface->isSOEArea(methodDesc, context, isFirst);
+}
+
+
 #ifdef USE_SECURITY_OBJECT
 void *
 Jitrino::GetAddressOfSecurityObject(MethodDesc* methodDesc, const ::JitFrameContext* context)
{

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/main/Jitrino.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/main/Jitrino.h?view=diff&rev=565339&r1=565338&r2=565339
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/main/Jitrino.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/main/Jitrino.h Mon Aug 13 06:16:03 2007
@@ -53,6 +53,7 @@
     static bool  CanEnumerate(MethodDesc* methodDesc, NativeCodePtr eip);
     static void  FixHandlerContext(MethodDesc* methodDesc, ::JitFrameContext* context, bool
isFirst);
     static void* GetAddressOfThis(MethodDesc* methodDesc, const ::JitFrameContext* context,
bool isFirst);
+    static bool  IsSOEArea(MethodDesc* methodDesc, const ::JitFrameContext* context, bool
isFirst);
 #ifdef USE_SECURITY_OBJECT
     static void* GetAddressOfSecurityObject(MethodDesc* methodDesc, const ::JitFrameContext*
context);
 #endif

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?view=diff&rev=565339&r1=565338&r2=565339
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Loop.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Loop.cpp Mon Aug 13 06:16:03 2007
@@ -67,9 +67,6 @@
     flags->peeling_threshold = argSource->getIntArg(p, "loop.peeling_threshold", 2);
     flags->fullpeel = argSource->getBoolArg(p, "loop.fullpeel", false);
     flags->fullpeel_max_inst = argSource->getIntArg(p, "loop.fullpeel_max_inst", 40);
-    flags->unroll = argSource->getBoolArg(p, "loop.unroll", false);
-    flags->unroll_count = argSource->getIntArg(p, "loop.unroll_count", 4);
-    flags->unroll_threshold = argSource->getIntArg(p, "loop.unroll_threshold", 10);
     flags->peel_upto_branch_no_instanceof = argSource->getBoolArg(p, "loop.peel_upto_branch_no_instanceof",
true);
 
 }
@@ -84,9 +81,6 @@
     os << "    loop.peel_upto_branch[={on|OFF}]   - peel only up to a branch" <<
std::endl;
     os << "    loop.old_static_peeling[={on|OFF}] - use old-style peeling for static
runs" << std::endl;
     os << "    loop.peeling_threshold[=int]  - (default 2)" << std::endl;
-    os << "    loop.unroll[={on|OFF}]" << std::endl;
-    os << "    loop.unroll_count[=int] - (default 4)" << std::endl;
-    os << "    loop.unroll_threshold[=int] - (default 10)" << std::endl;
     os << "    loop.peel_upto_branch_no_instanceof[={on|OFF}] - with peel_upto_branch,
peel only up to a branch or instanceof" << std::endl;
 }
 
@@ -563,53 +557,6 @@
                     if(preheader == tail)
                         preheader = header->getInEdges().back()->getSourceNode(); 
          
                 }            
-            }
-
-            if(flags.unroll && newHeader == originalInvertedHeader && newTail
!= NULL && header->getExecCount() >= heatThreshold && (header->getExecCount()
>= flags.unroll_threshold * preheader->getExecCount())) {
-                header = newHeader;
-                // n is the number of times to unroll the loop
-                uint32 n = ::std::min(flags.unroll_count, (uint32) (header->getExecCount()
/ preheader->getExecCount()));
-                double headerFreq = header->getExecCount();
-                Node* backTarget = header;
-                Edge* backEdge = tail->findTargetEdge(header);
-                double noEarlyExitProb = (tail->getExecCount() * backEdge->getEdgeProb())
/ header->getExecCount();
-                if(!(noEarlyExitProb > 0 && noEarlyExitProb <= 1)) {
-                    Log::out() << "headerFreq=" << headerFreq << std::endl;
-                    Log::out() << "tailFreq=" << tail->getExecCount() <<
std::endl;
-                    Log::out() << "backProb=" << backEdge->getEdgeProb() <<
std::endl;
-                    Log::out() << "noEarlyExit=" << noEarlyExitProb <<
std::endl;
-                    assert(0);
-                }
-
-                uint32 k;
-                double scale = 1;
-                double sum = 1;
-                for(k = 0; k < (n-1); ++k) {
-                    // Probability of starting the k+1 iteration.
-                    scale *= noEarlyExitProb;
-                    sum += scale;
-                }
-                for(k = 0; k < (n-1); ++k) {
-                    Node* unrolled = FlowGraph::duplicateRegion(irManager, header, nodesToPeel,
defUses, headerFreq * scale / sum);
-                    scale /= noEarlyExitProb;
-                    backEdge = tail->findTargetEdge(backTarget);
-                    if(backEdge == NULL) {
-                        //
-                        // An intervening stVar block was added to promote a temp to a var

-                        // in the duplicated block.  The new tail should be the stVar block.
-                        //
-                        tail =  tail->getUnconditionalEdge()->getTargetNode();
-                        assert(tail != NULL);
-                        Edge* backEdge = tail->findTargetEdge(backTarget);
-                        if( !(backEdge != NULL) ) assert(0);
-                    }
-                    fg.replaceEdgeTarget(backEdge, unrolled);
-                    backTarget = unrolled;
-                }
-                assert(header->getInDegree() == 2);
-                tail = header->getInEdges().front()->getSourceNode();
-                if(preheader == tail)
-                    tail = header->getInEdges().back()->getSourceNode();
             }
             if(preheader->getOutDegree() > 1) {
                 Edge* edge = preheader->findTargetEdge(header);

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Loop.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Loop.h?view=diff&rev=565339&r1=565338&r2=565339
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Loop.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Loop.h Mon Aug 13 06:16:03 2007
@@ -44,9 +44,6 @@
     uint32 peeling_threshold; 
     bool fullpeel;
     uint32 fullpeel_max_inst;
-    bool unroll;
-    uint32 unroll_count;
-    uint32 unroll_threshold; 
     bool peel_upto_branch_no_instanceof;
 };
 

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?view=diff&rev=565339&r1=565338&r2=565339
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/inliner.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/inliner.cpp Mon Aug 13 06:16:03
2007
@@ -63,7 +63,7 @@
 #define INLINE_RECURSION_PENALTY 300
 #define INLINE_EXACT_ARG_BONUS 0
 #define INLINE_EXACT_ALL_BONUS 0
-#define INLINE_SKIP_EXCEPTION_PATH true
+#define INLINE_SKIP_EXCEPTION_PATH false
 
 #define PRAGMA_INLINE_BENEFIT (2*1000*1000*1000)
 

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/syncopt.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/syncopt.cpp?view=diff&rev=565339&r1=565338&r2=565339
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/syncopt.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/syncopt.cpp Mon Aug 13 06:16:03
2007
@@ -138,8 +138,8 @@
     Inst *nextInst = firstInst->getNextInst();
     Node *ciNode = node;
     int counter = 0;
-    while (nextInst->getOpcode() != Op_Catch) {
-        if (nextInst == firstInst) {
+    while ( (nextInst && nextInst->getOpcode() != Op_Catch) || !nextInst ) {
+        if (nextInst == NULL) {
             if (++counter > 3) {
                 if (EXTRA_DEBUGGING && Log::isEnabled()) {
                     Log::out() << " isCatchAll case 5" << ::std::endl;
@@ -213,17 +213,26 @@
                                                 Node *&catchInstNode)
 {
     catchInstNode = 0;
-    if (isCatchAll(node, caughtOpnd, catchInstNode) &&
+    if (node && isCatchAll(node, caughtOpnd, catchInstNode) &&
         isMonExit(catchInstNode, monOpnd, dispatchNode, dispatchEdge)) {
         // make sure that's all it is
         assert(catchInstNode);
         Inst *labelInst = (Inst*)catchInstNode->getFirstInst();
         Inst *catchInst = labelInst->getNextInst();
         // with DPGO, we may see an incCounter here
-        Inst *thirdInst = catchInst->getNextInst(); // monexit or tausafe or incCounter
-        Inst *fourthInst = thirdInst->getNextInst(); // label or monexit or tausafe or
incCounter
-        Inst *fifthInst = fourthInst->getNextInst(); // label or taumonexit(tausafe)
-        Inst *sixthInst = fifthInst->getNextInst(); // .. or label
+        Inst *thirdInst  = catchInst  == NULL ? NULL : catchInst->getNextInst();  // monexit
or tausafe or incCounter
+        Inst *fourthInst = thirdInst  == NULL ? NULL : thirdInst->getNextInst();  // label
or monexit or tausafe or incCounter
+        Inst *fifthInst, *sixthInst;
+        if ( fourthInst && fourthInst->getNextInst() == NULL ) {
+            fifthInst = labelInst;
+        }else{
+            fifthInst  = fourthInst == NULL ? NULL : fourthInst->getNextInst(); // label
or taumonexit(tausafe)
+        }
+        if ( fifthInst && fifthInst->getNextInst() == NULL ) {
+            sixthInst = labelInst;
+        }else{
+            sixthInst  = fifthInst  == NULL ? NULL : fifthInst->getNextInst();  // ..
or label
+        }
         return ((labelInst == fourthInst)
                 || ((labelInst == fifthInst) && 
                     ((thirdInst->getOpcode() == Op_TauSafe) ||
@@ -276,8 +285,7 @@
             return target;
         }
     }
-    assert(0);
-    return false;
+    return NULL;
 }
 
 // look for a particular idiom:

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/drl/DrlJITInterface.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/drl/DrlJITInterface.cpp?view=diff&rev=565339&r1=565338&r2=565339
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/drl/DrlJITInterface.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/drl/DrlJITInterface.cpp Mon Aug 13 06:16:03
2007
@@ -470,6 +470,22 @@
 }
 
 extern "C"
+JITEXPORT Boolean
+JIT_is_soe_area
+(JIT_Handle jit, Method_Handle method,
+                        const ::JitFrameContext   *context)
+{
+#ifdef USE_FAST_PATH
+    if (isJET(jit)) {
+        return Jet::rt_is_soe_area(jit, method, context);
+    }
+#endif
+    MethodDesc methodDesc(method, jit);
+    return Jitrino::IsSOEArea(&methodDesc, context, context->is_ip_past == FALSE);
+}
+
+
+extern "C"
 JITEXPORT void *
 JIT_get_address_of_this(JIT_Handle jit, Method_Handle method,
                         const ::JitFrameContext   *context)

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/include/dll_jit_intf.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/include/dll_jit_intf.h?view=diff&rev=565339&r1=565338&r2=565339
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/include/dll_jit_intf.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/include/dll_jit_intf.h Mon Aug 13 06:16:03 2007
@@ -170,7 +170,18 @@
     {
         return (void *)_get_address_of_this(this, method, context);
     }
-
+    
+    Boolean
+        is_soe_area(Method_Handle            method,
+        const JitFrameContext* context
+        )
+    {
+        if (_is_soe_area != 0) {
+            return (Boolean)_is_soe_area(this, method, context);
+        }
+        return 0;
+        
+    }
 
     Boolean
     call_returns_a_reference(Method_Handle            method,
@@ -372,6 +383,12 @@
                             Method_Handle            method,
                             const JitFrameContext* context
                             );
+
+    Boolean
+        (*_is_soe_area)(JIT_Handle              jit,
+        Method_Handle                           method,
+        const JitFrameContext*                  context
+        );
 
     Boolean
     (*_call_returns_a_reference)(JIT_Handle               jit,

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/include/jit_intf_cpp.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/include/jit_intf_cpp.h?view=diff&rev=565339&r1=565338&r2=565339
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/include/jit_intf_cpp.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/include/jit_intf_cpp.h Mon Aug 13 06:16:03 2007
@@ -201,6 +201,24 @@
                         ) = 0;
 
 
+    //
+    // Returns if EIP is in SOE checking area: an area in a prologue of
+    // the method before all instructions from bytecode
+    // This function is called when an exception is propagated out of
+    // a stack frame of a synchronized method.  The VM checks if 
+    // exception was thrown from SOE area (stack overflow error)
+    // and do not call monitor_exit if its true.
+    //
+    // Arguments:
+    // - method   -- A handle for the method which corresponds to the current frame.
+    // - context  -- The register context.
+    //
+
+    virtual Boolean
+        is_soe_area(Method_Handle            method,  // in
+        const JitFrameContext   *context              // in
+        ) = 0;
+
 
 
     //

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/include/thread_manager.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/include/thread_manager.h?view=diff&rev=565339&r1=565338&r2=565339
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/include/thread_manager.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/include/thread_manager.h Mon Aug 13 06:16:03 2007
@@ -170,7 +170,7 @@
     // In case exception is thrown, Exception object is put here
     volatile struct Exception thread_exception;
 
-    // flag which indicate that guard page on the stak should be restored
+    // flag which indicate that guard page on the stack should be restored
     unsigned char restore_guard_page;
 
     // thread stack address

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions_jit.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions_jit.cpp?view=diff&rev=565339&r1=565338&r2=565339
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions_jit.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions_jit.cpp Mon Aug 13 06:16:03
2007
@@ -173,11 +173,11 @@
 
 
 //////////////////////////////////////////////////////////////////////////
-// Main Exception Propogation Function
+// Main Exception Propagation Function
 
 // This function propagates an exception to its handler.
 // It can only be called for the current thread.
-// The input stack iterator provides the starting point for propogation.  If the top frame
is an M2nFrame, it is ignored.
+// The input stack iterator provides the starting point for propagation.  If the top frame
is an M2nFrame, it is ignored.
 // Let A be the current frame, let B be the most recent M2nFrame prior to A.
 // The exception is propagated to the first managed frame between A and B that has a handler
for the exception,
 // or to the native code that managed frame immediately after B if no such managed frame
exists.
@@ -187,7 +187,7 @@
 // The client should either use si_transfer_control to resume it, or use an OS context mechanism
 // copied from the final stack iterator.
 
-// function can be safe point & should be called with disable reqursion = 1
+// function can be safe point & should be called with disable recursion = 1
 static void exn_propagate_exception(
     StackIterator * si,
     ManagedObject ** exn_obj,
@@ -267,7 +267,7 @@
     }
 
     // When VM is in shutdown stage we need to execute "finally" clause to
-    // release monitors and propogate an exception to the upper frames.
+    // release monitors and propagate an exception to the upper frames.
     Class_Handle search_exn_class = !VM_Global_State::loader_env->IsVmShutdowning()
         ? exn_class : VM_Global_State::loader_env->JavaLangObject_Class;
 
@@ -378,14 +378,8 @@
                 }
             }
 
-            
             // No appropriate handler found, undo synchronization
-
-            // Contract with JIT: check SOE for synchronized methods before monenter
-            // So if SOE happens in synchronized method -> no need to call monexit
-            if (!restore_guard_page) {
-                vm_monitor_exit_synchronized_method(si);
-            }
+            vm_monitor_exit_synchronized_method(si);
 
             BEGIN_RAISE_AREA;
             jvalue ret_val = {(jlong)0};

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/dll_jit.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/dll_jit.cpp?view=diff&rev=565339&r1=565338&r2=565339
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/dll_jit.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/dll_jit.cpp Mon Aug 13 06:16:03 2007
@@ -129,6 +129,9 @@
     GET_FUNCTION(fn, handle, "JIT_get_address_of_this");
     _get_address_of_this = (void * (*)(JIT_Handle, Method_Handle, const JitFrameContext *))
fn;
 
+    GET_OPTIONAL_FUNCTION(fn, handle, "JIT_is_soe_area");
+    _is_soe_area = (Boolean (*)(JIT_Handle, Method_Handle, const JitFrameContext *)) fn;
+
     GET_FUNCTION(fn, handle, "JIT_call_returns_a_reference");
     _call_returns_a_reference = (Boolean (*)(JIT_Handle, Method_Handle, const JitFrameContext
*)) fn;
 

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/mon_enter_exit.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/mon_enter_exit.cpp?view=diff&rev=565339&r1=565338&r2=565339
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/mon_enter_exit.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/mon_enter_exit.cpp Mon Aug 13 06:16:03
2007
@@ -83,23 +83,31 @@
     CodeChunkInfo *cci = si_get_code_chunk_info(si);
     assert(cci);
     Method *method = cci->get_method();
-
+    JIT *jit = cci->get_jit();
+    
     assert(!hythread_is_suspend_enabled());
-    if (method->is_synchronized()) {
-        if (method->is_static()) {
-            TRACE2("tm.locks", ("unlock static sync methods...%x",
-                struct_Class_to_java_lang_Class(method->get_class())));
-            IDATA UNREF status = vm_monitor_try_exit(
-                struct_Class_to_java_lang_Class(method->get_class()));
-        }
-        else {
-            JIT *jit = cci->get_jit();
-            void **p_this =
-                (void **) jit->get_address_of_this(method,
-                si_get_jit_context(si));
-            TRACE2("tm.locks", ("unlock sync methods...%x" , *p_this));
-            IDATA UNREF status = vm_monitor_try_exit((ManagedObject *) * p_this);
-        }
+
+    if (!method->is_synchronized()) {
+        return;
+    }
+    //SOE checking area is an area in the beginning of a method.
+    //when unwinding from SOE EIP no need to call monexit -> no monenter was done
+    Boolean is_soe_area = jit->is_soe_area(method, si_get_jit_context(si));
+    if (is_soe_area) {
+        return;
+    }
+    if (method->is_static()) {
+        TRACE2("tm.locks", ("unlock static sync methods...%x",
+            struct_Class_to_java_lang_Class(method->get_class())));
+        IDATA UNREF status = vm_monitor_try_exit(
+            struct_Class_to_java_lang_Class(method->get_class()));
+    }
+    else {
+        void **p_this =
+            (void **) jit->get_address_of_this(method,
+            si_get_jit_context(si));
+        TRACE2("tm.locks", ("unlock sync methods...%x" , *p_this));
+        IDATA UNREF status = vm_monitor_try_exit((ManagedObject *) * p_this);
     }
 }
 



Mime
View raw message