changeset 18517:e846c9e2f0e5

added support for binding arguments of arbitrary types to parameters of a node intrinsic constructor (or factory method)
author Doug Simon <doug.simon@oracle.com>
date Wed, 26 Nov 2014 09:50:21 +0100
parents 91c479ed10f3
children 5366863364e2
files graal/com.oracle.graal.api.replacements/src/com/oracle/graal/api/replacements/SnippetReflectionProvider.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSnippetReflectionProvider.java graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/NodeIntrinsificationPhase.java
diffstat 3 files changed, 23 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.api.replacements/src/com/oracle/graal/api/replacements/SnippetReflectionProvider.java	Wed Nov 26 09:41:24 2014 +0100
+++ b/graal/com.oracle.graal.api.replacements/src/com/oracle/graal/api/replacements/SnippetReflectionProvider.java	Wed Nov 26 09:50:21 2014 +0100
@@ -76,4 +76,13 @@
      *         if this provider cannot provide a value of the requested type
      */
     Object getSubstitutionGuardParameter(Class<?> type);
+
+    /**
+     * Gets the value to bind to an injected parameter in a node intrinsic.
+     *
+     * @param type the type of a parameter in a node intrinsic constructor
+     * @return the value that should be bound to the parameter when invoking the constructor or null
+     *         if this provider cannot provide a value of the requested type
+     */
+    Object getInjectedNodeIntrinsicParameter(ResolvedJavaType type);
 }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSnippetReflectionProvider.java	Wed Nov 26 09:41:24 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSnippetReflectionProvider.java	Wed Nov 26 09:50:21 2014 +0100
@@ -60,4 +60,14 @@
         }
         return null;
     }
+
+    public Object getInjectedNodeIntrinsicParameter(ResolvedJavaType type) {
+        if (type.isInstance(forObject(runtime))) {
+            return runtime;
+        }
+        if (type.isInstance(forObject(runtime.getConfig()))) {
+            return runtime.getConfig();
+        }
+        return null;
+    }
 }
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/NodeIntrinsificationPhase.java	Wed Nov 26 09:41:24 2014 +0100
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/NodeIntrinsificationPhase.java	Wed Nov 26 09:50:21 2014 +0100
@@ -278,7 +278,10 @@
         for (int i = 0; i < signature.length; i++) {
             if (m.getParameterAnnotation(InjectedNodeParameter.class, i) != null) {
                 injected = injected == null ? new JavaConstant[1] : Arrays.copyOf(injected, injected.length + 1);
-                if (signature[i].equals(metaAccess.lookupJavaType(MetaAccessProvider.class))) {
+                Object injectedParameter = snippetReflection.getInjectedNodeIntrinsicParameter(signature[i]);
+                if (injectedParameter != null) {
+                    injected[injected.length - 1] = snippetReflection.forObject(injectedParameter);
+                } else if (signature[i].equals(metaAccess.lookupJavaType(MetaAccessProvider.class))) {
                     injected[injected.length - 1] = snippetReflection.forObject(metaAccess);
                 } else if (signature[i].equals(metaAccess.lookupJavaType(StructuredGraph.class))) {
                     injected[injected.length - 1] = snippetReflection.forObject(graph);