Skip to content

Commit 0e13bbb

Browse files
committed
move setting of the lazy python class into the object library
1 parent 5c7b73f commit 0e13bbb

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/object/ObjectBuiltins.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@
9393
import com.oracle.graal.python.nodes.object.GetClassNode;
9494
import com.oracle.graal.python.nodes.object.GetLazyClassNode;
9595
import com.oracle.graal.python.nodes.object.IsBuiltinClassProfile;
96-
import com.oracle.truffle.api.Assumption;
9796
import com.oracle.truffle.api.CompilerDirectives;
9897
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
9998
import com.oracle.truffle.api.dsl.Cached;
@@ -145,7 +144,7 @@ LazyPythonClass setClass(@SuppressWarnings("unused") Object self, @SuppressWarni
145144

146145
@Specialization
147146
PNone setClass(VirtualFrame frame, PythonObject self, PythonAbstractClass value,
148-
@Cached("singleContextAssumption()") Assumption singleContextAssumption,
147+
@CachedLibrary("self") PythonObjectLibrary lib,
149148
@Cached("create()") BranchProfile errorValueBranch,
150149
@Cached("create()") BranchProfile errorSelfBranch,
151150
@Cached("create()") BranchProfile errorSlotsBranch,
@@ -167,7 +166,7 @@ PNone setClass(VirtualFrame frame, PythonObject self, PythonAbstractClass value,
167166
throw raise(TypeError, "__class__ assignment: '%s' object layout differs from '%s'", getTypeName(value), getTypeName(lazyClass));
168167
}
169168
}
170-
self.setLazyPythonClass(value, singleContextAssumption);
169+
lib.setLazyPythonClass(self, value);
171170
return PNone.NONE;
172171
}
173172

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/object/PythonObject.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
4444
import com.oracle.truffle.api.dsl.Cached;
4545
import com.oracle.truffle.api.dsl.Cached.Exclusive;
46+
import com.oracle.truffle.api.dsl.CachedLanguage;
4647
import com.oracle.truffle.api.dsl.GenerateUncached;
4748
import com.oracle.truffle.api.dsl.Specialization;
4849
import com.oracle.truffle.api.library.ExportLibrary;
@@ -86,7 +87,10 @@ public final PythonAbstractClass getPythonClass() {
8687
}
8788
}
8889

89-
public final void setLazyPythonClass(PythonAbstractClass cls, Assumption storingClassesInShapes) {
90+
@ExportMessage
91+
public final void setLazyPythonClass(PythonAbstractClass cls,
92+
@SuppressWarnings("unused") @CachedLanguage PythonLanguage language,
93+
@Cached("language.singleContextAssumption") Assumption storingClassesInShapes) {
9094
storedPythonClass = cls;
9195
if (storingClassesInShapes.isValid()) {
9296
PythonObjectLayoutImpl.INSTANCE.setLazyPythonClass(storage, cls);

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/object/PythonObjectLibrary.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242

4343
import com.oracle.graal.python.builtins.objects.PythonAbstractObject;
4444
import com.oracle.graal.python.builtins.objects.common.PHashingCollection;
45+
import com.oracle.graal.python.builtins.objects.type.LazyPythonClass;
4546
import com.oracle.truffle.api.interop.UnsupportedMessageException;
4647
import com.oracle.truffle.api.library.GenerateLibrary;
4748
import com.oracle.truffle.api.library.GenerateLibrary.Abstract;
@@ -65,6 +66,8 @@ public void setDict(PythonAbstractObject receiver, PHashingCollection dict) thro
6566
throw UnsupportedMessageException.create();
6667
}
6768

69+
public abstract void setLazyPythonClass(PythonAbstractObject receiver, LazyPythonClass cls);
70+
6871
static final LibraryFactory<PythonObjectLibrary> FACTORY = LibraryFactory.resolve(PythonObjectLibrary.class);
6972

7073
public static LibraryFactory<PythonObjectLibrary> getFactory() {

0 commit comments

Comments
 (0)