# HG changeset patch
# User Gilles Duboscq
# Date 1435055536 -7200
# Node ID 2bca65cc5f3ac79ba5af5204fc14cd8439ab91c7
# Parent b3a22c989adbfb34e98e97f84eee3ac04dba46ce
Make it possible to disable unsafe access tracking
diff -r b3a22c989adb -r 2bca65cc5f3a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ForeignCallStub.java
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ForeignCallStub.java Tue Jun 23 12:03:39 2015 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ForeignCallStub.java Tue Jun 23 12:32:16 2015 +0200
@@ -199,6 +199,7 @@
StructuredGraph graph = new StructuredGraph(toString(), null, AllowAssumptions.NO);
graph.disableInlinedMethodRecording();
+ graph.disableUnsafeAccessTracking();
GraphKit kit = new GraphKit(graph, providers, wordTypes, providers.getGraphBuilderPlugins());
ParameterNode[] params = createParameters(kit, args);
diff -r b3a22c989adb -r 2bca65cc5f3a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/SnippetStub.java
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/SnippetStub.java Tue Jun 23 12:03:39 2015 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/SnippetStub.java Tue Jun 23 12:32:16 2015 +0200
@@ -101,6 +101,7 @@
// evolved or have breakpoints.
final StructuredGraph graph = new StructuredGraph(method, AllowAssumptions.NO);
graph.disableInlinedMethodRecording();
+ graph.disableUnsafeAccessTracking();
if (SnippetGraphUnderConstruction != null) {
assert SnippetGraphUnderConstruction.get() == null : SnippetGraphUnderConstruction.get().toString() + " " + graph;
diff -r b3a22c989adb -r 2bca65cc5f3a graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/StructuredGraph.java
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/StructuredGraph.java Tue Jun 23 12:03:39 2015 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/StructuredGraph.java Tue Jun 23 12:32:16 2015 +0200
@@ -125,7 +125,13 @@
*/
private Map inlinedMethods = new HashMap<>();
- private boolean hasUnsafeAccess = false;
+ private static enum UnsafeAccessState {
+ NO_ACCESS,
+ HAS_ACCESS,
+ DISABLED
+ }
+
+ private UnsafeAccessState hasUnsafeAccess = UnsafeAccessState.NO_ACCESS;
/**
* Creates a new Graph containing a single {@link AbstractBeginNode} as the {@link #start()
@@ -251,6 +257,7 @@
if (!enableInlinedMethodRecording) {
copy.disableInlinedMethodRecording();
}
+ copy.hasUnsafeAccess = hasUnsafeAccess;
copy.setGuardsStage(getGuardsStage());
copy.isAfterFloatingReadPhase = isAfterFloatingReadPhase;
copy.hasValueProxies = hasValueProxies;
@@ -625,11 +632,22 @@
}
public boolean hasUnsafeAccess() {
- return hasUnsafeAccess;
+ return hasUnsafeAccess == UnsafeAccessState.HAS_ACCESS;
}
public void markUnsafeAccess() {
- hasUnsafeAccess = true;
+ if (hasUnsafeAccess == UnsafeAccessState.DISABLED) {
+ return;
+ }
+ hasUnsafeAccess = UnsafeAccessState.HAS_ACCESS;
+ }
+
+ public void disableUnsafeAccessTracking() {
+ hasUnsafeAccess = UnsafeAccessState.DISABLED;
+ }
+
+ public boolean isUnsafeAccessTrackingEnabled() {
+ return hasUnsafeAccess != UnsafeAccessState.DISABLED;
}
public SpeculationLog getSpeculationLog() {
diff -r b3a22c989adb -r 2bca65cc5f3a graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/info/elem/InlineableGraph.java
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/info/elem/InlineableGraph.java Tue Jun 23 12:03:39 2015 +0200
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/info/elem/InlineableGraph.java Tue Jun 23 12:32:16 2015 +0200
@@ -122,10 +122,8 @@
/**
* This method detects:
*
- * -
- * constants among the arguments to the
invoke
- * -
- * arguments with more precise type than that declared by the corresponding parameter
+ * - constants among the arguments to the
invoke
+ * - arguments with more precise type than that declared by the corresponding parameter
*
*
*
@@ -181,7 +179,7 @@
/**
* This method builds the IR nodes for the given method
and canonicalizes them.
* Provided profiling info is mature, the resulting graph is cached. The caller is responsible
- * for cloning before modification.
+ * for cloning before modification.
*/
private static StructuredGraph parseBytecodes(ResolvedJavaMethod method, HighTierContext context, CanonicalizerPhase canonicalizer, StructuredGraph caller) {
StructuredGraph newGraph = new StructuredGraph(method, AllowAssumptions.from(caller.getAssumptions() != null));
@@ -193,6 +191,9 @@
// ok since the graph cache is compilation local.
newGraph.disableInlinedMethodRecording();
}
+ if (!caller.isUnsafeAccessTrackingEnabled()) {
+ newGraph.disableUnsafeAccessTracking();
+ }
if (context.getGraphBuilderSuite() != null) {
context.getGraphBuilderSuite().apply(newGraph, context);
}
diff -r b3a22c989adb -r 2bca65cc5f3a graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java Tue Jun 23 12:03:39 2015 +0200
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java Tue Jun 23 12:32:16 2015 +0200
@@ -558,6 +558,8 @@
// They will also never evolve or have breakpoints set in them
graph.disableInlinedMethodRecording();
+ // They are not user code so they do not participate in unsafe access tracking
+ graph.disableUnsafeAccessTracking();
try (Scope s = Debug.scope("buildInitialGraph", graph)) {
MetaAccessProvider metaAccess = replacements.providers.getMetaAccess();
diff -r b3a22c989adb -r 2bca65cc5f3a graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java Tue Jun 23 12:03:39 2015 +0200
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java Tue Jun 23 12:32:16 2015 +0200
@@ -586,6 +586,9 @@
if (!snippetGraph.isInlinedMethodRecordingEnabled()) {
snippetCopy.disableInlinedMethodRecording();
}
+ if (!snippetGraph.isUnsafeAccessTrackingEnabled()) {
+ snippetCopy.disableUnsafeAccessTracking();
+ }
Map nodeReplacements = Node.newIdentityMap();
nodeReplacements.put(snippetGraph.start(), snippetCopy.start());
@@ -678,7 +681,7 @@
exploded = false;
ExplodeLoopNode explodeLoop = snippetCopy.getNodes().filter(ExplodeLoopNode.class).first();
if (explodeLoop != null) { // Earlier canonicalization may have removed the loop
- // altogether
+ // altogether
LoopBeginNode loopBegin = explodeLoop.findLoopBegin();
if (loopBegin != null) {
LoopEx loop = new LoopsData(snippetCopy).loop(loopBegin);