1
1
/*
2
- * Copyright (c) 2017, 2022 , Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 2017, 2023 , Oracle and/or its affiliates. All rights reserved.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* The Universal Permissive License (UPL), Version 1.0
83
83
import com .oracle .graal .python .builtins .objects .bytes .BytesNodes ;
84
84
import com .oracle .graal .python .builtins .objects .bytes .PBytes ;
85
85
import com .oracle .graal .python .builtins .objects .cext .capi .CExtNodes .ExecModuleNode ;
86
- import com .oracle .graal .python .builtins .objects .cext .capi .DynamicObjectNativeWrapper ;
87
86
import com .oracle .graal .python .builtins .objects .cext .capi .ExternalFunctionNodesFactory .DefaultCheckFunctionResultNodeGen ;
88
- import com .oracle .graal .python .builtins .objects .cext .capi .NativeMember ;
89
87
import com .oracle .graal .python .builtins .objects .cext .common .CExtCommonNodes .CheckFunctionResultNode ;
90
88
import com .oracle .graal .python .builtins .objects .cext .common .CExtContext ;
91
89
import com .oracle .graal .python .builtins .objects .cext .common .CExtContext .ModuleSpec ;
95
93
import com .oracle .graal .python .builtins .objects .cext .hpy .HPyExternalFunctionNodesFactory .HPyCheckHandleResultNodeGen ;
96
94
import com .oracle .graal .python .builtins .objects .code .CodeNodes ;
97
95
import com .oracle .graal .python .builtins .objects .code .PCode ;
98
- import com .oracle .graal .python .builtins .objects .common .HashingStorageNodes .HashingStorageGetItem ;
99
96
import com .oracle .graal .python .builtins .objects .function .PArguments ;
100
97
import com .oracle .graal .python .builtins .objects .ints .IntBuiltins ;
101
98
import com .oracle .graal .python .builtins .objects .memoryview .PMemoryView ;
135
132
import com .oracle .truffle .api .dsl .NodeFactory ;
136
133
import com .oracle .truffle .api .dsl .Specialization ;
137
134
import com .oracle .truffle .api .frame .VirtualFrame ;
135
+ import com .oracle .truffle .api .interop .InteropLibrary ;
138
136
import com .oracle .truffle .api .library .CachedLibrary ;
139
137
import com .oracle .truffle .api .profiles .ConditionProfile ;
140
138
import com .oracle .truffle .api .strings .TruffleString ;
@@ -355,7 +353,7 @@ private HPyCheckFunctionResultNode getCheckHPyResultNode() {
355
353
public abstract static class ExecDynamicNode extends PythonBuiltinNode {
356
354
@ Specialization
357
355
int doPythonModule (VirtualFrame frame , PythonModule extensionModule ,
358
- @ Cached HashingStorageGetItem getItem ,
356
+ @ CachedLibrary ( limit = "1" ) InteropLibrary lib ,
359
357
@ Cached ExecModuleNode execModuleNode ) {
360
358
Object nativeModuleDef = extensionModule .getNativeModuleDef ();
361
359
if (nativeModuleDef == null ) {
@@ -364,15 +362,11 @@ int doPythonModule(VirtualFrame frame, PythonModule extensionModule,
364
362
365
363
/*
366
364
* Check if module is already initialized. CPython does that by testing if 'md_state !=
367
- * NULL'. So, we do the same. Currently, we store this in the generic storage of the
368
- * native wrapper.
365
+ * NULL'. So, we do the same.
369
366
*/
370
- DynamicObjectNativeWrapper nativeWrapper = extensionModule .getNativeWrapper ();
371
- if (nativeWrapper != null && nativeWrapper .getNativeMemberStore () != null ) {
372
- Object item = getItem .execute (nativeWrapper .getNativeMemberStore (), NativeMember .MD_STATE .getMemberNameTruffleString ());
373
- if (item != PNone .NO_VALUE ) {
374
- return 0 ;
375
- }
367
+ Object mdState = extensionModule .getNativeModuleState ();
368
+ if (mdState != null && !lib .isNull (mdState )) {
369
+ return 0 ;
376
370
}
377
371
378
372
PythonContext context = getContext ();
0 commit comments