Skip to content

Commit 17303b6

Browse files
committed
Use WriteAttributeToDynamicObject for hidden keys
1 parent 5b14cc4 commit 17303b6

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CExtNodes.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1752,6 +1752,7 @@ static Object doSingleContext(Object cls, NativeMember nativeMemberName, HiddenK
17521752
@Cached SequenceStorageNodes.GetItemDynamicNode getItemNode,
17531753
@Cached("createForceType()") ReadAttributeFromObjectNode readAttrNode,
17541754
@Cached GetTypeMemberNode getTypeMemberNode) {
1755+
CompilerAsserts.partialEvaluationConstant(builtinCallback);
17551756

17561757
MroSequenceStorage mroStorage = getMroNode.execute(cls);
17571758
int n = mroStorage.length();

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TypeNodes.java

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,9 @@
169169
import com.oracle.graal.python.nodes.attributes.GetAttributeNode;
170170
import com.oracle.graal.python.nodes.attributes.LookupAttributeInMRONode;
171171
import com.oracle.graal.python.nodes.attributes.LookupInheritedSlotNode;
172+
import com.oracle.graal.python.nodes.attributes.ReadAttributeFromDynamicObjectNode;
172173
import com.oracle.graal.python.nodes.attributes.ReadAttributeFromObjectNode;
173-
import com.oracle.graal.python.nodes.attributes.WriteAttributeToObjectNode;
174+
import com.oracle.graal.python.nodes.attributes.WriteAttributeToDynamicObjectNode;
174175
import com.oracle.graal.python.nodes.call.CallNode;
175176
import com.oracle.graal.python.nodes.call.special.CallUnaryMethodNode;
176177
import com.oracle.graal.python.nodes.classes.IsSubtypeNode;
@@ -241,17 +242,17 @@ public abstract static class GetTypeFlagsNode extends Node {
241242
@Specialization
242243
long doBuiltinClassType(PythonBuiltinClassType clazz,
243244
@Bind("this") Node inliningTarget,
244-
@Shared("read") @Cached ReadAttributeFromObjectNode readHiddenFlagsNode,
245-
@Shared("write") @Cached WriteAttributeToObjectNode writeHiddenFlagsNode,
245+
@Shared("read") @Cached ReadAttributeFromDynamicObjectNode readHiddenFlagsNode,
246+
@Shared("write") @Cached WriteAttributeToDynamicObjectNode writeHiddenFlagsNode,
246247
@Shared("profile") @Cached InlinedCountingConditionProfile profile) {
247248
return doManaged(PythonContext.get(this).getCore().lookupType(clazz), inliningTarget, readHiddenFlagsNode, writeHiddenFlagsNode, profile);
248249
}
249250

250251
@Specialization
251252
long doManaged(PythonManagedClass clazz,
252253
@Bind("this") Node inliningTarget,
253-
@Shared("read") @Cached ReadAttributeFromObjectNode readHiddenFlagsNode,
254-
@Shared("write") @Cached WriteAttributeToObjectNode writeHiddenFlagsNode,
254+
@Shared("read") @Cached ReadAttributeFromDynamicObjectNode readHiddenFlagsNode,
255+
@Shared("write") @Cached WriteAttributeToDynamicObjectNode writeHiddenFlagsNode,
255256
@Shared("profile") @Cached InlinedCountingConditionProfile profile) {
256257

257258
Object flagsObject = readHiddenFlagsNode.execute(clazz, TYPE_FLAGS);
@@ -301,7 +302,7 @@ private long computeFlags(PythonManagedClass clazz) {
301302
if (mroEntry instanceof PythonAbstractNativeObject) {
302303
result = setFlags(result, doNative((PythonAbstractNativeObject) mroEntry, GetTypeMemberNodeGen.getUncached()));
303304
} else if (mroEntry != clazz && mroEntry instanceof PythonManagedClass) {
304-
long flags = doManaged((PythonManagedClass) mroEntry, null, ReadAttributeFromObjectNode.getUncached(), WriteAttributeToObjectNode.getUncached(),
305+
long flags = doManaged((PythonManagedClass) mroEntry, null, ReadAttributeFromDynamicObjectNode.getUncached(), WriteAttributeToDynamicObjectNode.getUncached(),
305306
InlinedCountingConditionProfile.getUncached());
306307
result = setFlags(result, flags);
307308
}
@@ -453,13 +454,13 @@ public abstract static class SetTypeFlagsNode extends Node {
453454

454455
@Specialization
455456
void doPBCT(PythonBuiltinClassType clazz, long flags,
456-
@Shared("write") @Cached WriteAttributeToObjectNode writeHiddenFlagsNode) {
457+
@Shared("write") @Cached WriteAttributeToDynamicObjectNode writeHiddenFlagsNode) {
457458
doManaged(PythonContext.get(this).getCore().lookupType(clazz), flags, writeHiddenFlagsNode);
458459
}
459460

460461
@Specialization
461462
static void doManaged(PythonManagedClass clazz, long flags,
462-
@Shared("write") @Cached WriteAttributeToObjectNode writeHiddenFlagsNode) {
463+
@Shared("write") @Cached WriteAttributeToDynamicObjectNode writeHiddenFlagsNode) {
463464
writeHiddenFlagsNode.execute(clazz, TYPE_FLAGS, flags);
464465
}
465466

@@ -1716,7 +1717,7 @@ public abstract static class IsAcceptableBaseNode extends Node {
17161717
@Specialization
17171718
static boolean doUserClass(PythonClass obj,
17181719
@Bind("this") Node inliningTarget,
1719-
@Cached ReadAttributeFromObjectNode readAttributeFromObjectNode,
1720+
@Cached ReadAttributeFromDynamicObjectNode readAttributeFromObjectNode,
17201721
@Cached InlinedBranchProfile hasHPyFlagsProfile) {
17211722
// Special case for custom classes created via HPy: They are managed classes but can
17221723
// have custom flags. The flags may prohibit subtyping.
@@ -2569,7 +2570,7 @@ public static void executeUncached(PythonManagedClass cls, long value) {
25692570

25702571
@Specialization
25712572
void set(PythonManagedClass cls, long value,
2572-
@Cached WriteAttributeToObjectNode write) {
2573+
@Cached WriteAttributeToDynamicObjectNode write) {
25732574
write.execute(cls, TYPE_BASICSIZE, value);
25742575
}
25752576
}
@@ -2622,7 +2623,7 @@ public static void executeUncached(PythonManagedClass cls, long value) {
26222623

26232624
@Specialization
26242625
void set(PythonManagedClass cls, long value,
2625-
@Cached WriteAttributeToObjectNode write) {
2626+
@Cached WriteAttributeToDynamicObjectNode write) {
26262627
write.execute(cls, TYPE_ITEMSIZE, value);
26272628
}
26282629
}
@@ -2657,7 +2658,7 @@ public static void executeUncached(PythonManagedClass cls, long value) {
26572658

26582659
@Specialization
26592660
void set(PythonManagedClass cls, long value,
2660-
@Cached WriteAttributeToObjectNode write) {
2661+
@Cached WriteAttributeToDynamicObjectNode write) {
26612662
write.execute(cls, TYPE_DICTOFFSET, value);
26622663
}
26632664
}

0 commit comments

Comments
 (0)