You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by va...@apache.org on 2006/12/20 12:29:44 UTC

svn commit: r489054 - in /harmony/enhanced/drlvm/trunk: src/test/regression/H2259/ vm/jitrino/src/codegenerator/ia32/ vm/jitrino/src/shared/

Author: varlax
Date: Wed Dec 20 03:29:42 2006
New Revision: 489054

URL: http://svn.apache.org/viewvc?view=rev&rev=489054
Log:
Applied HARMONY-2259 [drlvm][jit][opt] tests.api.java.lang.reflect.ProxyTest fails on Jitrino.OPT while passes on Jitrino.JET
Tested on SUSE9

Added:
    harmony/enhanced/drlvm/trunk/src/test/regression/H2259/
    harmony/enhanced/drlvm/trunk/src/test/regression/H2259/H2259.java
    harmony/enhanced/drlvm/trunk/src/test/regression/H2259/run.test.xml
Modified:
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32CodeSelector.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/ControlFlowGraph.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/ControlFlowGraph.h

Added: harmony/enhanced/drlvm/trunk/src/test/regression/H2259/H2259.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/src/test/regression/H2259/H2259.java?view=auto&rev=489054
==============================================================================
--- harmony/enhanced/drlvm/trunk/src/test/regression/H2259/H2259.java (added)
+++ harmony/enhanced/drlvm/trunk/src/test/regression/H2259/H2259.java Wed Dec 20 03:29:42 2006
@@ -0,0 +1,65 @@
+
+package org.apache.harmony.drlvm.tests.regression.h2259;
+
+import junit.framework.TestCase;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.lang.reflect.UndeclaredThrowableException;
+
+interface I1 {
+	String string(String s) throws ParentException;
+}
+
+interface I2 {
+	String string(String s) throws SubException;
+}
+
+class ParentException extends Exception {}
+class SubException extends ParentException {}
+
+public class H2259 extends TestCase {
+
+	/*
+	 * When multiple interfaces define the same method, the list of thrown
+	 * exceptions are those which can be mapped to another exception in the
+	 * other method:
+	 * 
+	 * String foo(String s) throws SubException, LinkageError;
+	 * 
+	 * UndeclaredThrowableException wrappers any checked exception which is not
+	 * in the merged list. So ParentException would be wrapped, BUT LinkageError
+	 * would not be since its not an Error/RuntimeException.
+	 * 
+	 * interface I1 { String foo(String s) throws ParentException, LinkageError; }
+	 * interface I2 { String foo(String s) throws SubException, Error; }
+	 */
+
+	public void test_H2259() {
+
+		Object p = Proxy.newProxyInstance(I1.class.getClassLoader(),
+                                          new Class[] { I1.class, I2.class },
+                                          new InvocationHandler() {
+                                  			  public Object invoke(Object proxy,
+                                                                   Method method,
+                                                                   Object[] args)
+                                        					throws Throwable {
+                                        						throw new ArrayStoreException();
+                                                			}
+		});
+
+		I1 proxy = (I1) p;
+        int res = 0;
+
+        try {
+            proxy.string("error");
+        } catch (ParentException e) { // is never thrown
+        } catch (UndeclaredThrowableException e) {
+        } catch (RuntimeException e) {
+            res = 104;
+        }
+        assertFalse("RuntimeException was not thrown", res == 0);
+	}
+}
+

Added: harmony/enhanced/drlvm/trunk/src/test/regression/H2259/run.test.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/src/test/regression/H2259/run.test.xml?view=auto&rev=489054
==============================================================================
--- harmony/enhanced/drlvm/trunk/src/test/regression/H2259/run.test.xml (added)
+++ harmony/enhanced/drlvm/trunk/src/test/regression/H2259/run.test.xml Wed Dec 20 03:29:42 2006
@@ -0,0 +1,9 @@
+<project name="RUN HARMONY-2259 Regression Test">
+    <target name="run-test">
+        <run-junit-test 
+            test="org.apache.harmony.drlvm.tests.regression.h2259.H2259"
+            vmarg="-Xem:opt">
+        </run-junit-test>
+    </target>
+</project>
+

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32CodeSelector.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32CodeSelector.cpp?view=diff&rev=489054&r1=489053&r2=489054
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32CodeSelector.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32CodeSelector.cpp Wed Dec 20 03:29:42 2006
@@ -441,6 +441,21 @@
                 assert(target!=NULL);
                 fg->addEdge(node, target, 1.0);
             }
+            // fixup empty catch blocks otherwise respective catchEdges will be lost
+            // There is no [catchBlock]-->[catchHandler] edge. Catch block will be removed
+            // as an empty one and exception handling will be incorrect
+            if (node->isCatchBlock() && node->isEmpty()) {
+                assert(node->getInDegree()==1);
+                Edge* catchEdge = node->getInEdges().front();
+                assert(catchEdge->getSourceNode()->isDispatchNode());
+                assert(node->getOutDegree()==1);
+                Node* succ = node->getUnconditionalEdgeTarget();
+                while( succ->isEmpty() && (succ->getOutDegree() == 1) ) {
+                    succ = succ->getUnconditionalEdgeTarget();
+                }
+                assert(succ && ((Inst*)succ->getFirstInst())->hasKind(Inst::Kind_CatchPseudoInst));
+                fg->replaceEdgeTarget(catchEdge,succ,true/*keepOldBody*/);
+            }
         }
     }
 }

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?view=diff&rev=489054&r1=489053&r2=489054
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/ControlFlowGraph.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/ControlFlowGraph.cpp Wed Dec 20 03:29:42 2006
@@ -302,13 +302,19 @@
     lastEdgeRemovalTraversalNumber = traversalNumber;
 }
 
-Edge* ControlFlowGraph::replaceEdgeTarget(Edge* edge, Node* newTarget) {
+Edge* ControlFlowGraph::replaceEdgeTarget(Edge* edge, Node* newTarget, bool keepOldBody) {
     Node* source = edge->getSourceNode();
     Node* oldTarget = edge->getTargetNode();
     CFGInst* lastInst = source->getLastInst();
-    
-    removeEdge(edge);
-    Edge* newEdge = addEdge(source, newTarget);
+
+    Edge* newEdge = NULL;
+    if (keepOldBody) {
+        edge->target = newTarget;
+        newEdge = edge;
+    } else {
+        removeEdge(edge);
+        newEdge = addEdge(source, newTarget);
+    }
     if (lastInst!=NULL) {
         lastInst->updateControlTransferInst(oldTarget, newTarget);
     }

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?view=diff&rev=489054&r1=489053&r2=489054
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/ControlFlowGraph.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/ControlFlowGraph.h Wed Dec 20 03:29:42 2006
@@ -1287,17 +1287,17 @@
    * Removes the edge, creates a new one and connects it to 
    * the <code>newTarget</code> node.
    *
-   * @param[in] edge      - the edge to change the target
-   * @param[in] newTarget - a new <code>Target</code> node
+   * @param[in] edge        - the edge to change the target
+   * @param[in] newTarget   - a new <code>Target</code> node
+   * @param[in] keepOldBody - modify old or create a new edge
    * 
    * @return The edge connecting the <code>Source</code> node of the  
    *         edge and the </code>newTarget</code> node.
    *
-   * @note The removal of the old edge is obsolete and should be refactored.
-   *       The only place to take care is retargeting edges 
+   * @note The removal of the old edge is needed
    *       while inlining CFG: edge IDs must be renewed.
    */
-    Edge* replaceEdgeTarget(Edge* edge, Node *newTarget);
+    Edge* replaceEdgeTarget(Edge* edge, Node *newTarget, bool keepOldBody = false);
 
   /** 
    * Checks if CFG is annotated with the edge profile information.