Skip to content

Commit 7c48ea7

Browse files
committed
use direclty WriteAttributeToObjectNode instead of dict in PyModule_AddObject
1 parent bf08e32 commit 7c48ea7

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

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

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
import com.oracle.graal.python.builtins.objects.object.ObjectBuiltins;
6868
import com.oracle.graal.python.builtins.objects.str.PString;
6969
import com.oracle.graal.python.lib.PyObjectLookupAttr;
70+
import com.oracle.graal.python.nodes.attributes.WriteAttributeToObjectNode;
7071
import com.oracle.graal.python.nodes.call.CallNode;
7172
import com.oracle.graal.python.nodes.classes.IsSubtypeNode;
7273
import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
@@ -202,19 +203,11 @@ public abstract static class PyModuleAddObjectNode extends PythonTernaryBuiltinN
202203
Object addObject(VirtualFrame frame, Object m, String k, Object o,
203204
@SuppressWarnings("unused") @Cached GetClassNode getClassNode,
204205
@SuppressWarnings("unused") @Cached IsSubtypeNode isSubtypeNode,
205-
@Cached PyObjectLookupAttr lookupAttrNode,
206-
@Cached GetDictIfExistsNode getDictNode,
207-
@Cached BranchProfile noDictProfile,
208-
@CachedLibrary(limit = "3") HashingStorageLibrary lib,
206+
@Cached WriteAttributeToObjectNode writeAtrrNode,
209207
@Cached PRaiseNativeNode raiseNativeNode,
210208
@Cached TransformExceptionToNativeNode transformExceptionToNativeNode) {
211209
try {
212-
PDict dict = getDictNode.execute(m);
213-
if (dict == null) {
214-
noDictProfile.enter();
215-
return raiseNativeNode.raiseInt(frame, -1, SystemError, MODULE_S_HAS_NO, lookupAttrNode.execute(frame, m, __NAME__), __DICT__);
216-
}
217-
lib.setItem(dict.getDictStorage(), k, o);
210+
writeAtrrNode.execute(m, k, o);
218211
return 0;
219212
} catch (PException e) {
220213
transformExceptionToNativeNode.execute(e);
@@ -226,13 +219,10 @@ Object addObject(VirtualFrame frame, Object m, String k, Object o,
226219
Object addObject(VirtualFrame frame, Object m, PString k, Object o,
227220
@SuppressWarnings("unused") @Cached GetClassNode getClassNode,
228221
@SuppressWarnings("unused") @Cached IsSubtypeNode isSubtypeNode,
229-
@Cached PyObjectLookupAttr lookupAttrNode,
230-
@Cached GetDictIfExistsNode getDictNode,
231-
@Cached BranchProfile noDictProfile,
232-
@CachedLibrary(limit = "3") HashingStorageLibrary lib,
222+
@Cached WriteAttributeToObjectNode writeAtrrNode,
233223
@Cached PRaiseNativeNode raiseNativeNode,
234224
@Cached TransformExceptionToNativeNode transformExceptionToNativeNode) {
235-
return addObject(frame, m, k.getValue(), o, getClassNode, isSubtypeNode, lookupAttrNode, getDictNode, noDictProfile, lib, raiseNativeNode, transformExceptionToNativeNode);
225+
return addObject(frame, m, k.getValue(), o, getClassNode, isSubtypeNode, writeAtrrNode, raiseNativeNode, transformExceptionToNativeNode);
236226
}
237227

238228
@SuppressWarnings("unused")

0 commit comments

Comments
 (0)