251
251
import com .oracle .graal .python .util .OverflowException ;
252
252
import com .oracle .graal .python .util .PythonUtils ;
253
253
import com .oracle .graal .python .util .Supplier ;
254
- import com .oracle .truffle .api .Assumption ;
255
254
import com .oracle .truffle .api .CompilerAsserts ;
256
255
import com .oracle .truffle .api .CompilerDirectives ;
257
256
import com .oracle .truffle .api .CompilerDirectives .TruffleBoundary ;
258
257
import com .oracle .truffle .api .RootCallTarget ;
259
- import com .oracle .truffle .api .Truffle ;
260
258
import com .oracle .truffle .api .TruffleLanguage .ContextReference ;
261
259
import com .oracle .truffle .api .TruffleLogger ;
262
260
import com .oracle .truffle .api .dsl .Bind ;
@@ -510,8 +508,7 @@ Object doPythonCallable(String name, PythonNativeWrapper callable, PExternalFunc
510
508
Object managedCallable = nativeWrapperLibrary .getDelegate (callable );
511
509
RootCallTarget wrappedCallTarget = wrapper .getOrCreateCallTarget (lang , name , false );
512
510
if (wrappedCallTarget != null ) {
513
- Assumption callableStableAssumption = getCallableStableAssumption ();
514
- PCell [] closure = ExternalFunctionNodes .createPythonClosure (managedCallable , factory (), callableStableAssumption );
511
+ PCell [] closure = ExternalFunctionNodes .createPythonClosure (managedCallable , factory (), lang .getCallableStableAssumption ());
515
512
return factory ().createBuiltinFunction (name , type , 0 , closure , wrappedCallTarget );
516
513
}
517
514
return managedCallable ;
@@ -542,8 +539,7 @@ Object doDecoratedManaged(String name, PyCFunctionDecorator callable, PExternalF
542
539
Object managedCallable = nativeWrapperLibrary .getDelegate (callable .getNativeFunction ());
543
540
RootCallTarget wrappedCallTarget = wrapper .getOrCreateCallTarget (lang , name , false );
544
541
if (wrappedCallTarget != null ) {
545
- Assumption callableStableAssumption = getCallableStableAssumption ();
546
- PCell [] closure = ExternalFunctionNodes .createPythonClosure (managedCallable , factory (), callableStableAssumption );
542
+ PCell [] closure = ExternalFunctionNodes .createPythonClosure (managedCallable , factory (), lang .getCallableStableAssumption ());
547
543
return factory ().createBuiltinFunction (name , type , 0 , closure , wrappedCallTarget );
548
544
}
549
545
@@ -558,8 +554,7 @@ PBuiltinFunction doNativeCallableWithType(String name, Object callable, PExterna
558
554
@ Shared ("lang" ) @ CachedLanguage PythonLanguage lang ,
559
555
@ SuppressWarnings ("unused" ) @ CachedLibrary (limit = "2" ) PythonObjectLibrary lib ) {
560
556
RootCallTarget wrappedCallTarget = wrapper .getOrCreateCallTarget (lang , name , true );
561
- Assumption callableStableAssumption = getCallableStableAssumption ();
562
- PCell [] closure = ExternalFunctionNodes .createPythonClosure (callable , factory (), callableStableAssumption );
557
+ PCell [] closure = ExternalFunctionNodes .createPythonClosure (callable , factory (), lang .getCallableStableAssumption ());
563
558
return factory ().createBuiltinFunction (name , type , 0 , closure , wrappedCallTarget );
564
559
}
565
560
@@ -574,8 +569,7 @@ PBuiltinFunction doNativeCallableWithoutWrapper(String name, Object callable, Ob
574
569
@ Shared ("lang" ) @ CachedLanguage PythonLanguage lang ,
575
570
@ SuppressWarnings ("unused" ) @ CachedLibrary (limit = "2" ) PythonObjectLibrary lib ) {
576
571
RootCallTarget callTarget = PythonUtils .getOrCreateCallTarget (MethDirectRoot .create (lang , name ));
577
- Assumption callableStableAssumption = getCallableStableAssumption ();
578
- PCell [] closure = ExternalFunctionNodes .createPythonClosure (callable , factory (), callableStableAssumption );
572
+ PCell [] closure = ExternalFunctionNodes .createPythonClosure (callable , factory (), lang .getCallableStableAssumption ());
579
573
return factory ().createBuiltinFunction (name , type , 0 , closure , callTarget );
580
574
}
581
575
@@ -585,19 +579,6 @@ PBuiltinFunction doNativeCallableWithoutWrapperAndType(String name, Object calla
585
579
return doNativeCallableWithoutWrapper (name , callable , null , wrapper , lang , null );
586
580
}
587
581
588
- private Assumption getCallableStableAssumption () {
589
- CApiContext cApiContext = getContext ().getCApiContext ();
590
- if (cApiContext != null ) {
591
- return cApiContext .getCallableStableAssumption ();
592
- }
593
- return createAssumption ();
594
- }
595
-
596
- @ TruffleBoundary
597
- private static Assumption createAssumption () {
598
- return Truffle .getRuntime ().createAssumption ();
599
- }
600
-
601
582
static boolean isNativeWrapper (Object obj ) {
602
583
return CApiGuards .isNativeWrapper (obj ) || isDecoratedManagedFunction (obj );
603
584
}
0 commit comments