Skip to content

Commit d575aa6

Browse files
committed
Fix repeated deopts in GetForeignObjectClassNode in multi contexts
1 parent cb58013 commit d575aa6

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/object/GetForeignObjectClassNode.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
import com.oracle.graal.python.nodes.PNodeWithContext;
5050
import com.oracle.graal.python.util.PythonUtils;
5151
import com.oracle.truffle.api.CompilerDirectives;
52+
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
5253
import com.oracle.truffle.api.dsl.Cached;
5354
import com.oracle.truffle.api.dsl.GenerateCached;
5455
import com.oracle.truffle.api.dsl.GenerateInline;
@@ -150,13 +151,15 @@ protected static int getTraits(Object object, InteropLibrary interop) {
150151
private PythonManagedClass classForTraits(int traits) {
151152
PythonManagedClass pythonClass = getContext().polyglotForeignClasses[traits];
152153
if (pythonClass == null) {
153-
CompilerDirectives.transferToInterpreterAndInvalidate();
154+
if (isSingleContext(this)) {
155+
CompilerDirectives.transferToInterpreterAndInvalidate();
156+
}
154157
pythonClass = resolvePolyglotForeignClass(traits);
155-
getContext().polyglotForeignClasses[traits] = pythonClass;
156158
}
157159
return pythonClass;
158160
}
159161

162+
@TruffleBoundary
160163
private PythonManagedClass resolvePolyglotForeignClass(int traits) {
161164
PythonBuiltinClass base = getContext().lookupType(PythonBuiltinClassType.ForeignObject);
162165
if (traits == 0) {
@@ -197,6 +200,8 @@ private PythonManagedClass resolvePolyglotForeignClass(int traits) {
197200

198201
polyglotModule.setAttribute(name, pythonClass);
199202

203+
getContext().polyglotForeignClasses[traits] = pythonClass;
204+
200205
return pythonClass;
201206
}
202207

0 commit comments

Comments
 (0)