Skip to content

Commit 2e75028

Browse files
author
Adam Hrbac
committed
Use an assumption instead of an @CompilationFinal field
1 parent 209504f commit 2e75028

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/PythonContext.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555
import static com.oracle.graal.python.util.PythonUtils.TS_ENCODING;
5656
import static com.oracle.graal.python.util.PythonUtils.toTruffleStringUncached;
5757
import static com.oracle.graal.python.util.PythonUtils.tsLiteral;
58-
import static com.oracle.truffle.api.CompilerDirectives.transferToInterpreterAndInvalidate;
5958

6059
import java.io.IOException;
6160
import java.io.InputStream;
@@ -237,8 +236,11 @@ public static final class PythonThreadState {
237236
*/
238237
PThreadState nativeWrapper;
239238

239+
/* Assume that no trace function was ever set. */
240+
public Assumption noTracingInThread = Assumption.create("noTracingInThread");
241+
240242
/* The global tracing function, set by sys.settrace and returned by sys.gettrace. */
241-
@CompilationFinal Object traceFun;
243+
Object traceFun;
242244

243245
/* Keep track of execution to avoid tracing code inside the tracing function. */
244246
boolean tracing;
@@ -343,12 +345,12 @@ public void dispose() {
343345
}
344346

345347
public Object getTraceFun() {
346-
return traceFun;
348+
return noTracingInThread.isValid() ? null : traceFun;
347349
}
348350

349351
public void setTraceFun(Object traceFun) {
350352
if (this.traceFun != traceFun) {
351-
transferToInterpreterAndInvalidate();
353+
noTracingInThread.invalidate();
352354
this.traceFun = traceFun;
353355
}
354356
}

0 commit comments

Comments
 (0)