harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gshiman...@apache.org
Subject svn commit: r548801 - in /harmony/enhanced/drlvm/trunk: src/test/regression/H3225/NegativeJsrTest.java src/test/regression/H3225/RetOrderNegativeTest.j vm/vmcore/src/verifier/ver_graph.h vm/vmcore/src/verifier/ver_subroutine.cpp
Date Tue, 19 Jun 2007 17:10:40 GMT
Author: gshimansky
Date: Tue Jun 19 10:10:37 2007
New Revision: 548801

URL: http://svn.apache.org/viewvc?view=rev&rev=548801
Log:
Applied HARMONY-4219
[drlvm][verifier] reaching ret without jsr edges check is improved


Added:
    harmony/enhanced/drlvm/trunk/src/test/regression/H3225/RetOrderNegativeTest.j
Modified:
    harmony/enhanced/drlvm/trunk/src/test/regression/H3225/NegativeJsrTest.java
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_graph.h
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_subroutine.cpp

Modified: harmony/enhanced/drlvm/trunk/src/test/regression/H3225/NegativeJsrTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/src/test/regression/H3225/NegativeJsrTest.java?view=diff&rev=548801&r1=548800&r2=548801
==============================================================================
--- harmony/enhanced/drlvm/trunk/src/test/regression/H3225/NegativeJsrTest.java (original)
+++ harmony/enhanced/drlvm/trunk/src/test/regression/H3225/NegativeJsrTest.java Tue Jun 19
10:10:37 2007
@@ -9,39 +9,40 @@
         junit.textui.TestRunner.run(org.apache.harmony.drlvm.tests.regression.h3225.NegativeJsrTest.class);
     }
 
-    public void testMergeExecution() {
+    private void checkVerifyError() {
+        final String testMethodName = Thread.currentThread().getStackTrace()[3].getMethodName();
+        assertEquals("test", testMethodName.substring(0, 4));
+
+        final String testClassName = "org.apache.harmony.drlvm.tests.regression.h3225."
+           + testMethodName.substring(4) + "NegativeTest";
         try {
-            MergeExecutionNegativeTest.test();
+            Class.forName(testClassName).getConstructors();
         } catch (VerifyError ve) {
             return;
+        } catch (ClassNotFoundException cnfe) {
+            fail("Failed to load " + testClassName);
         }
-        fail("The test should throw java.lang.VerifyError");
+        fail(testClassName + " should throw java.lang.VerifyError");
+    }
+
+    public void testMergeExecution() {
+        checkVerifyError();
     }
 
     public void testMergeEmptyStack() {
-        try {
-            MergeEmptyStackNegativeTest.test();
-        } catch (VerifyError ve) {
-            return;
-        }
-        fail("The test should throw java.lang.VerifyError");
+        checkVerifyError();
     }
 
     public void testMergeIntFloat() {
-        try {
-            MergeIntFloatNegativeTest.test();
-        } catch (VerifyError ve) {
-            return;
-        }
-        fail("The test should throw java.lang.VerifyError");
+        checkVerifyError();
     }
 
     public void testMergeStack() {
-        try {
-            MergeStackNegativeTest.test();
-        } catch (VerifyError ve) {
-            return;
-        }
-        fail("The test should throw java.lang.VerifyError");
+        checkVerifyError();
+    }
+
+    public void testRetOrder() {
+        checkVerifyError();
     }
 }
+

Added: harmony/enhanced/drlvm/trunk/src/test/regression/H3225/RetOrderNegativeTest.j
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/src/test/regression/H3225/RetOrderNegativeTest.j?view=auto&rev=548801
==============================================================================
--- harmony/enhanced/drlvm/trunk/src/test/regression/H3225/RetOrderNegativeTest.j (added)
+++ harmony/enhanced/drlvm/trunk/src/test/regression/H3225/RetOrderNegativeTest.j Tue Jun
19 10:10:37 2007
@@ -0,0 +1,22 @@
+.class public org/apache/harmony/drlvm/tests/regression/h3225/RetOrderNegativeTest
+.super java/lang/Object 
+
+;
+; Uses return addresses in incorrect order.
+;
+.method test()V 
+   .limit stack 2
+   .limit locals 2
+    jsr LabelSub
+    ret 0
+    return
+LabelSub:
+    astore_1
+    jsr LabelSubBranch
+    return
+LabelSubBranch:
+    astore_0
+    ret 1
+    
+.end method
+

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_graph.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_graph.h?view=diff&rev=548801&r1=548800&r2=548801
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_graph.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_graph.h Tue Jun 19 10:10:37 2007
@@ -840,7 +840,7 @@
         unsigned node_num = 0;
         vf_NodeContainer *nodes = m_nodes;
         while (nodes) {
-            unsigned index = node - nodes->m_node;
+            unsigned index = (unsigned) (node - nodes->m_node);
             if (index < nodes->container.m_max) {
                 node_num += index;
                 assert(node_num < m_nodenum);

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_subroutine.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_subroutine.cpp?view=diff&rev=548801&r1=548800&r2=548801
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_subroutine.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_subroutine.cpp Tue Jun 19 10:10:37
2007
@@ -318,11 +318,8 @@
         return VF_OK;           // already marked
     }
 
+    assert(node != ctx->m_graph->GetStartNode());
     if (NULL == node->m_sub) {
-        if (node == ctx->m_graph->GetStartNode()) {
-            VF_REPORT(ctx, "Reached ret not using jsr branches");
-            return VF_ErrorJsrOther;
-        }
 
         node->m_sub = sub;
         if (node->m_mark) {
@@ -372,24 +369,26 @@
              << ctx->m_graph->GetNodeNum(node) << " -> #"
              << ctx->m_graph->GetNodeNum(stack.m_node));
 
+    if (stack.m_node->m_sub && (stack.m_node->m_sub->m_entry != stack.m_node))
{
+        // a subroutine entry is already resolved and
+        // jsr doesn't branch to the entry node
+        VF_REPORT(ctx,
+                  "A subroutine splits execution into "
+                  "several ret instructions");
+        return VF_ErrorJsrMultipleRet;
+    }
+
     if (stack.m_node->m_mark) {
+        if (!stack.m_node->m_sub) {
+            // we assume that the branch is to the top
+            // level code, or the same subroutine, so there
+            // is no return
+            return VF_OK;
+        }
+
         // FIXME subroutine node copies might have different stack maps, though
         // this is not a security threat, just incompatibility with RI.
         if (path_start) {
-            if (!stack.m_node->m_sub) {
-                // we assume that the branch is to the top
-                // level code, or the same subroutine, so there
-                // is no return
-                return VF_OK;
-            }
-
-            if (stack.m_node->m_sub->m_entry != stack.m_node) {
-                VF_REPORT(ctx,
-                          "A subroutine splits execution into "
-                          "several ret instructions");
-                return VF_ErrorJsrMultipleRet;
-            }
-
             EnsureStackMapInitialized(ctx);
             vf_NodeStackHandle &p_element = ctx->m_sub_ctx->m_path_start;
             for (; p_element != &stack; p_element = p_element->m_next) {
@@ -503,8 +502,11 @@
     if ((VF_NODE_CODE_RANGE == stack.m_node->m_type)
         && (VF_INSTR_RET == stack.m_node->m_end->m_type)) {
         vf_Sub *sub = AddNewSub(stack.m_node, ctx->m_sub_ctx);
+        if (!ctx->m_sub_ctx->m_path_start) {
+            VF_REPORT(ctx, "Reached ret on the top level");
+            return VF_ErrorJsrOther;
+        }
         result = SetSubMarks(sub, stack.m_node, ctx);
-        assert(ctx->m_sub_ctx->m_path_start);
         if (VF_OK != result) {
             return result;
         }



Mime
View raw message