Skip to content

Commit 1b42925

Browse files
committed
Remove LazyPythonClass use in PythonCextBuiltins
1 parent 3a862f3 commit 1b42925

File tree

1 file changed

+26
-22
lines changed

1 file changed

+26
-22
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PythonCextBuiltins.java

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@
188188
import com.oracle.graal.python.builtins.objects.traceback.LazyTraceback;
189189
import com.oracle.graal.python.builtins.objects.traceback.PTraceback;
190190
import com.oracle.graal.python.builtins.objects.tuple.PTuple;
191-
import com.oracle.graal.python.builtins.objects.type.LazyPythonClass;
192191
import com.oracle.graal.python.builtins.objects.type.PythonAbstractClass;
193192
import com.oracle.graal.python.builtins.objects.type.PythonBuiltinClass;
194193
import com.oracle.graal.python.builtins.objects.type.PythonClass;
@@ -478,20 +477,22 @@ Object runWithoutCWrapper(PBuiltinFunction descriptor, Object self) {
478477
@TypeSystemReference(PythonArithmeticTypes.class)
479478
abstract static class CreateFunctionNode extends PythonBuiltinNode {
480479

481-
@Specialization(guards = "isNoValue(wrapper)", limit = "3")
480+
@Specialization(guards = {"lib.isLazyPythonClass(type)", "isNoValue(wrapper)"}, limit = "3")
482481
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) {
485485
// This can happen if a native type inherits slots from a managed type. Therefore,
486486
// something like 'base->tp_new' will be a wrapper of the managed '__new__'. So, in this
487487
// case, we assume that the object is already callable.
488488
return nativeWrapperLibrary.getDelegate(callable);
489489
}
490490

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,
493493
@Shared("lang") @CachedLanguage PythonLanguage lang,
494-
@CachedLibrary("callable") PythonNativeWrapperLibrary nativeWrapperLibrary) {
494+
@CachedLibrary("callable") PythonNativeWrapperLibrary nativeWrapperLibrary,
495+
@SuppressWarnings("unused") @CachedLibrary(limit = "2") PythonObjectLibrary lib) {
495496
// This can happen if a native type inherits slots from a managed type. Therefore,
496497
// something like 'base->tp_new' will be a wrapper of the managed '__new__'. So, in this
497498
// case, we assume that the object is already callable.
@@ -504,10 +505,11 @@ Object doPythonCallable(String name, PythonNativeWrapper callable, PExternalFunc
504505
return managedCallable;
505506
}
506507

507-
@Specialization(guards = {"isDecoratedManagedFunction(callable)", "isNoValue(wrapper)"})
508+
@Specialization(guards = {"lib.isLazyPythonClass(type)", "isDecoratedManagedFunction(callable)", "isNoValue(wrapper)"})
508509
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) {
511513
// This can happen if a native type inherits slots from a managed type. Therefore,
512514
// something like 'base->tp_new' will be a wrapper of the managed '__new__'. So, in this
513515
// case, we assume that the object is already callable.
@@ -517,7 +519,7 @@ static Object doDecoratedManagedWithoutWrapper(@SuppressWarnings("unused") Strin
517519
}
518520

519521
@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,
521523
@Shared("lang") @CachedLanguage PythonLanguage lang,
522524
@CachedLibrary(limit = "3") PythonNativeWrapperLibrary nativeWrapperLibrary) {
523525
// 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
537539
return managedCallable;
538540
}
539541

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) {
543546
RootCallTarget wrappedCallTarget = wrapper.createCallTarget(lang, name, callable, wrapper.createConvertArgsToSulongNode());
544547
return factory().createBuiltinFunction(name, type, 0, wrappedCallTarget);
545548
}
546549

547550
@Specialization(guards = {"isNoValue(type)", "!isNativeWrapper(callable)"})
548551
PBuiltinFunction doNativeCallableWithoutType(String name, Object callable, PExternalFunctionWrapper wrapper, @SuppressWarnings("unused") PNone type,
549552
@Shared("lang") @CachedLanguage PythonLanguage lang) {
550-
return doNativeCallableWithType(name, callable, wrapper, null, lang);
553+
return doNativeCallableWithType(name, callable, wrapper, null, lang, null);
551554
}
552555

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) {
556560
RootCallTarget callTarget = PExternalFunctionWrapper.createCallTarget(MethDirectRoot.create(lang, name, callable));
557561
return factory().createBuiltinFunction(name, type, 0, callTarget);
558562
}
559563

560564
@Specialization(guards = {"isNoValue(wrapper)", "isNoValue(type)", "!isNativeWrapper(callable)"})
561565
PBuiltinFunction doNativeCallableWithoutWrapperAndType(String name, Object callable, PNone wrapper, @SuppressWarnings("unused") PNone type,
562566
@Shared("lang") @CachedLanguage PythonLanguage lang) {
563-
return doNativeCallableWithoutWrapper(name, callable, null, wrapper, lang);
567+
return doNativeCallableWithoutWrapper(name, callable, null, wrapper, lang, null);
564568
}
565569

566570
static boolean isNativeWrapper(Object obj) {
@@ -1663,17 +1667,17 @@ PThreadState get() {
16631667
@GenerateNodeFactory
16641668
public abstract static class GetSetDescriptorNode extends PythonBuiltinNode {
16651669
@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) {
16671671
return factory().createGetSetDescriptor(get, set, name, owner, true);
16681672
}
16691673

16701674
@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) {
16721676
return factory().createGetSetDescriptor(get, null, name, owner);
16731677
}
16741678

16751679
@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) {
16771681
return factory().createGetSetDescriptor(null, set, name, owner, true);
16781682
}
16791683
}

0 commit comments

Comments
 (0)