changeset 19618:98d7ecef3657

New Truffle API method CompilerAsserts#partialEvaluationConstant(Object).
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Fri, 27 Feb 2015 13:54:05 +0100
parents 1ae2bbd0fc07
children 711f46f691cf
files graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/substitutions/TruffleGraphBuilderPlugins.java graal/com.oracle.truffle.api/src/com/oracle/truffle/api/CompilerAsserts.java
diffstat 2 files changed, 25 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/substitutions/TruffleGraphBuilderPlugins.java	Fri Feb 27 12:49:59 2015 +0100
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/substitutions/TruffleGraphBuilderPlugins.java	Fri Feb 27 13:54:05 2015 +0100
@@ -190,6 +190,22 @@
                 return true;
             }
         });
+
+        r = new Registration(plugins, metaAccess, CompilerAsserts.class);
+        r.register1("partialEvaluationConstant", Object.class, new InvocationPlugin() {
+            public boolean apply(GraphBuilderContext builder, ValueNode value) {
+                ValueNode curValue = value;
+                if (curValue instanceof BoxNode) {
+                    BoxNode boxNode = (BoxNode) curValue;
+                    curValue = boxNode.getValue();
+                }
+                if (curValue.isConstant()) {
+                    return true;
+                } else {
+                    throw builder.bailout("Partial evaluation did not reduce value to a constant, is a regular compiler node: " + curValue);
+                }
+            }
+        });
     }
 
     public static void registerOptimizedCallTargetPlugins(MetaAccessProvider metaAccess, InvocationPlugins plugins) {
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/CompilerAsserts.java	Fri Feb 27 12:49:59 2015 +0100
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/CompilerAsserts.java	Fri Feb 27 13:54:05 2015 +0100
@@ -64,4 +64,13 @@
             neverPartOfCompilation("Value is not compilation constant");
         }
     }
+
+    /**
+     * Assertion that the corresponding value is reduced to a constant during the initial partial
+     * evaluation phase.
+     *
+     * @param value the value that must be constant during compilation
+     */
+    public static <T> void partialEvaluationConstant(Object value) {
+    }
 }