harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gshiman...@apache.org
Subject svn commit: r548409 - in /harmony/enhanced/drlvm/trunk: src/test/regression/H1859/ src/test/regression/excludes/ vm/jitrino/src/codegenerator/ia32/ vm/jitrino/src/jet/
Date Mon, 18 Jun 2007 16:40:28 GMT
Author: gshimansky
Date: Mon Jun 18 09:40:26 2007
New Revision: 548409

URL: http://svn.apache.org/viewvc?view=rev&rev=548409
Log:
Applied HARMONY-4118
[drlvm][jit] Stack overflow handling support in Jitrino compiler


Added:
    harmony/enhanced/drlvm/trunk/src/test/regression/H1859/
    harmony/enhanced/drlvm/trunk/src/test/regression/H1859/Test.java   (with props)
    harmony/enhanced/drlvm/trunk/src/test/regression/H1859/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/ia32/Ia32IRManager.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32IRManager.h
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Inst.h
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32StackLayout.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/cg.cpp

Added: harmony/enhanced/drlvm/trunk/src/test/regression/H1859/Test.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/src/test/regression/H1859/Test.java?view=auto&rev=548409
==============================================================================
--- harmony/enhanced/drlvm/trunk/src/test/regression/H1859/Test.java (added)
+++ harmony/enhanced/drlvm/trunk/src/test/regression/H1859/Test.java Mon Jun 18 09:40:26 2007
@@ -0,0 +1,30 @@
+package org.apache.harmony.drlvm.tests.regression.h1859;
+
+import junit.framework.TestCase;
+
+public class Test extends TestCase {
+
+    public void test() {
+        boolean passed = false;
+        try {
+            foo(1, 2, 3, 4, 5, 6);
+        } catch (StackOverflowError e) {
+            passed = true;
+        }
+        assertTrue(passed);
+        assertEquals(0, i);
+    }
+
+    static int i=0;
+
+    static void foo(int i1, int i2, int i3, int i4, int i5, int i6) {
+        try {
+            i++;
+            foo(i1, i2, i3, i4, i5, i6);
+        } finally {
+            i--;
+        }
+    }
+
+}
+

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

Added: harmony/enhanced/drlvm/trunk/src/test/regression/H1859/run.test.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/src/test/regression/H1859/run.test.xml?view=auto&rev=548409
==============================================================================
--- harmony/enhanced/drlvm/trunk/src/test/regression/H1859/run.test.xml (added)
+++ harmony/enhanced/drlvm/trunk/src/test/regression/H1859/run.test.xml Mon Jun 18 09:40:26
2007
@@ -0,0 +1,14 @@
+<project name="RUN HARMONY-1859 Regression Test">
+    <target name="run-test">
+        <run-junit-test 
+             test="org.apache.harmony.drlvm.tests.regression.h1859.Test"
+             vmarg="-Xem:opt">
+        </run-junit-test>
+
+        <run-junit-test 
+             test="org.apache.harmony.drlvm.tests.regression.h1859.Test"
+             vmarg="-Xem:jet">
+        </run-junit-test>
+    </target>
+</project>
+

Propchange: harmony/enhanced/drlvm/trunk/src/test/regression/H1859/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=548409&r1=548408&r2=548409
==============================================================================
--- 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 Jun
18 09:40:26 2007
@@ -1,3 +1,5 @@
+# Exclude this test because of problems with hardware exceptions handling in VM for this
platform
+H1859
 H2086
 H2151
 # Exclude this test because JVMTI is not implemented for x86_64 in JIT mode yet

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=548409&r1=548408&r2=548409
==============================================================================
--- 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 Jun
18 09:40:26 2007
@@ -1,3 +1,5 @@
+# Exclude this test because of problems with hardware exceptions handling in VM for this
platform
+H1859
 H2151
 H2873
 # Exclude this test because JVMTI is not implemented for x86_64 in JIT mode yet

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?view=diff&rev=548409&r1=548408&r2=548409
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32IRManager.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32IRManager.cpp Mon Jun
18 09:40:26 2007
@@ -1761,11 +1761,11 @@
 }
 
 //_____________________________________________________________________________________________
-void IRManager::calculateStackDepth()
+uint32 IRManager::calculateStackDepth()
 {
     MemoryManager mm("calculateStackDepth");
     StlVector<int32> stackDepths(mm, fg->getNodeCount(), -1);
-    
+    int32 maxMethodStackDepth = -1;    
     
     const Nodes& nodes = fg->getNodesPostOrder();
     //iterating in topological (reverse postorder) order
@@ -1813,12 +1813,15 @@
                             stackDepth -= ((CallInst *)inst)->getArgStackDepth();
                         }
                     }
+                    maxMethodStackDepth = std::max(maxMethodStackDepth, stackDepth);
                 }
                 assert(stackDepth>=0);
             }
             stackDepths[node->getDfNum()]=stackDepth;
         }
     }
+    assert(maxMethodStackDepth>=0);
+    return (uint32)maxMethodStackDepth;
 }
 
 //_____________________________________________________________________________________________

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32IRManager.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32IRManager.h?view=diff&rev=548409&r1=548408&r2=548409
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32IRManager.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32IRManager.h Mon Jun
18 09:40:26 2007
@@ -427,10 +427,10 @@
     uint32 getLayoutOpndAlignment(Opnd * opnd);
     void finalizeCallSites();
 
-    /** Calculates dislacement from stack entry point
-        for every instruction.
+    /** Calculates displacement from stack entry point
+        for every instruction and returns maximum stack depth needed for a method
     */
-    void calculateStackDepth();
+    uint32 calculateStackDepth();
     //-----------------------------------------------------------------------------------------------
     bool verify();
     bool verifyOpnds() const;

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Inst.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Inst.h?view=diff&rev=548409&r1=548408&r2=548409
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Inst.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Inst.h Mon Jun 18 09:40:26
2007
@@ -795,8 +795,12 @@
 
     Inst(Mnemonic m, uint32 _id, Form f)
         :kind(Kind_Inst), id(_id), mnemonic(m), prefix(InstPrefix_Null),
-        form(f), reservedFlags(0), 
-        opcodeGroup(0), index(0), defOpndCount(0), opndCount(0)
+        form(f), reservedFlags(0), codeSize(0), properties(0), reservedFlags2(0),
+        opcodeGroup(0), index(0), codeOffset(0), 
+        /*allocatedOpndCount(0), */defOpndCount(0), opndCount(0), stackDepth(0)/*, opnds(0)*/

+        
+        // WARN! commented opnds are assigned in overloaded 'new' operator before the constructor
+        // : void* Inst::operator new(size_t sz, MemoryManager& mm, uint32 opndCount)
     {}
     virtual ~Inst(){};
 

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32StackLayout.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32StackLayout.cpp?view=diff&rev=548409&r1=548408&r2=548409
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32StackLayout.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32StackLayout.cpp Mon
Jun 18 09:40:26 2007
@@ -166,6 +166,23 @@
 {
 };
 
+static void insertSOEHandler(IRManager& irm, uint32 maxStackSize) {
+    if (maxStackSize == 0) {
+        return;
+    }
+#ifdef _EM64T_
+    RegName eaxReg = RegName_RAX;
+    RegName espReg = RegName_RSP;
+#else
+    RegName eaxReg = RegName_EAX;
+    RegName espReg = RegName_ESP;
+#endif
+    Opnd* guardedMemOpnd = irm.newMemOpnd(irm.getTypeFromTag(Type::IntPtr), MemOpndKind_Heap,
irm.getRegOpnd(espReg), -(int)maxStackSize);
+    Inst* guardInst = irm.newInst(Mnemonic_MOV, irm.getRegOpnd(eaxReg), guardedMemOpnd);
+    Inst* entryInst = irm.getEntryPointInst();
+    guardInst->insertAfter(entryInst);
+}
+
 void StackLayouter::runImpl()
 {
     IRManager & irm=getIRManager();
@@ -180,7 +197,8 @@
     irm.calculateTotalRegUsage(OpndKind_GPReg);
     createProlog();
     createEpilog();
-    irm.calculateStackDepth();
+    uint32 maxStackDepth = irm.calculateStackDepth();
+    insertSOEHandler(irm, maxStackDepth);
     irm.layoutAliasOpnds();
 
     //fill StackInfo object

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/cg.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/cg.cpp?view=diff&rev=548409&r1=548408&r2=548409
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/cg.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/cg.cpp Mon Jun 18 09:40:26 2007
@@ -535,7 +535,7 @@
         (cs.cc() == CCONV_MANAGED_IA32)) {
         int fix = 0;
         if (cnt != 0) {
-            // find the differenece between last used slot and the end of 
+            // find the difference between last used slot and the end of 
             // stack frame
             int s = m_stack.stack_slot(m_jframe->depth2slot(0));
             fix = m_stack.size() + s; // s is < 0
@@ -556,6 +556,11 @@
 
     if (idx == 0 && cs.size() != 0) {
         alu(alu_sub, sp, cs.size());
+        
+        //SOE handler -> read by maximum stack offset
+        Opnd maxStackAddr(iplatf, sp, -(int)cs.size(), ar_x, 0);
+        Opnd unusedRes(iplatf, valloc(iplatf));
+        do_mov(unusedRes, maxStackAddr);
     }
     int depth = 0;
     // 1st pass - free all register that are used for args passing



Mime
View raw message