|
43 | 43 | import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
|
44 | 44 | import com.oracle.truffle.api.dsl.Cached;
|
45 | 45 | import com.oracle.truffle.api.dsl.Cached.Exclusive;
|
46 |
| -import com.oracle.truffle.api.dsl.CachedLanguage; |
47 | 46 | import com.oracle.truffle.api.dsl.GenerateUncached;
|
48 | 47 | import com.oracle.truffle.api.dsl.Specialization;
|
49 | 48 | import com.oracle.truffle.api.library.ExportLibrary;
|
@@ -88,18 +87,27 @@ public final PythonAbstractClass getPythonClass() {
|
88 | 87 | }
|
89 | 88 |
|
90 | 89 | @ExportMessage
|
91 |
| - public final void setLazyPythonClass(PythonAbstractClass cls, |
92 |
| - @SuppressWarnings("unused") @CachedLanguage PythonLanguage language, |
93 |
| - @Cached("language.singleContextAssumption") Assumption storingClassesInShapes) { |
94 |
| - storedPythonClass = cls; |
95 |
| - if (storingClassesInShapes.isValid()) { |
96 |
| - PythonObjectLayoutImpl.INSTANCE.setLazyPythonClass(storage, cls); |
97 |
| - } else { |
98 |
| - if (PythonObjectLayoutImpl.INSTANCE.getLazyPythonClass(storage) != null) { |
| 90 | + @GenerateUncached |
| 91 | + public abstract static class SetLazyPythonClass { |
| 92 | + public static Assumption getSingleContextAssumption() { |
| 93 | + return PythonLanguage.getCurrent().singleContextAssumption; |
| 94 | + } |
| 95 | + |
| 96 | + @Specialization(assumptions = "storingClassesInShapes") |
| 97 | + public static void setSingle(PythonObject self, PythonAbstractClass cls, |
| 98 | + @SuppressWarnings("unused") @Cached(value = "getSingleContextAssumption()", allowUncached = true) Assumption storingClassesInShapes) { |
| 99 | + self.storedPythonClass = cls; |
| 100 | + PythonObjectLayoutImpl.INSTANCE.setLazyPythonClass(self.storage, cls); |
| 101 | + } |
| 102 | + |
| 103 | + @Specialization |
| 104 | + public static void setMultiContext(PythonObject self, PythonAbstractClass cls) { |
| 105 | + self.storedPythonClass = cls; |
| 106 | + if (PythonObjectLayoutImpl.INSTANCE.getLazyPythonClass(self.storage) != null) { |
99 | 107 | // for the builtin class enums, we now should change the shape
|
100 | 108 | // to the generic one that just doesn't store the class
|
101 |
| - Shape shape = storage.getShape(); |
102 |
| - storage.setShapeAndGrow(shape, shape.changeType(emptyShape.getObjectType())); |
| 109 | + Shape shape = self.storage.getShape(); |
| 110 | + self.storage.setShapeAndGrow(shape, shape.changeType(emptyShape.getObjectType())); |
103 | 111 | }
|
104 | 112 | }
|
105 | 113 | }
|
@@ -240,7 +248,7 @@ public static Shape freshShape() {
|
240 | 248 | return emptyShape;
|
241 | 249 | }
|
242 | 250 |
|
243 |
| - public static LazyPythonClass getLazyPythonClass(ObjectType type) { |
| 251 | + public static LazyPythonClass getLazyClassFromObjectType(ObjectType type) { |
244 | 252 | return PythonObjectLayoutImpl.INSTANCE.getLazyPythonClass(type);
|
245 | 253 | }
|
246 | 254 | }
|
0 commit comments