@@ -152,51 +152,51 @@ public abstract static class ImportCExtSymbolNode extends PNodeWithContext {
152
152
public abstract Object execute (CExtContext nativeContext , NativeCExtSymbol symbol );
153
153
154
154
@ Specialization (guards = "cachedSymbol == symbol" , limit = "1" , assumptions = "singleContextAssumption()" )
155
- @ SuppressWarnings ("unused" )
156
- static Object doSymbolCached (CExtContext nativeContext , NativeCExtSymbol symbol ,
157
- @ Cached ("symbol" ) NativeCExtSymbol cachedSymbol ,
158
- @ Shared ("raiseNode" ) @ Cached PRaiseNode raiseNode ,
159
- @ Cached ("importCAPISymbolUncached(nativeContext, raiseNode, symbol)" ) Object llvmSymbol ) {
155
+ static Object doSymbolCached (@ SuppressWarnings ("unused" ) CExtContext nativeContext , @ SuppressWarnings ("unused" ) NativeCExtSymbol symbol ,
156
+ @ Cached ("symbol" ) @ SuppressWarnings ("unused" ) NativeCExtSymbol cachedSymbol ,
157
+ @ Cached ("importCAPISymbolUncached(nativeContext, symbol)" ) Object llvmSymbol ) {
160
158
return llvmSymbol ;
161
159
}
162
160
163
161
// n.b. if 'singleContextAssumption' is valid, we may also cache the native context
164
162
@ Specialization (guards = "nativeContext == cachedNativeContext" , limit = "1" , //
165
163
assumptions = "singleContextAssumption()" , //
166
164
replaces = "doSymbolCached" )
167
- @ SuppressWarnings ("unused" )
168
- static Object doWithSymbolCacheSingleContext (CExtContext nativeContext , NativeCExtSymbol symbol ,
165
+ Object doWithSymbolCacheSingleContext (@ SuppressWarnings ("unused" ) CExtContext nativeContext , NativeCExtSymbol symbol ,
169
166
@ Cached ("nativeContext" ) CExtContext cachedNativeContext ,
170
167
@ Cached ("nativeContext.getSymbolCache()" ) DynamicObject cachedSymbolCache ,
171
- @ CachedLibrary ("cachedSymbolCache" ) DynamicObjectLibrary dynamicObjectLib ,
172
- @ Shared ("raiseNode" ) @ Cached PRaiseNode raiseNode ,
173
- @ Cached ("importCAPISymbolUncached(nativeContext, raiseNode, symbol)" ) Object sym ) {
174
- return doWithSymbolCache (cachedNativeContext , symbol , cachedSymbolCache , dynamicObjectLib , raiseNode );
168
+ @ CachedLibrary ("cachedSymbolCache" ) DynamicObjectLibrary dynamicObjectLib ) {
169
+ return doWithSymbolCache (cachedNativeContext , symbol , cachedSymbolCache , dynamicObjectLib );
175
170
}
176
171
177
172
@ Specialization (replaces = {"doSymbolCached" , "doWithSymbolCacheSingleContext" }, limit = "1" )
178
- static Object doWithSymbolCache (CExtContext nativeContext , NativeCExtSymbol symbol ,
173
+ Object doWithSymbolCache (CExtContext nativeContext , NativeCExtSymbol symbol ,
179
174
@ Bind ("nativeContext.getSymbolCache()" ) DynamicObject symbolCache ,
180
- @ CachedLibrary ("symbolCache" ) DynamicObjectLibrary dynamicObjectLib ,
181
- @ Shared ("raiseNode" ) @ Cached PRaiseNode raiseNode ) {
175
+ @ CachedLibrary ("symbolCache" ) DynamicObjectLibrary dynamicObjectLib ) {
182
176
Object nativeSymbol = dynamicObjectLib .getOrDefault (symbolCache , symbol , PNone .NO_VALUE );
183
177
if (nativeSymbol == PNone .NO_VALUE ) {
184
- CompilerDirectives .transferToInterpreter ();
185
- nativeSymbol = importCAPISymbolUncached (nativeContext , raiseNode , symbol );
186
- dynamicObjectLib .put (symbolCache , symbol , nativeSymbol );
178
+ nativeSymbol = importCAPISymbolUncached (nativeContext , symbol , symbolCache , dynamicObjectLib );
187
179
}
188
180
return nativeSymbol ;
189
181
}
190
182
191
- protected static Object importCAPISymbolUncached (CExtContext nativeContext , PRaiseNode raiseNode , NativeCExtSymbol symbol ) {
183
+ protected Object importCAPISymbolUncached (CExtContext nativeContext , NativeCExtSymbol symbol ) {
184
+ CompilerAsserts .neverPartOfCompilation ();
185
+ return importCAPISymbolUncached (nativeContext , symbol , nativeContext .getSymbolCache (), DynamicObjectLibrary .getUncached ());
186
+ }
187
+
188
+ @ TruffleBoundary
189
+ protected Object importCAPISymbolUncached (CExtContext nativeContext , NativeCExtSymbol symbol , DynamicObject symbolCache , DynamicObjectLibrary dynamicObjectLib ) {
192
190
Object llvmLibrary = nativeContext .getLLVMLibrary ();
193
191
String name = symbol .getName ();
194
192
try {
195
- return InteropLibrary .getUncached ().readMember (llvmLibrary , name );
193
+ Object nativeSymbol = InteropLibrary .getUncached ().readMember (llvmLibrary , name );
194
+ dynamicObjectLib .put (symbolCache , symbol , nativeSymbol );
195
+ return nativeSymbol ;
196
196
} catch (UnknownIdentifierException e ) {
197
- throw raiseNode . raise ( PythonBuiltinClassType .SystemError , ErrorMessages .INVALID_CAPI_FUNC , name );
197
+ throw PRaiseNode . raiseUncached ( this , PythonBuiltinClassType .SystemError , ErrorMessages .INVALID_CAPI_FUNC , name );
198
198
} catch (UnsupportedMessageException e ) {
199
- throw raiseNode . raise ( PythonBuiltinClassType .SystemError , ErrorMessages .CORRUPTED_CAPI_LIB_OBJ , llvmLibrary );
199
+ throw PRaiseNode . raiseUncached ( this , PythonBuiltinClassType .SystemError , ErrorMessages .CORRUPTED_CAPI_LIB_OBJ , llvmLibrary );
200
200
}
201
201
}
202
202
}
0 commit comments