harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject svn commit: r557179 - in /harmony/enhanced/drlvm/trunk: src/test/regression/H3862/ vm/vmcore/src/verifier-3363/
Date Wed, 18 Jul 2007 07:11:14 GMT
Author: mloenko
Date: Wed Jul 18 00:11:13 2007
New Revision: 557179

URL: http://svn.apache.org/viewvc?view=rev&rev=557179
Log:
fix and regression test for jsr/ret processing, including HARMONY-3862 (A subroutine splits
execution into several ret instructions)

Added:
    harmony/enhanced/drlvm/trunk/src/test/regression/H3862/
    harmony/enhanced/drlvm/trunk/src/test/regression/H3862/SubrBounds.java   (with props)
    harmony/enhanced/drlvm/trunk/src/test/regression/H3862/neg.j   (with props)
    harmony/enhanced/drlvm/trunk/src/test/regression/H3862/neg2.j   (with props)
    harmony/enhanced/drlvm/trunk/src/test/regression/H3862/neg3.j   (with props)
    harmony/enhanced/drlvm/trunk/src/test/regression/H3862/pos.j   (with props)
    harmony/enhanced/drlvm/trunk/src/test/regression/H3862/pos2.j   (with props)
    harmony/enhanced/drlvm/trunk/src/test/regression/H3862/run.test.xml   (with props)
Modified:
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/Pass1.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/Pass2.cpp

Added: harmony/enhanced/drlvm/trunk/src/test/regression/H3862/SubrBounds.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/src/test/regression/H3862/SubrBounds.java?view=auto&rev=557179
==============================================================================
--- harmony/enhanced/drlvm/trunk/src/test/regression/H3862/SubrBounds.java (added)
+++ harmony/enhanced/drlvm/trunk/src/test/regression/H3862/SubrBounds.java Wed Jul 18 00:11:13
2007
@@ -0,0 +1,38 @@
+package org.apache.harmony.drlvm.tests.regression.h3862;
+
+import junit.framework.TestCase;
+
+public class SubrBounds extends TestCase {
+    
+    public void testPos() throws Exception {
+        pos.test();
+    }
+    
+    public void testNeg() throws Exception {
+        try {
+            neg.test();
+            fail("VerifyError expected");
+        } catch( VerifyError e) {
+        }
+    }
+
+    public void testPos2() throws Exception {
+        pos2.test();
+    }
+    
+    public void testNeg2() throws Exception {
+        try {
+            neg2.test();
+            fail("VerifyError expected");
+        } catch( VerifyError e) {
+        }
+    }
+    
+    public void testNeg3() throws Exception {
+        try {
+            neg3.test();
+            fail("VerifyError expected");
+        } catch( VerifyError e) {
+        }
+    }
+}
\ No newline at end of file

Propchange: harmony/enhanced/drlvm/trunk/src/test/regression/H3862/SubrBounds.java
------------------------------------------------------------------------------
    svn:executable = *

Added: harmony/enhanced/drlvm/trunk/src/test/regression/H3862/neg.j
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/src/test/regression/H3862/neg.j?view=auto&rev=557179
==============================================================================
--- harmony/enhanced/drlvm/trunk/src/test/regression/H3862/neg.j (added)
+++ harmony/enhanced/drlvm/trunk/src/test/regression/H3862/neg.j Wed Jul 18 00:11:13 2007
@@ -0,0 +1,27 @@
+.class public org/apache/harmony/drlvm/tests/regression/h3862/neg
+.super java/lang/Object
+.method public <init>()V
+   aload_0
+   invokespecial java/lang/Object/<init>()V
+   return
+.end method
+
+;
+; Subroutine call order differs from ret order
+;
+.method public static test()V
+   .limit stack 1
+   .limit locals 2
+
+   jsr L1
+   ret 0
+
+L1:
+   astore 1
+   jsr L2
+   return
+
+L2:
+   astore 0
+   ret 1
+.end method

Propchange: harmony/enhanced/drlvm/trunk/src/test/regression/H3862/neg.j
------------------------------------------------------------------------------
    svn:executable = *

Added: harmony/enhanced/drlvm/trunk/src/test/regression/H3862/neg2.j
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/src/test/regression/H3862/neg2.j?view=auto&rev=557179
==============================================================================
--- harmony/enhanced/drlvm/trunk/src/test/regression/H3862/neg2.j (added)
+++ harmony/enhanced/drlvm/trunk/src/test/regression/H3862/neg2.j Wed Jul 18 00:11:13 2007
@@ -0,0 +1,27 @@
+.class public org/apache/harmony/drlvm/tests/regression/h3862/neg2
+.super java/lang/Object
+.method public <init>()V
+   aload_0
+   invokespecial java/lang/Object/<init>()V
+   return
+.end method
+
+;
+; Return ret address remains on the stack after returning from subroutine
+;
+.method public static test()V
+   .limit stack 5
+   .limit locals 5
+
+   jsr L1
+   astore 1
+   ret 1
+
+   return
+
+L1:
+   dup
+   astore 1
+   ret 1
+
+.end method

Propchange: harmony/enhanced/drlvm/trunk/src/test/regression/H3862/neg2.j
------------------------------------------------------------------------------
    svn:executable = *

Added: harmony/enhanced/drlvm/trunk/src/test/regression/H3862/neg3.j
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/src/test/regression/H3862/neg3.j?view=auto&rev=557179
==============================================================================
--- harmony/enhanced/drlvm/trunk/src/test/regression/H3862/neg3.j (added)
+++ harmony/enhanced/drlvm/trunk/src/test/regression/H3862/neg3.j Wed Jul 18 00:11:13 2007
@@ -0,0 +1,25 @@
+.class public org/apache/harmony/drlvm/tests/regression/h3862/neg3
+.super java/lang/Object
+.method public <init>()V
+   aload_0
+   invokespecial java/lang/Object/<init>()V
+   return
+.end method
+
+;
+; Return ret address remains on the stack after returning from subroutine
+;
+.method public static test()V
+   .limit stack 5
+   .limit locals 5
+
+   jsr L1
+   ret 1
+
+   return
+
+L1:
+   astore 1
+   ret 1
+
+.end method

Propchange: harmony/enhanced/drlvm/trunk/src/test/regression/H3862/neg3.j
------------------------------------------------------------------------------
    svn:executable = *

Added: harmony/enhanced/drlvm/trunk/src/test/regression/H3862/pos.j
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/src/test/regression/H3862/pos.j?view=auto&rev=557179
==============================================================================
--- harmony/enhanced/drlvm/trunk/src/test/regression/H3862/pos.j (added)
+++ harmony/enhanced/drlvm/trunk/src/test/regression/H3862/pos.j Wed Jul 18 00:11:13 2007
@@ -0,0 +1,27 @@
+.class public org/apache/harmony/drlvm/tests/regression/h3862/pos
+.super java/lang/Object
+.method public <init>()V
+   aload_0
+   invokespecial java/lang/Object/<init>()V
+   return
+.end method
+
+;
+; Return from non-top subroutine
+;
+.method public static test()V
+   .limit stack 1
+   .limit locals 2
+
+   jsr L1
+   return
+
+L1:
+   astore 1
+   jsr L2
+   return
+
+L2:
+   astore 0
+   ret 1
+.end method

Propchange: harmony/enhanced/drlvm/trunk/src/test/regression/H3862/pos.j
------------------------------------------------------------------------------
    svn:executable = *

Added: harmony/enhanced/drlvm/trunk/src/test/regression/H3862/pos2.j
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/src/test/regression/H3862/pos2.j?view=auto&rev=557179
==============================================================================
--- harmony/enhanced/drlvm/trunk/src/test/regression/H3862/pos2.j (added)
+++ harmony/enhanced/drlvm/trunk/src/test/regression/H3862/pos2.j Wed Jul 18 00:11:13 2007
@@ -0,0 +1,28 @@
+.class public org/apache/harmony/drlvm/tests/regression/h3862/pos2
+.super java/lang/Object
+.method public <init>()V
+   aload_0
+   invokespecial java/lang/Object/<init>()V
+   return
+.end method
+
+;
+; Return store ret addr in sub-sub
+;
+.method public static test()V
+   .limit stack 5
+   .limit locals 5
+
+   jsr L1
+   return
+
+L1:
+   jsr L2
+   ret 2
+
+L2:
+   astore 1
+   astore 2
+   ret 1
+
+.end method

Propchange: harmony/enhanced/drlvm/trunk/src/test/regression/H3862/pos2.j
------------------------------------------------------------------------------
    svn:executable = *

Added: harmony/enhanced/drlvm/trunk/src/test/regression/H3862/run.test.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/src/test/regression/H3862/run.test.xml?view=auto&rev=557179
==============================================================================
--- harmony/enhanced/drlvm/trunk/src/test/regression/H3862/run.test.xml (added)
+++ harmony/enhanced/drlvm/trunk/src/test/regression/H3862/run.test.xml Wed Jul 18 00:11:13
2007
@@ -0,0 +1,8 @@
+<project name="RUN HARMONY-3862 Regression Test">
+    <target name="run-test">
+        <run-junit-test 
+            test="org.apache.harmony.drlvm.tests.regression.h3862.SubrBounds">
+        </run-junit-test>
+    </target>
+</project>
+

Propchange: harmony/enhanced/drlvm/trunk/src/test/regression/H3862/run.test.xml
------------------------------------------------------------------------------
    svn:executable = *

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/Pass1.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/Pass1.cpp?view=diff&rev=557179&r1=557178&r2=557179
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/Pass1.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/Pass1.cpp Wed Jul 18 00:11:13
2007
@@ -473,12 +473,9 @@
             }
         }
 
-        if(dead_code_parsing) {
-            return VF_OK;
-        }
-
-        // control went out of method bounds
-        return error(VF_ErrorCodeEnd, "control went out of method bounds");
+        //it might be a dead code -- code followed by JSR which never returns
+        //if it's a dead code - it's OK, if it's not - we will catch it on the second pass
+        return VF_OK;
     }
 
 } // namespace CPVerifier

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/Pass2.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/Pass2.cpp?view=diff&rev=557179&r1=557178&r2=557179
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/Pass2.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/Pass2.cpp Wed Jul 18 00:11:13
2007
@@ -1844,7 +1844,7 @@
 
             vf_Result tcr;
 
-            while( true) {
+            while( instr < m_code_length ) {
                 if( !workmap_is_a_copy_of_stackmap && props.isMultiway(instr) ) {
                     //if instruction has a stackmap and workmap was not just obtained from
that stackmap
                     // add constraint: workmap is assignable to stackmap(instr)
@@ -1906,16 +1906,6 @@
                         PropsHead *target_pro = props.getInstrProps(target);
 
                         if( !props.isDataflowPassed(target) ) {
-                            //for each local and stack (except just added retaddr) replace
other retaddresses
-                            //by SM_BOGUS to avoid ret from non-top subroutine on stack
-                            assert(workmap->depth == target_pro->stackmap.depth);
-                            for( unsigned i = 0; i < m_stack_start + workmap->depth
- 1; i++ ) {
-                                StackmapElement &el = target_pro->stackmap.elements[i];
-                                if( el.getAnyIncomingValue().isRetAddr() ) {
-                                    el.newIncomingType(&mem, SM_BOGUS);
-                                }
-                            }
-
                             for( unsigned i = 0; i < m_stack_start; i++ ) {
                                 StackmapElement &el = target_pro->stackmap.elements[i];
                                 el.clearJsrModified();
@@ -2009,6 +1999,9 @@
                 }
 
             }
+
+            // control went out of method bounds
+            return error(VF_ErrorCodeEnd, "control went out of method bounds");
         }
 
         inline vf_Result vf_Context_t::dataflow_handlers(Address instr) {
@@ -2311,6 +2304,47 @@
 
             //if it is a first ret from the given subroutine (majority of the cases)
             if( subrdata->retCount == 1 ) {
+                //remove newly appeared ret addresses: it might happen
+                //if non-top subroutine made a ret
+                StackmapHead* original = inpro->getStackmap();
+                unsigned i;
+
+                for( i = 0; i < m_stack_start + workmap->depth; i++ ) {
+                    if( i < m_stack_start && !workmap->elements[i].isJsrModified()
) {
+                        //nothing new here
+                        continue;
+                    }
+
+                    SmConstant val = workmap->elements[i].getAnyPossibleValue();
+                    if( val.isRetAddr() ) {
+                        //check if it's a newly appeared ret addfress
+
+                        // '-1' is twice below to exclude top of the stack. 
+                        // top of the stack contains ret address for the current subroutine
+                        // it also cleaned up if it's still there
+
+                        if( i < m_stack_start + original->depth - 1 && 
+                            original->elements[i].getAnyIncomingValue() == val ) 
+                        {
+                            //most likely: this ret address was there before
+                            continue;
+                        }
+
+                        //iterate thru original types and look for this ret address
+                        int found_in_original = 0;
+                        for( unsigned j = 0; j < m_stack_start + original->depth -
1; j++ ) {
+                            if( original->elements[j].getAnyIncomingValue() == val ) {
+                                found_in_original = 1;
+                                break;
+                            }
+                        }
+                        if( !found_in_original ) {
+                            //original types did not have this ret address
+                            workmap->elements[i] = _WorkmapElement(SM_BOGUS);
+                        }
+                    }
+                }
+
                 //TODO make sure incoming was created as JSR transformation
                 tc_memcpy(outpro->getWorkmap(), workmap, sizeof(WorkmapHead) + sizeof(WorkmapElement)
* (m_stack_start + workmap->depth));
                 return VF_OK;



Mime
View raw message