Mercurial > hg > graal-compiler
comparison graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTarget.java @ 23380:d7e25fa8bc3e
Truffle: compilation queue should weakly reference call targets
author | Andreas Woess <andreas.woess@oracle.com> |
---|---|
date | Thu, 04 Feb 2016 14:14:16 +0100 |
parents | 90de09b99c79 |
children |
comparison
equal
deleted
inserted
replaced
23379:b6c33361df1e | 23380:d7e25fa8bc3e |
---|---|
38 import java.util.Iterator; | 38 import java.util.Iterator; |
39 import java.util.LinkedHashMap; | 39 import java.util.LinkedHashMap; |
40 import java.util.List; | 40 import java.util.List; |
41 import java.util.Map; | 41 import java.util.Map; |
42 import java.util.Spliterators; | 42 import java.util.Spliterators; |
43 import java.util.concurrent.Future; | |
43 import java.util.concurrent.atomic.AtomicInteger; | 44 import java.util.concurrent.atomic.AtomicInteger; |
44 import java.util.stream.Stream; | 45 import java.util.stream.Stream; |
45 import java.util.stream.StreamSupport; | 46 import java.util.stream.StreamSupport; |
46 | 47 |
47 import jdk.vm.ci.code.BailoutException; | 48 import jdk.vm.ci.code.BailoutException; |
97 private final Map<TruffleStamp, OptimizedCallTarget> splitVersions = new HashMap<>(); | 98 private final Map<TruffleStamp, OptimizedCallTarget> splitVersions = new HashMap<>(); |
98 private TruffleStamp argumentStamp = DefaultTruffleStamp.getInstance(); | 99 private TruffleStamp argumentStamp = DefaultTruffleStamp.getInstance(); |
99 | 100 |
100 private TruffleInlining inlining; | 101 private TruffleInlining inlining; |
101 private int cachedNonTrivialNodeCount = -1; | 102 private int cachedNonTrivialNodeCount = -1; |
102 private boolean compiling; | |
103 private int cloneIndex; | 103 private int cloneIndex; |
104 | 104 |
105 /** | 105 /** |
106 * When this call target is inlined, the inlining {@link InstalledCode} registers this | 106 * When this call target is inlined, the inlining {@link InstalledCode} registers this |
107 * assumption. It gets invalidated when a node rewriting is performed. This ensures that all | 107 * assumption. It gets invalidated when a node rewriting is performed. This ensures that all |
108 * compiled methods that have this call target inlined are properly invalidated. | 108 * compiled methods that have this call target inlined are properly invalidated. |
109 */ | 109 */ |
110 private final CyclicAssumption nodeRewritingAssumption; | 110 private final CyclicAssumption nodeRewritingAssumption; |
111 | |
112 private volatile Future<?> compilationTask; | |
111 | 113 |
112 public final RootNode getRootNode() { | 114 public final RootNode getRootNode() { |
113 return rootNode; | 115 return rootNode; |
114 } | 116 } |
115 | 117 |
133 public final void log(String message) { | 135 public final void log(String message) { |
134 runtime.log(message); | 136 runtime.log(message); |
135 } | 137 } |
136 | 138 |
137 public final boolean isCompiling() { | 139 public final boolean isCompiling() { |
138 return compiling; | 140 return getCompilationTask() != null; |
139 } | 141 } |
140 | 142 |
141 private static RootNode cloneRootNode(RootNode root) { | 143 private static RootNode cloneRootNode(RootNode root) { |
142 if (root == null || !root.isCloningAllowed()) { | 144 if (root == null || !root.isCloningAllowed()) { |
143 return null; | 145 return null; |
383 } | 385 } |
384 } | 386 } |
385 | 387 |
386 public final void compile() { | 388 public final void compile() { |
387 if (!isCompiling()) { | 389 if (!isCompiling()) { |
388 compiling = true; | |
389 ensureCloned(); | 390 ensureCloned(); |
390 runtime.compile(this, TruffleBackgroundCompilation.getValue() && !TruffleCompilationExceptionsAreThrown.getValue()); | 391 runtime.compile(this, TruffleBackgroundCompilation.getValue() && !TruffleCompilationExceptionsAreThrown.getValue()); |
391 } | 392 } |
392 } | 393 } |
393 | 394 |
421 | 422 |
422 public void notifyCompilationFinished(boolean successful) { | 423 public void notifyCompilationFinished(boolean successful) { |
423 if (successful && inlining != null) { | 424 if (successful && inlining != null) { |
424 dequeueInlinedCallSites(inlining); | 425 dequeueInlinedCallSites(inlining); |
425 } | 426 } |
426 compiling = false; | 427 setCompilationTask(null); |
427 } | 428 } |
428 | 429 |
429 private void dequeueInlinedCallSites(TruffleInlining parentDecision) { | 430 private void dequeueInlinedCallSites(TruffleInlining parentDecision) { |
430 for (TruffleInliningDecision decision : parentDecision) { | 431 for (TruffleInliningDecision decision : parentDecision) { |
431 if (decision.isInline()) { | 432 if (decision.isInline()) { |
621 | 622 |
622 @Override | 623 @Override |
623 public final int hashCode() { | 624 public final int hashCode() { |
624 return System.identityHashCode(this); | 625 return System.identityHashCode(this); |
625 } | 626 } |
627 | |
628 Future<?> getCompilationTask() { | |
629 return compilationTask; | |
630 } | |
631 | |
632 void setCompilationTask(Future<?> compilationTask) { | |
633 this.compilationTask = compilationTask; | |
634 } | |
626 } | 635 } |