234
234
import com .oracle .graal .python .nodes .attributes .ReadAttributeFromObjectNode ;
235
235
import com .oracle .graal .python .nodes .attributes .WriteAttributeToDynamicObjectNode ;
236
236
import com .oracle .graal .python .nodes .attributes .WriteAttributeToObjectNode ;
237
- import com .oracle .graal .python .nodes .builtins .FunctionNodes .GetSignatureNode ;
238
237
import com .oracle .graal .python .nodes .builtins .FunctionNodes .GetCallTargetNode ;
238
+ import com .oracle .graal .python .nodes .builtins .FunctionNodes .GetSignatureNode ;
239
239
import com .oracle .graal .python .nodes .call .CallNode ;
240
240
import com .oracle .graal .python .nodes .call .GenericInvokeNode ;
241
241
import com .oracle .graal .python .nodes .call .special .CallBinaryMethodNode ;
298
298
import com .oracle .truffle .api .dsl .Cached .Shared ;
299
299
import com .oracle .truffle .api .dsl .Fallback ;
300
300
import com .oracle .truffle .api .dsl .GenerateNodeFactory ;
301
+ import com .oracle .truffle .api .dsl .GenerateUncached ;
301
302
import com .oracle .truffle .api .dsl .ImportStatic ;
302
303
import com .oracle .truffle .api .dsl .NodeFactory ;
303
304
import com .oracle .truffle .api .dsl .ReportPolymorphism ;
@@ -537,6 +538,7 @@ Object importCExtFunction(String name, Object capiLibrary,
537
538
}
538
539
}
539
540
541
+ @ GenerateUncached
540
542
@ ImportStatic (PGuards .class )
541
543
abstract static class CreateFunctionNode extends Node {
542
544
@@ -556,28 +558,23 @@ static Object doPythonCallableWithoutWrapper(@SuppressWarnings("unused") String
556
558
return nativeWrapperLibrary .getDelegate (callable );
557
559
}
558
560
559
- @ Specialization (guards = "lib.isLazyPythonClass(type)" , limit = "3" )
561
+ @ Specialization (guards = "lib.isLazyPythonClass(type)" )
560
562
@ TruffleBoundary
561
- Object doPythonCallable (String name , PythonNativeWrapper callable , int signature , Object type , int flags , PythonObjectFactory factory ,
562
- @ CachedLibrary ("callable" ) PythonNativeWrapperLibrary nativeWrapperLibrary ,
563
+ static Object doPythonCallable (String name , PythonNativeWrapper callable , int signature , Object type , int flags , PythonObjectFactory factory ,
563
564
@ SuppressWarnings ("unused" ) @ CachedLibrary (limit = "2" ) PythonObjectLibrary lib ) {
564
565
// This can happen if a native type inherits slots from a managed type. Therefore,
565
566
// something like 'base->tp_new' will be a wrapper of the managed '__new__'. So, in this
566
567
// case, we assume that the object is already callable.
567
- Object managedCallable = nativeWrapperLibrary .getDelegate (callable );
568
- PBuiltinFunction function = PExternalFunctionWrapper .createWrapperFunction (name , managedCallable , type , flags ,
569
- signature , PythonLanguage .get (nativeWrapperLibrary ), factory , false );
568
+ Object managedCallable = callable .getDelegateSlowPath ();
569
+ PBuiltinFunction function = PExternalFunctionWrapper .createWrapperFunction (name , managedCallable , type , flags , signature , PythonLanguage .get (lib ), factory , false );
570
570
return function != null ? function : managedCallable ;
571
571
}
572
572
573
573
@ Specialization (guards = {"lib.isLazyPythonClass(type)" , "isDecoratedManagedFunction(callable)" , "isNoValue(wrapper)" })
574
- static Object doDecoratedManagedWithoutWrapper (@ SuppressWarnings ("unused" ) String name , PyCFunctionDecorator callable ,
575
- @ SuppressWarnings ("unused" ) PNone wrapper ,
576
- @ SuppressWarnings ("unused" ) Object type ,
577
- @ SuppressWarnings ("unused" ) Object flags ,
578
- @ SuppressWarnings ("unused" ) PythonObjectFactory factory ,
574
+ @ SuppressWarnings ("unused" )
575
+ static Object doDecoratedManagedWithoutWrapper (@ SuppressWarnings ("unused" ) String name , PyCFunctionDecorator callable , PNone wrapper , Object type , Object flags , PythonObjectFactory factory ,
579
576
@ CachedLibrary (limit = "3" ) PythonNativeWrapperLibrary nativeWrapperLibrary ,
580
- @ SuppressWarnings ( "unused" ) @ CachedLibrary (limit = "2" ) PythonObjectLibrary lib ) {
577
+ @ CachedLibrary (limit = "2" ) PythonObjectLibrary lib ) {
581
578
// This can happen if a native type inherits slots from a managed type. Therefore,
582
579
// something like 'base->tp_new' will be a wrapper of the managed '__new__'. So, in this
583
580
// case, we assume that the object is already callable.
@@ -588,7 +585,7 @@ static Object doDecoratedManagedWithoutWrapper(@SuppressWarnings("unused") Strin
588
585
589
586
@ Specialization (guards = "isDecoratedManagedFunction(callable)" )
590
587
@ TruffleBoundary
591
- Object doDecoratedManaged (String name , PyCFunctionDecorator callable , int signature , Object type , int flags , PythonObjectFactory factory ,
588
+ static Object doDecoratedManaged (String name , PyCFunctionDecorator callable , int signature , Object type , int flags , PythonObjectFactory factory ,
592
589
@ CachedLibrary (limit = "3" ) PythonNativeWrapperLibrary nativeWrapperLibrary ) {
593
590
// This can happen if a native type inherits slots from a managed type. Therefore,
594
591
// something like 'base->tp_new' will be a wrapper of the managed '__new__'. So, in this
@@ -610,21 +607,21 @@ Object doDecoratedManaged(String name, PyCFunctionDecorator callable, int signat
610
607
611
608
@ Specialization (guards = {"lib.isLazyPythonClass(type)" , "!isNativeWrapper(callable)" })
612
609
@ TruffleBoundary
613
- PBuiltinFunction doNativeCallableWithType (String name , Object callable , int signature , Object type , int flags , PythonObjectFactory factory ,
610
+ static PBuiltinFunction doNativeCallableWithType (String name , Object callable , int signature , Object type , int flags , PythonObjectFactory factory ,
614
611
@ SuppressWarnings ("unused" ) @ CachedLibrary (limit = "2" ) PythonObjectLibrary lib ) {
615
612
return PExternalFunctionWrapper .createWrapperFunction (name , callable , type , flags ,
616
613
signature , PythonLanguage .get (lib ), factory , true );
617
614
}
618
615
619
616
@ Specialization (guards = {"isNoValue(type)" , "!isNativeWrapper(callable)" })
620
617
@ TruffleBoundary
621
- PBuiltinFunction doNativeCallableWithoutType (String name , Object callable , int signature , @ SuppressWarnings ("unused" ) PNone type , int flags , PythonObjectFactory factory ) {
618
+ static PBuiltinFunction doNativeCallableWithoutType (String name , Object callable , int signature , @ SuppressWarnings ("unused" ) PNone type , int flags , PythonObjectFactory factory ) {
622
619
return doNativeCallableWithType (name , callable , signature , null , flags , factory , null );
623
620
}
624
621
625
622
@ Specialization (guards = {"lib.isLazyPythonClass(type)" , "isNoValue(wrapper)" , "!isNativeWrapper(callable)" })
626
623
@ TruffleBoundary
627
- PBuiltinFunction doNativeCallableWithoutWrapper (String name , Object callable , Object type ,
624
+ static PBuiltinFunction doNativeCallableWithoutWrapper (String name , Object callable , Object type ,
628
625
@ SuppressWarnings ("unused" ) PNone wrapper ,
629
626
@ SuppressWarnings ("unused" ) Object flags , PythonObjectFactory factory ,
630
627
@ SuppressWarnings ("unused" ) @ CachedLibrary (limit = "2" ) PythonObjectLibrary lib ) {
@@ -634,7 +631,7 @@ PBuiltinFunction doNativeCallableWithoutWrapper(String name, Object callable, Ob
634
631
635
632
@ Specialization (guards = {"isNoValue(wrapper)" , "isNoValue(type)" , "!isNativeWrapper(callable)" })
636
633
@ TruffleBoundary
637
- PBuiltinFunction doNativeCallableWithoutWrapperAndType (String name , Object callable , PNone wrapper , @ SuppressWarnings ("unused" ) PNone type , Object flags , PythonObjectFactory factory ) {
634
+ static PBuiltinFunction doNativeCallableWithoutWrapperAndType (String name , Object callable , PNone wrapper , @ SuppressWarnings ("unused" ) PNone type , Object flags , PythonObjectFactory factory ) {
638
635
return doNativeCallableWithoutWrapper (name , callable , null , wrapper , flags , factory , null );
639
636
}
640
637
0 commit comments