changeset 18522:2fa2460f99b3

Merge.
author Doug Simon <doug.simon@oracle.com>
date Wed, 26 Nov 2014 10:26:24 +0100
parents 41208d675d3d (diff) a21a4039ce7b (current diff)
children 57880e95102e
files
diffstat 21 files changed, 230 insertions(+), 114 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.api.replacements/src/com/oracle/graal/api/replacements/SnippetReflectionProvider.java	Tue Nov 25 19:20:48 2014 +0100
+++ b/graal/com.oracle.graal.api.replacements/src/com/oracle/graal/api/replacements/SnippetReflectionProvider.java	Wed Nov 26 10:26:24 2014 +0100
@@ -67,4 +67,22 @@
      * @return the value of the constant
      */
     Object asBoxedValue(JavaConstant constant);
+
+    /**
+     * Gets the value to bind to a parameter in a {@link SubstitutionGuard} constructor.
+     *
+     * @param type the type of a parameter in a {@link SubstitutionGuard} 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 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.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackendFactory.java	Tue Nov 25 19:20:48 2014 +0100
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackendFactory.java	Wed Nov 26 10:26:24 2014 +0100
@@ -157,7 +157,7 @@
             Assumptions assumptions = new Assumptions(false);
             Providers p = new Providers(metaAccess, codeCache, constantReflection, foreignCalls, lowerer, null, new HotSpotStampProvider());
             try (InitTimer rt = timer("create SnippetReflection provider")) {
-                snippetReflection = createSnippetReflection();
+                snippetReflection = createSnippetReflection(runtime);
             }
             try (InitTimer rt = timer("create Replacements provider")) {
                 replacements = createReplacements(runtime, assumptions, p, snippetReflection);
@@ -216,8 +216,8 @@
         return new HotSpotSuitesProvider(runtime);
     }
 
-    protected HotSpotSnippetReflectionProvider createSnippetReflection() {
-        return new HotSpotSnippetReflectionProvider();
+    protected HotSpotSnippetReflectionProvider createSnippetReflection(HotSpotGraalRuntime runtime) {
+        return new HotSpotSnippetReflectionProvider(runtime);
     }
 
     protected HotSpotLoweringProvider createLowerer(HotSpotGraalRuntime runtime, HotSpotMetaAccessProvider metaAccess, HotSpotForeignCallsProvider foreignCalls, HotSpotRegistersProvider registers,
--- a/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotBackend.java	Tue Nov 25 19:20:48 2014 +0100
+++ b/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotBackend.java	Wed Nov 26 10:26:24 2014 +0100
@@ -27,6 +27,7 @@
 import static com.oracle.graal.api.code.ValueUtil.*;
 import static com.oracle.graal.api.meta.LocationIdentity.*;
 import static com.oracle.graal.compiler.GraalCompiler.*;
+import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*;
 import static com.oracle.graal.hotspot.hsail.HSAILHotSpotBackend.Options.*;
 import static com.oracle.graal.hotspot.hsail.replacements.HSAILNewObjectSnippets.Options.*;
 
@@ -682,7 +683,7 @@
         // Emit object array load prologue here.
         if (isObjectLambda) {
             boolean useCompressedOops = config.useCompressedOops;
-            final int arrayElementsOffset = HotSpotGraalRuntime.getArrayBaseOffset(wordKind);
+            final int arrayElementsOffset = runtime().getArrayBaseOffset(wordKind);
             String iterationObjArgReg = HSAIL.mapRegister(cc.getArgument(nonConstantParamCount - 1));
             /*
              * iterationObjArgReg will be the highest $d register in use (it is the last parameter)
--- a/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotLoweringProvider.java	Tue Nov 25 19:20:48 2014 +0100
+++ b/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotLoweringProvider.java	Wed Nov 26 10:26:24 2014 +0100
@@ -67,7 +67,7 @@
                 if (n instanceof NewInstanceNode) {
                     hsailNewObjectSnippets.lower((NewInstanceNode) n, tool);
                 } else if (n instanceof NewArrayNode) {
-                    hsailNewObjectSnippets.lower((NewArrayNode) n, tool);
+                    hsailNewObjectSnippets.lower((NewArrayNode) n, runtime, tool);
                 }
             }
         }
--- a/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/replacements/HSAILNewObjectSnippets.java	Tue Nov 25 19:20:48 2014 +0100
+++ b/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/replacements/HSAILNewObjectSnippets.java	Wed Nov 26 10:26:24 2014 +0100
@@ -303,13 +303,13 @@
         /**
          * Lowers a {@link NewArrayNode}.
          */
-        public void lower(NewArrayNode newArrayNode, LoweringTool tool) {
+        public void lower(NewArrayNode newArrayNode, HotSpotGraalRuntimeProvider runtime, LoweringTool tool) {
             StructuredGraph graph = newArrayNode.graph();
             ResolvedJavaType elementType = newArrayNode.elementType();
             HotSpotResolvedObjectType arrayType = (HotSpotResolvedObjectType) elementType.getArrayClass();
             Kind elementKind = elementType.getKind();
             ConstantNode hub = ConstantNode.forConstant(KlassPointerStamp.klassNonNull(), arrayType.klass(), providers.getMetaAccess(), graph);
-            final int headerSize = HotSpotGraalRuntime.getArrayBaseOffset(elementKind);
+            final int headerSize = runtime.getArrayBaseOffset(elementKind);
             // lowerer extends HotSpotLoweringProvider so we can just use that
             HotSpotLoweringProvider lowerer = (HotSpotLoweringProvider) providers.getLowerer();
             int log2ElementSize = CodeUtil.log2(lowerer.arrayScalingFactor(elementKind));
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackendFactory.java	Tue Nov 25 19:20:48 2014 +0100
+++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackendFactory.java	Wed Nov 26 10:26:24 2014 +0100
@@ -64,7 +64,7 @@
         // to be valid for the entire run of the VM.
         Assumptions assumptions = new Assumptions(false);
         Providers p = new Providers(metaAccess, codeCache, constantReflection, foreignCalls, lowerer, null, new HotSpotStampProvider());
-        HotSpotSnippetReflectionProvider snippetReflection = new HotSpotSnippetReflectionProvider();
+        HotSpotSnippetReflectionProvider snippetReflection = new HotSpotSnippetReflectionProvider(runtime);
         HotSpotReplacementsImpl replacements = new HotSpotReplacementsImpl(p, snippetReflection, runtime.getConfig(), assumptions, target);
         HotSpotDisassemblerProvider disassembler = new HotSpotDisassemblerProvider(runtime);
         HotSpotSuitesProvider suites = new HotSpotSuitesProvider(runtime);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java	Tue Nov 25 19:20:48 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java	Wed Nov 26 10:26:24 2014 +0100
@@ -60,7 +60,7 @@
 /**
  * Singleton class holding the instance of the {@link GraalRuntime}.
  */
-public final class HotSpotGraalRuntime implements GraalRuntime, RuntimeProvider, StackIntrospection {
+public final class HotSpotGraalRuntime implements HotSpotGraalRuntimeProvider {
 
     private static final HotSpotGraalRuntime instance;
 
@@ -327,11 +327,6 @@
         return backend;
     }
 
-    /**
-     * Gets the Graal mirror for a {@link Class} object.
-     *
-     * @return the {@link ResolvedJavaType} corresponding to {@code javaClass}
-     */
     public ResolvedJavaType fromClass(Class<?> javaClass) {
         return graalMirrors.get(javaClass);
     }
@@ -376,19 +371,6 @@
         return compilerToVm;
     }
 
-    /**
-     * Converts a name to a Java type. This method attempts to resolve {@code name} to a
-     * {@link ResolvedJavaType}.
-     *
-     * @param name a well formed Java type in {@linkplain JavaType#getName() internal} format
-     * @param accessingType the context of resolution which must be non-null
-     * @param resolve specifies whether resolution failure results in an unresolved type being
-     *            return or a {@link LinkageError} being thrown
-     * @return a Java type for {@code name} which is guaranteed to be of type
-     *         {@link ResolvedJavaType} if {@code resolve == true}
-     * @throws LinkageError if {@code resolve == true} and the resolution failed
-     * @throws NullPointerException if {@code accessingClass} is {@code null}
-     */
     public JavaType lookupType(String name, HotSpotResolvedObjectType accessingType, boolean resolve) {
         Objects.requireNonNull(accessingType, "cannot resolve type without an accessing class");
         // If the name represents a primitive type we can short-circuit the lookup.
@@ -465,12 +447,7 @@
         return Collections.unmodifiableMap(backends);
     }
 
-    /**
-     * The offset from the origin of an array to the first element.
-     *
-     * @return the offset in bytes
-     */
-    public static int getArrayBaseOffset(Kind kind) {
+    public int getArrayBaseOffset(Kind kind) {
         switch (kind) {
             case Boolean:
                 return Unsafe.ARRAY_BOOLEAN_BASE_OFFSET;
@@ -495,12 +472,7 @@
         }
     }
 
-    /**
-     * The scale used for the index when accessing elements of an array of this kind.
-     *
-     * @return the scale in order to convert the index into a byte offset
-     */
-    public static int getArrayIndexScale(Kind kind) {
+    public int getArrayIndexScale(Kind kind) {
         switch (kind) {
             case Boolean:
                 return Unsafe.ARRAY_BOOLEAN_INDEX_SCALE;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntimeProvider.java	Wed Nov 26 10:26:24 2014 +0100
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.hotspot;
+
+import com.oracle.graal.api.code.*;
+import com.oracle.graal.api.code.stack.*;
+import com.oracle.graal.api.meta.*;
+import com.oracle.graal.api.runtime.*;
+import com.oracle.graal.hotspot.bridge.*;
+import com.oracle.graal.hotspot.meta.*;
+import com.oracle.graal.runtime.*;
+
+//JaCoCo Exclude
+
+/**
+ * Configuration information for the HotSpot Graal runtime.
+ */
+public interface HotSpotGraalRuntimeProvider extends GraalRuntime, RuntimeProvider, StackIntrospection, Remote {
+
+    HotSpotVMConfig getConfig();
+
+    TargetDescription getTarget();
+
+    CompilerToVM getCompilerToVM();
+
+    /**
+     * Converts a name to a Java type. This method attempts to resolve {@code name} to a
+     * {@link ResolvedJavaType}.
+     *
+     * @param name a well formed Java type in {@linkplain JavaType#getName() internal} format
+     * @param accessingType the context of resolution which must be non-null
+     * @param resolve specifies whether resolution failure results in an unresolved type being
+     *            return or a {@link LinkageError} being thrown
+     * @return a Java type for {@code name} which is guaranteed to be of type
+     *         {@link ResolvedJavaType} if {@code resolve == true}
+     * @throws LinkageError if {@code resolve == true} and the resolution failed
+     * @throws NullPointerException if {@code accessingClass} is {@code null}
+     */
+    JavaType lookupType(String name, HotSpotResolvedObjectType accessingType, boolean resolve);
+
+    HotSpotProviders getHostProviders();
+
+    default String getName() {
+        return getClass().getSimpleName();
+    }
+
+    HotSpotBackend getHostBackend();
+
+    /**
+     * The offset from the origin of an array to the first element.
+     *
+     * @return the offset in bytes
+     */
+    int getArrayBaseOffset(Kind kind);
+
+    /**
+     * The scale used for the index when accessing elements of an array of this kind.
+     *
+     * @return the scale in order to convert the index into a byte offset
+     */
+    int getArrayIndexScale(Kind kind);
+
+    /**
+     * Gets the Graal mirror for a {@link Class} object.
+     *
+     * @return the {@link ResolvedJavaType} corresponding to {@code javaClass}
+     */
+    ResolvedJavaType fromClass(Class<?> clazz);
+}
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/DefaultHotSpotLoweringProvider.java	Tue Nov 25 19:20:48 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/DefaultHotSpotLoweringProvider.java	Wed Nov 26 10:26:24 2014 +0100
@@ -58,7 +58,7 @@
  */
 public class DefaultHotSpotLoweringProvider extends DefaultJavaLoweringProvider implements HotSpotLoweringProvider {
 
-    protected final HotSpotGraalRuntime runtime;
+    protected final HotSpotGraalRuntimeProvider runtime;
     protected final ForeignCallsProvider foreignCalls;
     protected final HotSpotRegistersProvider registers;
 
@@ -71,7 +71,8 @@
     protected UnsafeLoadSnippets.Templates unsafeLoadSnippets;
     protected AssertionSnippets.Templates assertionSnippets;
 
-    public DefaultHotSpotLoweringProvider(HotSpotGraalRuntime runtime, MetaAccessProvider metaAccess, ForeignCallsProvider foreignCalls, HotSpotRegistersProvider registers, TargetDescription target) {
+    public DefaultHotSpotLoweringProvider(HotSpotGraalRuntimeProvider runtime, MetaAccessProvider metaAccess, ForeignCallsProvider foreignCalls, HotSpotRegistersProvider registers,
+                    TargetDescription target) {
         super(metaAccess, target);
         this.runtime = runtime;
         this.foreignCalls = foreignCalls;
@@ -129,7 +130,7 @@
             }
         } else if (n instanceof NewArrayNode) {
             if (graph.getGuardsStage() == StructuredGraph.GuardsStage.AFTER_FSA) {
-                newObjectSnippets.lower((NewArrayNode) n, registers, tool);
+                newObjectSnippets.lower((NewArrayNode) n, registers, runtime, tool);
             }
         } else if (n instanceof DynamicNewArrayNode) {
             if (graph.getGuardsStage() == StructuredGraph.GuardsStage.AFTER_FSA) {
@@ -460,7 +461,7 @@
 
     @Override
     protected int arrayBaseOffset(Kind kind) {
-        return HotSpotGraalRuntime.getArrayBaseOffset(kind);
+        return runtime.getArrayBaseOffset(kind);
     }
 
     @Override
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMetaAccessProvider.java	Tue Nov 25 19:20:48 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMetaAccessProvider.java	Wed Nov 26 10:26:24 2014 +0100
@@ -23,6 +23,7 @@
 package com.oracle.graal.hotspot.meta;
 
 import static com.oracle.graal.compiler.common.UnsafeAccess.*;
+import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*;
 import static com.oracle.graal.hotspot.meta.HotSpotResolvedJavaType.*;
 import static com.oracle.graal.hotspot.meta.HotSpotResolvedObjectTypeImpl.*;
 
@@ -295,7 +296,7 @@
                     int length = Array.getLength(((HotSpotObjectConstantImpl) constant).object());
                     ResolvedJavaType elementType = lookupJavaType.getComponentType();
                     Kind elementKind = elementType.getKind();
-                    final int headerSize = HotSpotGraalRuntime.getArrayBaseOffset(elementKind);
+                    final int headerSize = runtime().getArrayBaseOffset(elementKind);
                     int sizeOfElement = HotSpotGraalRuntime.runtime().getTarget().getSizeInBytes(elementKind);
                     int alignment = HotSpotGraalRuntime.runtime().getTarget().wordSize;
                     int log2ElementSize = CodeUtil.log2(sizeOfElement);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSnippetReflectionProvider.java	Tue Nov 25 19:20:48 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSnippetReflectionProvider.java	Wed Nov 26 10:26:24 2014 +0100
@@ -24,9 +24,16 @@
 
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.api.replacements.*;
+import com.oracle.graal.hotspot.*;
 
 public class HotSpotSnippetReflectionProvider implements SnippetReflectionProvider {
 
+    private final HotSpotGraalRuntimeProvider runtime;
+
+    public HotSpotSnippetReflectionProvider(HotSpotGraalRuntimeProvider runtime) {
+        this.runtime = runtime;
+    }
+
     @Override
     public JavaConstant forObject(Object object) {
         return HotSpotObjectConstantImpl.forObject(object);
@@ -46,4 +53,21 @@
     public Object asBoxedValue(JavaConstant constant) {
         return HotSpotObjectConstantImpl.asBoxedValue(constant);
     }
+
+    public Object getSubstitutionGuardParameter(Class<?> type) {
+        if (type.isInstance(runtime)) {
+            return runtime;
+        }
+        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.hotspot/src/com/oracle/graal/hotspot/nfi/NativeCallStubGraphBuilder.java	Tue Nov 25 19:20:48 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nfi/NativeCallStubGraphBuilder.java	Wed Nov 26 10:26:24 2014 +0100
@@ -117,9 +117,9 @@
                 // array value
                 Kind arrayElementKind = getElementKind(type);
                 LocationIdentity locationIdentity = NamedLocationIdentity.getArrayLocation(arrayElementKind);
-                int displacement = getArrayBaseOffset(arrayElementKind);
+                int displacement = runtime().getArrayBaseOffset(arrayElementKind);
                 ConstantNode index = ConstantNode.forInt(0, g);
-                int indexScaling = getArrayIndexScale(arrayElementKind);
+                int indexScaling = runtime().getArrayIndexScale(arrayElementKind);
                 IndexedLocationNode locationNode = IndexedLocationNode.create(locationIdentity, arrayElementKind, displacement, index, g, indexScaling);
                 Stamp wordStamp = StampFactory.forKind(providers.getCodeCache().getTarget().wordKind);
                 ComputeAddressNode arrayAddress = g.unique(ComputeAddressNode.create(boxedElement, locationNode, wordStamp));
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ArrayCopyCallNode.java	Tue Nov 25 19:20:48 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ArrayCopyCallNode.java	Wed Nov 26 10:26:24 2014 +0100
@@ -24,12 +24,12 @@
 package com.oracle.graal.hotspot.replacements;
 
 import static com.oracle.graal.api.meta.LocationIdentity.*;
-import static com.oracle.graal.hotspot.replacements.HotSpotReplacementsUtil.*;
 
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.api.runtime.*;
 import com.oracle.graal.compiler.common.*;
 import com.oracle.graal.compiler.common.type.*;
+import com.oracle.graal.hotspot.*;
 import com.oracle.graal.hotspot.meta.*;
 import com.oracle.graal.hotspot.nodes.*;
 import com.oracle.graal.nodeinfo.*;
@@ -58,12 +58,15 @@
     protected boolean disjoint;
     protected boolean uninitialized;
 
-    public static ArrayCopyCallNode create(ValueNode src, ValueNode srcPos, ValueNode dest, ValueNode destPos, ValueNode length, Kind elementKind, boolean aligned, boolean disjoint,
-                    boolean uninitialized) {
-        return new ArrayCopyCallNode(src, srcPos, dest, destPos, length, elementKind, aligned, disjoint, uninitialized);
+    protected final HotSpotGraalRuntimeProvider runtime;
+
+    public static ArrayCopyCallNode create(@InjectedNodeParameter HotSpotGraalRuntimeProvider runtime, ValueNode src, ValueNode srcPos, ValueNode dest, ValueNode destPos, ValueNode length,
+                    Kind elementKind, boolean aligned, boolean disjoint, boolean uninitialized) {
+        return new ArrayCopyCallNode(src, srcPos, dest, destPos, length, elementKind, aligned, disjoint, uninitialized, runtime);
     }
 
-    protected ArrayCopyCallNode(ValueNode src, ValueNode srcPos, ValueNode dest, ValueNode destPos, ValueNode length, Kind elementKind, boolean aligned, boolean disjoint, boolean uninitialized) {
+    protected ArrayCopyCallNode(ValueNode src, ValueNode srcPos, ValueNode dest, ValueNode destPos, ValueNode length, Kind elementKind, boolean aligned, boolean disjoint, boolean uninitialized,
+                    HotSpotGraalRuntimeProvider runtime) {
         super(StampFactory.forVoid());
         assert elementKind != null;
         this.src = src;
@@ -75,14 +78,12 @@
         this.aligned = aligned;
         this.disjoint = disjoint;
         this.uninitialized = uninitialized;
+        this.runtime = runtime;
     }
 
-    public static ArrayCopyCallNode create(ValueNode src, ValueNode srcPos, ValueNode dest, ValueNode destPos, ValueNode length, Kind elementKind, boolean disjoint) {
-        return new ArrayCopyCallNode(src, srcPos, dest, destPos, length, elementKind, disjoint);
-    }
-
-    protected ArrayCopyCallNode(ValueNode src, ValueNode srcPos, ValueNode dest, ValueNode destPos, ValueNode length, Kind elementKind, boolean disjoint) {
-        this(src, srcPos, dest, destPos, length, elementKind, false, disjoint, false);
+    public static ArrayCopyCallNode create(@InjectedNodeParameter HotSpotGraalRuntimeProvider runtime, ValueNode src, ValueNode srcPos, ValueNode dest, ValueNode destPos, ValueNode length,
+                    Kind elementKind, boolean disjoint) {
+        return new ArrayCopyCallNode(src, srcPos, dest, destPos, length, elementKind, false, disjoint, false, runtime);
     }
 
     public ValueNode getSource() {
@@ -124,7 +125,7 @@
     private ValueNode computeBase(ValueNode base, ValueNode pos) {
         FixedWithNextNode basePtr = graph().add(GetObjectAddressNode.create(base));
         graph().addBeforeFixed(this, basePtr);
-        ValueNode loc = IndexedLocationNode.create(getLocationIdentity(), elementKind, arrayBaseOffset(elementKind), pos, graph(), arrayIndexScale(elementKind));
+        ValueNode loc = IndexedLocationNode.create(getLocationIdentity(), elementKind, runtime.getArrayBaseOffset(elementKind), pos, graph(), runtime.getArrayIndexScale(elementKind));
         return graph().unique(ComputeAddressNode.create(basePtr, loc, StampFactory.forKind(Kind.Long)));
     }
 
@@ -183,8 +184,8 @@
         return uninitialized;
     }
 
-    static boolean isHeapWordAligned(JavaConstant value, Kind kind) {
-        return (arrayBaseOffset(kind) + (long) value.asInt() * arrayIndexScale(kind)) % heapWordSize() == 0;
+    boolean isHeapWordAligned(JavaConstant value, Kind kind) {
+        return (runtime.getArrayBaseOffset(kind) + (long) value.asInt() * runtime.getArrayIndexScale(kind)) % runtime.getConfig().heapWordSize == 0;
     }
 
     public void updateAlignedDisjoint() {
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/CRC32Substitutions.java	Tue Nov 25 19:20:48 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/CRC32Substitutions.java	Wed Nov 26 10:26:24 2014 +0100
@@ -31,6 +31,7 @@
 import com.oracle.graal.api.replacements.*;
 import com.oracle.graal.graph.Node.ConstantNodeParameter;
 import com.oracle.graal.graph.Node.NodeIntrinsic;
+import com.oracle.graal.hotspot.*;
 import com.oracle.graal.hotspot.nodes.*;
 import com.oracle.graal.nodes.extended.*;
 import com.oracle.graal.word.*;
@@ -42,8 +43,15 @@
 public class CRC32Substitutions {
 
     public static class Guard implements SubstitutionGuard {
+
+        private HotSpotGraalRuntimeProvider runtime;
+
+        public Guard(HotSpotGraalRuntimeProvider runtime) {
+            this.runtime = runtime;
+        }
+
         public boolean execute() {
-            return runtime().getConfig().useCRC32Intrinsics;
+            return runtime.getConfig().useCRC32Intrinsics;
         }
     }
 
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ClassGetHubNode.java	Tue Nov 25 19:20:48 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ClassGetHubNode.java	Wed Nov 26 10:26:24 2014 +0100
@@ -22,7 +22,6 @@
  */
 package com.oracle.graal.hotspot.replacements;
 
-import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*;
 import static com.oracle.graal.hotspot.replacements.HotSpotReplacementsUtil.*;
 
 import com.oracle.graal.api.meta.*;
@@ -39,30 +38,28 @@
 import com.oracle.graal.nodes.spi.*;
 
 /**
- * Read Class::_klass to get the hub for a {@link java.lang.Class}. This node mostly exists to
- * replace _klass._java_mirror._klass with _klass. The constant folding could be handled by
+ * Read {@code Class::_klass} to get the hub for a {@link java.lang.Class}. This node mostly exists
+ * to replace {@code _klass._java_mirror._klass} with {@code _klass}. The constant folding could be
+ * handled by
  * {@link ReadNode#canonicalizeRead(ValueNode, LocationNode, ValueNode, CanonicalizerTool)}.
  */
 @NodeInfo
 public class ClassGetHubNode extends FloatingGuardedNode implements Lowerable, Canonicalizable {
     @Input protected ValueNode clazz;
+    protected final HotSpotGraalRuntimeProvider runtime;
 
-    public static ClassGetHubNode create(ValueNode clazz) {
-        return new ClassGetHubNode(clazz);
-    }
-
-    public static ClassGetHubNode create(ValueNode clazz, ValueNode guard) {
-        return new ClassGetHubNode(clazz, guard);
+    public static ClassGetHubNode create(@InjectedNodeParameter HotSpotGraalRuntimeProvider runtime, ValueNode clazz) {
+        return new ClassGetHubNode(clazz, null, runtime);
     }
 
-    protected ClassGetHubNode(ValueNode clazz) {
-        super(KlassPointerStamp.klass(), null);
-        this.clazz = clazz;
+    public static ClassGetHubNode create(@InjectedNodeParameter HotSpotGraalRuntimeProvider runtime, ValueNode clazz, ValueNode guard) {
+        return new ClassGetHubNode(clazz, guard, runtime);
     }
 
-    protected ClassGetHubNode(ValueNode clazz, ValueNode guard) {
+    protected ClassGetHubNode(ValueNode clazz, ValueNode guard, HotSpotGraalRuntimeProvider runtime) {
         super(KlassPointerStamp.klass(), (GuardingNode) guard);
         this.clazz = clazz;
+        this.runtime = runtime;
     }
 
     public ValueNode getHub() {
@@ -77,7 +74,7 @@
             if (clazz.isConstant()) {
                 MetaAccessProvider metaAccess = tool.getMetaAccess();
                 if (metaAccess != null) {
-                    HotSpotResolvedJavaType exactType = (HotSpotResolvedJavaType) tool.getConstantReflection().asJavaType(clazz.asJavaConstant());
+                    ResolvedJavaType exactType = tool.getConstantReflection().asJavaType(clazz.asJavaConstant());
                     if (exactType instanceof HotSpotResolvedObjectType) {
                         HotSpotResolvedObjectType objectType = (HotSpotResolvedObjectType) exactType;
                         ConstantNode cn = ConstantNode.forConstant(stamp(), objectType.getObjectHub(), metaAccess);
@@ -101,8 +98,7 @@
             return;
         }
 
-        HotSpotVMConfig config = runtime().getConfig();
-        LocationNode location = ConstantLocationNode.create(CLASS_KLASS_LOCATION, getWordKind(), config.klassOffset, graph());
+        LocationNode location = ConstantLocationNode.create(CLASS_KLASS_LOCATION, runtime.getTarget().wordKind, runtime.getConfig().klassOffset, graph());
         assert !clazz.isConstant();
         FloatingReadNode read = graph().unique(FloatingReadNode.create(clazz, location, null, stamp(), getGuard(), BarrierType.NONE));
         graph().replaceFloating(this, read);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HotSpotReplacementsUtil.java	Tue Nov 25 19:20:48 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HotSpotReplacementsUtil.java	Wed Nov 26 10:26:24 2014 +0100
@@ -426,12 +426,12 @@
 
     @Fold
     public static int arrayBaseOffset(Kind elementKind) {
-        return HotSpotGraalRuntime.getArrayBaseOffset(elementKind);
+        return runtime().getArrayBaseOffset(elementKind);
     }
 
     @Fold
     public static int arrayIndexScale(Kind elementKind) {
-        return HotSpotGraalRuntime.getArrayIndexScale(elementKind);
+        return runtime().getArrayIndexScale(elementKind);
     }
 
     @Fold
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HubGetClassNode.java	Tue Nov 25 19:20:48 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HubGetClassNode.java	Wed Nov 26 10:26:24 2014 +0100
@@ -22,7 +22,6 @@
  */
 package com.oracle.graal.hotspot.replacements;
 
-import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*;
 import static com.oracle.graal.hotspot.replacements.HotSpotReplacementsUtil.*;
 
 import com.oracle.graal.api.meta.*;
@@ -38,20 +37,22 @@
 import com.oracle.graal.nodes.spi.*;
 
 /**
- * Read Klass::_java_mirror and incorporate non-null type information into stamp. This is also used
- * by {@link ClassGetHubNode} to eliminate chains of klass._java_mirror._klass.
+ * Read {@code Klass::_java_mirror} and incorporate non-null type information into stamp. This is
+ * also used by {@link ClassGetHubNode} to eliminate chains of {@code klass._java_mirror._klass}.
  */
 @NodeInfo
 public class HubGetClassNode extends FloatingGuardedNode implements Lowerable, Canonicalizable {
     @Input protected ValueNode hub;
+    protected final HotSpotVMConfig config;
 
-    public static HubGetClassNode create(ValueNode hub) {
-        return new HubGetClassNode(hub);
+    public static HubGetClassNode create(@InjectedNodeParameter MetaAccessProvider metaAccess, @InjectedNodeParameter HotSpotVMConfig config, ValueNode hub) {
+        return new HubGetClassNode(hub, metaAccess, config);
     }
 
-    protected HubGetClassNode(ValueNode hub) {
-        super(StampFactory.declaredNonNull(runtime().fromClass(Class.class)), null);
+    protected HubGetClassNode(ValueNode hub, MetaAccessProvider metaAccess, HotSpotVMConfig config) {
+        super(StampFactory.declaredNonNull(metaAccess.lookupJavaType(Class.class)), null);
         this.hub = hub;
+        this.config = config;
     }
 
     public ValueNode getHub() {
@@ -80,7 +81,6 @@
             return;
         }
 
-        HotSpotVMConfig config = runtime().getConfig();
         LocationNode location = ConstantLocationNode.create(CLASS_MIRROR_LOCATION, Kind.Object, config.classMirrorOffset, graph());
         assert !hub.isConstant();
         FloatingReadNode read = graph().unique(FloatingReadNode.create(hub, location, null, stamp(), getGuard(), BarrierType.NONE));
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/KlassLayoutHelperNode.java	Tue Nov 25 19:20:48 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/KlassLayoutHelperNode.java	Wed Nov 26 10:26:24 2014 +0100
@@ -22,13 +22,13 @@
  */
 package com.oracle.graal.hotspot.replacements;
 
-import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*;
 import static com.oracle.graal.hotspot.replacements.HotSpotReplacementsUtil.*;
 
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.compiler.common.type.*;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.graph.spi.*;
+import com.oracle.graal.hotspot.*;
 import com.oracle.graal.hotspot.meta.*;
 import com.oracle.graal.nodeinfo.*;
 import com.oracle.graal.nodes.*;
@@ -37,30 +37,27 @@
 import com.oracle.graal.nodes.spi.*;
 
 /**
- * Read Klass::_layout_helper and incorporate any useful stamp information based on any type
+ * Read {@code Klass::_layout_helper} and incorporate any useful stamp information based on any type
  * information in {@code klass}.
  */
 @NodeInfo
 public class KlassLayoutHelperNode extends FloatingGuardedNode implements Canonicalizable, Lowerable {
 
     @Input protected ValueNode klass;
+    protected final HotSpotVMConfig config;
 
-    public static KlassLayoutHelperNode create(ValueNode klass) {
-        return new KlassLayoutHelperNode(klass);
-    }
-
-    public static KlassLayoutHelperNode create(ValueNode klass, ValueNode guard) {
-        return new KlassLayoutHelperNode(klass, guard);
+    public static KlassLayoutHelperNode create(@InjectedNodeParameter HotSpotVMConfig config, ValueNode klass) {
+        return new KlassLayoutHelperNode(config, klass, null);
     }
 
-    protected KlassLayoutHelperNode(ValueNode klass) {
-        super(StampFactory.forKind(Kind.Int));
-        this.klass = klass;
+    public static KlassLayoutHelperNode create(@InjectedNodeParameter HotSpotVMConfig config, ValueNode klass, ValueNode guard) {
+        return new KlassLayoutHelperNode(config, klass, guard);
     }
 
-    protected KlassLayoutHelperNode(ValueNode klass, ValueNode guard) {
+    protected KlassLayoutHelperNode(HotSpotVMConfig config, ValueNode klass, ValueNode guard) {
         super(StampFactory.forKind(Kind.Int), (GuardingNode) guard);
         this.klass = klass;
+        this.config = config;
     }
 
     @Override
@@ -76,10 +73,10 @@
                         /*
                          * Definitely some form of instance type.
                          */
-                        return updateStamp(StampFactory.forInteger(Kind.Int, runtime().getConfig().klassLayoutHelperNeutralValue, Integer.MAX_VALUE));
+                        return updateStamp(StampFactory.forInteger(Kind.Int, config.klassLayoutHelperNeutralValue, Integer.MAX_VALUE));
                     }
                     if (type.isArray()) {
-                        return updateStamp(StampFactory.forInteger(Kind.Int, Integer.MIN_VALUE, runtime().getConfig().klassLayoutHelperNeutralValue - 1));
+                        return updateStamp(StampFactory.forInteger(Kind.Int, Integer.MIN_VALUE, config.klassLayoutHelperNeutralValue - 1));
                     }
                 }
             }
@@ -94,7 +91,7 @@
         } else {
             if (klass.isConstant()) {
                 if (!klass.asConstant().isDefaultForKind()) {
-                    Constant constant = stamp().readConstant(tool.getConstantReflection().getMemoryAccessProvider(), klass.asJavaConstant(), runtime().getConfig().klassLayoutHelperOffset);
+                    Constant constant = stamp().readConstant(tool.getConstantReflection().getMemoryAccessProvider(), klass.asJavaConstant(), config.klassLayoutHelperOffset);
                     return ConstantNode.forConstant(stamp(), constant, tool.getMetaAccess());
                 }
             }
@@ -106,7 +103,7 @@
                     HotSpotResolvedObjectType type = (HotSpotResolvedObjectType) ostamp.type();
                     if (type != null && type.isArray() && !type.getComponentType().isPrimitive()) {
                         // The layout for all object arrays is the same.
-                        Constant constant = stamp().readConstant(tool.getConstantReflection().getMemoryAccessProvider(), type.klass(), runtime().getConfig().klassLayoutHelperOffset);
+                        Constant constant = stamp().readConstant(tool.getConstantReflection().getMemoryAccessProvider(), type.klass(), config.klassLayoutHelperOffset);
                         return ConstantNode.forConstant(stamp(), constant, tool.getMetaAccess());
                     }
                 }
@@ -120,7 +117,7 @@
         if (tool.getLoweringStage() == LoweringTool.StandardLoweringStage.HIGH_TIER) {
             return;
         }
-        LocationNode location = ConstantLocationNode.create(KLASS_LAYOUT_HELPER_LOCATION, Kind.Int, runtime().getConfig().klassLayoutHelperOffset, graph());
+        LocationNode location = ConstantLocationNode.create(KLASS_LAYOUT_HELPER_LOCATION, Kind.Int, config.klassLayoutHelperOffset, graph());
         assert !klass.isConstant();
         graph().replaceFloating(this, graph().unique(FloatingReadNode.create(klass, location, null, stamp(), getGuard(), BarrierType.NONE)));
     }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/NewObjectSnippets.java	Tue Nov 25 19:20:48 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/NewObjectSnippets.java	Wed Nov 26 10:26:24 2014 +0100
@@ -410,13 +410,13 @@
         /**
          * Lowers a {@link NewArrayNode}.
          */
-        public void lower(NewArrayNode newArrayNode, HotSpotRegistersProvider registers, LoweringTool tool) {
+        public void lower(NewArrayNode newArrayNode, HotSpotRegistersProvider registers, HotSpotGraalRuntimeProvider runtime, LoweringTool tool) {
             StructuredGraph graph = newArrayNode.graph();
             ResolvedJavaType elementType = newArrayNode.elementType();
             HotSpotResolvedObjectType arrayType = (HotSpotResolvedObjectType) elementType.getArrayClass();
             Kind elementKind = elementType.getKind();
             ConstantNode hub = ConstantNode.forConstant(KlassPointerStamp.klassNonNull(), arrayType.klass(), providers.getMetaAccess(), graph);
-            final int headerSize = HotSpotGraalRuntime.getArrayBaseOffset(elementKind);
+            final int headerSize = runtime.getArrayBaseOffset(elementKind);
             HotSpotLoweringProvider lowerer = (HotSpotLoweringProvider) providers.getLowerer();
             int log2ElementSize = CodeUtil.log2(lowerer.arrayScalingFactor(elementKind));
 
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/NodeIntrinsificationPhase.java	Tue Nov 25 19:20:48 2014 +0100
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/NodeIntrinsificationPhase.java	Wed Nov 26 10:26:24 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);
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java	Tue Nov 25 19:20:48 2014 +0100
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java	Wed Nov 26 10:26:24 2014 +0100
@@ -313,17 +313,22 @@
             Class<?>[] paramTypes = constructor.getParameterTypes();
             // Check for supported constructor signatures
             try {
-                if (constructor.getParameterCount() == 1 && paramTypes[0] == Architecture.class) {
-                    // Guard(Architecture)
-                    return (SubstitutionGuard) constructor.newInstance(target.arch);
-                } else if (constructor.getParameterCount() == 0) {
-                    // Guard()
-                    return (SubstitutionGuard) constructor.newInstance();
+                Object[] args = new Object[constructor.getParameterCount()];
+                for (int i = 0; i < args.length; i++) {
+                    Object arg = snippetReflection.getSubstitutionGuardParameter(paramTypes[0]);
+                    if (arg != null) {
+                        args[i] = arg;
+                    } else if (paramTypes[0].isInstance(target.arch)) {
+                        args[i] = target.arch;
+                    } else {
+                        throw new GraalInternalError("Unsupported type %s in substitution guard constructor: %s", paramTypes[i].getName(), constructor);
+                    }
                 }
+
+                return (SubstitutionGuard) constructor.newInstance(args);
             } catch (Exception e) {
                 throw new GraalInternalError(e);
             }
-            throw new GraalInternalError("Unsupported constructor signature in substitution guard: " + constructor);
         }
         return null;
     }