< prev index next >

src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotSpeculationLog.java

Print this page

        

*** 49,79 **** /** All speculations that have caused a deoptimization. */ private Set<SpeculationReason> failedSpeculations; /** Strong references to all reasons embedded in the current nmethod. */ ! private Map<Long, SpeculationReason> speculations; private long currentSpeculationID; @Override public synchronized void collectFailedSpeculations() { if (lastFailed != 0) { if (failedSpeculations == null) { failedSpeculations = new HashSet<>(2); } if (speculations != null) { ! SpeculationReason lastFailedSpeculation = speculations.get(lastFailed); if (lastFailedSpeculation != null) { failedSpeculations.add(lastFailedSpeculation); } lastFailed = 0; speculations = null; } } } @Override public synchronized boolean maySpeculate(SpeculationReason reason) { if (failedSpeculations != null && failedSpeculations.contains(reason)) { return false; } --- 49,88 ---- /** All speculations that have caused a deoptimization. */ private Set<SpeculationReason> failedSpeculations; /** Strong references to all reasons embedded in the current nmethod. */ ! private HashMap<SpeculationReason, JavaConstant> speculations; private long currentSpeculationID; @Override public synchronized void collectFailedSpeculations() { if (lastFailed != 0) { if (failedSpeculations == null) { failedSpeculations = new HashSet<>(2); } if (speculations != null) { ! SpeculationReason lastFailedSpeculation = lookupSpeculation(this.lastFailed); if (lastFailedSpeculation != null) { failedSpeculations.add(lastFailedSpeculation); } lastFailed = 0; speculations = null; } } } + private SpeculationReason lookupSpeculation(long value) { + for (Map.Entry<SpeculationReason, JavaConstant> entry : speculations.entrySet()) { + if (value == entry.getValue().asLong()) { + return entry.getKey(); + } + } + return null; + } + @Override public synchronized boolean maySpeculate(SpeculationReason reason) { if (failedSpeculations != null && failedSpeculations.contains(reason)) { return false; }
*** 83,94 **** @Override public synchronized Speculation speculate(SpeculationReason reason) { if (speculations == null) { speculations = new HashMap<>(); } ! speculations.put(++currentSpeculationID, reason); ! return new HotSpotSpeculation(reason, JavaConstant.forLong(currentSpeculationID)); } @Override public synchronized boolean hasSpeculations() { return speculations != null && !speculations.isEmpty(); --- 92,107 ---- @Override public synchronized Speculation speculate(SpeculationReason reason) { if (speculations == null) { speculations = new HashMap<>(); } ! JavaConstant id = speculations.get(reason); ! if (id == null) { ! id = JavaConstant.forLong(++currentSpeculationID); ! speculations.put(reason, id); ! } ! return new HotSpotSpeculation(reason, id); } @Override public synchronized boolean hasSpeculations() { return speculations != null && !speculations.isEmpty();
*** 97,106 **** @Override public synchronized Speculation lookupSpeculation(JavaConstant constant) { if (constant.isDefaultForKind()) { return NO_SPECULATION; } ! SpeculationReason reason = speculations.get(constant.asLong()); assert reason != null : "Speculation should have been registered"; return new HotSpotSpeculation(reason, constant); } } --- 110,119 ---- @Override public synchronized Speculation lookupSpeculation(JavaConstant constant) { if (constant.isDefaultForKind()) { return NO_SPECULATION; } ! SpeculationReason reason = lookupSpeculation(constant.asLong()); assert reason != null : "Speculation should have been registered"; return new HotSpotSpeculation(reason, constant); } }
< prev index next >