Skip to content

Commit 5001ff1

Browse files
committed
Add slot tp_setattr/o, migrate __setattr__/__delattr__ to it & improve compatibility, remove SpecialMethodSlot#SetAttr
1 parent 44437db commit 5001ff1

File tree

25 files changed

+817
-394
lines changed

25 files changed

+817
-394
lines changed

graalpython/com.oracle.graal.python.annotations/src/com/oracle/graal/python/annotations/Slot.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ enum SlotKind {
9797
mp_length,
9898
tp_descr_get,
9999
tp_get_attro,
100-
tp_descr_set
100+
tp_descr_set,
101+
tp_set_attro,
101102
}
102103
}

graalpython/com.oracle.graal.python.processor/src/com/oracle/graal/python/processor/SlotsMapping.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ static String getSlotBaseClass(Slot s) {
5555
case tp_get_attro -> "TpSlotGetAttr.TpSlotGetAttrBuiltin";
5656
case tp_descr_get -> "TpSlotDescrGet.TpSlotDescrGetBuiltin" + getSuffix(s.isComplex());
5757
case tp_descr_set -> "TpSlotDescrSet.TpSlotDescrSetBuiltin";
58+
case tp_set_attro -> "TpSlotSetAttr.TpSlotSetAttrBuiltin";
5859
};
5960
}
6061

@@ -65,6 +66,7 @@ static String getSlotNodeBaseClass(Slot s) {
6566
case sq_length, mp_length -> "com.oracle.graal.python.builtins.objects.type.slots.TpSlotLen.LenBuiltinNode";
6667
case tp_get_attro -> "com.oracle.graal.python.builtins.objects.type.slots.TpSlotGetAttr.GetAttrBuiltinNode";
6768
case tp_descr_set -> "com.oracle.graal.python.builtins.objects.type.slots.TpSlotDescrSet.DescrSetBuiltinNode";
69+
case tp_set_attro -> "com.oracle.graal.python.builtins.objects.type.slots.TpSlotSetAttr.SetAttrBuiltinNode";
6870
};
6971
}
7072

@@ -73,22 +75,22 @@ static String getUncachedExecuteSignature(SlotKind s) {
7375
case nb_bool -> "boolean executeUncached(Object self)";
7476
case tp_descr_get -> "Object executeUncached(Object self, Object obj, Object type)";
7577
case sq_length, mp_length -> "int executeUncached(Object self)";
76-
case tp_get_attro, tp_descr_set ->
78+
case tp_get_attro, tp_descr_set, tp_set_attro ->
7779
throw new AssertionError("Should not reach here: should be always complex");
7880
};
7981
}
8082

8183
static boolean supportsComplex(SlotKind s) {
8284
return switch (s) {
8385
case nb_bool -> false;
84-
case sq_length, mp_length, tp_get_attro, tp_descr_get, tp_descr_set -> true;
86+
case sq_length, mp_length, tp_get_attro, tp_descr_get, tp_descr_set, tp_set_attro -> true;
8587
};
8688
}
8789

8890
static boolean supportsSimple(SlotKind s) {
8991
return switch (s) {
9092
case nb_bool, sq_length, mp_length, tp_descr_get -> true;
91-
case tp_get_attro, tp_descr_set -> false;
93+
case tp_get_attro, tp_descr_set, tp_set_attro -> false;
9294
};
9395
}
9496

@@ -97,8 +99,8 @@ static String getUncachedExecuteCall(SlotKind s) {
9799
case nb_bool -> "executeBool(null, self)";
98100
case sq_length, mp_length -> "executeInt(null, self)";
99101
case tp_descr_get -> "execute(null, self, obj, type)";
100-
case tp_descr_set, tp_get_attro ->
101-
throw new AssertionError("Should not reach here since isComplexByDefault gives true");
102+
case tp_get_attro, tp_descr_set, tp_set_attro ->
103+
throw new AssertionError("Should not reach here: should be always complex");
102104
};
103105
}
104106
}

graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/builtin/objects/TpSlotsTests.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,20 +66,23 @@ public void testBuilderBasic() {
6666
checkSlotValue(TpSlotMeta.SQ_LENGTH, slots.combined_sq_mp_length());
6767
checkSlotValue(TpSlotMeta.MP_LENGTH, slots.combined_mp_sq_length());
6868
checkSlotValue(TpSlotMeta.TP_GET_ATTRO, slots.combined_tp_getattro_getattr());
69+
checkSlotValue(TpSlotMeta.TP_SET_ATTRO, slots.combined_tp_setattro_setattr());
6970
}
7071

7172
@Test
7273
public void testBuilderOptimizations1() {
7374
Builder builder = TpSlots.newBuilder();
7475
builder.set(TpSlotMeta.MP_LENGTH, new TpSlotNative(TpSlotMeta.MP_LENGTH));
7576
builder.set(TpSlotMeta.TP_GET_ATTR, new TpSlotNative(TpSlotMeta.TP_GET_ATTR));
77+
builder.set(TpSlotMeta.TP_SET_ATTR, new TpSlotNative(TpSlotMeta.TP_SET_ATTR));
7678

7779
TpSlots slots = builder.build();
78-
verifySlots(slots, def -> def == TpSlotMeta.MP_LENGTH || def == TpSlotMeta.TP_GET_ATTR);
80+
verifySlots(slots, def -> def == TpSlotMeta.MP_LENGTH || def == TpSlotMeta.TP_GET_ATTR || def == TpSlotMeta.TP_SET_ATTR);
7981

8082
checkSlotValue(TpSlotMeta.MP_LENGTH, slots.combined_sq_mp_length());
8183
checkSlotValue(TpSlotMeta.MP_LENGTH, slots.combined_mp_sq_length());
8284
checkSlotValue(TpSlotMeta.TP_GET_ATTR, slots.combined_tp_getattro_getattr());
85+
checkSlotValue(TpSlotMeta.TP_SET_ATTR, slots.combined_tp_setattro_setattr());
8386
}
8487

8588
@Test

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/PythonBuiltinClassType.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@
118118
import com.oracle.graal.python.builtins.modules.ctypes.PyCArrayBuiltins;
119119
import com.oracle.graal.python.builtins.modules.ctypes.PyCFuncPtrBuiltins;
120120
import com.oracle.graal.python.builtins.modules.ctypes.PyCPointerBuiltins;
121+
import com.oracle.graal.python.builtins.modules.ctypes.PyCStructTypeBuiltins;
121122
import com.oracle.graal.python.builtins.modules.ctypes.SimpleCDataBuiltins;
122123
import com.oracle.graal.python.builtins.modules.ctypes.StgDictBuiltins;
123124
import com.oracle.graal.python.builtins.modules.functools.LruCacheWrapperBuiltins;
@@ -406,8 +407,8 @@ public enum PythonBuiltinClassType implements TruffleObject {
406407
CArgObject("CArgObject", Flags.PUBLIC_BASE_WODICT),
407408
CThunkObject("CThunkObject", J__CTYPES, Flags.PUBLIC_BASE_WODICT),
408409
StgDict("StgDict", Flags.PRIVATE_DERIVED_WODICT, DICT_M_FLAGS, StgDictBuiltins.SLOTS),
409-
PyCStructType("PyCStructType", J__CTYPES, Flags.PUBLIC_BASE_WODICT, PYCSTRUCTTYPE_M_FLAGS),
410-
UnionType("UnionType", J__CTYPES, Flags.PUBLIC_BASE_WODICT, UNIONTYPE_M_FLAGS),
410+
PyCStructType("PyCStructType", J__CTYPES, Flags.PUBLIC_BASE_WODICT, PYCSTRUCTTYPE_M_FLAGS, PyCStructTypeBuiltins.SLOTS),
411+
UnionType("UnionType", J__CTYPES, Flags.PUBLIC_BASE_WODICT, UNIONTYPE_M_FLAGS, com.oracle.graal.python.builtins.modules.ctypes.UnionTypeBuiltins.SLOTS),
411412
PyCPointerType("PyCPointerType", J__CTYPES, Flags.PUBLIC_BASE_WODICT, PYCPOINTERTYPE_M_FLAGS),
412413
PyCArrayType("PyCArrayType", J__CTYPES, Flags.PUBLIC_BASE_WODICT, PYCARRAYTYPE_M_FLAGS),
413414
PyCSimpleType("PyCSimpleType", J__CTYPES, Flags.PUBLIC_BASE_WODICT, PYCSIMPLETYPE_M_FLAGS),

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextModuleBuiltins.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@
7171
import com.oracle.graal.python.lib.PyUnicodeCheckNode;
7272
import com.oracle.graal.python.nodes.ErrorMessages;
7373
import com.oracle.graal.python.nodes.PRaiseNode;
74-
import com.oracle.graal.python.nodes.attributes.ReadAttributeFromPythonObjectNode;
7574
import com.oracle.graal.python.nodes.attributes.ReadAttributeFromObjectNode;
75+
import com.oracle.graal.python.nodes.attributes.ReadAttributeFromPythonObjectNode;
7676
import com.oracle.graal.python.nodes.attributes.WriteAttributeToObjectNode;
7777
import com.oracle.graal.python.nodes.call.CallNode;
7878
import com.oracle.graal.python.nodes.classes.IsSubtypeNode;
@@ -94,7 +94,7 @@ abstract static class PyModule_SetDocString extends CApiBinaryBuiltinNode {
9494
@Specialization
9595
static int run(PythonModule module, Object doc,
9696
@Cached ObjectBuiltins.SetattrNode setattrNode) {
97-
setattrNode.execute(null, module, T___DOC__, doc);
97+
setattrNode.executeSetAttr(null, module, T___DOC__, doc);
9898
return 0;
9999
}
100100
}
@@ -139,7 +139,7 @@ Object run(TruffleString name,
139139
int nameLength = codePointLengthNode.execute(newModuleName, TS_ENCODING);
140140
int idx = lastIndexNode.execute(newModuleName, '.', nameLength, 0, TS_ENCODING);
141141
if (idx > -1) {
142-
setattrNode.execute(null, newModule, T___PACKAGE__, substringNode.execute(newModuleName, 0, idx, TS_ENCODING, false));
142+
setattrNode.executeSetAttr(null, newModule, T___PACKAGE__, substringNode.execute(newModuleName, 0, idx, TS_ENCODING, false));
143143
}
144144
return newModule;
145145
}
@@ -238,7 +238,7 @@ static Object moduleFunction(Object methodDefPtr, PythonModule mod, TruffleStrin
238238
Object modName = readAttrNode.execute(mod, T___NAME__, null);
239239
assert modName != null : "module name is missing!";
240240
Object func = cFunctionNewExMethodNode.execute(inliningTarget, methodDefPtr, name, cfunc, flags, wrapper, mod, modName, doc);
241-
setattrNode.execute(null, mod, name, func);
241+
setattrNode.executeSetAttr(null, mod, name, func);
242242
return 0;
243243
}
244244
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCSimpleTypeBuiltins.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ static Object PyCSimpleType_new(VirtualFrame frame, Object type, Object[] args,
146146
@Cached PyObjectLookupAttr lookupAttrType,
147147
@Cached GetBaseClassNode getBaseClassNode,
148148
@Cached CastToTruffleStringNode toTruffleStringNode,
149-
@Cached SetAttributeNode.Dynamic setAttrString,
149+
@Cached SetAttributeNode.DynamicStringKey setAttrString,
150150
@Cached PyTypeStgDictNode pyTypeStgDictNode,
151151
@Cached TruffleString.IndexOfStringNode indexOfStringNode,
152152
@Cached TruffleString.CodePointAtIndexNode codePointAtIndexNode,

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCStructTypeBuiltins.java

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -42,25 +42,28 @@
4242

4343
import static com.oracle.graal.python.nodes.ErrorMessages.ATTR_NAME_MUST_BE_STRING;
4444
import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEW__;
45-
import static com.oracle.graal.python.nodes.SpecialMethodNames.J___SETATTR__;
4645
import static com.oracle.graal.python.util.PythonUtils.TS_ENCODING;
4746

4847
import java.util.List;
4948

49+
import com.oracle.graal.python.annotations.Slot;
50+
import com.oracle.graal.python.annotations.Slot.SlotKind;
5051
import com.oracle.graal.python.builtins.Builtin;
5152
import com.oracle.graal.python.builtins.CoreFunctions;
5253
import com.oracle.graal.python.builtins.PythonBuiltinClassType;
5354
import com.oracle.graal.python.builtins.PythonBuiltins;
5455
import com.oracle.graal.python.builtins.modules.ctypes.StructUnionTypeBuiltins.PyCStructUnionTypeUpdateStgDict;
5556
import com.oracle.graal.python.builtins.modules.ctypes.StructUnionTypeBuiltins.StructUnionTypeNewNode;
56-
import com.oracle.graal.python.builtins.objects.PNone;
5757
import com.oracle.graal.python.builtins.objects.str.StringNodes.CastToTruffleStringCheckedNode;
58-
import com.oracle.graal.python.nodes.attributes.WriteAttributeToObjectNode;
58+
import com.oracle.graal.python.builtins.objects.type.TpSlots;
59+
import com.oracle.graal.python.builtins.objects.type.TypeBuiltins;
60+
import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSetAttr.SetAttrBuiltinNode;
5961
import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
60-
import com.oracle.graal.python.nodes.function.builtins.PythonTernaryBuiltinNode;
6162
import com.oracle.graal.python.runtime.object.PythonObjectFactory;
63+
import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff;
6264
import com.oracle.truffle.api.dsl.Bind;
6365
import com.oracle.truffle.api.dsl.Cached;
66+
import com.oracle.truffle.api.dsl.Cached.Shared;
6467
import com.oracle.truffle.api.dsl.GenerateNodeFactory;
6568
import com.oracle.truffle.api.dsl.NodeFactory;
6669
import com.oracle.truffle.api.dsl.Specialization;
@@ -70,6 +73,7 @@
7073

7174
@CoreFunctions(extendClasses = PythonBuiltinClassType.PyCStructType)
7275
public final class PyCStructTypeBuiltins extends PythonBuiltins {
76+
public static final TpSlots SLOTS = PyCStructTypeBuiltinsSlotsGen.SLOTS;
7377

7478
@Override
7579
protected List<? extends NodeFactory<? extends PythonBuiltinBaseNode>> getNodeFactories() {
@@ -81,24 +85,34 @@ protected List<? extends NodeFactory<? extends PythonBuiltinBaseNode>> getNodeFa
8185
protected abstract static class NewNode extends StructUnionTypeNewNode {
8286
}
8387

84-
@Builtin(name = J___SETATTR__, minNumOfPositionalArgs = 3)
88+
@Slot(value = SlotKind.tp_set_attro, isComplex = true)
8589
@GenerateNodeFactory
86-
protected abstract static class SetattrNode extends PythonTernaryBuiltinNode {
90+
protected abstract static class SetattrNode extends SetAttrBuiltinNode {
91+
@Specialization
92+
void doStringKey(VirtualFrame frame, Object object, TruffleString key, Object value,
93+
@Shared @Cached TypeBuiltins.SetattrNode typeSetAttr,
94+
@Shared @Cached TruffleString.EqualNode equalNode,
95+
@Shared @Cached PyCStructUnionTypeUpdateStgDict updateStgDict,
96+
@Shared @Cached PythonObjectFactory factory) {
97+
// CPython just delegates to "PyType_Type.tp_setattro" with the comment:
98+
/* XXX Should we disallow deleting _fields_? */
99+
typeSetAttr.executeSetAttr(frame, object, key, value);
100+
if (equalNode.execute(key, StructUnionTypeBuiltins.T__FIELDS_, TS_ENCODING)) {
101+
updateStgDict.execute(frame, object, value, true, factory);
102+
}
103+
}
87104

88105
@Specialization
89-
PNone doStringKey(VirtualFrame frame, Object object, Object keyObject, Object value,
106+
@InliningCutoff
107+
void doGeneric(VirtualFrame frame, Object object, Object keyObject, Object value,
90108
@Bind("this") Node inliningTarget,
91-
@Cached TruffleString.EqualNode equalNode,
92-
@Cached WriteAttributeToObjectNode writeNode,
93-
@Cached PyCStructUnionTypeUpdateStgDict updateStgDict,
94109
@Cached CastToTruffleStringCheckedNode castKeyToStringNode,
95-
@Cached PythonObjectFactory factory) {
110+
@Shared @Cached TypeBuiltins.SetattrNode typeSetAttr,
111+
@Shared @Cached TruffleString.EqualNode equalNode,
112+
@Shared @Cached PyCStructUnionTypeUpdateStgDict updateStgDict,
113+
@Shared @Cached PythonObjectFactory factory) {
96114
TruffleString key = castKeyToStringNode.cast(inliningTarget, keyObject, ATTR_NAME_MUST_BE_STRING, keyObject);
97-
writeNode.execute(object, key, value);
98-
if (equalNode.execute(key, StructUnionTypeBuiltins.T__FIELDS_, TS_ENCODING)) {
99-
updateStgDict.execute(frame, object, value, true, factory);
100-
}
101-
return PNone.NONE;
115+
doStringKey(frame, object, key, value, typeSetAttr, equalNode, updateStgDict, factory);
102116
}
103117
}
104118
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/UnionTypeBuiltins.java

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -41,31 +41,42 @@
4141
package com.oracle.graal.python.builtins.modules.ctypes;
4242

4343
import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEW__;
44-
import static com.oracle.graal.python.nodes.SpecialMethodNames.J___SETATTR__;
4544
import static com.oracle.graal.python.util.PythonUtils.TS_ENCODING;
4645

4746
import java.util.List;
4847

48+
import com.oracle.graal.python.annotations.Slot;
49+
import com.oracle.graal.python.annotations.Slot.SlotKind;
4950
import com.oracle.graal.python.builtins.Builtin;
5051
import com.oracle.graal.python.builtins.CoreFunctions;
5152
import com.oracle.graal.python.builtins.PythonBuiltinClassType;
5253
import com.oracle.graal.python.builtins.PythonBuiltins;
5354
import com.oracle.graal.python.builtins.modules.ctypes.StructUnionTypeBuiltins.PyCStructUnionTypeUpdateStgDict;
5455
import com.oracle.graal.python.builtins.modules.ctypes.StructUnionTypeBuiltins.StructUnionTypeNewNode;
55-
import com.oracle.graal.python.builtins.objects.PNone;
56+
import com.oracle.graal.python.builtins.objects.object.ObjectNodes;
57+
import com.oracle.graal.python.builtins.objects.object.ObjectNodes.GenericSetAttrNode;
58+
import com.oracle.graal.python.builtins.objects.type.TpSlots;
59+
import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSetAttr.SetAttrBuiltinNode;
60+
import com.oracle.graal.python.nodes.PRaiseNode;
5661
import com.oracle.graal.python.nodes.attributes.WriteAttributeToObjectNode;
5762
import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
58-
import com.oracle.graal.python.nodes.function.builtins.PythonTernaryBuiltinNode;
63+
import com.oracle.graal.python.nodes.util.CastToTruffleStringNode;
5964
import com.oracle.graal.python.runtime.object.PythonObjectFactory;
65+
import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff;
66+
import com.oracle.truffle.api.dsl.Bind;
6067
import com.oracle.truffle.api.dsl.Cached;
68+
import com.oracle.truffle.api.dsl.Cached.Shared;
6169
import com.oracle.truffle.api.dsl.GenerateNodeFactory;
6270
import com.oracle.truffle.api.dsl.NodeFactory;
6371
import com.oracle.truffle.api.dsl.Specialization;
6472
import com.oracle.truffle.api.frame.VirtualFrame;
73+
import com.oracle.truffle.api.nodes.Node;
6574
import com.oracle.truffle.api.strings.TruffleString;
75+
import com.oracle.truffle.api.strings.TruffleString.EqualNode;
6676

6777
@CoreFunctions(extendClasses = PythonBuiltinClassType.UnionType)
6878
public final class UnionTypeBuiltins extends PythonBuiltins {
79+
public static final TpSlots SLOTS = UnionTypeBuiltinsSlotsGen.SLOTS;
6980

7081
@Override
7182
protected List<? extends NodeFactory<? extends PythonBuiltinBaseNode>> getNodeFactories() {
@@ -81,21 +92,42 @@ protected boolean isStruct() {
8192
}
8293
}
8394

84-
@Builtin(name = J___SETATTR__, minNumOfPositionalArgs = 3)
95+
@Slot(value = SlotKind.tp_set_attro, isComplex = true)
8596
@GenerateNodeFactory
86-
protected abstract static class SetattrNode extends PythonTernaryBuiltinNode {
97+
protected abstract static class SetattrNode extends SetAttrBuiltinNode {
98+
@Specialization
99+
static void doStringKey(VirtualFrame frame, Object object, TruffleString key, Object value,
100+
@Bind("this") Node inliningTarget,
101+
@Shared @Cached ObjectNodes.GenericSetAttrNode genericSetAttrNode,
102+
@Shared @Cached WriteAttributeToObjectNode write,
103+
@Shared @Cached TruffleString.EqualNode equalNode,
104+
@Shared @Cached PyCStructUnionTypeUpdateStgDict updateStgDict,
105+
@Shared @Cached PythonObjectFactory factory) {
106+
genericSetAttrNode.execute(inliningTarget, frame, object, key, value, write);
107+
updateStgDictIfNecessary(frame, object, key, value, equalNode, updateStgDict, factory);
108+
}
87109

88110
@Specialization
89-
static PNone doStringKey(VirtualFrame frame, Object object, TruffleString key, Object value,
90-
@Cached TruffleString.EqualNode equalNode,
91-
@Cached WriteAttributeToObjectNode writeNode,
92-
@Cached PyCStructUnionTypeUpdateStgDict updateStgDict,
93-
@Cached PythonObjectFactory factory) {
94-
writeNode.execute(object, key, value);
111+
@InliningCutoff
112+
static void doGenericKey(VirtualFrame frame, Object object, Object keyObject, Object value,
113+
@Bind("this") Node inliningTarget,
114+
@Cached CastToTruffleStringNode castKeyNode,
115+
@Cached PRaiseNode.Lazy raiseNode,
116+
@Shared @Cached ObjectNodes.GenericSetAttrNode genericSetAttrNode,
117+
@Shared @Cached WriteAttributeToObjectNode write,
118+
@Shared @Cached TruffleString.EqualNode equalNode,
119+
@Shared @Cached PyCStructUnionTypeUpdateStgDict updateStgDict,
120+
@Shared @Cached PythonObjectFactory factory) {
121+
TruffleString key = GenericSetAttrNode.castAttributeKey(inliningTarget, keyObject, castKeyNode, raiseNode);
122+
genericSetAttrNode.execute(inliningTarget, frame, object, key, value, write);
123+
updateStgDictIfNecessary(frame, object, key, value, equalNode, updateStgDict, factory);
124+
}
125+
126+
private static void updateStgDictIfNecessary(VirtualFrame frame, Object object, TruffleString key, Object value,
127+
EqualNode equalNode, PyCStructUnionTypeUpdateStgDict updateStgDict, PythonObjectFactory factory) {
95128
if (equalNode.execute(key, StructUnionTypeBuiltins.T__FIELDS_, TS_ENCODING)) {
96129
updateStgDict.execute(frame, object, value, false, factory);
97130
}
98-
return PNone.NONE;
99131
}
100132
}
101133

0 commit comments

Comments
 (0)