|
198 | 198 | import com.oracle.graal.python.builtins.objects.module.PythonModule;
|
199 | 199 | import com.oracle.graal.python.builtins.objects.object.ObjectBuiltins;
|
200 | 200 | import com.oracle.graal.python.builtins.objects.object.PythonObject;
|
201 |
| -import com.oracle.graal.python.builtins.objects.object.PythonObjectLibrary; |
202 | 201 | import com.oracle.graal.python.builtins.objects.set.PBaseSet;
|
203 | 202 | import com.oracle.graal.python.builtins.objects.set.PSet;
|
204 | 203 | import com.oracle.graal.python.builtins.objects.str.NativeCharSequence;
|
|
226 | 225 | import com.oracle.graal.python.nodes.BuiltinNames;
|
227 | 226 | import com.oracle.graal.python.nodes.ErrorMessages;
|
228 | 227 | import com.oracle.graal.python.nodes.PGuards;
|
| 228 | +import com.oracle.graal.python.nodes.PNodeWithContext; |
229 | 229 | import com.oracle.graal.python.nodes.PRaiseNode;
|
230 | 230 | import com.oracle.graal.python.nodes.SpecialAttributeNames;
|
231 | 231 | import com.oracle.graal.python.nodes.SpecialMethodNames;
|
@@ -542,42 +542,41 @@ Object importCExtFunction(String name, Object capiLibrary,
|
542 | 542 | }
|
543 | 543 |
|
544 | 544 | @GenerateUncached
|
545 |
| - @ImportStatic(PGuards.class) |
546 |
| - abstract static class CreateFunctionNode extends Node { |
| 545 | + abstract static class CreateFunctionNode extends PNodeWithContext { |
547 | 546 |
|
548 | 547 | abstract Object execute(String name, Object callable, Object wrapper, Object type, Object flags, PythonObjectFactory factory);
|
549 | 548 |
|
550 |
| - @Specialization(guards = {"lib.isLazyPythonClass(type)", "isNoValue(wrapper)"}, limit = "3") |
| 549 | + @Specialization(guards = {"isTypeNode.execute(type)", "isNoValue(wrapper)"}, limit = "3") |
551 | 550 | static Object doPythonCallableWithoutWrapper(@SuppressWarnings("unused") String name, PythonNativeWrapper callable,
|
552 | 551 | @SuppressWarnings("unused") PNone wrapper,
|
553 | 552 | @SuppressWarnings("unused") Object type,
|
554 | 553 | @SuppressWarnings("unused") Object flags,
|
555 | 554 | @SuppressWarnings("unused") PythonObjectFactory factory,
|
556 | 555 | @CachedLibrary("callable") PythonNativeWrapperLibrary nativeWrapperLibrary,
|
557 |
| - @SuppressWarnings("unused") @CachedLibrary(limit = "2") PythonObjectLibrary lib) { |
| 556 | + @SuppressWarnings("unused") @Cached TypeNodes.IsTypeNode isTypeNode) { |
558 | 557 | // This can happen if a native type inherits slots from a managed type. Therefore,
|
559 | 558 | // something like 'base->tp_new' will be a wrapper of the managed '__new__'. So, in this
|
560 | 559 | // case, we assume that the object is already callable.
|
561 | 560 | return nativeWrapperLibrary.getDelegate(callable);
|
562 | 561 | }
|
563 | 562 |
|
564 |
| - @Specialization(guards = "lib.isLazyPythonClass(type)") |
| 563 | + @Specialization(guards = "isTypeNode.execute(type)", limit = "1") |
565 | 564 | @TruffleBoundary
|
566 |
| - static Object doPythonCallable(String name, PythonNativeWrapper callable, int signature, Object type, int flags, PythonObjectFactory factory, |
567 |
| - @SuppressWarnings("unused") @CachedLibrary(limit = "2") PythonObjectLibrary lib) { |
| 565 | + Object doPythonCallable(String name, PythonNativeWrapper callable, int signature, Object type, int flags, PythonObjectFactory factory, |
| 566 | + @SuppressWarnings("unused") @Cached TypeNodes.IsTypeNode isTypeNode) { |
568 | 567 | // This can happen if a native type inherits slots from a managed type. Therefore,
|
569 | 568 | // something like 'base->tp_new' will be a wrapper of the managed '__new__'. So, in this
|
570 | 569 | // case, we assume that the object is already callable.
|
571 | 570 | Object managedCallable = callable.getDelegateSlowPath();
|
572 |
| - PBuiltinFunction function = PExternalFunctionWrapper.createWrapperFunction(name, managedCallable, type, flags, signature, PythonLanguage.get(lib), factory, false); |
| 571 | + PBuiltinFunction function = PExternalFunctionWrapper.createWrapperFunction(name, managedCallable, type, flags, signature, getLanguage(), factory, false); |
573 | 572 | return function != null ? function : managedCallable;
|
574 | 573 | }
|
575 | 574 |
|
576 |
| - @Specialization(guards = {"lib.isLazyPythonClass(type)", "isDecoratedManagedFunction(callable)", "isNoValue(wrapper)"}) |
| 575 | + @Specialization(guards = {"isTypeNode.execute(type)", "isDecoratedManagedFunction(callable)", "isNoValue(wrapper)"}, limit = "1") |
577 | 576 | @SuppressWarnings("unused")
|
578 | 577 | static Object doDecoratedManagedWithoutWrapper(@SuppressWarnings("unused") String name, PyCFunctionDecorator callable, PNone wrapper, Object type, Object flags, PythonObjectFactory factory,
|
579 | 578 | @CachedLibrary(limit = "3") PythonNativeWrapperLibrary nativeWrapperLibrary,
|
580 |
| - @CachedLibrary(limit = "2") PythonObjectLibrary lib) { |
| 579 | + @Cached TypeNodes.IsTypeNode isTypeNode) { |
581 | 580 | // This can happen if a native type inherits slots from a managed type. Therefore,
|
582 | 581 | // something like 'base->tp_new' will be a wrapper of the managed '__new__'. So, in this
|
583 | 582 | // case, we assume that the object is already callable.
|
@@ -608,33 +607,33 @@ static Object doDecoratedManaged(String name, PyCFunctionDecorator callable, int
|
608 | 607 | return managedCallable;
|
609 | 608 | }
|
610 | 609 |
|
611 |
| - @Specialization(guards = {"lib.isLazyPythonClass(type)", "!isNativeWrapper(callable)"}) |
| 610 | + @Specialization(guards = {"isTypeNode.execute(type)", "!isNativeWrapper(callable)"}, limit = "1") |
612 | 611 | @TruffleBoundary
|
613 |
| - static PBuiltinFunction doNativeCallableWithType(String name, Object callable, int signature, Object type, int flags, PythonObjectFactory factory, |
614 |
| - @SuppressWarnings("unused") @CachedLibrary(limit = "2") PythonObjectLibrary lib) { |
| 612 | + PBuiltinFunction doNativeCallableWithType(String name, Object callable, int signature, Object type, int flags, PythonObjectFactory factory, |
| 613 | + @SuppressWarnings("unused") @Cached TypeNodes.IsTypeNode isTypeNode) { |
615 | 614 | return PExternalFunctionWrapper.createWrapperFunction(name, callable, type, flags,
|
616 |
| - signature, PythonLanguage.get(lib), factory, true); |
| 615 | + signature, getLanguage(), factory, true); |
617 | 616 | }
|
618 | 617 |
|
619 | 618 | @Specialization(guards = {"isNoValue(type)", "!isNativeWrapper(callable)"})
|
620 | 619 | @TruffleBoundary
|
621 |
| - static PBuiltinFunction doNativeCallableWithoutType(String name, Object callable, int signature, @SuppressWarnings("unused") PNone type, int flags, PythonObjectFactory factory) { |
| 620 | + PBuiltinFunction doNativeCallableWithoutType(String name, Object callable, int signature, @SuppressWarnings("unused") PNone type, int flags, PythonObjectFactory factory) { |
622 | 621 | return doNativeCallableWithType(name, callable, signature, null, flags, factory, null);
|
623 | 622 | }
|
624 | 623 |
|
625 |
| - @Specialization(guards = {"lib.isLazyPythonClass(type)", "isNoValue(wrapper)", "!isNativeWrapper(callable)"}) |
| 624 | + @Specialization(guards = {"isTypeNode.execute(type)", "isNoValue(wrapper)", "!isNativeWrapper(callable)"}, limit = "1") |
626 | 625 | @TruffleBoundary
|
627 |
| - static PBuiltinFunction doNativeCallableWithoutWrapper(String name, Object callable, Object type, |
| 626 | + PBuiltinFunction doNativeCallableWithoutWrapper(String name, Object callable, Object type, |
628 | 627 | @SuppressWarnings("unused") PNone wrapper,
|
629 | 628 | @SuppressWarnings("unused") Object flags, PythonObjectFactory factory,
|
630 |
| - @SuppressWarnings("unused") @CachedLibrary(limit = "2") PythonObjectLibrary lib) { |
| 629 | + @SuppressWarnings("unused") @Cached TypeNodes.IsTypeNode isTypeNode) { |
631 | 630 | return PExternalFunctionWrapper.createWrapperFunction(name, callable, type, 0,
|
632 |
| - PExternalFunctionWrapper.DIRECT, PythonLanguage.get(lib), factory, true); |
| 631 | + PExternalFunctionWrapper.DIRECT, getLanguage(), factory, true); |
633 | 632 | }
|
634 | 633 |
|
635 | 634 | @Specialization(guards = {"isNoValue(wrapper)", "isNoValue(type)", "!isNativeWrapper(callable)"})
|
636 | 635 | @TruffleBoundary
|
637 |
| - static PBuiltinFunction doNativeCallableWithoutWrapperAndType(String name, Object callable, PNone wrapper, @SuppressWarnings("unused") PNone type, Object flags, PythonObjectFactory factory) { |
| 636 | + PBuiltinFunction doNativeCallableWithoutWrapperAndType(String name, Object callable, PNone wrapper, @SuppressWarnings("unused") PNone type, Object flags, PythonObjectFactory factory) { |
638 | 637 | return doNativeCallableWithoutWrapper(name, callable, null, wrapper, flags, factory, null);
|
639 | 638 | }
|
640 | 639 |
|
|
0 commit comments