@@ -231,12 +231,11 @@ Object callNativeConstructor(Object object, Object arg,
231
231
@ Bind ("this" ) Node inliningTarget ,
232
232
@ Cached PythonToNativeNode toSulongNode ,
233
233
@ Cached NativeToPythonNode toJavaNode ,
234
- @ CachedLibrary (limit = "1" ) InteropLibrary interopLibrary ,
235
- @ Cached ImportCAPISymbolNode importCAPISymbolNode ) {
234
+ @ CachedLibrary (limit = "1" ) InteropLibrary interopLibrary ) {
236
235
assert TypeNodes .NeedsNativeAllocationNode .executeUncached (object );
237
236
try {
238
- CApiContext cApiContext = PythonContext . get (inliningTarget ). getCApiContext ( );
239
- Object result = interopLibrary .execute (importCAPISymbolNode . execute ( inliningTarget , cApiContext , getFunction ()) , toSulongNode .execute (object ), arg );
237
+ Object callable = CApiContext . getNativeSymbol (inliningTarget , getFunction () );
238
+ Object result = interopLibrary .execute (callable , toSulongNode .execute (object ), arg );
240
239
return toJavaNode .execute (result );
241
240
} catch (UnsupportedMessageException | UnsupportedTypeException | ArityException e ) {
242
241
throw shouldNotReachHere ("C subtype_new function failed" , e );
@@ -583,9 +582,9 @@ public abstract static class PointerCompareNode extends Node {
583
582
584
583
public abstract boolean execute (Node inliningTarget , ComparisonOp op , Object a , Object b );
585
584
586
- private static boolean executeCFunction (Node inliningTarget , int op , Object a , Object b , InteropLibrary interopLibrary , ImportCAPISymbolNode importCAPISymbolNode ) {
585
+ private static boolean executeCFunction (Node inliningTarget , int op , Object a , Object b , InteropLibrary interopLibrary ) {
587
586
try {
588
- Object sym = importCAPISymbolNode . execute (inliningTarget , FUN_PTR_COMPARE );
587
+ Object sym = CApiContext . getNativeSymbol (inliningTarget , FUN_PTR_COMPARE );
589
588
return (int ) interopLibrary .execute (sym , a , b , op ) != 0 ;
590
589
} catch (UnsupportedTypeException | ArityException | UnsupportedMessageException e ) {
591
590
CompilerDirectives .transferToInterpreterAndInvalidate ();
@@ -602,26 +601,23 @@ static boolean doEqNe(ComparisonOp op, PythonAbstractNativeObject a, PythonAbstr
602
601
603
602
@ Specialization
604
603
static boolean doPythonNativeObject (Node inliningTarget , ComparisonOp op , PythonNativeObject a , PythonNativeObject b ,
605
- @ Shared @ CachedLibrary (limit = "1" ) InteropLibrary interopLibrary ,
606
- @ Shared @ Cached ImportCAPISymbolNode importCAPISymbolNode ) {
604
+ @ Shared @ CachedLibrary (limit = "1" ) InteropLibrary interopLibrary ) {
607
605
CompilerAsserts .partialEvaluationConstant (op );
608
- return executeCFunction (inliningTarget , op .opCode , a .getPtr (), b .getPtr (), interopLibrary , importCAPISymbolNode );
606
+ return executeCFunction (inliningTarget , op .opCode , a .getPtr (), b .getPtr (), interopLibrary );
609
607
}
610
608
611
609
@ Specialization
612
610
static boolean doPythonNativeObjectLong (Node inliningTarget , ComparisonOp op , PythonNativeObject a , long b ,
613
- @ Shared @ CachedLibrary (limit = "1" ) InteropLibrary interopLibrary ,
614
- @ Shared @ Cached ImportCAPISymbolNode importCAPISymbolNode ) {
611
+ @ Shared @ CachedLibrary (limit = "1" ) InteropLibrary interopLibrary ) {
615
612
CompilerAsserts .partialEvaluationConstant (op );
616
- return executeCFunction (inliningTarget , op .opCode , a .getPtr (), b , interopLibrary , importCAPISymbolNode );
613
+ return executeCFunction (inliningTarget , op .opCode , a .getPtr (), b , interopLibrary );
617
614
}
618
615
619
616
@ Specialization
620
617
static boolean doNativeVoidPtrLong (Node inliningTarget , ComparisonOp op , PythonNativeVoidPtr a , long b ,
621
- @ Shared @ CachedLibrary (limit = "1" ) InteropLibrary interopLibrary ,
622
- @ Shared @ Cached ImportCAPISymbolNode importCAPISymbolNode ) {
618
+ @ Shared @ CachedLibrary (limit = "1" ) InteropLibrary interopLibrary ) {
623
619
CompilerAsserts .partialEvaluationConstant (op );
624
- return executeCFunction (inliningTarget , op .opCode , a .getPointerObject (), b , interopLibrary , importCAPISymbolNode );
620
+ return executeCFunction (inliningTarget , op .opCode , a .getPointerObject (), b , interopLibrary );
625
621
}
626
622
}
627
623
@@ -822,22 +818,19 @@ public final Object call(NativeCAPISymbol symbol, Object... args) {
822
818
protected abstract Object execute (NativeCAPISymbol symbol , Object [] args );
823
819
824
820
@ Specialization
825
- static Object doWithoutContext (NativeCAPISymbol name , Object [] args ,
821
+ static Object doWithoutContext (NativeCAPISymbol symbol , Object [] args ,
826
822
@ Bind ("this" ) Node inliningTarget ,
827
- @ Cached ImportCAPISymbolNode importCAPISymbolNode ,
828
823
@ CachedLibrary (limit = "1" ) InteropLibrary interopLibrary ,
829
824
@ Cached EnsureTruffleStringNode ensureTruffleStringNode ) {
830
825
try {
831
826
PythonContext pythonContext = PythonContext .get (inliningTarget );
832
- CApiContext cApiContext ;
833
827
if (!pythonContext .hasCApiContext ()) {
834
828
CompilerDirectives .transferToInterpreterAndInvalidate ();
835
- cApiContext = CApiContext .ensureCapiWasLoaded ();
836
- } else {
837
- cApiContext = pythonContext .getCApiContext ();
829
+ CApiContext .ensureCapiWasLoaded ();
838
830
}
839
831
// TODO review EnsureTruffleStringNode with GR-37896
840
- return ensureTruffleStringNode .execute (inliningTarget , interopLibrary .execute (importCAPISymbolNode .execute (inliningTarget , cApiContext , name ), args ));
832
+ Object callable = CApiContext .getNativeSymbol (inliningTarget , symbol );
833
+ return ensureTruffleStringNode .execute (inliningTarget , interopLibrary .execute (callable , args ));
841
834
} catch (UnsupportedTypeException | ArityException | UnsupportedMessageException e ) {
842
835
// consider these exceptions to be fatal internal errors
843
836
throw shouldNotReachHere (e );
@@ -2020,21 +2013,4 @@ public static Object resolveClosurePointer(PythonContext context, Object callabl
2020
2013
return null ;
2021
2014
}
2022
2015
}
2023
-
2024
- @ GenerateUncached
2025
- @ GenerateInline
2026
- @ GenerateCached (false )
2027
- public abstract static class ImportCAPISymbolNode extends PNodeWithContext {
2028
-
2029
- public final Object execute (Node inliningTarget , NativeCAPISymbol symbol ) {
2030
- return execute (inliningTarget , PythonContext .get (inliningTarget ).getCApiContext (), symbol );
2031
- }
2032
-
2033
- public abstract Object execute (Node inliningTarget , CApiContext nativeContext , NativeCAPISymbol symbol );
2034
-
2035
- @ Specialization
2036
- static Object doGeneric (Node inliningTarget , @ SuppressWarnings ("unused" ) CApiContext nativeContext , NativeCAPISymbol symbol ) {
2037
- return CApiContext .getNativeSymbol (inliningTarget , symbol );
2038
- }
2039
- }
2040
2016
}
0 commit comments