changeset 22769:d04e35a28e30

Merge
author Christian Wimmer <christian.wimmer@oracle.com>
date Tue, 06 Oct 2015 18:44:23 -0700
parents 942bc81f277e 582a97b6fdd1
children 42b173295a32
files graal/com.oracle.graal.debug/src/com/oracle/graal/debug/query/DelimitationAPI.java graal/com.oracle.graal.debug/src/com/oracle/graal/debug/query/GraalQueryAPI.java graal/com.oracle.graal.debug/src/com/oracle/graal/debug/query/SpecialIntrinsicGuard.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/DefaultHotSpotLoweringProvider.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/DelimitationAPISubstitutions.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/GraalQueryAPISubstitutions.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/query/GetRootNameNode.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/query/GetRuntimePathNode.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/query/IsMethodInlinedNode.java graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/query/ExtractICGPhase.java graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/query/HighTierReconcileICGPhase.java graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/query/InlineICGPhase.java graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/query/MidTierReconcileICGPhase.java graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/query/nodes/GraalQueryNode.java graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/query/nodes/InstrumentationBeginNode.java graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/query/nodes/InstrumentationEndNode.java graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/query/nodes/InstrumentationNode.java graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/query/nodes/MonitorProxyNode.java
diffstat 46 files changed, 1474 insertions(+), 1452 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.api.directives/src/com/oracle/graal/api/directives/GraalDirectives.java	Tue Oct 06 16:52:56 2015 -0700
+++ b/graal/com.oracle.graal.api.directives/src/com/oracle/graal/api/directives/GraalDirectives.java	Tue Oct 06 18:44:23 2015 -0700
@@ -296,4 +296,70 @@
      */
     public static void ensureVirtualizedHere(@SuppressWarnings("unused") Object object) {
     }
+
+    /**
+     * Marks the beginning of the instrumentation boundary. The instrumentation will be folded
+     * during compilation and will not affect inlining heuristics regarding graph size except the
+     * one on compiled low-level graph size (see GraalOptions.SmallCompiledLowLevelGraphSize). The
+     * offset specifies a target node to whom the instrumentation is associated. If the target node
+     * is a NewInstanceNode or a MonitorEnterNode, the instrumentation will be duplicated and
+     * inserted after the relocated CommitAllocationNode.
+     *
+     * Example (the instrumentation is associated with the allocation):
+     *
+     * <blockquote>
+     *
+     * <pre>
+     * new java.lang.Object
+     * iconst_m1
+     * invokestatic GraalDirectives.instrumentationBegin(int)
+     * invokestatic AllocationProfiler.countActualAllocation()
+     * invokestatic GraalDirectives.instrumentationEnd()
+     * invokespecial java.lang.Object()
+     * </pre>
+     *
+     * </blockquote>
+     *
+     * @param offset the length of a sequential path from a target node to the invocation to this
+     *            API (if negative), or from the invocation to {@link #instrumentationEnd()} to a
+     *            target node (if positive). Pass 0 to anchor the instrumentation.
+     */
+    public static void instrumentationBegin(int offset) {
+    }
+
+    /**
+     * Marks the end of the instrumentation boundary. See {@link #instrumentationBegin(int)}.
+     */
+    public static void instrumentationEnd() {
+    }
+
+    /**
+     * @return an integer representing a runtime path taken for a @Snippet. This API is valid only
+     *         if invoked within an instrumentation (see {@link #instrumentationBegin(int)} and
+     *         {@link #instrumentationEnd()} , and the associated target node of the instrumentation
+     *         is a preceding node that will be substituted by a @Snippet with multiple runtime
+     *         paths. It will be replaced with a ValuePhiNode with constant integer inputs [0, N-1],
+     *         where N denotes the number of runtime paths of the snippet.
+     */
+    public static int runtimePath() {
+        return -1;
+    }
+
+    /**
+     * @return true if the enclosing method is inlined. This API is valid only if invoked within an
+     *         instrumentation (see {@link #instrumentationBegin(int)} and
+     *         {@link #instrumentationEnd()} .
+     */
+    public static boolean isMethodInlined() {
+        return false;
+    }
+
+    /**
+     * @return the name of the root method for the current compilation task. If the enclosing method
+     *         is inlined, it returns the name of the method into which it is inlined.
+     */
+    public static String rootName() {
+        return "unknown";
+    }
+
 }
--- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/GraalOptions.java	Tue Oct 06 16:52:56 2015 -0700
+++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/GraalOptions.java	Tue Oct 06 18:44:23 2015 -0700
@@ -312,7 +312,7 @@
         }
     };
 
-    @Option(help = "Enable compiler decision queries")
-    public static final OptionValue<Boolean> UseGraalQueries = new OptionValue<>(false);
+    @Option(help = "Enable Graal instrumentation")
+    public static final OptionValue<Boolean> UseGraalInstrumentation = new OptionValue<>(false);
 
 }
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java	Tue Oct 06 16:52:56 2015 -0700
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java	Tue Oct 06 18:44:23 2015 -0700
@@ -24,7 +24,7 @@
 
 import static com.oracle.graal.compiler.GraalCompilerOptions.EmitLIRRepeatCount;
 import static com.oracle.graal.compiler.common.GraalOptions.RegisterPressure;
-import static com.oracle.graal.compiler.common.GraalOptions.UseGraalQueries;
+import static com.oracle.graal.compiler.common.GraalOptions.UseGraalInstrumentation;
 import static com.oracle.graal.compiler.common.alloc.RegisterAllocationConfig.ALL_REGISTERS;
 import static com.oracle.graal.phases.common.DeadCodeEliminationPhase.Optionality.Optional;
 
@@ -76,7 +76,7 @@
 import com.oracle.graal.phases.OptimisticOptimizations;
 import com.oracle.graal.phases.PhaseSuite;
 import com.oracle.graal.phases.common.DeadCodeEliminationPhase;
-import com.oracle.graal.phases.common.query.ExtractICGPhase;
+import com.oracle.graal.phases.common.instrumentation.ExtractInstrumentationPhase;
 import com.oracle.graal.phases.schedule.SchedulePhase;
 import com.oracle.graal.phases.tiers.HighTierContext;
 import com.oracle.graal.phases.tiers.LowTierContext;
@@ -203,8 +203,8 @@
             HighTierContext highTierContext = new HighTierContext(providers, graphBuilderSuite, optimisticOpts);
             if (graph.start().next() == null) {
                 graphBuilderSuite.apply(graph, highTierContext);
-                if (UseGraalQueries.getValue()) {
-                    new ExtractICGPhase().apply(graph, highTierContext);
+                if (UseGraalInstrumentation.getValue()) {
+                    new ExtractInstrumentationPhase().apply(graph, highTierContext);
                 }
                 new DeadCodeEliminationPhase(Optional).apply(graph);
             } else {
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/HighTier.java	Tue Oct 06 16:52:56 2015 -0700
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/HighTier.java	Tue Oct 06 18:44:23 2015 -0700
@@ -31,7 +31,7 @@
 import static com.oracle.graal.compiler.common.GraalOptions.OptConvertDeoptsToGuards;
 import static com.oracle.graal.compiler.common.GraalOptions.OptLoopTransform;
 import static com.oracle.graal.compiler.common.GraalOptions.PartialEscapeAnalysis;
-import static com.oracle.graal.compiler.common.GraalOptions.UseGraalQueries;
+import static com.oracle.graal.compiler.common.GraalOptions.UseGraalInstrumentation;
 import static com.oracle.graal.phases.common.DeadCodeEliminationPhase.Optionality.Optional;
 import jdk.internal.jvmci.options.Option;
 import jdk.internal.jvmci.options.OptionType;
@@ -49,7 +49,7 @@
 import com.oracle.graal.phases.common.LoweringPhase;
 import com.oracle.graal.phases.common.RemoveValueProxyPhase;
 import com.oracle.graal.phases.common.inlining.InliningPhase;
-import com.oracle.graal.phases.common.query.HighTierReconcileICGPhase;
+import com.oracle.graal.phases.common.instrumentation.HighTierReconcileInstrumentationPhase;
 import com.oracle.graal.phases.tiers.HighTierContext;
 import com.oracle.graal.virtual.phases.ea.PartialEscapePhase;
 
@@ -110,8 +110,8 @@
         appendPhase(new RemoveValueProxyPhase());
 
         appendPhase(new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.HIGH_TIER));
-        if (UseGraalQueries.getValue()) {
-            appendPhase(new HighTierReconcileICGPhase());
+        if (UseGraalInstrumentation.getValue()) {
+            appendPhase(new HighTierReconcileInstrumentationPhase());
         }
     }
 }
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/LowTier.java	Tue Oct 06 16:52:56 2015 -0700
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/LowTier.java	Tue Oct 06 18:44:23 2015 -0700
@@ -25,7 +25,7 @@
 import static com.oracle.graal.compiler.common.GraalOptions.ConditionalElimination;
 import static com.oracle.graal.compiler.common.GraalOptions.ImmutableCode;
 import static com.oracle.graal.compiler.common.GraalOptions.OptCanonicalizer;
-import static com.oracle.graal.compiler.common.GraalOptions.UseGraalQueries;
+import static com.oracle.graal.compiler.common.GraalOptions.UseGraalInstrumentation;
 import static com.oracle.graal.phases.common.DeadCodeEliminationPhase.Optionality.Required;
 import jdk.internal.jvmci.options.Option;
 import jdk.internal.jvmci.options.OptionType;
@@ -41,7 +41,7 @@
 import com.oracle.graal.phases.common.ProfileCompiledMethodsPhase;
 import com.oracle.graal.phases.common.RemoveValueProxyPhase;
 import com.oracle.graal.phases.common.UseTrappingNullChecksPhase;
-import com.oracle.graal.phases.common.query.InlineICGPhase;
+import com.oracle.graal.phases.common.instrumentation.InlineInstrumentationPhase;
 import com.oracle.graal.phases.tiers.LowTierContext;
 
 public class LowTier extends PhaseSuite<LowTierContext> {
@@ -66,8 +66,8 @@
         }
 
         appendPhase(new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.LOW_TIER));
-        if (UseGraalQueries.getValue()) {
-            appendPhase(new InlineICGPhase());
+        if (UseGraalInstrumentation.getValue()) {
+            appendPhase(new InlineInstrumentationPhase());
         }
 
         appendPhase(new RemoveValueProxyPhase());
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/MidTier.java	Tue Oct 06 16:52:56 2015 -0700
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/MidTier.java	Tue Oct 06 18:44:23 2015 -0700
@@ -31,7 +31,7 @@
 import static com.oracle.graal.compiler.common.GraalOptions.OptPushThroughPi;
 import static com.oracle.graal.compiler.common.GraalOptions.OptReadElimination;
 import static com.oracle.graal.compiler.common.GraalOptions.ReassociateInvariants;
-import static com.oracle.graal.compiler.common.GraalOptions.UseGraalQueries;
+import static com.oracle.graal.compiler.common.GraalOptions.UseGraalInstrumentation;
 import static com.oracle.graal.compiler.common.GraalOptions.VerifyHeapAtReturn;
 
 import com.oracle.graal.loop.phases.LoopSafepointEliminationPhase;
@@ -53,7 +53,7 @@
 import com.oracle.graal.phases.common.RemoveValueProxyPhase;
 import com.oracle.graal.phases.common.ValueAnchorCleanupPhase;
 import com.oracle.graal.phases.common.VerifyHeapAtReturnPhase;
-import com.oracle.graal.phases.common.query.MidTierReconcileICGPhase;
+import com.oracle.graal.phases.common.instrumentation.MidTierReconcileInstrumentationPhase;
 import com.oracle.graal.phases.tiers.MidTierContext;
 import com.oracle.graal.virtual.phases.ea.EarlyReadEliminationPhase;
 
@@ -115,8 +115,8 @@
         }
 
         appendPhase(new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.MID_TIER));
-        if (UseGraalQueries.getValue()) {
-            appendPhase(new MidTierReconcileICGPhase());
+        if (UseGraalInstrumentation.getValue()) {
+            appendPhase(new MidTierReconcileInstrumentationPhase());
         }
 
         appendPhase(new FrameStateAssignmentPhase());
--- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/query/DelimitationAPI.java	Tue Oct 06 16:52:56 2015 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2015, 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.debug.query;
-
-public class DelimitationAPI {
-
-    /**
-     * Marks the beginning of the instrumentation boundary. - The target parameter indicates whether
-     * to associate the instrumentation with the preceding or the following base program IR node.
-     * Supported values are -1 (predecessor), 1 (successor)}.
-     */
-    public static void instrumentationBegin(@SuppressWarnings("unused") int offset) {
-    }
-
-    public static void instrumentationBegin(@SuppressWarnings("unused") int offset, @SuppressWarnings("unused") int type) {
-    }
-
-    /**
-     * Marks the end of the instrumentation boundary.
-     */
-    public static void instrumentationEnd() {
-    }
-
-}
--- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/query/GraalQueryAPI.java	Tue Oct 06 16:52:56 2015 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,79 +0,0 @@
-/*
- * Copyright (c) 2015, 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.debug.query;
-
-/**
- * NOTE that these queries return fixed constants in the interpreter mode. The Graal option
- * RemoveNeverExecutedCode is switched off to prevent de-optimization.
- */
-public final class GraalQueryAPI {
-
-    // Static query intrinsics
-
-    /**
-     * @return true if the enclosing method has been compiled by the dynamic compiler.
-     */
-    public static boolean isMethodCompiled() {
-        return false;
-    }
-
-    /**
-     * @return true if the enclosing method is inlined.
-     */
-    public static boolean isMethodInlined() {
-        return false;
-    }
-
-    /**
-     * @return the name of the root method for the current compilation task. If the enclosing method
-     *         is inlined, this query returns the name of the method into which it is inlined.
-     */
-    public static String getRootName() {
-        return "unknown";
-    }
-
-    // Dynamic query intrinsics
-
-    public static final int ERROR = -1;
-
-    /**
-     * @return the kind of heap allocation for a directly preceding allocation site. The possible
-     *         return values are {ERROR(-1), TLAB(0), HEAP(1)}. While ERROR denotes either the
-     *         utility is not supported, e.g. in interpreter, or if the allocation site was
-     *         eliminated, the other two represent a TLAB allocation (fast path) or a direct heap
-     *         allocation (slow path).
-     */
-    public static int getAllocationType() {
-        return ERROR;
-    }
-
-    /**
-     * @return the runtime lock type for a directly preceding lock site. The possible return values
-     *         are {ERROR(-1), bias:existing(0), bias:acquired(1), bias:transfer(2),
-     *         stub:revoke_or_stub:epoch-expired(3), stub:failed-cas(4), recursive(5), cas(6)}.
-     */
-    public static int getLockType() {
-        return ERROR;
-    }
-
-}
--- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/query/SpecialIntrinsicGuard.java	Tue Oct 06 16:52:56 2015 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2015, 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.debug.query;
-
-import jdk.internal.jvmci.meta.ResolvedJavaMethod;
-
-public class SpecialIntrinsicGuard {
-
-    public static final String CN_DELIMITATIONAPI = DelimitationAPI.class.getName();
-    public static final String CN_GRAALQUERYAPI = GraalQueryAPI.class.getName();
-
-    public static boolean isQueryIntrinsic(ResolvedJavaMethod method) {
-        String klass = method.getDeclaringClass().toJavaName();
-        return CN_DELIMITATIONAPI.equals(klass) || CN_GRAALQUERYAPI.equals(klass);
-    }
-
-}
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalCompiler.java	Tue Oct 06 16:52:56 2015 -0700
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalCompiler.java	Tue Oct 06 18:44:23 2015 -0700
@@ -46,7 +46,6 @@
 import com.oracle.graal.debug.TTY;
 import com.oracle.graal.debug.TopLevelDebugConfig;
 import com.oracle.graal.debug.internal.DebugScope;
-import com.oracle.graal.debug.query.SpecialIntrinsicGuard;
 import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration;
 import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration.Plugins;
 import com.oracle.graal.graphbuilderconf.IntrinsicContext;
@@ -109,9 +108,7 @@
         HotSpotBackend backend = graalRuntime.getHostBackend();
         HotSpotProviders providers = backend.getProviders();
         final boolean isOSR = entryBCI != Compiler.INVOCATION_ENTRY_BCI;
-        // avoid compiling the intrinsic graphs for GraalQueryAPI methods
-        boolean bypassIntrinsic = method.isNative() || isOSR || SpecialIntrinsicGuard.isQueryIntrinsic(method);
-        StructuredGraph graph = bypassIntrinsic ? null : getIntrinsicGraph(method, providers);
+        StructuredGraph graph = method.isNative() || isOSR ? null : getIntrinsicGraph(method, providers);
 
         if (graph == null) {
             SpeculationLog speculationLog = method.getSpeculationLog();
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/DefaultHotSpotLoweringProvider.java	Tue Oct 06 16:52:56 2015 -0700
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/DefaultHotSpotLoweringProvider.java	Tue Oct 06 18:44:23 2015 -0700
@@ -86,6 +86,7 @@
 import com.oracle.graal.hotspot.replacements.LoadExceptionObjectSnippets;
 import com.oracle.graal.hotspot.replacements.MonitorSnippets;
 import com.oracle.graal.hotspot.replacements.NewObjectSnippets;
+import com.oracle.graal.hotspot.replacements.RuntimeStringSnippets;
 import com.oracle.graal.hotspot.replacements.UnsafeLoadSnippets;
 import com.oracle.graal.hotspot.replacements.WriteBarrierSnippets;
 import com.oracle.graal.hotspot.replacements.arraycopy.ArrayCopyNode;
@@ -111,6 +112,7 @@
 import com.oracle.graal.nodes.calc.RemNode;
 import com.oracle.graal.nodes.calc.UnsignedDivNode;
 import com.oracle.graal.nodes.calc.UnsignedRemNode;
+import com.oracle.graal.nodes.debug.RuntimeStringNode;
 import com.oracle.graal.nodes.debug.VerifyHeapNode;
 import com.oracle.graal.nodes.extended.BytecodeExceptionNode;
 import com.oracle.graal.nodes.extended.ForeignCallNode;
@@ -166,6 +168,7 @@
     protected UnsafeLoadSnippets.Templates unsafeLoadSnippets;
     protected AssertionSnippets.Templates assertionSnippets;
     protected ArrayCopySnippets.Templates arraycopySnippets;
+    protected RuntimeStringSnippets.Templates runtimeStringSnippets;
 
     public DefaultHotSpotLoweringProvider(HotSpotGraalRuntimeProvider runtime, MetaAccessProvider metaAccess, ForeignCallsProvider foreignCalls, HotSpotRegistersProvider registers,
                     ConstantReflectionProvider constantReflection, TargetDescription target) {
@@ -189,6 +192,7 @@
         unsafeLoadSnippets = new UnsafeLoadSnippets.Templates(providers, target);
         assertionSnippets = new AssertionSnippets.Templates(providers, target);
         arraycopySnippets = new ArrayCopySnippets.Templates(providers, target);
+        runtimeStringSnippets = new RuntimeStringSnippets.Templates(providers, target);
         providers.getReplacements().registerSnippetTemplateCache(new UnsafeArrayCopySnippets.Templates(providers, target));
     }
 
@@ -277,6 +281,8 @@
             exceptionObjectSnippets.lower((LoadExceptionObjectNode) n, registers, tool);
         } else if (n instanceof AssertionNode) {
             assertionSnippets.lower((AssertionNode) n, tool);
+        } else if (n instanceof RuntimeStringNode) {
+            runtimeStringSnippets.lower((RuntimeStringNode) n, tool);
         } else if (n instanceof IntegerDivNode || n instanceof IntegerRemNode || n instanceof UnsignedDivNode || n instanceof UnsignedRemNode) {
             // Nothing to do for division nodes. The HotSpot signal handler catches divisions by
             // zero and the MIN_VALUE / -1 cases.
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/DelimitationAPISubstitutions.java	Tue Oct 06 16:52:56 2015 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2015, 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.replacements;
-
-import com.oracle.graal.api.replacements.ClassSubstitution;
-import com.oracle.graal.api.replacements.MethodSubstitution;
-import com.oracle.graal.debug.query.DelimitationAPI;
-import com.oracle.graal.phases.common.query.nodes.InstrumentationBeginNode;
-import com.oracle.graal.phases.common.query.nodes.InstrumentationEndNode;
-
-@ClassSubstitution(DelimitationAPI.class)
-public class DelimitationAPISubstitutions {
-
-    @MethodSubstitution(isStatic = true)
-    public static void instrumentationBegin(int target) {
-        InstrumentationBeginNode.instantiate(target, 0);
-    }
-
-    @MethodSubstitution(isStatic = true)
-    public static void instrumentationBegin(int target, int type) {
-        InstrumentationBeginNode.instantiate(target, type);
-    }
-
-    @MethodSubstitution(isStatic = true)
-    public static void instrumentationEnd() {
-        InstrumentationEndNode.instantiate();
-    }
-
-}
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/GraalQueryAPISubstitutions.java	Tue Oct 06 16:52:56 2015 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 2015, 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.replacements;
-
-import com.oracle.graal.api.replacements.ClassSubstitution;
-import com.oracle.graal.api.replacements.MethodSubstitution;
-import com.oracle.graal.debug.query.GraalQueryAPI;
-import com.oracle.graal.hotspot.replacements.query.GetRootNameNode;
-import com.oracle.graal.hotspot.replacements.query.GetRuntimePathNode;
-import com.oracle.graal.hotspot.replacements.query.IsMethodInlinedNode;
-
-@ClassSubstitution(GraalQueryAPI.class)
-public class GraalQueryAPISubstitutions {
-
-    @MethodSubstitution(isStatic = true)
-    public static boolean isMethodCompiled() {
-        return true;
-    }
-
-    @MethodSubstitution(isStatic = true)
-    public static boolean isMethodInlined() {
-        return IsMethodInlinedNode.instantiate();
-    }
-
-    @MethodSubstitution(isStatic = true)
-    public static String getRootName() {
-        return GetRootNameNode.instantiate();
-    }
-
-    @MethodSubstitution(isStatic = true)
-    public static int getAllocationType() {
-        return GetRuntimePathNode.instantiate();
-    }
-
-    @MethodSubstitution(isStatic = true)
-    public static int getLockType() {
-        return GetRuntimePathNode.instantiate();
-    }
-
-}
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HotSpotSubstitutions.java	Tue Oct 06 16:52:56 2015 -0700
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HotSpotSubstitutions.java	Tue Oct 06 18:44:23 2015 -0700
@@ -22,20 +22,17 @@
  */
 package com.oracle.graal.hotspot.replacements;
 
-import static com.oracle.graal.compiler.common.GraalOptions.UseGraalQueries;
+import com.oracle.graal.api.replacements.SnippetReflectionProvider;
+import com.oracle.graal.nodes.spi.LoweringProvider;
+import com.oracle.graal.nodes.spi.Replacements;
+import com.oracle.graal.nodes.spi.ReplacementsProvider;
+
 import jdk.internal.jvmci.code.TargetDescription;
 import jdk.internal.jvmci.meta.MetaAccessProvider;
 import jdk.internal.jvmci.service.ServiceProvider;
 import sun.reflect.ConstantPool;
 import sun.reflect.Reflection;
 
-import com.oracle.graal.api.replacements.SnippetReflectionProvider;
-import com.oracle.graal.debug.query.DelimitationAPI;
-import com.oracle.graal.debug.query.GraalQueryAPI;
-import com.oracle.graal.nodes.spi.LoweringProvider;
-import com.oracle.graal.nodes.spi.Replacements;
-import com.oracle.graal.nodes.spi.ReplacementsProvider;
-
 @ServiceProvider(ReplacementsProvider.class)
 public class HotSpotSubstitutions implements ReplacementsProvider {
 
@@ -45,9 +42,5 @@
         replacements.registerSubstitutions(Thread.class, ThreadSubstitutions.class);
         replacements.registerSubstitutions(Reflection.class, ReflectionSubstitutions.class);
         replacements.registerSubstitutions(ConstantPool.class, ConstantPoolSubstitutions.class);
-        if (UseGraalQueries.getValue()) {
-            replacements.registerSubstitutions(GraalQueryAPI.class, GraalQueryAPISubstitutions.class);
-            replacements.registerSubstitutions(DelimitationAPI.class, DelimitationAPISubstitutions.class);
-        }
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/RuntimeStringSnippets.java	Tue Oct 06 18:44:23 2015 -0700
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2012, 2015, 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.replacements;
+
+import static com.oracle.graal.hotspot.replacements.UnsafeAccess.UNSAFE;
+import static com.oracle.graal.replacements.SnippetTemplate.DEFAULT_REPLACER;
+
+import com.oracle.graal.api.replacements.Fold;
+import com.oracle.graal.graph.Node.ConstantNodeParameter;
+import com.oracle.graal.graph.Node.NodeIntrinsic;
+import com.oracle.graal.hotspot.meta.HotSpotProviders;
+import com.oracle.graal.hotspot.nodes.CStringNode;
+import com.oracle.graal.nodes.debug.RuntimeStringNode;
+import com.oracle.graal.nodes.java.NewArrayNode;
+import com.oracle.graal.nodes.java.NewInstanceNode;
+import com.oracle.graal.nodes.spi.LoweringTool;
+import com.oracle.graal.replacements.Snippet;
+import com.oracle.graal.replacements.Snippet.ConstantParameter;
+import com.oracle.graal.replacements.SnippetTemplate;
+import com.oracle.graal.replacements.SnippetTemplate.AbstractTemplates;
+import com.oracle.graal.replacements.SnippetTemplate.Arguments;
+import com.oracle.graal.replacements.SnippetTemplate.SnippetInfo;
+import com.oracle.graal.replacements.Snippets;
+import com.oracle.graal.word.Word;
+
+import jdk.internal.jvmci.code.TargetDescription;
+import jdk.internal.jvmci.common.JVMCIError;
+
+public class RuntimeStringSnippets implements Snippets {
+
+    @Fold
+    private static long valueOffset() {
+        try {
+            return UNSAFE.objectFieldOffset(String.class.getDeclaredField("value"));
+        } catch (Exception e) {
+            throw new JVMCIError(e);
+        }
+    }
+
+    @Fold
+    private static long hashOffset() {
+        try {
+            return UNSAFE.objectFieldOffset(String.class.getDeclaredField("hash"));
+        } catch (Exception e) {
+            throw new JVMCIError(e);
+        }
+    }
+
+    @Fold
+    private static long arrayBaseOffset() {
+        return UNSAFE.arrayBaseOffset(char[].class);
+    }
+
+    @Snippet
+    public static String create(@ConstantParameter String compilationTimeString) {
+        int i = compilationTimeString.length();
+        char[] array = (char[]) NewArrayNode.newUninitializedArray(char.class, i);
+        Word cArray = CStringNode.cstring(compilationTimeString);
+        while (i-- > 0) {
+            // assuming it is ASCII string
+            // array[i] = (char) cArray.readByte(i);
+            UNSAFE.putChar(array, arrayBaseOffset() + i * 2, (char) cArray.readByte(i));
+        }
+        String newString = (String) newInstance(String.class, false);
+        UNSAFE.putObject(newString, valueOffset(), array);
+        UNSAFE.putInt(newString, hashOffset(), 0);
+        return newString;
+    }
+
+    @NodeIntrinsic(NewInstanceNode.class)
+    public static native Object newInstance(@ConstantNodeParameter Class<?> type, @ConstantNodeParameter boolean fillContent);
+
+    public static class Templates extends AbstractTemplates {
+
+        private final SnippetInfo create = snippet(RuntimeStringSnippets.class, "create");
+
+        public Templates(HotSpotProviders providers, TargetDescription target) {
+            super(providers, providers.getSnippetReflection(), target);
+        }
+
+        public void lower(RuntimeStringNode runtimeStringNode, LoweringTool tool) {
+            Arguments args = new Arguments(create, runtimeStringNode.graph().getGuardsStage(), tool.getLoweringStage());
+            args.addConst("value", runtimeStringNode.getValue());
+            SnippetTemplate template = template(args);
+            template.instantiate(providers.getMetaAccess(), runtimeStringNode, DEFAULT_REPLACER, args);
+        }
+
+    }
+
+}
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/query/GetRootNameNode.java	Tue Oct 06 16:52:56 2015 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,59 +0,0 @@
-/*
- * Copyright (c) 2015, 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.replacements.query;
-
-import jdk.internal.jvmci.hotspot.HotSpotResolvedObjectType;
-import jdk.internal.jvmci.meta.Constant;
-import jdk.internal.jvmci.meta.ConstantReflectionProvider;
-import jdk.internal.jvmci.meta.ResolvedJavaMethod;
-
-import com.oracle.graal.compiler.common.type.StampFactory;
-import com.oracle.graal.graph.NodeClass;
-import com.oracle.graal.nodeinfo.NodeInfo;
-import com.oracle.graal.nodes.ConstantNode;
-import com.oracle.graal.nodes.FixedNode;
-import com.oracle.graal.phases.common.query.nodes.GraalQueryNode;
-import com.oracle.graal.phases.common.query.nodes.InstrumentationNode;
-
-@NodeInfo
-public final class GetRootNameNode extends GraalQueryNode {
-
-    public static final NodeClass<GetRootNameNode> TYPE = NodeClass.create(GetRootNameNode.class);
-
-    public GetRootNameNode() {
-        super(TYPE, StampFactory.exactNonNull(HotSpotResolvedObjectType.fromObjectClass(String.class)));
-    }
-
-    @Override
-    public void onInlineICG(InstrumentationNode instrumentation, FixedNode position, ConstantReflectionProvider constantReflection) {
-        ResolvedJavaMethod method = graph().method();
-        String root = method.getDeclaringClass().toJavaName() + "." + method.getName() + method.getSignature().toMethodDescriptor();
-        Constant constant = constantReflection.forObject(root);
-        ConstantNode constantNode = graph().unique(new ConstantNode(constant, stamp()));
-        graph().replaceFixedWithFloating(this, constantNode);
-    }
-
-    @NodeIntrinsic
-    public static native String instantiate();
-
-}
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/query/GetRuntimePathNode.java	Tue Oct 06 16:52:56 2015 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,86 +0,0 @@
-/*
- * Copyright (c) 2015, 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.replacements.query;
-
-import jdk.internal.jvmci.meta.ConstantReflectionProvider;
-import jdk.internal.jvmci.meta.JavaKind;
-
-import com.oracle.graal.compiler.common.type.StampFactory;
-import com.oracle.graal.graph.Node;
-import com.oracle.graal.graph.NodeClass;
-import com.oracle.graal.graph.NodeFlood;
-import com.oracle.graal.nodeinfo.NodeInfo;
-import com.oracle.graal.nodes.AbstractEndNode;
-import com.oracle.graal.nodes.AbstractMergeNode;
-import com.oracle.graal.nodes.ConstantNode;
-import com.oracle.graal.nodes.FixedNode;
-import com.oracle.graal.nodes.LoopEndNode;
-import com.oracle.graal.nodes.ValuePhiNode;
-import com.oracle.graal.phases.common.query.nodes.GraalQueryNode;
-import com.oracle.graal.phases.common.query.nodes.InstrumentationNode;
-
-@NodeInfo
-public final class GetRuntimePathNode extends GraalQueryNode {
-
-    public static final NodeClass<GetRuntimePathNode> TYPE = NodeClass.create(GetRuntimePathNode.class);
-
-    public GetRuntimePathNode() {
-        super(TYPE, StampFactory.forKind(JavaKind.Int));
-    }
-
-    private static boolean isCFGAccessible(FixedNode from, FixedNode to) {
-        NodeFlood flood = from.graph().createNodeFlood();
-        flood.add(from);
-        for (Node current : flood) {
-            if (current instanceof LoopEndNode) {
-                continue;
-            } else if (current instanceof AbstractEndNode) {
-                flood.add(((AbstractEndNode) current).merge());
-            } else {
-                flood.addAll(current.successors());
-            }
-        }
-        return flood.isMarked(to);
-    }
-
-    @Override
-    public void onInlineICG(InstrumentationNode instrumentation, FixedNode position, ConstantReflectionProvider constantReflection) {
-        if (instrumentation.target() instanceof AbstractMergeNode) {
-            AbstractMergeNode merge = (AbstractMergeNode) instrumentation.target();
-
-            if (isCFGAccessible(merge, position)) {
-                ValuePhiNode phi = graph().addWithoutUnique(new ValuePhiNode(StampFactory.intValue(), merge));
-                for (int i = 0; i < merge.cfgPredecessors().count(); i++) {
-                    phi.addInput(ConstantNode.forInt(i, merge.graph()));
-                }
-                graph().replaceFixedWithFloating(this, phi);
-                return;
-            }
-        }
-        graph().replaceFixedWithFloating(this, ConstantNode.forInt(-1, graph()));
-    }
-
-    @NodeIntrinsic
-    public static native int instantiate();
-
-}
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/query/IsMethodInlinedNode.java	Tue Oct 06 16:52:56 2015 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 2015, 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.replacements.query;
-
-import jdk.internal.jvmci.meta.ConstantReflectionProvider;
-import jdk.internal.jvmci.meta.JavaKind;
-
-import com.oracle.graal.compiler.common.type.StampFactory;
-import com.oracle.graal.graph.NodeClass;
-import com.oracle.graal.nodeinfo.NodeInfo;
-import com.oracle.graal.nodes.ConstantNode;
-import com.oracle.graal.nodes.FixedNode;
-import com.oracle.graal.phases.common.query.nodes.GraalQueryNode;
-import com.oracle.graal.phases.common.query.nodes.InstrumentationNode;
-
-@NodeInfo
-public final class IsMethodInlinedNode extends GraalQueryNode {
-
-    public static final NodeClass<IsMethodInlinedNode> TYPE = NodeClass.create(IsMethodInlinedNode.class);
-
-    protected int original;
-
-    public IsMethodInlinedNode() {
-        super(TYPE, StampFactory.forKind(JavaKind.Boolean));
-    }
-
-    @Override
-    public void onExtractICG(InstrumentationNode instrumentation) {
-        original = System.identityHashCode(instrumentation.graph());
-    }
-
-    @Override
-    public void onInlineICG(InstrumentationNode instrumentation, FixedNode position, ConstantReflectionProvider constantReflection) {
-        graph().replaceFixedWithFloating(this, ConstantNode.forBoolean(original != System.identityHashCode(instrumentation.graph()), graph()));
-    }
-
-    @NodeIntrinsic
-    public static native boolean instantiate();
-
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/debug/RuntimeStringNode.java	Tue Oct 06 18:44:23 2015 -0700
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2015, 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.nodes.debug;
+
+import com.oracle.graal.compiler.common.type.Stamp;
+import com.oracle.graal.graph.NodeClass;
+import com.oracle.graal.nodeinfo.NodeInfo;
+import com.oracle.graal.nodes.FixedWithNextNode;
+import com.oracle.graal.nodes.spi.Lowerable;
+import com.oracle.graal.nodes.spi.LoweringTool;
+
+@NodeInfo
+public final class RuntimeStringNode extends FixedWithNextNode implements Lowerable {
+
+    public static final NodeClass<RuntimeStringNode> TYPE = NodeClass.create(RuntimeStringNode.class);
+
+    private final String value;
+
+    public RuntimeStringNode(String value, Stamp stamp) {
+        super(TYPE, stamp);
+        this.value = value;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    public void lower(LoweringTool tool) {
+        tool.getLowerer().lower(this, tool);
+    }
+
+}
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/InliningUtil.java	Tue Oct 06 16:52:56 2015 -0700
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/InliningUtil.java	Tue Oct 06 18:44:23 2015 -0700
@@ -23,7 +23,7 @@
 package com.oracle.graal.phases.common.inlining;
 
 import static com.oracle.graal.compiler.common.GraalOptions.HotSpotPrintInlining;
-import static com.oracle.graal.compiler.common.GraalOptions.UseGraalQueries;
+import static com.oracle.graal.compiler.common.GraalOptions.UseGraalInstrumentation;
 import static jdk.internal.jvmci.meta.DeoptimizationAction.InvalidateReprofile;
 import static jdk.internal.jvmci.meta.DeoptimizationReason.NullCheckException;
 
@@ -95,7 +95,7 @@
 import com.oracle.graal.nodes.type.StampTool;
 import com.oracle.graal.nodes.util.GraphUtil;
 import com.oracle.graal.phases.common.inlining.info.InlineInfo;
-import com.oracle.graal.phases.common.query.nodes.InstrumentationNode;
+import com.oracle.graal.phases.common.instrumentation.nodes.InstrumentationNode;
 
 public class InliningUtil {
 
@@ -365,7 +365,7 @@
             unwindNode = (UnwindNode) duplicates.get(unwindNode);
         }
 
-        if (UseGraalQueries.getValue()) {
+        if (UseGraalInstrumentation.getValue()) {
             removeAttachedInstrumentation(invoke);
         }
         finishInlining(invoke, graph, firstCFGNode, returnNodes, unwindNode, inlineGraph.getAssumptions(), inlineGraph, canonicalizedNodes);
@@ -761,7 +761,7 @@
 
     // exclude InstrumentationNode for inlining heuristics
     public static int getNodeCount(StructuredGraph graph) {
-        if (UseGraalQueries.getValue()) {
+        if (UseGraalInstrumentation.getValue()) {
             return graph.getNodeCount() - graph.getNodes().filter(InstrumentationNode.class).count();
         } else {
             return graph.getNodeCount();
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/info/MultiTypeGuardInlineInfo.java	Tue Oct 06 16:52:56 2015 -0700
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/info/MultiTypeGuardInlineInfo.java	Tue Oct 06 18:44:23 2015 -0700
@@ -22,7 +22,7 @@
  */
 package com.oracle.graal.phases.common.inlining.info;
 
-import static com.oracle.graal.compiler.common.GraalOptions.UseGraalQueries;
+import static com.oracle.graal.compiler.common.GraalOptions.UseGraalInstrumentation;
 
 import java.util.ArrayList;
 import java.util.Collection;
@@ -243,7 +243,7 @@
         assert invoke.next() == continuation;
         invoke.setNext(null);
         returnMerge.setNext(continuation);
-        if (UseGraalQueries.getValue()) {
+        if (UseGraalInstrumentation.getValue()) {
             InliningUtil.removeAttachedInstrumentation(invoke);
         }
         if (returnValuePhi != null) {
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/info/elem/InlineableGraph.java	Tue Oct 06 16:52:56 2015 -0700
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/info/elem/InlineableGraph.java	Tue Oct 06 18:44:23 2015 -0700
@@ -23,7 +23,7 @@
 package com.oracle.graal.phases.common.inlining.info.elem;
 
 import static com.oracle.graal.compiler.common.GraalOptions.OptCanonicalizer;
-import static com.oracle.graal.compiler.common.GraalOptions.UseGraalQueries;
+import static com.oracle.graal.compiler.common.GraalOptions.UseGraalInstrumentation;
 import static com.oracle.graal.phases.common.DeadCodeEliminationPhase.Optionality.Optional;
 
 import java.util.ArrayList;
@@ -45,7 +45,7 @@
 import com.oracle.graal.phases.common.CanonicalizerPhase;
 import com.oracle.graal.phases.common.DeadCodeEliminationPhase;
 import com.oracle.graal.phases.common.inlining.InliningUtil;
-import com.oracle.graal.phases.common.query.ExtractICGPhase;
+import com.oracle.graal.phases.common.instrumentation.ExtractInstrumentationPhase;
 import com.oracle.graal.phases.graph.FixedNodeProbabilityCache;
 import com.oracle.graal.phases.tiers.HighTierContext;
 
@@ -211,8 +211,8 @@
             }
             assert newGraph.start().next() != null : "graph needs to be populated by the GraphBuilderSuite " + method + ", " + method.canBeInlined();
 
-            if (UseGraalQueries.getValue()) {
-                new ExtractICGPhase().apply(newGraph, context);
+            if (UseGraalInstrumentation.getValue()) {
+                new ExtractInstrumentationPhase().apply(newGraph, context);
             }
             new DeadCodeEliminationPhase(Optional).apply(newGraph);
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/instrumentation/ExtractInstrumentationPhase.java	Tue Oct 06 18:44:23 2015 -0700
@@ -0,0 +1,224 @@
+/*
+ * Copyright (c) 2015, 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.phases.common.instrumentation;
+
+import java.util.Map;
+
+import com.oracle.graal.debug.Debug;
+import com.oracle.graal.graph.Node;
+import com.oracle.graal.graph.NodeBitMap;
+import com.oracle.graal.graph.NodeFlood;
+import com.oracle.graal.graph.NodePosIterator;
+import com.oracle.graal.graph.Position;
+import com.oracle.graal.nodeinfo.InputType;
+import com.oracle.graal.nodes.AbstractEndNode;
+import com.oracle.graal.nodes.AbstractLocalNode;
+import com.oracle.graal.nodes.CallTargetNode;
+import com.oracle.graal.nodes.FixedNode;
+import com.oracle.graal.nodes.FixedWithNextNode;
+import com.oracle.graal.nodes.FrameState;
+import com.oracle.graal.nodes.LoopEndNode;
+import com.oracle.graal.nodes.ParameterNode;
+import com.oracle.graal.nodes.ReturnNode;
+import com.oracle.graal.nodes.StructuredGraph;
+import com.oracle.graal.nodes.ValueNode;
+import com.oracle.graal.nodes.calc.FloatingNode;
+import com.oracle.graal.nodes.java.MonitorEnterNode;
+import com.oracle.graal.nodes.java.MonitorIdNode;
+import com.oracle.graal.nodes.util.GraphUtil;
+import com.oracle.graal.phases.BasePhase;
+import com.oracle.graal.phases.common.DeadCodeEliminationPhase;
+import com.oracle.graal.phases.common.instrumentation.nodes.InstrumentationBeginNode;
+import com.oracle.graal.phases.common.instrumentation.nodes.InstrumentationContentNode;
+import com.oracle.graal.phases.common.instrumentation.nodes.InstrumentationEndNode;
+import com.oracle.graal.phases.common.instrumentation.nodes.InstrumentationNode;
+import com.oracle.graal.phases.common.instrumentation.nodes.MonitorProxyNode;
+import com.oracle.graal.phases.tiers.HighTierContext;
+
+import jdk.internal.jvmci.common.JVMCIError;
+
+public class ExtractInstrumentationPhase extends BasePhase<HighTierContext> {
+
+    @Override
+    protected void run(StructuredGraph graph, HighTierContext context) {
+        for (InstrumentationBeginNode begin : graph.getNodes().filter(InstrumentationBeginNode.class)) {
+            Instrumentation instrumentation = new Instrumentation(begin);
+            InstrumentationNode instrumentationNode = instrumentation.createInstrumentationNode();
+
+            graph.addBeforeFixed(begin, instrumentationNode);
+            Debug.dump(instrumentationNode.instrumentationGraph(), "After extracted instrumentation at " + instrumentation);
+
+            instrumentation.unlink();
+        }
+
+        for (InstrumentationNode instrumentationNode : graph.getNodes().filter(InstrumentationNode.class)) {
+            for (InstrumentationContentNode query : instrumentationNode.instrumentationGraph().getNodes().filter(InstrumentationContentNode.class)) {
+                query.onExtractInstrumentation(instrumentationNode);
+            }
+        }
+    }
+
+    static class Instrumentation {
+
+        protected InstrumentationBeginNode begin;
+        protected InstrumentationEndNode end;
+        protected ValueNode target;
+        protected NodeBitMap nodes;
+
+        public Instrumentation(InstrumentationBeginNode begin) {
+            this.begin = begin;
+
+            resolveInstrumentationNodes();
+            resolveTarget();
+        }
+
+        private static boolean shouldIncludeInput(Node node, NodeBitMap cfgNodes) {
+            if (node instanceof FloatingNode && !(node instanceof AbstractLocalNode)) {
+                NodePosIterator iterator = node.inputs().iterator();
+                while (iterator.hasNext()) {
+                    Position pos = iterator.nextPosition();
+                    if (pos.getInputType() == InputType.Value) {
+                        continue;
+                    }
+                    if (!cfgNodes.isMarked(pos.get(node))) {
+                        return false;
+                    }
+                }
+                return true;
+            }
+            if (node instanceof CallTargetNode || node instanceof MonitorIdNode || node instanceof FrameState) {
+                return true;
+            }
+            return false;
+        }
+
+        private void resolveInstrumentationNodes() {
+            NodeFlood cfgFlood = begin.graph().createNodeFlood();
+            cfgFlood.add(begin.next());
+            for (Node current : cfgFlood) {
+                if (current instanceof InstrumentationEndNode) {
+                    end = (InstrumentationEndNode) current;
+                } else if (current instanceof LoopEndNode) {
+                    // do nothing
+                } else if (current instanceof AbstractEndNode) {
+                    cfgFlood.add(((AbstractEndNode) current).merge());
+                } else {
+                    cfgFlood.addAll(current.successors());
+                }
+            }
+
+            NodeBitMap cfgNodes = cfgFlood.getVisited();
+            NodeFlood dfgFlood = begin.graph().createNodeFlood();
+            dfgFlood.addAll(cfgNodes);
+            for (Node current : dfgFlood) {
+                if (current instanceof FrameState) {
+                    continue;
+                }
+                for (Node input : current.inputs()) {
+                    if (shouldIncludeInput(input, cfgNodes)) {
+                        dfgFlood.add(input);
+                    }
+                }
+            }
+            nodes = dfgFlood.getVisited();
+
+            if (end == null) {
+                // this may be caused by DeoptimizationReason.Unresolved
+                throw JVMCIError.shouldNotReachHere("could not find invocation to instrumentationEnd()");
+            }
+        }
+
+        private void resolveTarget() {
+            int offset = begin.getOffset();
+            if (offset < 0) {
+                Node pred = begin;
+                while (offset < 0) {
+                    pred = pred.predecessor();
+                    if (pred == null || !(pred instanceof FixedNode)) {
+                        target = null;
+                        return;
+                    }
+                    offset++;
+                }
+                target = (FixedNode) pred;
+            } else if (offset > 0) {
+                FixedNode next = end;
+                while (offset > 0) {
+                    next = ((FixedWithNextNode) next).next();
+                    if (next == null || !(next instanceof FixedWithNextNode)) {
+                        target = null;
+                        return;
+                    }
+                    offset--;
+                }
+                target = next;
+            }
+        }
+
+        public InstrumentationNode createInstrumentationNode() {
+            ValueNode newTarget = target;
+            // MonitorEnterNode may be deleted during PEA
+            if (newTarget instanceof MonitorEnterNode) {
+                newTarget = new MonitorProxyNode(newTarget, ((MonitorEnterNode) newTarget).getMonitorId());
+                begin.graph().addWithoutUnique(newTarget);
+            }
+            InstrumentationNode instrumentationNode = new InstrumentationNode(newTarget, begin.getOffset());
+            begin.graph().addWithoutUnique(instrumentationNode);
+            // copy instrumentation nodes to the InstrumentationNode instance
+            StructuredGraph instrumentationGraph = instrumentationNode.instrumentationGraph();
+            Map<Node, Node> replacements = Node.newMap();
+            int index = 0;
+            for (Node current : nodes) {
+                if (current instanceof FrameState) {
+                    continue;
+                }
+                for (Node input : current.inputs()) {
+                    if (!(input instanceof ValueNode)) {
+                        continue;
+                    }
+                    if (!nodes.isMarked(input) && !replacements.containsKey(input)) {
+                        ParameterNode parameter = new ParameterNode(index++, ((ValueNode) input).stamp());
+                        instrumentationGraph.addWithoutUnique(parameter);
+                        replacements.put(input, parameter);
+                        instrumentationNode.addInput(input);
+                    }
+                }
+            }
+            replacements = instrumentationGraph.addDuplicates(nodes, begin.graph(), nodes.count(), replacements);
+            instrumentationGraph.start().setNext((FixedNode) replacements.get(begin.next()));
+            replacements.get(end).replaceAtPredecessor(instrumentationGraph.addWithoutUnique(new ReturnNode(null)));
+
+            new DeadCodeEliminationPhase().apply(instrumentationGraph, false);
+            return instrumentationNode;
+        }
+
+        public void unlink() {
+            FixedNode next = end.next();
+            end.setNext(null);
+            begin.replaceAtPredecessor(next);
+            GraphUtil.killCFG(begin);
+        }
+
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/instrumentation/HighTierReconcileInstrumentationPhase.java	Tue Oct 06 18:44:23 2015 -0700
@@ -0,0 +1,164 @@
+/*
+ * Copyright (c) 2015, 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.phases.common.instrumentation;
+
+import java.util.HashMap;
+import java.util.function.Predicate;
+import java.util.function.Supplier;
+
+import com.oracle.graal.graph.Node;
+import com.oracle.graal.graph.NodeFlood;
+import com.oracle.graal.nodes.AbstractEndNode;
+import com.oracle.graal.nodes.FixedWithNextNode;
+import com.oracle.graal.nodes.LoopEndNode;
+import com.oracle.graal.nodes.StructuredGraph;
+import com.oracle.graal.nodes.ValueNode;
+import com.oracle.graal.nodes.java.AccessMonitorNode;
+import com.oracle.graal.nodes.java.MonitorIdNode;
+import com.oracle.graal.nodes.util.GraphUtil;
+import com.oracle.graal.nodes.virtual.AllocatedObjectNode;
+import com.oracle.graal.nodes.virtual.CommitAllocationNode;
+import com.oracle.graal.nodes.virtual.VirtualObjectNode;
+import com.oracle.graal.phases.Phase;
+import com.oracle.graal.phases.common.instrumentation.nodes.InstrumentationNode;
+import com.oracle.graal.phases.common.instrumentation.nodes.MonitorProxyNode;
+
+public class HighTierReconcileInstrumentationPhase extends Phase {
+
+    @Override
+    protected void run(StructuredGraph graph) {
+        for (CommitAllocationNode commit : graph.getNodes().filter(CommitAllocationNode.class)) {
+            InstrumentationAggregation aggregation = new InstrumentationAggregation(commit);
+
+            for (int objIndex = 0; objIndex < commit.getVirtualObjects().size(); objIndex++) {
+                VirtualObjectNode virtual = commit.getVirtualObjects().get(objIndex);
+                aggregation.duplicateInstrumentationIfMatch(i -> i.target() == virtual, () -> getAllocatedObject(commit, virtual));
+            }
+
+            for (int objIndex = 0; objIndex < commit.getVirtualObjects().size(); objIndex++) {
+                VirtualObjectNode virtual = commit.getVirtualObjects().get(objIndex);
+                for (MonitorIdNode monitorId : commit.getLocks(objIndex)) {
+                    aggregation.duplicateInstrumentationIfMatch(i -> i.target() instanceof MonitorProxyNode && ((MonitorProxyNode) i.target()).getMonitorId() == monitorId, () -> new MonitorProxyNode(
+                                    getAllocatedObject(commit, virtual), monitorId));
+                }
+            }
+        }
+
+        for (InstrumentationNode instrumentationNode : graph.getNodes().filter(InstrumentationNode.class)) {
+            ValueNode target = instrumentationNode.target();
+            if (target instanceof VirtualObjectNode) {
+                // at this point, we can remove InstrumentationNode whose target is still virtual.
+                GraphUtil.unlinkFixedNode(instrumentationNode);
+                instrumentationNode.safeDelete();
+            } else if (target instanceof MonitorProxyNode) {
+                MonitorProxyNode proxy = (MonitorProxyNode) target;
+                if (proxy.target() == null || proxy.target().isDeleted()) {
+                    GraphUtil.unlinkFixedNode(instrumentationNode);
+                    instrumentationNode.safeDelete();
+                } else if (proxy.target() instanceof AccessMonitorNode) {
+                    // unproxify the target of the InstrumentationNode.
+                    instrumentationNode.replaceFirstInput(proxy, proxy.target());
+                }
+            }
+        }
+    }
+
+    class InstrumentationAggregation {
+
+        protected CommitAllocationNode commit;
+        protected FixedWithNextNode insertingLocation;
+
+        public InstrumentationAggregation(CommitAllocationNode commit) {
+            this.commit = commit;
+            this.insertingLocation = commit;
+        }
+
+        public void insert(InstrumentationNode instrumentationNode) {
+            commit.graph().addAfterFixed(insertingLocation, instrumentationNode);
+            insertingLocation = instrumentationNode;
+        }
+
+        public void duplicateInstrumentationIfMatch(Predicate<InstrumentationNode> guard, Supplier<ValueNode> newTargetSupplier) {
+            StructuredGraph graph = commit.graph();
+            for (InstrumentationNode instrumentationNode : graph.getNodes().filter(InstrumentationNode.class)) {
+                // insert instrumentation node only if the CommitAllocationNode is accessible from
+                // the original instrumentation node
+                if (!(isCFGAccessible(instrumentationNode, commit) && guard.test(instrumentationNode))) {
+                    continue;
+                }
+                InstrumentationNode clone = (InstrumentationNode) instrumentationNode.copyWithInputs();
+                ValueNode newTarget = newTargetSupplier.get();
+                if (!newTarget.isAlive()) {
+                    graph.addWithoutUnique(newTarget);
+                }
+                clone.replaceFirstInput(clone.target(), newTarget);
+                updateVirtualInputs(clone);
+                insert(clone);
+            }
+        }
+
+        private void updateVirtualInputs(InstrumentationNode clone) {
+            for (ValueNode input : clone.getWeakDependencies()) {
+                if ((input instanceof VirtualObjectNode) && (commit.getVirtualObjects().contains(input))) {
+                    clone.replaceFirstInput(input, getAllocatedObject(commit, (VirtualObjectNode) input));
+                }
+            }
+        }
+
+    }
+
+    private final HashMap<InstrumentationNode, NodeFlood> cachedNodeFloods = new HashMap<>();
+
+    private boolean isCFGAccessible(InstrumentationNode from, CommitAllocationNode to) {
+        // we only insert InstrumentationNode during this phase, so it is fine to reuse cached
+        // NodeFlood.
+        NodeFlood flood = cachedNodeFloods.get(from);
+        if (flood == null) {
+            flood = from.graph().createNodeFlood();
+            flood.add(from);
+            for (Node current : flood) {
+                if (current instanceof LoopEndNode) {
+                    continue;
+                } else if (current instanceof AbstractEndNode) {
+                    flood.add(((AbstractEndNode) current).merge());
+                } else {
+                    flood.addAll(current.successors());
+                }
+            }
+            cachedNodeFloods.put(from, flood);
+        }
+        return flood.isMarked(to);
+    }
+
+    private static AllocatedObjectNode getAllocatedObject(CommitAllocationNode commit, VirtualObjectNode virtual) {
+        for (AllocatedObjectNode object : commit.graph().getNodes().filter(AllocatedObjectNode.class)) {
+            if (object.getCommit() == commit && object.getVirtualObject() == virtual) {
+                return object;
+            }
+        }
+        AllocatedObjectNode object = commit.graph().addWithoutUnique(new AllocatedObjectNode(virtual));
+        object.setCommit(commit);
+        return object;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/instrumentation/InlineInstrumentationPhase.java	Tue Oct 06 18:44:23 2015 -0700
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2015, 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.phases.common.instrumentation;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import com.oracle.graal.nodeinfo.InputType;
+import com.oracle.graal.nodes.StructuredGraph;
+import com.oracle.graal.nodes.memory.MemoryAnchorNode;
+import com.oracle.graal.nodes.spi.LoweringTool;
+import com.oracle.graal.nodes.util.GraphUtil;
+import com.oracle.graal.phases.BasePhase;
+import com.oracle.graal.phases.common.CanonicalizerPhase;
+import com.oracle.graal.phases.common.FloatingReadPhase;
+import com.oracle.graal.phases.common.FrameStateAssignmentPhase;
+import com.oracle.graal.phases.common.GuardLoweringPhase;
+import com.oracle.graal.phases.common.LoweringPhase;
+import com.oracle.graal.phases.common.instrumentation.nodes.InstrumentationContentNode;
+import com.oracle.graal.phases.common.instrumentation.nodes.InstrumentationNode;
+import com.oracle.graal.phases.tiers.LowTierContext;
+
+public class InlineInstrumentationPhase extends BasePhase<LowTierContext> {
+
+    @Override
+    protected void run(StructuredGraph graph, LowTierContext context) {
+        // instrumentation may be shared amongst multiple InstrumentationNode
+        Set<StructuredGraph> instrumentationGraphs = new HashSet<>();
+        for (InstrumentationNode instrumentationNode : graph.getNodes().filter(InstrumentationNode.class)) {
+            instrumentationGraphs.add(instrumentationNode.instrumentationGraph());
+        }
+        for (StructuredGraph instrumentation : instrumentationGraphs) {
+            new GuardLoweringPhase().apply(instrumentation, null);
+            new FrameStateAssignmentPhase().apply(instrumentation, false);
+            new LoweringPhase(new CanonicalizerPhase(), LoweringTool.StandardLoweringStage.LOW_TIER).apply(instrumentation, context);
+            new FloatingReadPhase(true, true).apply(instrumentation, false);
+
+            MemoryAnchorNode anchor = instrumentation.add(new MemoryAnchorNode());
+            instrumentation.start().replaceAtUsages(InputType.Memory, anchor);
+            if (anchor.hasNoUsages()) {
+                anchor.safeDelete();
+            } else {
+                instrumentation.addAfterFixed(instrumentation.start(), anchor);
+            }
+        }
+
+        for (InstrumentationNode instrumentationNode : graph.getNodes().filter(InstrumentationNode.class)) {
+            instrumentationNode.inlineAt(instrumentationNode);
+
+            for (InstrumentationContentNode query : graph.getNodes().filter(InstrumentationContentNode.class)) {
+                query.onInlineInstrumentation(instrumentationNode, instrumentationNode);
+            }
+
+            GraphUtil.unlinkFixedNode(instrumentationNode);
+            instrumentationNode.clearInputs();
+            GraphUtil.killCFG(instrumentationNode);
+        }
+
+        new CanonicalizerPhase().apply(graph, context);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/instrumentation/MidTierReconcileInstrumentationPhase.java	Tue Oct 06 18:44:23 2015 -0700
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2015, 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.phases.common.instrumentation;
+
+import com.oracle.graal.nodes.StructuredGraph;
+import com.oracle.graal.nodes.ValueNode;
+import com.oracle.graal.nodes.extended.FixedValueAnchorNode;
+import com.oracle.graal.nodes.java.RawMonitorEnterNode;
+import com.oracle.graal.nodes.util.GraphUtil;
+import com.oracle.graal.phases.Phase;
+import com.oracle.graal.phases.common.instrumentation.nodes.InstrumentationNode;
+import com.oracle.graal.phases.common.instrumentation.nodes.MonitorProxyNode;
+
+public class MidTierReconcileInstrumentationPhase extends Phase {
+
+    private static RawMonitorEnterNode unproxify(MonitorProxyNode proxy) {
+        for (RawMonitorEnterNode monitorEnter : proxy.getMonitorId().usages().filter(RawMonitorEnterNode.class)) {
+            if (monitorEnter.object() == proxy.target()) {
+                return monitorEnter;
+            }
+        }
+        return null;
+    }
+
+    @Override
+    protected void run(StructuredGraph graph) {
+        for (InstrumentationNode instrumentationNode : graph.getNodes().filter(InstrumentationNode.class)) {
+            instrumentationNode.onMidTierReconcileInstrumentation();
+            ValueNode target = instrumentationNode.target();
+            if (target instanceof MonitorProxyNode) {
+                instrumentationNode.replaceFirstInput(target, unproxify((MonitorProxyNode) target));
+            } else if (target instanceof FixedValueAnchorNode) {
+                instrumentationNode.replaceFirstInput(target, GraphUtil.unproxify(target));
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/instrumentation/nodes/InstrumentationBeginNode.java	Tue Oct 06 18:44:23 2015 -0700
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2015, 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.phases.common.instrumentation.nodes;
+
+import com.oracle.graal.compiler.common.type.StampFactory;
+import com.oracle.graal.graph.NodeClass;
+import com.oracle.graal.nodeinfo.NodeInfo;
+import com.oracle.graal.nodes.ConstantNode;
+import com.oracle.graal.nodes.FixedWithNextNode;
+import com.oracle.graal.nodes.ValueNode;
+
+import jdk.internal.jvmci.common.JVMCIError;
+import jdk.internal.jvmci.meta.JavaConstant;
+
+@NodeInfo
+public final class InstrumentationBeginNode extends FixedWithNextNode {
+
+    public static final NodeClass<InstrumentationBeginNode> TYPE = NodeClass.create(InstrumentationBeginNode.class);
+
+    private final int offset;
+
+    public InstrumentationBeginNode(ValueNode offset) {
+        super(TYPE, StampFactory.forVoid());
+
+        if (!(offset instanceof ConstantNode)) {
+            throw JVMCIError.shouldNotReachHere("should pass constant integer to instrumentationBegin(int)");
+        }
+
+        ConstantNode constantNode = (ConstantNode) offset;
+        JavaConstant constant = (JavaConstant) constantNode.asConstant();
+        this.offset = constant.asInt();
+    }
+
+    public int getOffset() {
+        return offset;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/instrumentation/nodes/InstrumentationContentNode.java	Tue Oct 06 18:44:23 2015 -0700
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2015, 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.phases.common.instrumentation.nodes;
+
+import com.oracle.graal.compiler.common.type.Stamp;
+import com.oracle.graal.graph.NodeClass;
+import com.oracle.graal.nodeinfo.NodeInfo;
+import com.oracle.graal.nodes.FixedNode;
+import com.oracle.graal.nodes.FixedWithNextNode;
+
+@NodeInfo
+public abstract class InstrumentationContentNode extends FixedWithNextNode {
+
+    public static final NodeClass<InstrumentationContentNode> TYPE = NodeClass.create(InstrumentationContentNode.class);
+
+    public InstrumentationContentNode(NodeClass<? extends FixedWithNextNode> c, Stamp stamp) {
+        super(c, stamp);
+    }
+
+    public void onExtractInstrumentation(@SuppressWarnings("unused") InstrumentationNode instrumentation) {
+    }
+
+    public void onInlineInstrumentation(@SuppressWarnings("unused") InstrumentationNode instrumentation, @SuppressWarnings("unused") FixedNode position) {
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/instrumentation/nodes/InstrumentationEndNode.java	Tue Oct 06 18:44:23 2015 -0700
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2015, 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.phases.common.instrumentation.nodes;
+
+import com.oracle.graal.compiler.common.type.StampFactory;
+import com.oracle.graal.graph.NodeClass;
+import com.oracle.graal.nodeinfo.NodeInfo;
+import com.oracle.graal.nodes.FixedWithNextNode;
+
+@NodeInfo
+public final class InstrumentationEndNode extends FixedWithNextNode {
+
+    public static final NodeClass<InstrumentationEndNode> TYPE = NodeClass.create(InstrumentationEndNode.class);
+
+    public InstrumentationEndNode() {
+        super(TYPE, StampFactory.forVoid());
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/instrumentation/nodes/InstrumentationNode.java	Tue Oct 06 18:44:23 2015 -0700
@@ -0,0 +1,227 @@
+/*
+ * Copyright (c) 2015, 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.phases.common.instrumentation.nodes;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Map;
+
+import com.oracle.graal.compiler.common.type.StampFactory;
+import com.oracle.graal.graph.Graph.DuplicationReplacement;
+import com.oracle.graal.graph.Node;
+import com.oracle.graal.graph.NodeClass;
+import com.oracle.graal.graph.NodeInputList;
+import com.oracle.graal.nodeinfo.InputType;
+import com.oracle.graal.nodeinfo.NodeInfo;
+import com.oracle.graal.nodes.AbstractBeginNode;
+import com.oracle.graal.nodes.AbstractMergeNode;
+import com.oracle.graal.nodes.ConstantNode;
+import com.oracle.graal.nodes.DeoptimizingFixedWithNextNode;
+import com.oracle.graal.nodes.DeoptimizingNode;
+import com.oracle.graal.nodes.EndNode;
+import com.oracle.graal.nodes.FixedNode;
+import com.oracle.graal.nodes.FrameState;
+import com.oracle.graal.nodes.Invoke;
+import com.oracle.graal.nodes.MergeNode;
+import com.oracle.graal.nodes.ParameterNode;
+import com.oracle.graal.nodes.ReturnNode;
+import com.oracle.graal.nodes.StartNode;
+import com.oracle.graal.nodes.StructuredGraph;
+import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
+import com.oracle.graal.nodes.debug.RuntimeStringNode;
+import com.oracle.graal.nodes.ValueNode;
+import com.oracle.graal.nodes.spi.Virtualizable;
+import com.oracle.graal.nodes.spi.VirtualizerTool;
+import com.oracle.graal.nodes.virtual.EscapeObjectState;
+import com.oracle.graal.nodes.virtual.VirtualObjectNode;
+
+import jdk.internal.jvmci.meta.JavaConstant;
+import jdk.internal.jvmci.meta.JavaKind;
+
+@NodeInfo
+public class InstrumentationNode extends DeoptimizingFixedWithNextNode implements Virtualizable {
+
+    public static final NodeClass<InstrumentationNode> TYPE = NodeClass.create(InstrumentationNode.class);
+
+    @OptionalInput(value = InputType.Association) protected ValueNode target;
+    @OptionalInput protected NodeInputList<ValueNode> weakDependencies;
+
+    protected StructuredGraph instrumentationGraph;
+    protected final int offset;
+
+    public InstrumentationNode(ValueNode target, int offset) {
+        super(TYPE, StampFactory.forVoid());
+
+        this.target = target;
+        this.instrumentationGraph = new StructuredGraph(AllowAssumptions.YES);
+        this.offset = offset;
+
+        this.weakDependencies = new NodeInputList<>(this);
+    }
+
+    public boolean addInput(Node node) {
+        return weakDependencies.add(node);
+    }
+
+    public ValueNode target() {
+        return target;
+    }
+
+    public StructuredGraph instrumentationGraph() {
+        return instrumentationGraph;
+    }
+
+    public int offset() {
+        return offset;
+    }
+
+    public NodeInputList<ValueNode> getWeakDependencies() {
+        return weakDependencies;
+    }
+
+    public void virtualize(VirtualizerTool tool) {
+        // InstrumentationNode allows non-materialized inputs. During the inlining of the
+        // InstrumentationNode, non-materialized inputs will be replaced by null.
+        if (target != null) {
+            ValueNode alias = tool.getAlias(target);
+            if (alias instanceof VirtualObjectNode) {
+                tool.replaceFirstInput(target, alias);
+            }
+        }
+        for (ValueNode input : weakDependencies) {
+            ValueNode alias = tool.getAlias(input);
+            if (alias instanceof VirtualObjectNode) {
+                tool.replaceFirstInput(input, alias);
+            }
+        }
+    }
+
+    public void onMidTierReconcileInstrumentation() {
+        for (RootNameNode rootNameNode : instrumentationGraph.getNodes().filter(RootNameNode.class)) {
+            RuntimeStringNode runtimeString = new RuntimeStringNode(RootNameNode.genRootName(graph().method()), rootNameNode.stamp());
+            instrumentationGraph.addWithoutUnique(runtimeString);
+            instrumentationGraph.replaceFixedWithFixed(rootNameNode, runtimeString);
+        }
+    }
+
+    public void inlineAt(FixedNode position) {
+        ArrayList<Node> nodes = new ArrayList<>(instrumentationGraph.getNodes().count());
+        final StartNode entryPointNode = instrumentationGraph.start();
+        FixedNode firstCFGNode = entryPointNode.next();
+        ArrayList<ReturnNode> returnNodes = new ArrayList<>(4);
+
+        for (Node node : instrumentationGraph.getNodes()) {
+            if (node == entryPointNode || node == entryPointNode.stateAfter() || node instanceof ParameterNode) {
+                // Do nothing.
+            } else {
+                nodes.add(node);
+                if (node instanceof ReturnNode) {
+                    returnNodes.add((ReturnNode) node);
+                }
+            }
+        }
+
+        final AbstractBeginNode prevBegin = AbstractBeginNode.prevBegin(position);
+        DuplicationReplacement localReplacement = new DuplicationReplacement() {
+
+            public Node replacement(Node replacement) {
+                if (replacement instanceof ParameterNode) {
+                    ValueNode value = getWeakDependencies().get(((ParameterNode) replacement).index());
+                    if (value == null || value.isDeleted() || value instanceof VirtualObjectNode || value.stamp().getStackKind() != JavaKind.Object) {
+                        return graph().unique(new ConstantNode(JavaConstant.NULL_POINTER, ((ParameterNode) replacement).stamp()));
+                    } else {
+                        return value;
+                    }
+                } else if (replacement == entryPointNode) {
+                    return prevBegin;
+                }
+                return replacement;
+            }
+
+        };
+
+        Map<Node, Node> duplicates = graph().addDuplicates(nodes, instrumentationGraph, instrumentationGraph.getNodeCount(), localReplacement);
+        FixedNode firstCFGNodeDuplicate = (FixedNode) duplicates.get(firstCFGNode);
+        position.replaceAtPredecessor(firstCFGNodeDuplicate);
+
+        if (!returnNodes.isEmpty()) {
+            if (returnNodes.size() == 1) {
+                ReturnNode returnNode = (ReturnNode) duplicates.get(returnNodes.get(0));
+                returnNode.replaceAndDelete(position);
+            } else {
+                ArrayList<ReturnNode> returnDuplicates = new ArrayList<>(returnNodes.size());
+                for (ReturnNode returnNode : returnNodes) {
+                    returnDuplicates.add((ReturnNode) duplicates.get(returnNode));
+                }
+                AbstractMergeNode merge = graph().add(new MergeNode());
+
+                for (ReturnNode returnNode : returnDuplicates) {
+                    EndNode endNode = graph().add(new EndNode());
+                    merge.addForwardEnd(endNode);
+                    returnNode.replaceAndDelete(endNode);
+                }
+
+                merge.setNext(position);
+            }
+        }
+
+        // since we may relocate InstrumentationNodes, the FrameState can be invalid
+        for (Node replacee : duplicates.values()) {
+            if (replacee instanceof FrameState) {
+                FrameState oldState = (FrameState) replacee;
+                FrameState newState = new FrameState(null, oldState.method(), oldState.bci, 0, 0, 0, oldState.rethrowException(), oldState.duringCall(), null,
+                                Collections.<EscapeObjectState> emptyList());
+                graph().addWithoutUnique(newState);
+                oldState.replaceAtUsages(newState);
+            }
+        }
+
+        for (Node replacee : duplicates.values()) {
+            // we cannot assign a random FrameState with valid bci to Invoke because it is used for
+            // resolving virtual call at runtime.
+            if (replacee instanceof DeoptimizingNode && !(replacee instanceof Invoke)) {
+                DeoptimizingNode deoptDup = (DeoptimizingNode) replacee;
+                if (deoptDup.canDeoptimize()) {
+                    if (deoptDup instanceof DeoptimizingNode.DeoptBefore) {
+                        ((DeoptimizingNode.DeoptBefore) deoptDup).setStateBefore(stateBefore());
+                    }
+                    if (deoptDup instanceof DeoptimizingNode.DeoptDuring) {
+                        DeoptimizingNode.DeoptDuring deoptDupDuring = (DeoptimizingNode.DeoptDuring) deoptDup;
+                        assert !deoptDupDuring.hasSideEffect() : "can't use stateBefore as stateDuring for state split " + deoptDupDuring;
+                        deoptDupDuring.setStateDuring(stateBefore());
+                    }
+                    if (deoptDup instanceof DeoptimizingNode.DeoptAfter) {
+                        DeoptimizingNode.DeoptAfter deoptDupAfter = (DeoptimizingNode.DeoptAfter) deoptDup;
+                        assert !deoptDupAfter.hasSideEffect() : "can't use stateBefore as stateAfter for state split " + deoptDupAfter;
+                        deoptDupAfter.setStateAfter(stateBefore());
+                    }
+                }
+            }
+        }
+    }
+
+    public boolean canDeoptimize() {
+        return true;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/instrumentation/nodes/IsMethodInlinedNode.java	Tue Oct 06 18:44:23 2015 -0700
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2015, 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.phases.common.instrumentation.nodes;
+
+import com.oracle.graal.compiler.common.type.StampFactory;
+import com.oracle.graal.graph.NodeClass;
+import com.oracle.graal.nodeinfo.NodeInfo;
+import com.oracle.graal.nodes.ConstantNode;
+import com.oracle.graal.nodes.FixedNode;
+
+import jdk.internal.jvmci.meta.JavaKind;
+
+@NodeInfo
+public final class IsMethodInlinedNode extends InstrumentationContentNode {
+
+    public static final NodeClass<IsMethodInlinedNode> TYPE = NodeClass.create(IsMethodInlinedNode.class);
+
+    protected int original;
+
+    public IsMethodInlinedNode() {
+        super(TYPE, StampFactory.forKind(JavaKind.Boolean));
+    }
+
+    @Override
+    public void onExtractInstrumentation(InstrumentationNode instrumentation) {
+        original = System.identityHashCode(instrumentation.graph());
+    }
+
+    @Override
+    public void onInlineInstrumentation(InstrumentationNode instrumentation, FixedNode position) {
+        graph().replaceFixedWithFloating(this, ConstantNode.forBoolean(original != System.identityHashCode(instrumentation.graph()), graph()));
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/instrumentation/nodes/MonitorProxyNode.java	Tue Oct 06 18:44:23 2015 -0700
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2015, 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.phases.common.instrumentation.nodes;
+
+import com.oracle.graal.compiler.common.type.StampFactory;
+import com.oracle.graal.graph.NodeClass;
+import com.oracle.graal.nodeinfo.InputType;
+import com.oracle.graal.nodeinfo.NodeInfo;
+import com.oracle.graal.nodes.ValueNode;
+import com.oracle.graal.nodes.java.MonitorIdNode;
+
+@NodeInfo
+public class MonitorProxyNode extends ValueNode {
+
+    public static final NodeClass<MonitorProxyNode> TYPE = NodeClass.create(MonitorProxyNode.class);
+
+    @OptionalInput(value = InputType.Association) protected ValueNode target;
+    @OptionalInput(value = InputType.Association) protected MonitorIdNode monitorId;
+
+    public MonitorProxyNode(ValueNode target, MonitorIdNode monitorId) {
+        super(TYPE, StampFactory.forVoid());
+
+        this.target = target;
+        this.monitorId = monitorId;
+    }
+
+    public ValueNode target() {
+        return target;
+    }
+
+    public MonitorIdNode getMonitorId() {
+        return monitorId;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/instrumentation/nodes/RootNameNode.java	Tue Oct 06 18:44:23 2015 -0700
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2015, 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.phases.common.instrumentation.nodes;
+
+import com.oracle.graal.compiler.common.type.Stamp;
+import com.oracle.graal.graph.NodeClass;
+import com.oracle.graal.nodeinfo.NodeInfo;
+import com.oracle.graal.nodes.FixedNode;
+import com.oracle.graal.nodes.debug.RuntimeStringNode;
+import com.oracle.graal.nodes.spi.Lowerable;
+import com.oracle.graal.nodes.spi.LoweringTool;
+
+import jdk.internal.jvmci.common.JVMCIError;
+import jdk.internal.jvmci.meta.ResolvedJavaMethod;
+
+@NodeInfo
+public final class RootNameNode extends InstrumentationContentNode implements Lowerable {
+
+    public static final NodeClass<RootNameNode> TYPE = NodeClass.create(RootNameNode.class);
+
+    public RootNameNode(Stamp stamp) {
+        super(TYPE, stamp);
+    }
+
+    public static String genRootName(ResolvedJavaMethod method) {
+        if (method == null) {
+            return "<unresolved method>";
+        }
+        return method.getDeclaringClass().toJavaName() + "." + method.getName() + method.getSignature().toMethodDescriptor();
+    }
+
+    public void lower(LoweringTool tool) {
+        RuntimeStringNode runtimeString = graph().add(new RuntimeStringNode(genRootName(graph().method()), stamp()));
+        graph().replaceFixedWithFixed(this, runtimeString);
+    }
+
+    @Override
+    public void onInlineInstrumentation(InstrumentationNode instrumentation, FixedNode position) {
+        throw JVMCIError.shouldNotReachHere("RootNameNode must be replaced before inlining an instrumentation");
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/instrumentation/nodes/RuntimePathNode.java	Tue Oct 06 18:44:23 2015 -0700
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2015, 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.phases.common.instrumentation.nodes;
+
+import com.oracle.graal.compiler.common.type.StampFactory;
+import com.oracle.graal.graph.Node;
+import com.oracle.graal.graph.NodeClass;
+import com.oracle.graal.graph.NodeFlood;
+import com.oracle.graal.nodeinfo.NodeInfo;
+import com.oracle.graal.nodes.AbstractEndNode;
+import com.oracle.graal.nodes.AbstractMergeNode;
+import com.oracle.graal.nodes.ConstantNode;
+import com.oracle.graal.nodes.FixedNode;
+import com.oracle.graal.nodes.LoopEndNode;
+import com.oracle.graal.nodes.ValuePhiNode;
+
+import jdk.internal.jvmci.meta.JavaKind;
+
+@NodeInfo
+public final class RuntimePathNode extends InstrumentationContentNode {
+
+    public static final NodeClass<RuntimePathNode> TYPE = NodeClass.create(RuntimePathNode.class);
+
+    public RuntimePathNode() {
+        super(TYPE, StampFactory.forKind(JavaKind.Int));
+    }
+
+    private static boolean isCFGAccessible(FixedNode from, FixedNode to) {
+        NodeFlood flood = from.graph().createNodeFlood();
+        flood.add(from);
+        for (Node current : flood) {
+            if (current instanceof LoopEndNode) {
+                continue;
+            } else if (current instanceof AbstractEndNode) {
+                flood.add(((AbstractEndNode) current).merge());
+            } else {
+                flood.addAll(current.successors());
+            }
+        }
+        return flood.isMarked(to);
+    }
+
+    @Override
+    public void onInlineInstrumentation(InstrumentationNode instrumentation, FixedNode position) {
+        if (instrumentation.target() instanceof AbstractMergeNode) {
+            AbstractMergeNode merge = (AbstractMergeNode) instrumentation.target();
+
+            if (isCFGAccessible(merge, position)) {
+                ValuePhiNode phi = graph().addWithoutUnique(new ValuePhiNode(StampFactory.intValue(), merge));
+                for (int i = 0; i < merge.cfgPredecessors().count(); i++) {
+                    phi.addInput(ConstantNode.forInt(i, merge.graph()));
+                }
+                graph().replaceFixedWithFloating(this, phi);
+                return;
+            }
+        }
+        graph().replaceFixedWithFloating(this, ConstantNode.forInt(-1, graph()));
+    }
+
+}
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/query/ExtractICGPhase.java	Tue Oct 06 16:52:56 2015 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,217 +0,0 @@
-/*
- * Copyright (c) 2015, 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.phases.common.query;
-
-import java.util.Map;
-
-import com.oracle.graal.debug.Debug;
-import com.oracle.graal.graph.Node;
-import com.oracle.graal.graph.NodeBitMap;
-import com.oracle.graal.graph.NodeFlood;
-import com.oracle.graal.graph.NodePosIterator;
-import com.oracle.graal.graph.Position;
-import com.oracle.graal.nodeinfo.InputType;
-import com.oracle.graal.nodes.AbstractEndNode;
-import com.oracle.graal.nodes.AbstractLocalNode;
-import com.oracle.graal.nodes.CallTargetNode;
-import com.oracle.graal.nodes.FixedNode;
-import com.oracle.graal.nodes.FixedWithNextNode;
-import com.oracle.graal.nodes.FrameState;
-import com.oracle.graal.nodes.LoopEndNode;
-import com.oracle.graal.nodes.ParameterNode;
-import com.oracle.graal.nodes.ReturnNode;
-import com.oracle.graal.nodes.StructuredGraph;
-import com.oracle.graal.nodes.ValueNode;
-import com.oracle.graal.nodes.calc.FloatingNode;
-import com.oracle.graal.nodes.java.MonitorEnterNode;
-import com.oracle.graal.nodes.java.MonitorIdNode;
-import com.oracle.graal.nodes.util.GraphUtil;
-import com.oracle.graal.phases.BasePhase;
-import com.oracle.graal.phases.common.DeadCodeEliminationPhase;
-import com.oracle.graal.phases.common.query.nodes.GraalQueryNode;
-import com.oracle.graal.phases.common.query.nodes.InstrumentationBeginNode;
-import com.oracle.graal.phases.common.query.nodes.InstrumentationEndNode;
-import com.oracle.graal.phases.common.query.nodes.InstrumentationNode;
-import com.oracle.graal.phases.common.query.nodes.MonitorProxyNode;
-import com.oracle.graal.phases.tiers.HighTierContext;
-
-public class ExtractICGPhase extends BasePhase<HighTierContext> {
-
-    @Override
-    protected void run(StructuredGraph graph, HighTierContext context) {
-        for (InstrumentationBeginNode icgBegin : graph.getNodes().filter(InstrumentationBeginNode.class)) {
-            Instrumentation instrumentation = new Instrumentation(icgBegin);
-            InstrumentationNode instrumentationNode = instrumentation.createInstrumentationNode();
-
-            graph.addBeforeFixed(icgBegin, instrumentationNode);
-            Debug.dump(instrumentationNode.icg(), "After extracted ICG at " + instrumentation);
-
-            instrumentation.unlink();
-        }
-
-        for (InstrumentationNode instrumentationNode : graph.getNodes().filter(InstrumentationNode.class)) {
-            for (GraalQueryNode query : instrumentationNode.icg().getNodes().filter(GraalQueryNode.class)) {
-                query.onExtractICG(instrumentationNode);
-            }
-        }
-    }
-
-    static class Instrumentation {
-
-        protected InstrumentationBeginNode icgBegin;
-        protected InstrumentationEndNode icgEnd;
-        protected ValueNode target;
-        protected NodeBitMap icgNodes;
-
-        public Instrumentation(InstrumentationBeginNode icgBegin) {
-            this.icgBegin = icgBegin;
-
-            resolveICGNodes();
-            resolveTarget();
-        }
-
-        private static boolean shouldIncludeInput(Node node, NodeBitMap cfgNodes) {
-            if (node instanceof FloatingNode && !(node instanceof AbstractLocalNode)) {
-                NodePosIterator iterator = node.inputs().iterator();
-                while (iterator.hasNext()) {
-                    Position pos = iterator.nextPosition();
-                    if (pos.getInputType() == InputType.Value) {
-                        continue;
-                    }
-                    if (!cfgNodes.isMarked(pos.get(node))) {
-                        return false;
-                    }
-                }
-                return true;
-            }
-            if (node instanceof CallTargetNode || node instanceof MonitorIdNode || node instanceof FrameState) {
-                return true;
-            }
-            return false;
-        }
-
-        private void resolveICGNodes() {
-            NodeFlood icgCFG = icgBegin.graph().createNodeFlood();
-            icgCFG.add(icgBegin.next());
-            for (Node current : icgCFG) {
-                if (current instanceof InstrumentationEndNode) {
-                    icgEnd = (InstrumentationEndNode) current;
-                } else if (current instanceof LoopEndNode) {
-                    // do nothing
-                } else if (current instanceof AbstractEndNode) {
-                    icgCFG.add(((AbstractEndNode) current).merge());
-                } else {
-                    icgCFG.addAll(current.successors());
-                }
-            }
-
-            NodeBitMap cfgNodes = icgCFG.getVisited();
-            NodeFlood icgDFG = icgBegin.graph().createNodeFlood();
-            icgDFG.addAll(cfgNodes);
-            for (Node current : icgDFG) {
-                if (current instanceof FrameState) {
-                    continue;
-                }
-                for (Node input : current.inputs()) {
-                    if (shouldIncludeInput(input, cfgNodes)) {
-                        icgDFG.add(input);
-                    }
-                }
-            }
-            icgNodes = icgDFG.getVisited();
-        }
-
-        private void resolveTarget() {
-            int offset = icgBegin.getOffset();
-            if (offset < 0) {
-                Node pred = icgBegin;
-                while (offset < 0) {
-                    pred = pred.predecessor();
-                    if (pred == null || !(pred instanceof FixedNode)) {
-                        target = null;
-                        return;
-                    }
-                    offset++;
-                }
-                target = (FixedNode) pred;
-            } else if (offset > 0) {
-                FixedNode next = icgEnd;
-                while (offset > 0) {
-                    next = ((FixedWithNextNode) next).next();
-                    if (next == null || !(next instanceof FixedWithNextNode)) {
-                        target = null;
-                        return;
-                    }
-                    offset--;
-                }
-                target = next;
-            }
-        }
-
-        public InstrumentationNode createInstrumentationNode() {
-            ValueNode newTarget = target;
-            // MonitorEnterNode may be deleted during PEA
-            if (newTarget instanceof MonitorEnterNode) {
-                newTarget = new MonitorProxyNode(newTarget, ((MonitorEnterNode) newTarget).getMonitorId());
-                icgBegin.graph().addWithoutUnique(newTarget);
-            }
-            InstrumentationNode instrumentationNode = new InstrumentationNode(newTarget, icgBegin.getOffset(), icgBegin.getType());
-            icgBegin.graph().addWithoutUnique(instrumentationNode);
-            // copy icg nodes to the InstrumentationNode instance
-            StructuredGraph icg = instrumentationNode.icg();
-            Map<Node, Node> replacements = Node.newMap();
-            int index = 0;
-            for (Node current : icgNodes) {
-                if (current instanceof FrameState) {
-                    continue;
-                }
-                for (Node input : current.inputs()) {
-                    if (!(input instanceof ValueNode)) {
-                        continue;
-                    }
-                    if (!icgNodes.isMarked(input) && !replacements.containsKey(input)) {
-                        ParameterNode parameter = new ParameterNode(index++, ((ValueNode) input).stamp());
-                        icg.addWithoutUnique(parameter);
-                        replacements.put(input, parameter);
-                        instrumentationNode.addInput(input);
-                    }
-                }
-            }
-            replacements = icg.addDuplicates(icgNodes, icgBegin.graph(), icgNodes.count(), replacements);
-            icg.start().setNext((FixedNode) replacements.get(icgBegin.next()));
-            replacements.get(icgEnd).replaceAtPredecessor(icg.addWithoutUnique(new ReturnNode(null)));
-
-            new DeadCodeEliminationPhase().apply(icg, false);
-            return instrumentationNode;
-        }
-
-        public void unlink() {
-            FixedNode next = icgEnd.next();
-            icgEnd.setNext(null);
-            icgBegin.replaceAtPredecessor(next);
-            GraphUtil.killCFG(icgBegin);
-        }
-
-    }
-
-}
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/query/HighTierReconcileICGPhase.java	Tue Oct 06 16:52:56 2015 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,164 +0,0 @@
-/*
- * Copyright (c) 2015, 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.phases.common.query;
-
-import java.util.HashMap;
-import java.util.function.Predicate;
-import java.util.function.Supplier;
-
-import com.oracle.graal.graph.Node;
-import com.oracle.graal.graph.NodeFlood;
-import com.oracle.graal.nodes.AbstractEndNode;
-import com.oracle.graal.nodes.FixedWithNextNode;
-import com.oracle.graal.nodes.LoopEndNode;
-import com.oracle.graal.nodes.StructuredGraph;
-import com.oracle.graal.nodes.ValueNode;
-import com.oracle.graal.nodes.java.AccessMonitorNode;
-import com.oracle.graal.nodes.java.MonitorIdNode;
-import com.oracle.graal.nodes.util.GraphUtil;
-import com.oracle.graal.nodes.virtual.AllocatedObjectNode;
-import com.oracle.graal.nodes.virtual.CommitAllocationNode;
-import com.oracle.graal.nodes.virtual.VirtualObjectNode;
-import com.oracle.graal.phases.Phase;
-import com.oracle.graal.phases.common.query.nodes.InstrumentationNode;
-import com.oracle.graal.phases.common.query.nodes.MonitorProxyNode;
-
-public class HighTierReconcileICGPhase extends Phase {
-
-    @Override
-    protected void run(StructuredGraph graph) {
-        for (CommitAllocationNode commit : graph.getNodes().filter(CommitAllocationNode.class)) {
-            InstrumentationAggregation aggregation = new InstrumentationAggregation(commit);
-
-            for (int objIndex = 0; objIndex < commit.getVirtualObjects().size(); objIndex++) {
-                VirtualObjectNode virtual = commit.getVirtualObjects().get(objIndex);
-                aggregation.duplicateInstrumentationIfMatch(i -> i.target() == virtual, () -> getAllocatedObject(commit, virtual));
-            }
-
-            for (int objIndex = 0; objIndex < commit.getVirtualObjects().size(); objIndex++) {
-                VirtualObjectNode virtual = commit.getVirtualObjects().get(objIndex);
-                for (MonitorIdNode monitorId : commit.getLocks(objIndex)) {
-                    aggregation.duplicateInstrumentationIfMatch(i -> i.target() instanceof MonitorProxyNode && ((MonitorProxyNode) i.target()).getMonitorId() == monitorId, () -> new MonitorProxyNode(
-                                    getAllocatedObject(commit, virtual), monitorId));
-                }
-            }
-        }
-
-        for (InstrumentationNode instrumentationNode : graph.getNodes().filter(InstrumentationNode.class)) {
-            ValueNode target = instrumentationNode.target();
-            if (target instanceof VirtualObjectNode) {
-                // at this point, we can remove InstrumentationNode whose target is still virtual.
-                GraphUtil.unlinkFixedNode(instrumentationNode);
-                instrumentationNode.safeDelete();
-            } else if (target instanceof MonitorProxyNode) {
-                MonitorProxyNode proxy = (MonitorProxyNode) target;
-                if (proxy.target() == null || proxy.target().isDeleted()) {
-                    GraphUtil.unlinkFixedNode(instrumentationNode);
-                    instrumentationNode.safeDelete();
-                } else if (proxy.target() instanceof AccessMonitorNode) {
-                    // unproxify the target of the InstrumentationNode.
-                    instrumentationNode.replaceFirstInput(proxy, proxy.target());
-                }
-            }
-        }
-    }
-
-    class InstrumentationAggregation {
-
-        protected CommitAllocationNode commit;
-        protected FixedWithNextNode insertingLocation;
-
-        public InstrumentationAggregation(CommitAllocationNode commit) {
-            this.commit = commit;
-            this.insertingLocation = commit;
-        }
-
-        public void insert(InstrumentationNode instrumentationNode) {
-            commit.graph().addAfterFixed(insertingLocation, instrumentationNode);
-            insertingLocation = instrumentationNode;
-        }
-
-        public void duplicateInstrumentationIfMatch(Predicate<InstrumentationNode> guard, Supplier<ValueNode> newTargetSupplier) {
-            StructuredGraph graph = commit.graph();
-            for (InstrumentationNode instrumentationNode : graph.getNodes().filter(InstrumentationNode.class)) {
-                // insert ICG only if the CommitAllocationNode is accessible from the
-                // instrumentation node
-                if (!(isCFGAccessible(instrumentationNode, commit) && guard.test(instrumentationNode))) {
-                    continue;
-                }
-                InstrumentationNode clone = (InstrumentationNode) instrumentationNode.copyWithInputs();
-                ValueNode newTarget = newTargetSupplier.get();
-                if (!newTarget.isAlive()) {
-                    graph.addWithoutUnique(newTarget);
-                }
-                clone.replaceFirstInput(clone.target(), newTarget);
-                updateVirtualInputs(clone);
-                insert(clone);
-            }
-        }
-
-        private void updateVirtualInputs(InstrumentationNode clone) {
-            for (ValueNode input : clone.getWeakDependencies()) {
-                if ((input instanceof VirtualObjectNode) && (commit.getVirtualObjects().contains(input))) {
-                    clone.replaceFirstInput(input, getAllocatedObject(commit, (VirtualObjectNode) input));
-                }
-            }
-        }
-
-    }
-
-    private final HashMap<InstrumentationNode, NodeFlood> cachedNodeFloods = new HashMap<>();
-
-    private boolean isCFGAccessible(InstrumentationNode from, CommitAllocationNode to) {
-        // we only insert InstrumentationNode during this phase, so it is fine to reuse cached
-        // NodeFlood.
-        NodeFlood flood = cachedNodeFloods.get(from);
-        if (flood == null) {
-            flood = from.graph().createNodeFlood();
-            flood.add(from);
-            for (Node current : flood) {
-                if (current instanceof LoopEndNode) {
-                    continue;
-                } else if (current instanceof AbstractEndNode) {
-                    flood.add(((AbstractEndNode) current).merge());
-                } else {
-                    flood.addAll(current.successors());
-                }
-            }
-            cachedNodeFloods.put(from, flood);
-        }
-        return flood.isMarked(to);
-    }
-
-    private static AllocatedObjectNode getAllocatedObject(CommitAllocationNode commit, VirtualObjectNode virtual) {
-        for (AllocatedObjectNode object : commit.graph().getNodes().filter(AllocatedObjectNode.class)) {
-            if (object.getCommit() == commit && object.getVirtualObject() == virtual) {
-                return object;
-            }
-        }
-        AllocatedObjectNode object = commit.graph().addWithoutUnique(new AllocatedObjectNode(virtual));
-        object.setCommit(commit);
-        return object;
-    }
-
-}
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/query/InlineICGPhase.java	Tue Oct 06 16:52:56 2015 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,82 +0,0 @@
-/*
- * Copyright (c) 2015, 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.phases.common.query;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import com.oracle.graal.nodeinfo.InputType;
-import com.oracle.graal.nodes.StructuredGraph;
-import com.oracle.graal.nodes.memory.MemoryAnchorNode;
-import com.oracle.graal.nodes.spi.LoweringTool;
-import com.oracle.graal.nodes.util.GraphUtil;
-import com.oracle.graal.phases.BasePhase;
-import com.oracle.graal.phases.common.CanonicalizerPhase;
-import com.oracle.graal.phases.common.FloatingReadPhase;
-import com.oracle.graal.phases.common.FrameStateAssignmentPhase;
-import com.oracle.graal.phases.common.GuardLoweringPhase;
-import com.oracle.graal.phases.common.LoweringPhase;
-import com.oracle.graal.phases.common.query.nodes.GraalQueryNode;
-import com.oracle.graal.phases.common.query.nodes.InstrumentationNode;
-import com.oracle.graal.phases.tiers.LowTierContext;
-
-public class InlineICGPhase extends BasePhase<LowTierContext> {
-
-    @Override
-    protected void run(StructuredGraph graph, LowTierContext context) {
-        // ICG may be shared amongst multiple InstrumentationNode
-        Set<StructuredGraph> icgs = new HashSet<>();
-        for (InstrumentationNode instrumentationNode : graph.getNodes().filter(InstrumentationNode.class)) {
-            icgs.add(instrumentationNode.icg());
-        }
-        for (StructuredGraph icg : icgs) {
-            new GuardLoweringPhase().apply(icg, null);
-            new FrameStateAssignmentPhase().apply(icg, false);
-            new LoweringPhase(new CanonicalizerPhase(), LoweringTool.StandardLoweringStage.LOW_TIER).apply(icg, context);
-            new FloatingReadPhase(true, true).apply(icg, false);
-
-            MemoryAnchorNode anchor = icg.add(new MemoryAnchorNode());
-            icg.start().replaceAtUsages(InputType.Memory, anchor);
-            if (anchor.hasNoUsages()) {
-                anchor.safeDelete();
-            } else {
-                icg.addAfterFixed(icg.start(), anchor);
-            }
-        }
-
-        for (InstrumentationNode instrumentationNode : graph.getNodes().filter(InstrumentationNode.class)) {
-            instrumentationNode.inlineAt(instrumentationNode);
-
-            for (GraalQueryNode query : graph.getNodes().filter(GraalQueryNode.class)) {
-                query.onInlineICG(instrumentationNode, instrumentationNode, context.getConstantReflection());
-            }
-
-            GraphUtil.unlinkFixedNode(instrumentationNode);
-            instrumentationNode.clearInputs();
-            GraphUtil.killCFG(instrumentationNode);
-        }
-
-        new CanonicalizerPhase().apply(graph, context);
-    }
-
-}
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/query/MidTierReconcileICGPhase.java	Tue Oct 06 16:52:56 2015 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-/*
- * Copyright (c) 2015, 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.phases.common.query;
-
-import com.oracle.graal.nodes.StructuredGraph;
-import com.oracle.graal.nodes.ValueNode;
-import com.oracle.graal.nodes.extended.FixedValueAnchorNode;
-import com.oracle.graal.nodes.java.AccessMonitorNode;
-import com.oracle.graal.nodes.util.GraphUtil;
-import com.oracle.graal.phases.Phase;
-import com.oracle.graal.phases.common.query.nodes.InstrumentationNode;
-import com.oracle.graal.phases.common.query.nodes.MonitorProxyNode;
-
-public class MidTierReconcileICGPhase extends Phase {
-
-    private static AccessMonitorNode unproxify(MonitorProxyNode proxy) {
-        for (AccessMonitorNode monitorEnter : proxy.getMonitorId().usages().filter(AccessMonitorNode.class)) {
-            if (monitorEnter.object() == proxy.target()) {
-                return monitorEnter;
-            }
-        }
-        return null;
-    }
-
-    @Override
-    protected void run(StructuredGraph graph) {
-        for (InstrumentationNode instrumentationNode : graph.getNodes().filter(InstrumentationNode.class)) {
-            ValueNode target = instrumentationNode.target();
-            if (target instanceof MonitorProxyNode) {
-                instrumentationNode.replaceFirstInput(target, unproxify((MonitorProxyNode) target));
-            } else if (target instanceof FixedValueAnchorNode) {
-                instrumentationNode.replaceFirstInput(target, GraphUtil.unproxify(target));
-            }
-        }
-    }
-}
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/query/nodes/GraalQueryNode.java	Tue Oct 06 16:52:56 2015 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2015, 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.phases.common.query.nodes;
-
-import jdk.internal.jvmci.meta.ConstantReflectionProvider;
-
-import com.oracle.graal.compiler.common.type.Stamp;
-import com.oracle.graal.graph.NodeClass;
-import com.oracle.graal.nodeinfo.NodeInfo;
-import com.oracle.graal.nodes.FixedNode;
-import com.oracle.graal.nodes.FixedWithNextNode;
-
-@NodeInfo
-public abstract class GraalQueryNode extends FixedWithNextNode {
-
-    public static final NodeClass<GraalQueryNode> TYPE = NodeClass.create(GraalQueryNode.class);
-
-    public GraalQueryNode(NodeClass<? extends FixedWithNextNode> c, Stamp stamp) {
-        super(c, stamp);
-    }
-
-    public void onExtractICG(@SuppressWarnings("unused") InstrumentationNode instrumentation) {
-    }
-
-    public void onInlineICG(@SuppressWarnings("unused") InstrumentationNode instrumentation, @SuppressWarnings("unused") FixedNode position,
-                    @SuppressWarnings("unused") ConstantReflectionProvider constantReflection) {
-    }
-
-}
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/query/nodes/InstrumentationBeginNode.java	Tue Oct 06 16:52:56 2015 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 2015, 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.phases.common.query.nodes;
-
-import com.oracle.graal.compiler.common.type.StampFactory;
-import com.oracle.graal.graph.NodeClass;
-import com.oracle.graal.nodeinfo.NodeInfo;
-import com.oracle.graal.nodes.FixedWithNextNode;
-
-@NodeInfo
-public final class InstrumentationBeginNode extends FixedWithNextNode {
-
-    public static final NodeClass<InstrumentationBeginNode> TYPE = NodeClass.create(InstrumentationBeginNode.class);
-
-    protected final int offset;
-    protected final int type;
-
-    public InstrumentationBeginNode(int offset, int type) {
-        super(TYPE, StampFactory.forVoid());
-        this.offset = offset;
-        this.type = type;
-    }
-
-    public int getOffset() {
-        return offset;
-    }
-
-    public int getType() {
-        return type;
-    }
-
-    @NodeIntrinsic
-    public static native void instantiate(@ConstantNodeParameter int offset, @ConstantNodeParameter int type);
-
-}
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/query/nodes/InstrumentationEndNode.java	Tue Oct 06 16:52:56 2015 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2015, 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.phases.common.query.nodes;
-
-import com.oracle.graal.compiler.common.type.StampFactory;
-import com.oracle.graal.graph.NodeClass;
-import com.oracle.graal.nodeinfo.NodeInfo;
-import com.oracle.graal.nodes.FixedWithNextNode;
-
-@NodeInfo
-public final class InstrumentationEndNode extends FixedWithNextNode {
-
-    public static final NodeClass<InstrumentationEndNode> TYPE = NodeClass.create(InstrumentationEndNode.class);
-
-    public InstrumentationEndNode() {
-        super(TYPE, StampFactory.forVoid());
-    }
-
-    @NodeIntrinsic
-    public static native void instantiate();
-
-}
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/query/nodes/InstrumentationNode.java	Tue Oct 06 16:52:56 2015 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,195 +0,0 @@
-/*
- * Copyright (c) 2015, 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.phases.common.query.nodes;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Map;
-
-import jdk.internal.jvmci.meta.JavaConstant;
-import jdk.internal.jvmci.meta.JavaKind;
-
-import com.oracle.graal.compiler.common.type.StampFactory;
-import com.oracle.graal.graph.Graph.DuplicationReplacement;
-import com.oracle.graal.graph.Node;
-import com.oracle.graal.graph.NodeClass;
-import com.oracle.graal.graph.NodeInputList;
-import com.oracle.graal.nodeinfo.InputType;
-import com.oracle.graal.nodeinfo.NodeInfo;
-import com.oracle.graal.nodes.AbstractBeginNode;
-import com.oracle.graal.nodes.AbstractMergeNode;
-import com.oracle.graal.nodes.ConstantNode;
-import com.oracle.graal.nodes.EndNode;
-import com.oracle.graal.nodes.FixedNode;
-import com.oracle.graal.nodes.FixedWithNextNode;
-import com.oracle.graal.nodes.FrameState;
-import com.oracle.graal.nodes.MergeNode;
-import com.oracle.graal.nodes.ParameterNode;
-import com.oracle.graal.nodes.ReturnNode;
-import com.oracle.graal.nodes.StartNode;
-import com.oracle.graal.nodes.StructuredGraph;
-import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
-import com.oracle.graal.nodes.ValueNode;
-import com.oracle.graal.nodes.spi.Virtualizable;
-import com.oracle.graal.nodes.spi.VirtualizerTool;
-import com.oracle.graal.nodes.virtual.EscapeObjectState;
-import com.oracle.graal.nodes.virtual.VirtualObjectNode;
-
-@NodeInfo
-public class InstrumentationNode extends FixedWithNextNode implements Virtualizable {
-
-    public static final NodeClass<InstrumentationNode> TYPE = NodeClass.create(InstrumentationNode.class);
-
-    @OptionalInput(value = InputType.Association) protected ValueNode target;
-    @OptionalInput protected NodeInputList<ValueNode> weakDependencies;
-
-    protected StructuredGraph icg;
-    protected final int offset;
-    protected final int type;
-
-    public InstrumentationNode(ValueNode target, int offset, int type) {
-        super(TYPE, StampFactory.forVoid());
-
-        this.target = target;
-        this.icg = new StructuredGraph(AllowAssumptions.YES);
-        this.offset = offset;
-        this.type = type;
-
-        this.weakDependencies = new NodeInputList<>(this);
-    }
-
-    public boolean addInput(Node node) {
-        return weakDependencies.add(node);
-    }
-
-    public ValueNode target() {
-        return target;
-    }
-
-    public StructuredGraph icg() {
-        return icg;
-    }
-
-    public int offset() {
-        return offset;
-    }
-
-    public int type() {
-        return type;
-    }
-
-    public NodeInputList<ValueNode> getWeakDependencies() {
-        return weakDependencies;
-    }
-
-    public void virtualize(VirtualizerTool tool) {
-        // InstrumentationNode allows non-materialized inputs. During the inlining of the
-        // InstrumentationNode, non-materialized inputs will be replaced by null.
-        if (target != null) {
-            ValueNode alias = tool.getAlias(target);
-            if (alias instanceof VirtualObjectNode) {
-                tool.replaceFirstInput(target, alias);
-            }
-        }
-        for (ValueNode input : weakDependencies) {
-            ValueNode alias = tool.getAlias(input);
-            if (alias instanceof VirtualObjectNode) {
-                tool.replaceFirstInput(input, alias);
-            }
-        }
-    }
-
-    public void inlineAt(FixedNode position) {
-        ArrayList<Node> nodes = new ArrayList<>(icg.getNodes().count());
-        final StartNode entryPointNode = icg.start();
-        FixedNode firstCFGNode = entryPointNode.next();
-        ArrayList<ReturnNode> returnNodes = new ArrayList<>(4);
-
-        for (Node icgnode : icg.getNodes()) {
-            if (icgnode == entryPointNode || icgnode == entryPointNode.stateAfter() || icgnode instanceof ParameterNode) {
-                // Do nothing.
-            } else {
-                nodes.add(icgnode);
-                if (icgnode instanceof ReturnNode) {
-                    returnNodes.add((ReturnNode) icgnode);
-                }
-            }
-        }
-
-        final AbstractBeginNode prevBegin = AbstractBeginNode.prevBegin(position);
-        DuplicationReplacement localReplacement = new DuplicationReplacement() {
-
-            public Node replacement(Node replacement) {
-                if (replacement instanceof ParameterNode) {
-                    ValueNode value = getWeakDependencies().get(((ParameterNode) replacement).index());
-                    if (value == null || value.isDeleted() || value instanceof VirtualObjectNode || value.stamp().getStackKind() != JavaKind.Object) {
-                        return graph().unique(new ConstantNode(JavaConstant.NULL_POINTER, ((ParameterNode) replacement).stamp()));
-                    } else {
-                        return value;
-                    }
-                } else if (replacement == entryPointNode) {
-                    return prevBegin;
-                }
-                return replacement;
-            }
-
-        };
-
-        Map<Node, Node> duplicates = graph().addDuplicates(nodes, icg, icg.getNodeCount(), localReplacement);
-        FixedNode firstCFGNodeDuplicate = (FixedNode) duplicates.get(firstCFGNode);
-        position.replaceAtPredecessor(firstCFGNodeDuplicate);
-
-        if (!returnNodes.isEmpty()) {
-            if (returnNodes.size() == 1) {
-                ReturnNode returnNode = (ReturnNode) duplicates.get(returnNodes.get(0));
-                returnNode.replaceAndDelete(position);
-            } else {
-                ArrayList<ReturnNode> returnDuplicates = new ArrayList<>(returnNodes.size());
-                for (ReturnNode returnNode : returnNodes) {
-                    returnDuplicates.add((ReturnNode) duplicates.get(returnNode));
-                }
-                AbstractMergeNode merge = graph().add(new MergeNode());
-
-                for (ReturnNode returnNode : returnDuplicates) {
-                    EndNode endNode = graph().add(new EndNode());
-                    merge.addForwardEnd(endNode);
-                    returnNode.replaceAndDelete(endNode);
-                }
-
-                merge.setNext(position);
-            }
-        }
-
-        // since we may relocate InstrumentationNodes, the FrameState can be invalid
-        for (Node replacee : duplicates.values()) {
-            if (replacee instanceof FrameState) {
-                FrameState oldState = (FrameState) replacee;
-                FrameState newState = new FrameState(null, oldState.method(), oldState.bci, 0, 0, 0, oldState.rethrowException(), oldState.duringCall(), null,
-                                Collections.<EscapeObjectState> emptyList());
-                graph().addWithoutUnique(newState);
-                oldState.replaceAtUsages(newState);
-            }
-        }
-    }
-
-}
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/query/nodes/MonitorProxyNode.java	Tue Oct 06 16:52:56 2015 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 2015, 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.phases.common.query.nodes;
-
-import com.oracle.graal.compiler.common.type.StampFactory;
-import com.oracle.graal.graph.NodeClass;
-import com.oracle.graal.nodeinfo.InputType;
-import com.oracle.graal.nodeinfo.NodeInfo;
-import com.oracle.graal.nodes.ValueNode;
-import com.oracle.graal.nodes.java.MonitorIdNode;
-
-@NodeInfo
-public class MonitorProxyNode extends ValueNode {
-
-    public static final NodeClass<MonitorProxyNode> TYPE = NodeClass.create(MonitorProxyNode.class);
-
-    @OptionalInput(value = InputType.Association) protected ValueNode target;
-    @OptionalInput(value = InputType.Association) protected MonitorIdNode monitorId;
-
-    public MonitorProxyNode(ValueNode target, MonitorIdNode monitorId) {
-        super(TYPE, StampFactory.forVoid());
-
-        this.target = target;
-        this.monitorId = monitorId;
-    }
-
-    public ValueNode target() {
-        return target;
-    }
-
-    public MonitorIdNode getMonitorId() {
-        return monitorId;
-    }
-
-}
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java	Tue Oct 06 16:52:56 2015 -0700
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java	Tue Oct 06 18:44:23 2015 -0700
@@ -22,7 +22,7 @@
  */
 package com.oracle.graal.replacements;
 
-import static com.oracle.graal.compiler.common.GraalOptions.UseGraalQueries;
+import static com.oracle.graal.compiler.common.GraalOptions.UseGraalInstrumentation;
 import static com.oracle.graal.debug.Debug.applyFormattingFlagsAndWidth;
 import static com.oracle.graal.phases.common.DeadCodeEliminationPhase.Optionality.Required;
 import static com.oracle.graal.replacements.SnippetTemplate.AbstractTemplates.UseSnippetTemplateCache;
@@ -118,7 +118,7 @@
 import com.oracle.graal.phases.common.GuardLoweringPhase;
 import com.oracle.graal.phases.common.LoweringPhase;
 import com.oracle.graal.phases.common.inlining.InliningUtil;
-import com.oracle.graal.phases.common.query.nodes.InstrumentationNode;
+import com.oracle.graal.phases.common.instrumentation.nodes.InstrumentationNode;
 import com.oracle.graal.phases.tiers.PhaseContext;
 import com.oracle.graal.phases.util.Providers;
 import com.oracle.graal.replacements.Snippet.ConstantParameter;
@@ -1338,7 +1338,7 @@
 
             updateStamps(replacee, duplicates);
 
-            if (UseGraalQueries.getValue()) {
+            if (UseGraalInstrumentation.getValue()) {
                 for (InstrumentationNode instrumentation : replaceeGraph.getNodes().filter(InstrumentationNode.class)) {
                     if (instrumentation.target() == replacee) {
                         if (instrumentation.offset() < 0) {
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/StandardGraphBuilderPlugins.java	Tue Oct 06 16:52:56 2015 -0700
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/StandardGraphBuilderPlugins.java	Tue Oct 06 18:44:23 2015 -0700
@@ -22,6 +22,7 @@
  */
 package com.oracle.graal.replacements;
 
+import static com.oracle.graal.compiler.common.GraalOptions.UseGraalInstrumentation;
 import static jdk.internal.jvmci.code.MemoryBarriers.JMM_POST_VOLATILE_READ;
 import static jdk.internal.jvmci.code.MemoryBarriers.JMM_POST_VOLATILE_WRITE;
 import static jdk.internal.jvmci.code.MemoryBarriers.JMM_PRE_VOLATILE_READ;
@@ -31,19 +32,6 @@
 import java.lang.reflect.Field;
 import java.util.Arrays;
 
-import jdk.internal.jvmci.common.JVMCIError;
-import jdk.internal.jvmci.meta.DeoptimizationAction;
-import jdk.internal.jvmci.meta.DeoptimizationReason;
-import jdk.internal.jvmci.meta.JavaKind;
-import jdk.internal.jvmci.meta.LocationIdentity;
-import jdk.internal.jvmci.meta.MetaAccessProvider;
-import jdk.internal.jvmci.meta.ResolvedJavaField;
-import jdk.internal.jvmci.meta.ResolvedJavaMethod;
-import jdk.internal.jvmci.meta.ResolvedJavaType;
-import jdk.internal.jvmci.options.Option;
-import jdk.internal.jvmci.options.OptionValue;
-import sun.misc.Unsafe;
-
 import com.oracle.graal.api.directives.GraalDirectives;
 import com.oracle.graal.compiler.common.calc.Condition;
 import com.oracle.graal.compiler.common.calc.UnsignedMath;
@@ -97,6 +85,11 @@
 import com.oracle.graal.nodes.java.RegisterFinalizerNode;
 import com.oracle.graal.nodes.util.GraphUtil;
 import com.oracle.graal.nodes.virtual.EnsureVirtualizedNode;
+import com.oracle.graal.phases.common.instrumentation.nodes.InstrumentationBeginNode;
+import com.oracle.graal.phases.common.instrumentation.nodes.InstrumentationEndNode;
+import com.oracle.graal.phases.common.instrumentation.nodes.IsMethodInlinedNode;
+import com.oracle.graal.phases.common.instrumentation.nodes.RootNameNode;
+import com.oracle.graal.phases.common.instrumentation.nodes.RuntimePathNode;
 import com.oracle.graal.replacements.nodes.DeferredPiNode;
 import com.oracle.graal.replacements.nodes.DirectReadNode;
 import com.oracle.graal.replacements.nodes.DirectStoreNode;
@@ -106,6 +99,19 @@
 import com.oracle.graal.replacements.nodes.arithmetic.IntegerMulExactNode;
 import com.oracle.graal.replacements.nodes.arithmetic.IntegerSubExactNode;
 
+import jdk.internal.jvmci.common.JVMCIError;
+import jdk.internal.jvmci.meta.DeoptimizationAction;
+import jdk.internal.jvmci.meta.DeoptimizationReason;
+import jdk.internal.jvmci.meta.JavaKind;
+import jdk.internal.jvmci.meta.LocationIdentity;
+import jdk.internal.jvmci.meta.MetaAccessProvider;
+import jdk.internal.jvmci.meta.ResolvedJavaField;
+import jdk.internal.jvmci.meta.ResolvedJavaMethod;
+import jdk.internal.jvmci.meta.ResolvedJavaType;
+import jdk.internal.jvmci.options.Option;
+import jdk.internal.jvmci.options.OptionValue;
+import sun.misc.Unsafe;
+
 /**
  * Provides non-runtime specific {@link InvocationPlugin}s.
  */
@@ -703,6 +709,39 @@
                 return true;
             }
         });
+        r.register0("rootName", new InvocationPlugin() {
+            public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
+                b.addPush(JavaKind.Object, new RootNameNode(b.getInvokeReturnStamp()));
+                return true;
+            }
+        });
+
+        if (UseGraalInstrumentation.getValue()) {
+            r.register1("instrumentationBegin", int.class, new InvocationPlugin() {
+                public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode offset) {
+                    b.add(new InstrumentationBeginNode(offset));
+                    return true;
+                }
+            });
+            r.register0("instrumentationEnd", new InvocationPlugin() {
+                public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
+                    b.add(new InstrumentationEndNode());
+                    return true;
+                }
+            });
+            r.register0("isMethodInlined", new InvocationPlugin() {
+                public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
+                    b.addPush(JavaKind.Boolean, new IsMethodInlinedNode());
+                    return true;
+                }
+            });
+            r.register0("runtimePath", new InvocationPlugin() {
+                public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
+                    b.addPush(JavaKind.Int, new RuntimePathNode());
+                    return true;
+                }
+            });
+        }
     }
 
     private static void registerJMHBlackholePlugins(InvocationPlugins plugins) {
--- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapeClosure.java	Tue Oct 06 16:52:56 2015 -0700
+++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapeClosure.java	Tue Oct 06 18:44:23 2015 -0700
@@ -22,7 +22,7 @@
  */
 package com.oracle.graal.virtual.phases.ea;
 
-import static com.oracle.graal.compiler.common.GraalOptions.UseGraalQueries;
+import static com.oracle.graal.compiler.common.GraalOptions.UseGraalInstrumentation;
 
 import java.util.ArrayDeque;
 import java.util.ArrayList;
@@ -73,7 +73,7 @@
 import com.oracle.graal.nodes.spi.VirtualizableAllocation;
 import com.oracle.graal.nodes.spi.VirtualizerTool;
 import com.oracle.graal.nodes.virtual.VirtualObjectNode;
-import com.oracle.graal.phases.common.query.nodes.InstrumentationNode;
+import com.oracle.graal.phases.common.instrumentation.nodes.InstrumentationNode;
 import com.oracle.graal.phases.schedule.SchedulePhase;
 
 public abstract class PartialEscapeClosure<BlockT extends PartialEscapeBlockState<BlockT>> extends EffectsClosure<BlockT> {
@@ -190,7 +190,7 @@
                     return true;
                 }
             }
-            if (UseGraalQueries.getValue() && (node instanceof InstrumentationNode)) {
+            if (UseGraalInstrumentation.getValue() && (node instanceof InstrumentationNode)) {
                 // ignore inputs for InstrumentationNode
                 return false;
             }