8279412: [JVMCI] failed speculations list must outlive any nmethod that refers to it
Reviewed-by: kvn, never
This commit is contained in:
parent
863bffb3b6
commit
1ffdc52cf0
src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot
@ -109,22 +109,12 @@ public class HotSpotCodeCacheProvider implements CodeCacheProvider {
|
||||
HotSpotCompiledCode hsCompiledCode = (HotSpotCompiledCode) compiledCode;
|
||||
String name = hsCompiledCode.getName();
|
||||
HotSpotCompiledNmethod hsCompiledNmethod = null;
|
||||
if (method == null) {
|
||||
// Must be a stub
|
||||
resultInstalledCode = new HotSpotRuntimeStub(name);
|
||||
} else {
|
||||
hsCompiledNmethod = (HotSpotCompiledNmethod) hsCompiledCode;
|
||||
HotSpotResolvedJavaMethodImpl hsMethod = (HotSpotResolvedJavaMethodImpl) method;
|
||||
resultInstalledCode = new HotSpotNmethod(hsMethod, name, isDefault, hsCompiledNmethod.id);
|
||||
}
|
||||
|
||||
HotSpotSpeculationLog speculationLog = null;
|
||||
if (log != null) {
|
||||
if (log.hasSpeculations()) {
|
||||
speculationLog = (HotSpotSpeculationLog) log;
|
||||
}
|
||||
}
|
||||
|
||||
byte[] speculations;
|
||||
long failedSpeculationsAddress;
|
||||
if (speculationLog != null) {
|
||||
@ -134,6 +124,18 @@ public class HotSpotCodeCacheProvider implements CodeCacheProvider {
|
||||
speculations = new byte[0];
|
||||
failedSpeculationsAddress = 0L;
|
||||
}
|
||||
|
||||
if (method == null) {
|
||||
// Must be a stub
|
||||
resultInstalledCode = new HotSpotRuntimeStub(name);
|
||||
} else {
|
||||
hsCompiledNmethod = (HotSpotCompiledNmethod) hsCompiledCode;
|
||||
HotSpotResolvedJavaMethodImpl hsMethod = (HotSpotResolvedJavaMethodImpl) method;
|
||||
HotSpotNmethod nmethod = new HotSpotNmethod(hsMethod, name, isDefault, hsCompiledNmethod.id);
|
||||
nmethod.setSpeculationLog(speculationLog);
|
||||
resultInstalledCode = nmethod;
|
||||
}
|
||||
|
||||
int result = runtime.getCompilerToVM().installCode(target, (HotSpotCompiledCode) compiledCode, resultInstalledCode, failedSpeculationsAddress, speculations);
|
||||
if (result != config.codeInstallResultOk) {
|
||||
String resultDesc = config.getCodeInstallResultDescription(result);
|
||||
|
@ -68,8 +68,8 @@ public class HotSpotNmethod extends HotSpotInstalledCode {
|
||||
|
||||
/**
|
||||
* If this field is 0, this object is in the oops table of the nmethod. Otherwise, the value of
|
||||
* the field records the nmethod's compile identifier. This value is used to confirm an entry in
|
||||
* the code cache retrieved by {@link #address} is indeed the nmethod represented by this
|
||||
* the field records the nmethod's compile identifier. This value is used to confirm if an entry
|
||||
* in the code cache retrieved by {@link #address} is indeed the nmethod represented by this
|
||||
* object.
|
||||
*
|
||||
* @see #inOopsTable
|
||||
@ -85,6 +85,23 @@ public class HotSpotNmethod extends HotSpotInstalledCode {
|
||||
assert inOopsTable || compileId != 0L : this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attaches {@code log} to this object. If {@code log.managesFailedSpeculations() == true}, this
|
||||
* ensures the failed speculation list lives at least as long as this object.
|
||||
*/
|
||||
public void setSpeculationLog(HotSpotSpeculationLog log) {
|
||||
this.speculationLog = log;
|
||||
}
|
||||
|
||||
/**
|
||||
* The speculation log containing speculations embedded in the nmethod.
|
||||
*
|
||||
* If {@code speculationLog.managesFailedSpeculations() == true}, this field ensures the failed
|
||||
* speculation list lives at least as long as this object. This prevents deoptimization from
|
||||
* appending to an already freed list.
|
||||
*/
|
||||
@SuppressWarnings("unused") private HotSpotSpeculationLog speculationLog;
|
||||
|
||||
/**
|
||||
* Determines if the nmethod associated with this object is the compiled entry point for
|
||||
* {@link #getMethod()}.
|
||||
|
Loading…
x
Reference in New Issue
Block a user