Skip to content

Commit 10bf45a

Browse files
committed
make Truffle compiled code non-entrant without deoptimizing it
1 parent 0d44bf3 commit 10bf45a

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

compiler/src/org.graalvm.compiler.truffle.runtime.hotspot/src/org/graalvm/compiler/truffle/runtime/hotspot/HotSpotOptimizedCallTarget.java

+21-5
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,25 @@ public boolean soleExecutionEntryPoint() {
8383
*/
8484
private static final Method setSpeculationLog;
8585

86+
/**
87+
* Reflective reference to {@code InstalledCode.invalidate(boolean deoptimize)} so that this
88+
* code can be compiled against older JVMCI API.
89+
*/
90+
private static final Method invalidateInstalledCode;
91+
8692
static {
8793
Method method = null;
8894
try {
8995
method = HotSpotNmethod.class.getDeclaredMethod("setSpeculationLog", HotSpotSpeculationLog.class);
9096
} catch (NoSuchMethodException e) {
9197
}
9298
setSpeculationLog = method;
99+
method = null;
100+
try {
101+
method = InstalledCode.class.getDeclaredMethod("invalidate", boolean.class);
102+
} catch (NoSuchMethodException e) {
103+
}
104+
invalidateInstalledCode = method;
93105
}
94106

95107
/**
@@ -101,11 +113,15 @@ public void setInstalledCode(InstalledCode code) {
101113
if (oldCode == code) {
102114
return;
103115
}
104-
/*
105-
* [GR-31220] This is where we want to make the old code not-entrant but not invalidate.
106-
*
107-
* oldCode.makeNotEntrant()
108-
*/
116+
if (oldCode != INVALID_CODE && invalidateInstalledCode != null) {
117+
try {
118+
invalidateInstalledCode.invoke(oldCode, false);
119+
} catch (Error e) {
120+
throw e;
121+
} catch (Throwable throwable) {
122+
throw new InternalError(throwable);
123+
}
124+
}
109125

110126
// A default nmethod can be called from entry points in the VM (e.g., Method::_code)
111127
// and so allowing it to be installed here would invalidate the truth of

0 commit comments

Comments
 (0)