changeset 9314:46f2b152d249

Merge.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Thu, 25 Apr 2013 20:00:23 +0200
parents 6369d37b37d1 (current diff) 21bb567c444e (diff)
children 9fde96e0c96b
files
diffstat 6 files changed, 61 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CompilationResult.java	Thu Apr 25 19:43:49 2013 +0200
+++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CompilationResult.java	Thu Apr 25 20:00:23 2013 +0200
@@ -22,6 +22,8 @@
  */
 package com.oracle.graal.api.code;
 
+import static java.util.Collections.*;
+
 import java.io.*;
 import java.util.*;
 
@@ -366,7 +368,7 @@
      */
     public void recordDataReference(int codePos, Constant data, int alignment, boolean inlined) {
         assert codePos >= 0 && data != null;
-        getDataReferences().add(new DataPatch(codePos, data, alignment, inlined));
+        dataReferences.add(new DataPatch(codePos, data, alignment, inlined));
     }
 
     /**
@@ -390,7 +392,7 @@
      * @param handlerPos the position of the handler
      */
     public void recordExceptionHandler(int codePos, int handlerPos) {
-        getExceptionHandlers().add(new ExceptionHandler(codePos, handlerPos));
+        exceptionHandlers.add(new ExceptionHandler(codePos, handlerPos));
     }
 
     /**
@@ -405,11 +407,11 @@
 
     private void addInfopoint(Infopoint infopoint) {
         // The infopoints list must always be sorted
-        if (!getInfopoints().isEmpty() && getInfopoints().get(getInfopoints().size() - 1).pcOffset >= infopoint.pcOffset) {
+        if (!infopoints.isEmpty() && infopoints.get(infopoints.size() - 1).pcOffset >= infopoint.pcOffset) {
             // This re-sorting should be very rare
-            Collections.sort(getInfopoints());
+            Collections.sort(infopoints);
         }
-        getInfopoints().add(infopoint);
+        infopoints.add(infopoint);
     }
 
     /**
@@ -421,7 +423,7 @@
      */
     public Mark recordMark(int codePos, Object id, Mark[] references) {
         Mark mark = new Mark(codePos, id, references);
-        getMarks().add(mark);
+        marks.add(mark);
         return mark;
     }
 
@@ -528,27 +530,39 @@
      * @return the list of infopoints, sorted by {@link Site#pcOffset}
      */
     public List<Infopoint> getInfopoints() {
-        return infopoints;
+        if (infopoints.isEmpty()) {
+            return emptyList();
+        }
+        return unmodifiableList(infopoints);
     }
 
     /**
      * @return the list of data references
      */
     public List<DataPatch> getDataReferences() {
-        return dataReferences;
+        if (dataReferences.isEmpty()) {
+            return emptyList();
+        }
+        return unmodifiableList(dataReferences);
     }
 
     /**
      * @return the list of exception handlers
      */
     public List<ExceptionHandler> getExceptionHandlers() {
-        return exceptionHandlers;
+        if (exceptionHandlers.isEmpty()) {
+            return emptyList();
+        }
+        return unmodifiableList(exceptionHandlers);
     }
 
     /**
      * @return the list of marks
      */
     public List<Mark> getMarks() {
-        return marks;
+        if (marks.isEmpty()) {
+            return emptyList();
+        }
+        return unmodifiableList(marks);
     }
 }
--- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/GraalInternalError.java	Thu Apr 25 19:43:49 2013 +0200
+++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/GraalInternalError.java	Thu Apr 25 20:00:23 2013 +0200
@@ -51,6 +51,23 @@
     }
 
     /**
+     * Checks a given condition and throws a {@link GraalInternalError} if it is false. Guarantees
+     * are stronger than assertions in that they are always checked. Error messages for guarantee
+     * violations should clearly indicate the nature of the problem as well as a suggested solution
+     * if possible.
+     * 
+     * @param condition the condition to check
+     * @param msg the message that will be associated with the error, in
+     *            {@link String#format(String, Object...)} syntax
+     * @param args arguments to the format string
+     */
+    public static void guarantee(boolean condition, String msg, Object... args) {
+        if (!condition) {
+            throw new GraalInternalError("failed guarantee: " + msg, args);
+        }
+    }
+
+    /**
      * This constructor creates a {@link GraalInternalError} with a message assembled via
      * {@link String#format(String, Object...)}. It always uses the ENGLISH locale in order to
      * always generate the same output.
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java	Thu Apr 25 19:43:49 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java	Thu Apr 25 20:00:23 2013 +0200
@@ -453,11 +453,11 @@
         return "MARK:" + mark.id;
     }
 
-    private static void addExceptionHandlersComment(CompilationResult tm, HexCodeFile hcf) {
-        if (!tm.getExceptionHandlers().isEmpty()) {
+    private static void addExceptionHandlersComment(CompilationResult compResult, HexCodeFile hcf) {
+        if (!compResult.getExceptionHandlers().isEmpty()) {
             String nl = HexCodeFile.NEW_LINE;
             StringBuilder buf = new StringBuilder("------ Exception Handlers ------").append(nl);
-            for (CompilationResult.ExceptionHandler e : tm.getExceptionHandlers()) {
+            for (CompilationResult.ExceptionHandler e : compResult.getExceptionHandlers()) {
                 buf.append("    ").append(e.pcOffset).append(" -> ").append(e.handlerPos).append(nl);
                 hcf.addComment(e.pcOffset, "[exception -> " + e.handlerPos + "]");
                 hcf.addComment(e.handlerPos, "[exception handler for " + e.pcOffset + "]");
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/NodeIntrinsificationVerificationPhase.java	Thu Apr 25 19:43:49 2013 +0200
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/NodeIntrinsificationVerificationPhase.java	Thu Apr 25 20:00:23 2013 +0200
@@ -24,20 +24,20 @@
 
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.graph.*;
+import com.oracle.graal.graph.Node.ConstantNodeParameter;
 import com.oracle.graal.graph.Node.NodeIntrinsic;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.java.*;
 import com.oracle.graal.phases.*;
-import com.oracle.graal.replacements.Snippet.*;
+import com.oracle.graal.replacements.Snippet.Fold;
 
 /**
  * Checks that a graph contains no calls to {@link NodeIntrinsic} or {@link Fold} methods.
  */
 public class NodeIntrinsificationVerificationPhase extends Phase {
 
-    public static boolean verify(StructuredGraph graph) {
+    public static void verify(StructuredGraph graph) {
         new NodeIntrinsificationVerificationPhase().apply(graph);
-        return true;
     }
 
     @Override
@@ -49,11 +49,17 @@
 
     private static void checkInvoke(MethodCallTargetNode n) {
         ResolvedJavaMethod target = n.targetMethod();
-        NodeIntrinsic intrinsic = target.getAnnotation(Node.NodeIntrinsic.class);
-        if (intrinsic != null) {
-            throw new GraalInternalError("Illegal call to node intrinsic in " + n.graph() + ": " + n.invoke());
+        if (target.getAnnotation(Node.NodeIntrinsic.class) != null) {
+            error(n, "Intrinsification");
         } else if (target.getAnnotation(Fold.class) != null) {
-            throw new GraalInternalError("Illegal call to foldable method in " + n.graph() + ": " + n.invoke());
+            error(n, "Folding");
         }
     }
+
+    private static void error(MethodCallTargetNode n, String failedAction) throws GraalInternalError {
+        String context = MetaUtil.format("%H.%n", ((StructuredGraph) n.graph()).method());
+        String target = n.invoke().callTarget().targetName();
+        throw new GraalInternalError(failedAction + " of call to '" + target + "' in '" + context + "' failed, most likely due to a parameter annotated with @" +
+                        ConstantNodeParameter.class.getSimpleName() + " not being resolvable to a constant during compilation");
+    }
 }
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java	Thu Apr 25 19:43:49 2013 +0200
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java	Thu Apr 25 20:00:23 2013 +0200
@@ -279,7 +279,9 @@
          */
         protected void finalizeGraph(StructuredGraph graph) {
             new NodeIntrinsificationPhase(runtime).apply(graph);
-            assert SnippetTemplate.hasConstantParameter(method) || NodeIntrinsificationVerificationPhase.verify(graph);
+            if (!SnippetTemplate.hasConstantParameter(method)) {
+                NodeIntrinsificationVerificationPhase.verify(graph);
+            }
 
             if (original == null) {
                 new SnippetFrameStateCleanupPhase().apply(graph);
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java	Thu Apr 25 19:43:49 2013 +0200
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java	Thu Apr 25 20:00:23 2013 +0200
@@ -378,7 +378,7 @@
 
             new CanonicalizerPhase.Instance(runtime, replacements.getAssumptions(), 0, null).apply(snippetCopy);
         }
-        assert NodeIntrinsificationVerificationPhase.verify(snippetCopy);
+        NodeIntrinsificationVerificationPhase.verify(snippetCopy);
 
         // Gather the template parameters
         parameters = new Object[parameterCount];