46
46
import com .oracle .graal .python .builtins .modules .ExternalFunctionNodesFactory .MaterializePrimitiveNodeGen ;
47
47
import com .oracle .graal .python .builtins .modules .ExternalFunctionNodesFactory .ReleaseNativeWrapperNodeGen ;
48
48
import com .oracle .graal .python .builtins .modules .PythonCextBuiltins .CheckFunctionResultNode ;
49
+ import com .oracle .graal .python .builtins .modules .PythonCextBuiltins .PExternalFunctionWrapper ;
50
+ import com .oracle .graal .python .builtins .modules .PythonCextBuiltinsFactory .DefaultCheckFunctionResultNodeGen ;
49
51
import com .oracle .graal .python .builtins .objects .PNone ;
50
52
import com .oracle .graal .python .builtins .objects .cext .CApiGuards ;
51
53
import com .oracle .graal .python .builtins .objects .cext .CExtNodes ;
@@ -192,7 +194,7 @@ public static MethDirectRoot create(PythonLanguage lang, String name, Object cal
192
194
*/
193
195
static final class ExternalFunctionInvokeNode extends PNodeWithContext implements IndirectCallNode {
194
196
@ Child private CExtNodes .ConvertArgsToSulongNode toSulongNode ;
195
- @ Child private CheckFunctionResultNode checkResultNode = CheckFunctionResultNode . create () ;
197
+ @ Child private CheckFunctionResultNode checkResultNode ;
196
198
@ Child private PForeignToPTypeNode fromForeign = PForeignToPTypeNode .create ();
197
199
@ Child private ToJavaStealingNode asPythonObjectNode = ToJavaStealingNodeGen .create ();
198
200
@ Child private InteropLibrary lib ;
@@ -220,12 +222,17 @@ public Node copy() {
220
222
return node ;
221
223
}
222
224
225
+ @ TruffleBoundary
223
226
ExternalFunctionInvokeNode () {
224
227
this .toSulongNode = CExtNodes .AllToSulongNode .create ();
225
228
}
226
229
227
- ExternalFunctionInvokeNode (ConvertArgsToSulongNode convertArgsNode ) {
230
+ @ TruffleBoundary
231
+ ExternalFunctionInvokeNode (PExternalFunctionWrapper provider ) {
232
+ ConvertArgsToSulongNode convertArgsNode = provider .createConvertArgsToSulongNode ();
228
233
this .toSulongNode = convertArgsNode != null ? convertArgsNode : CExtNodes .AllToSulongNode .create ();
234
+ CheckFunctionResultNode checkFunctionResultNode = provider .getCheckFunctionResultNode ();
235
+ this .checkResultNode = checkFunctionResultNode != null ? checkFunctionResultNode : DefaultCheckFunctionResultNodeGen .create ();
229
236
}
230
237
231
238
public Object execute (VirtualFrame frame , String name , Object callable , Object [] frameArgs , int argsOffset ) {
@@ -283,8 +290,8 @@ public static ExternalFunctionInvokeNode create() {
283
290
return new ExternalFunctionInvokeNode ();
284
291
}
285
292
286
- public static ExternalFunctionInvokeNode create (ConvertArgsToSulongNode convertArgsNode ) {
287
- return new ExternalFunctionInvokeNode (convertArgsNode );
293
+ public static ExternalFunctionInvokeNode create (PExternalFunctionWrapper provider ) {
294
+ return new ExternalFunctionInvokeNode (provider );
288
295
}
289
296
}
290
297
@@ -369,12 +376,12 @@ abstract static class MethodDescriptorRoot extends PRootNode {
369
376
}
370
377
371
378
@ TruffleBoundary
372
- MethodDescriptorRoot (PythonLanguage language , String name , Object callable , ConvertArgsToSulongNode convertArgsToSulongNode ) {
379
+ MethodDescriptorRoot (PythonLanguage language , String name , Object callable , PExternalFunctionWrapper provider ) {
373
380
super (language );
374
381
this .name = name ;
375
382
this .callable = callable ;
376
- if (convertArgsToSulongNode != null ) {
377
- this .externalInvokeNode = ExternalFunctionInvokeNode .create (convertArgsToSulongNode );
383
+ if (provider != null ) {
384
+ this .externalInvokeNode = ExternalFunctionInvokeNode .create (provider );
378
385
} else {
379
386
this .invokeNode = CallVarargsMethodNode .create ();
380
387
}
@@ -476,8 +483,8 @@ public MethKeywordsRoot(PythonLanguage language, String name, Object callable) {
476
483
super (language , name , callable );
477
484
}
478
485
479
- public MethKeywordsRoot (PythonLanguage language , String name , Object callable , ConvertArgsToSulongNode convertArgsToSulongNode ) {
480
- super (language , name , callable , convertArgsToSulongNode );
486
+ public MethKeywordsRoot (PythonLanguage language , String name , Object callable , PExternalFunctionWrapper provider ) {
487
+ super (language , name , callable , provider );
481
488
this .factory = PythonObjectFactory .create ();
482
489
this .readVarargsNode = ReadVarArgsNode .create (1 , true );
483
490
this .readKwargsNode = ReadVarKeywordsNode .create (new String [0 ]);
@@ -523,8 +530,8 @@ public MethVarargsRoot(PythonLanguage language, String name, Object callable) {
523
530
super (language , name , callable );
524
531
}
525
532
526
- public MethVarargsRoot (PythonLanguage language , String name , Object callable , ConvertArgsToSulongNode convertArgsToSulongNode ) {
527
- super (language , name , callable , convertArgsToSulongNode );
533
+ public MethVarargsRoot (PythonLanguage language , String name , Object callable , PExternalFunctionWrapper provider ) {
534
+ super (language , name , callable , provider );
528
535
this .factory = PythonObjectFactory .create ();
529
536
this .readVarargsNode = ReadVarArgsNode .create (1 , true );
530
537
this .createArgsTupleNode = CreateArgsTupleNodeGen .create ();
@@ -564,8 +571,8 @@ public MethNoargsRoot(PythonLanguage language, String name, Object callable) {
564
571
super (language , name , callable );
565
572
}
566
573
567
- public MethNoargsRoot (PythonLanguage language , String name , Object callable , ConvertArgsToSulongNode convertArgsToSulongNode ) {
568
- super (language , name , callable , convertArgsToSulongNode );
574
+ public MethNoargsRoot (PythonLanguage language , String name , Object callable , PExternalFunctionWrapper provider ) {
575
+ super (language , name , callable , provider );
569
576
}
570
577
571
578
@ Override
@@ -588,8 +595,8 @@ public MethORoot(PythonLanguage language, String name, Object callable) {
588
595
super (language , name , callable );
589
596
}
590
597
591
- public MethORoot (PythonLanguage language , String name , Object callable , ConvertArgsToSulongNode convertArgsToSulongNode ) {
592
- super (language , name , callable , convertArgsToSulongNode );
598
+ public MethORoot (PythonLanguage language , String name , Object callable , PExternalFunctionWrapper provider ) {
599
+ super (language , name , callable , provider );
593
600
this .readArgNode = ReadIndexedArgumentNode .create (1 );
594
601
}
595
602
@@ -616,8 +623,8 @@ public MethFastcallWithKeywordsRoot(PythonLanguage language, String name, Object
616
623
super (language , name , callable );
617
624
}
618
625
619
- public MethFastcallWithKeywordsRoot (PythonLanguage language , String name , Object callable , ConvertArgsToSulongNode convertArgsToSulongNode ) {
620
- super (language , name , callable , convertArgsToSulongNode );
626
+ public MethFastcallWithKeywordsRoot (PythonLanguage language , String name , Object callable , PExternalFunctionWrapper provider ) {
627
+ super (language , name , callable , provider );
621
628
this .factory = PythonObjectFactory .create ();
622
629
this .readVarargsNode = ReadVarArgsNode .create (1 , true );
623
630
this .readKwargsNode = ReadVarKeywordsNode .create (new String [0 ]);
@@ -653,8 +660,8 @@ public MethFastcallRoot(PythonLanguage language, String name, Object callable) {
653
660
super (language , name , callable );
654
661
}
655
662
656
- public MethFastcallRoot (PythonLanguage language , String name , Object callable , ConvertArgsToSulongNode convertArgsToSulongNode ) {
657
- super (language , name , callable , convertArgsToSulongNode );
663
+ public MethFastcallRoot (PythonLanguage language , String name , Object callable , PExternalFunctionWrapper provider ) {
664
+ super (language , name , callable , provider );
658
665
this .factory = PythonObjectFactory .create ();
659
666
this .readVarargsNode = ReadVarArgsNode .create (1 , true );
660
667
}
@@ -684,8 +691,8 @@ static class AllocFuncRootNode extends MethodDescriptorRoot {
684
691
super (language , name , callable );
685
692
}
686
693
687
- AllocFuncRootNode (PythonLanguage language , String name , Object callable , ConvertArgsToSulongNode convertArgsToSulongNode ) {
688
- super (language , name , callable , convertArgsToSulongNode );
694
+ AllocFuncRootNode (PythonLanguage language , String name , Object callable , PExternalFunctionWrapper provider ) {
695
+ super (language , name , callable , provider );
689
696
this .readArgNode = ReadIndexedArgumentNode .create (1 );
690
697
this .asSsizeTNode = ConvertPIntToPrimitiveNodeGen .create ();
691
698
}
@@ -720,8 +727,8 @@ static final class GetAttrFuncRootNode extends MethodDescriptorRoot {
720
727
super (language , name , callable );
721
728
}
722
729
723
- GetAttrFuncRootNode (PythonLanguage language , String name , Object callable , ConvertArgsToSulongNode convertArgsToSulongNode ) {
724
- super (language , name , callable , convertArgsToSulongNode );
730
+ GetAttrFuncRootNode (PythonLanguage language , String name , Object callable , PExternalFunctionWrapper provider ) {
731
+ super (language , name , callable , provider );
725
732
this .readArgNode = ReadIndexedArgumentNode .create (1 );
726
733
this .asCharPointerNode = CExtNodes .AsCharPointerNode .create ();
727
734
}
@@ -754,8 +761,8 @@ static final class SetAttrFuncRootNode extends MethodDescriptorRoot {
754
761
super (language , name , callable );
755
762
}
756
763
757
- SetAttrFuncRootNode (PythonLanguage language , String name , Object callable , ConvertArgsToSulongNode convertArgsToSulongNode ) {
758
- super (language , name , callable , convertArgsToSulongNode );
764
+ SetAttrFuncRootNode (PythonLanguage language , String name , Object callable , PExternalFunctionWrapper provider ) {
765
+ super (language , name , callable , provider );
759
766
this .readArg1Node = ReadIndexedArgumentNode .create (1 );
760
767
this .readArg2Node = ReadIndexedArgumentNode .create (2 );
761
768
this .asCharPointerNode = CExtNodes .AsCharPointerNode .create ();
@@ -790,8 +797,8 @@ static final class RichCmpFuncRootNode extends MethodDescriptorRoot {
790
797
super (language , name , callable );
791
798
}
792
799
793
- RichCmpFuncRootNode (PythonLanguage language , String name , Object callable , ConvertArgsToSulongNode convertArgsToSulongNode ) {
794
- super (language , name , callable , convertArgsToSulongNode );
800
+ RichCmpFuncRootNode (PythonLanguage language , String name , Object callable , PExternalFunctionWrapper provider ) {
801
+ super (language , name , callable , provider );
795
802
this .readArg1Node = ReadIndexedArgumentNode .create (1 );
796
803
this .readArg2Node = ReadIndexedArgumentNode .create (2 );
797
804
this .asSsizeTNode = ConvertPIntToPrimitiveNodeGen .create ();
@@ -829,8 +836,8 @@ static final class SSizeObjArgProcRootNode extends MethodDescriptorRoot {
829
836
super (language , name , callable );
830
837
}
831
838
832
- SSizeObjArgProcRootNode (PythonLanguage language , String name , Object callable , ConvertArgsToSulongNode convertArgsToSulongNode ) {
833
- super (language , name , callable , convertArgsToSulongNode );
839
+ SSizeObjArgProcRootNode (PythonLanguage language , String name , Object callable , PExternalFunctionWrapper provider ) {
840
+ super (language , name , callable , provider );
834
841
this .readArg1Node = ReadIndexedArgumentNode .create (1 );
835
842
this .readArg2Node = ReadIndexedArgumentNode .create (2 );
836
843
this .asSsizeTNode = ConvertPIntToPrimitiveNodeGen .create ();
@@ -869,8 +876,8 @@ static final class MethReverseRootNode extends MethodDescriptorRoot {
869
876
this .readArg1Node = ReadIndexedArgumentNode .create (1 );
870
877
}
871
878
872
- MethReverseRootNode (PythonLanguage language , String name , Object callable , ConvertArgsToSulongNode convertArgsToSulongNode ) {
873
- super (language , name , callable , convertArgsToSulongNode );
879
+ MethReverseRootNode (PythonLanguage language , String name , Object callable , PExternalFunctionWrapper provider ) {
880
+ super (language , name , callable , provider );
874
881
this .readArg0Node = ReadIndexedArgumentNode .create (0 );
875
882
this .readArg1Node = ReadIndexedArgumentNode .create (1 );
876
883
}
@@ -910,8 +917,8 @@ static class MethPowRootNode extends MethodDescriptorRoot {
910
917
this .profile = null ;
911
918
}
912
919
913
- MethPowRootNode (PythonLanguage language , String name , Object callable , ConvertArgsToSulongNode convertArgsToSulongNode ) {
914
- super (language , name , callable , convertArgsToSulongNode );
920
+ MethPowRootNode (PythonLanguage language , String name , Object callable , PExternalFunctionWrapper provider ) {
921
+ super (language , name , callable , provider );
915
922
this .readVarargsNode = ReadVarArgsNode .create (1 , true );
916
923
this .profile = ConditionProfile .createBinaryProfile ();
917
924
}
@@ -944,8 +951,8 @@ static final class MethRPowRootNode extends MethPowRootNode {
944
951
super (language , name , callable );
945
952
}
946
953
947
- MethRPowRootNode (PythonLanguage language , String name , Object callable , ConvertArgsToSulongNode convertArgsToSulongNode ) {
948
- super (language , name , callable , convertArgsToSulongNode );
954
+ MethRPowRootNode (PythonLanguage language , String name , Object callable , PExternalFunctionWrapper provider ) {
955
+ super (language , name , callable , provider );
949
956
}
950
957
951
958
@ Override
@@ -969,8 +976,8 @@ static final class MethRichcmpOpRootNode extends MethodDescriptorRoot {
969
976
this .op = op ;
970
977
}
971
978
972
- MethRichcmpOpRootNode (PythonLanguage language , String name , Object callable , ConvertArgsToSulongNode convertArgsToSulongNode , int op ) {
973
- super (language , name , callable , convertArgsToSulongNode );
979
+ MethRichcmpOpRootNode (PythonLanguage language , String name , Object callable , PExternalFunctionWrapper provider , int op ) {
980
+ super (language , name , callable , provider );
974
981
this .readArgNode = ReadIndexedArgumentNode .create (1 );
975
982
this .op = op ;
976
983
}
0 commit comments