188
188
import com .oracle .graal .python .builtins .objects .traceback .LazyTraceback ;
189
189
import com .oracle .graal .python .builtins .objects .traceback .PTraceback ;
190
190
import com .oracle .graal .python .builtins .objects .tuple .PTuple ;
191
- import com .oracle .graal .python .builtins .objects .type .LazyPythonClass ;
192
191
import com .oracle .graal .python .builtins .objects .type .PythonAbstractClass ;
193
192
import com .oracle .graal .python .builtins .objects .type .PythonBuiltinClass ;
194
193
import com .oracle .graal .python .builtins .objects .type .PythonClass ;
@@ -478,20 +477,22 @@ Object runWithoutCWrapper(PBuiltinFunction descriptor, Object self) {
478
477
@ TypeSystemReference (PythonArithmeticTypes .class )
479
478
abstract static class CreateFunctionNode extends PythonBuiltinNode {
480
479
481
- @ Specialization (guards = " isNoValue(wrapper)" , limit = "3" )
480
+ @ Specialization (guards = { "lib.isLazyPythonClass(type)" , " isNoValue(wrapper)"} , limit = "3" )
482
481
static Object doPythonCallableWithoutWrapper (@ SuppressWarnings ("unused" ) String name , PythonNativeWrapper callable , @ SuppressWarnings ("unused" ) PNone wrapper ,
483
- @ SuppressWarnings ("unused" ) LazyPythonClass type ,
484
- @ CachedLibrary ("callable" ) PythonNativeWrapperLibrary nativeWrapperLibrary ) {
482
+ @ SuppressWarnings ("unused" ) Object type ,
483
+ @ CachedLibrary ("callable" ) PythonNativeWrapperLibrary nativeWrapperLibrary ,
484
+ @ SuppressWarnings ("unused" ) @ CachedLibrary (limit = "2" ) PythonObjectLibrary lib ) {
485
485
// This can happen if a native type inherits slots from a managed type. Therefore,
486
486
// something like 'base->tp_new' will be a wrapper of the managed '__new__'. So, in this
487
487
// case, we assume that the object is already callable.
488
488
return nativeWrapperLibrary .getDelegate (callable );
489
489
}
490
490
491
- @ Specialization (limit = "3" )
492
- Object doPythonCallable (String name , PythonNativeWrapper callable , PExternalFunctionWrapper wrapper , @ SuppressWarnings ( "unused" ) LazyPythonClass type ,
491
+ @ Specialization (guards = "lib.isLazyPythonClass(type)" , limit = "3" )
492
+ Object doPythonCallable (String name , PythonNativeWrapper callable , PExternalFunctionWrapper wrapper , Object type ,
493
493
@ Shared ("lang" ) @ CachedLanguage PythonLanguage lang ,
494
- @ CachedLibrary ("callable" ) PythonNativeWrapperLibrary nativeWrapperLibrary ) {
494
+ @ CachedLibrary ("callable" ) PythonNativeWrapperLibrary nativeWrapperLibrary ,
495
+ @ SuppressWarnings ("unused" ) @ CachedLibrary (limit = "2" ) PythonObjectLibrary lib ) {
495
496
// This can happen if a native type inherits slots from a managed type. Therefore,
496
497
// something like 'base->tp_new' will be a wrapper of the managed '__new__'. So, in this
497
498
// case, we assume that the object is already callable.
@@ -504,10 +505,11 @@ Object doPythonCallable(String name, PythonNativeWrapper callable, PExternalFunc
504
505
return managedCallable ;
505
506
}
506
507
507
- @ Specialization (guards = {"isDecoratedManagedFunction(callable)" , "isNoValue(wrapper)" })
508
+ @ Specialization (guards = {"lib.isLazyPythonClass(type)" , " isDecoratedManagedFunction(callable)" , "isNoValue(wrapper)" })
508
509
static Object doDecoratedManagedWithoutWrapper (@ SuppressWarnings ("unused" ) String name , PyCFunctionDecorator callable , @ SuppressWarnings ("unused" ) PNone wrapper ,
509
- @ SuppressWarnings ("unused" ) LazyPythonClass type ,
510
- @ CachedLibrary (limit = "3" ) PythonNativeWrapperLibrary nativeWrapperLibrary ) {
510
+ @ SuppressWarnings ("unused" ) Object type ,
511
+ @ CachedLibrary (limit = "3" ) PythonNativeWrapperLibrary nativeWrapperLibrary ,
512
+ @ SuppressWarnings ("unused" ) @ CachedLibrary (limit = "2" ) PythonObjectLibrary lib ) {
511
513
// This can happen if a native type inherits slots from a managed type. Therefore,
512
514
// something like 'base->tp_new' will be a wrapper of the managed '__new__'. So, in this
513
515
// case, we assume that the object is already callable.
@@ -517,7 +519,7 @@ static Object doDecoratedManagedWithoutWrapper(@SuppressWarnings("unused") Strin
517
519
}
518
520
519
521
@ Specialization (guards = "isDecoratedManagedFunction(callable)" )
520
- Object doDecoratedManaged (String name , PyCFunctionDecorator callable , PExternalFunctionWrapper wrapper , @ SuppressWarnings ( "unused" ) LazyPythonClass type ,
522
+ Object doDecoratedManaged (String name , PyCFunctionDecorator callable , PExternalFunctionWrapper wrapper , Object type ,
521
523
@ Shared ("lang" ) @ CachedLanguage PythonLanguage lang ,
522
524
@ CachedLibrary (limit = "3" ) PythonNativeWrapperLibrary nativeWrapperLibrary ) {
523
525
// This can happen if a native type inherits slots from a managed type. Therefore,
@@ -537,30 +539,32 @@ Object doDecoratedManaged(String name, PyCFunctionDecorator callable, PExternalF
537
539
return managedCallable ;
538
540
}
539
541
540
- @ Specialization (guards = "!isNativeWrapper(callable)" )
541
- PBuiltinFunction doNativeCallableWithType (String name , Object callable , PExternalFunctionWrapper wrapper , LazyPythonClass type ,
542
- @ Shared ("lang" ) @ CachedLanguage PythonLanguage lang ) {
542
+ @ Specialization (guards = {"lib.isLazyPythonClass(type)" , "!isNativeWrapper(callable)" })
543
+ PBuiltinFunction doNativeCallableWithType (String name , Object callable , PExternalFunctionWrapper wrapper , Object type ,
544
+ @ Shared ("lang" ) @ CachedLanguage PythonLanguage lang ,
545
+ @ SuppressWarnings ("unused" ) @ CachedLibrary (limit = "2" ) PythonObjectLibrary lib ) {
543
546
RootCallTarget wrappedCallTarget = wrapper .createCallTarget (lang , name , callable , wrapper .createConvertArgsToSulongNode ());
544
547
return factory ().createBuiltinFunction (name , type , 0 , wrappedCallTarget );
545
548
}
546
549
547
550
@ Specialization (guards = {"isNoValue(type)" , "!isNativeWrapper(callable)" })
548
551
PBuiltinFunction doNativeCallableWithoutType (String name , Object callable , PExternalFunctionWrapper wrapper , @ SuppressWarnings ("unused" ) PNone type ,
549
552
@ Shared ("lang" ) @ CachedLanguage PythonLanguage lang ) {
550
- return doNativeCallableWithType (name , callable , wrapper , null , lang );
553
+ return doNativeCallableWithType (name , callable , wrapper , null , lang , null );
551
554
}
552
555
553
- @ Specialization (guards = {"isNoValue(wrapper)" , "!isNativeWrapper(callable)" })
554
- PBuiltinFunction doNativeCallableWithoutWrapper (String name , Object callable , LazyPythonClass type , @ SuppressWarnings ("unused" ) PNone wrapper ,
555
- @ Shared ("lang" ) @ CachedLanguage PythonLanguage lang ) {
556
+ @ Specialization (guards = {"lib.isLazyPythonClass(type)" , "isNoValue(wrapper)" , "!isNativeWrapper(callable)" })
557
+ PBuiltinFunction doNativeCallableWithoutWrapper (String name , Object callable , Object type , @ SuppressWarnings ("unused" ) PNone wrapper ,
558
+ @ Shared ("lang" ) @ CachedLanguage PythonLanguage lang ,
559
+ @ SuppressWarnings ("unused" ) @ CachedLibrary (limit = "2" ) PythonObjectLibrary lib ) {
556
560
RootCallTarget callTarget = PExternalFunctionWrapper .createCallTarget (MethDirectRoot .create (lang , name , callable ));
557
561
return factory ().createBuiltinFunction (name , type , 0 , callTarget );
558
562
}
559
563
560
564
@ Specialization (guards = {"isNoValue(wrapper)" , "isNoValue(type)" , "!isNativeWrapper(callable)" })
561
565
PBuiltinFunction doNativeCallableWithoutWrapperAndType (String name , Object callable , PNone wrapper , @ SuppressWarnings ("unused" ) PNone type ,
562
566
@ Shared ("lang" ) @ CachedLanguage PythonLanguage lang ) {
563
- return doNativeCallableWithoutWrapper (name , callable , null , wrapper , lang );
567
+ return doNativeCallableWithoutWrapper (name , callable , null , wrapper , lang , null );
564
568
}
565
569
566
570
static boolean isNativeWrapper (Object obj ) {
@@ -1663,17 +1667,17 @@ PThreadState get() {
1663
1667
@ GenerateNodeFactory
1664
1668
public abstract static class GetSetDescriptorNode extends PythonBuiltinNode {
1665
1669
@ Specialization (guards = {"!isNoValue(get)" , "!isNoValue(set)" })
1666
- Object call (Object get , Object set , String name , LazyPythonClass owner ) {
1670
+ Object call (Object get , Object set , String name , Object owner ) {
1667
1671
return factory ().createGetSetDescriptor (get , set , name , owner , true );
1668
1672
}
1669
1673
1670
1674
@ Specialization (guards = {"!isNoValue(get)" , "isNoValue(set)" })
1671
- Object call (Object get , @ SuppressWarnings ("unused" ) PNone set , String name , LazyPythonClass owner ) {
1675
+ Object call (Object get , @ SuppressWarnings ("unused" ) PNone set , String name , Object owner ) {
1672
1676
return factory ().createGetSetDescriptor (get , null , name , owner );
1673
1677
}
1674
1678
1675
1679
@ Specialization (guards = {"isNoValue(get)" , "!isNoValue(set)" })
1676
- Object call (@ SuppressWarnings ("unused" ) PNone get , Object set , String name , LazyPythonClass owner ) {
1680
+ Object call (@ SuppressWarnings ("unused" ) PNone get , Object set , String name , Object owner ) {
1677
1681
return factory ().createGetSetDescriptor (null , set , name , owner , true );
1678
1682
}
1679
1683
}
0 commit comments