@@ -808,14 +808,13 @@ dummy_func(
808808 assert (code -> co_argcount == 2 );
809809 DEOPT_IF (!_PyThreadState_HasStackSpace (tstate , code -> co_framesize ));
810810 STAT_INC (BINARY_SUBSCR , hit );
811- Py_INCREF (getitem );
812811 }
813812
814813 op (_BINARY_SUBSCR_INIT_CALL , (container , sub -- new_frame : _PyInterpreterFrame * )) {
815814 PyTypeObject * tp = Py_TYPE (PyStackRef_AsPyObjectBorrow (container ));
816815 PyHeapTypeObject * ht = (PyHeapTypeObject * )tp ;
817816 PyObject * getitem = ht -> _spec_cache .getitem ;
818- new_frame = _PyFrame_PushUnchecked (tstate , ( PyFunctionObject * ) getitem , 2 , frame );
817+ new_frame = _PyFrame_PushUnchecked (tstate , PyStackRef_FromPyObjectNew ( getitem ) , 2 , frame );
819818 SYNC_SP ();
820819 new_frame -> localsplus [0 ] = container ;
821820 new_frame -> localsplus [1 ] = sub ;
@@ -1666,8 +1665,9 @@ dummy_func(
16661665 inst (COPY_FREE_VARS , (-- )) {
16671666 /* Copy closure variables to free variables */
16681667 PyCodeObject * co = _PyFrame_GetCode (frame );
1669- assert (PyFunction_Check (frame -> f_funcobj ));
1670- PyObject * closure = ((PyFunctionObject * )frame -> f_funcobj )-> func_closure ;
1668+ assert (PyStackRef_FunctionCheck (frame -> f_funcobj ));
1669+ PyFunctionObject * func = (PyFunctionObject * )PyStackRef_AsPyObjectBorrow (frame -> f_funcobj );
1670+ PyObject * closure = func -> func_closure ;
16711671 assert (oparg == co -> co_nfreevars );
16721672 int offset = co -> co_nlocalsplus - oparg ;
16731673 for (int i = 0 ; i < oparg ; ++ i ) {
@@ -2170,8 +2170,7 @@ dummy_func(
21702170 DEOPT_IF (code -> co_argcount != 1 );
21712171 DEOPT_IF (!_PyThreadState_HasStackSpace (tstate , code -> co_framesize ));
21722172 STAT_INC (LOAD_ATTR , hit );
2173- Py_INCREF (fget );
2174- new_frame = _PyFrame_PushUnchecked (tstate , f , 1 , frame );
2173+ new_frame = _PyFrame_PushUnchecked (tstate , PyStackRef_FromPyObjectNew (fget ), 1 , frame );
21752174 new_frame -> localsplus [0 ] = owner ;
21762175 }
21772176
@@ -2202,8 +2201,8 @@ dummy_func(
22022201 STAT_INC (LOAD_ATTR , hit );
22032202
22042203 PyObject * name = GETITEM (FRAME_CO_NAMES , oparg >> 1 );
2205- Py_INCREF ( f );
2206- _PyInterpreterFrame * new_frame = _PyFrame_PushUnchecked ( tstate , f , 2 , frame );
2204+ _PyInterpreterFrame * new_frame = _PyFrame_PushUnchecked (
2205+ tstate , PyStackRef_FromPyObjectNew ( f ) , 2 , frame );
22072206 // Manipulate stack directly because we exit with DISPATCH_INLINED().
22082207 STACK_SHRINK (1 );
22092208 new_frame -> localsplus [0 ] = owner ;
@@ -3251,7 +3250,7 @@ dummy_func(
32513250 int code_flags = ((PyCodeObject * )PyFunction_GET_CODE (callable_o ))-> co_flags ;
32523251 PyObject * locals = code_flags & CO_OPTIMIZED ? NULL : Py_NewRef (PyFunction_GET_GLOBALS (callable_o ));
32533252 _PyInterpreterFrame * new_frame = _PyEvalFramePushAndInit (
3254- tstate , ( PyFunctionObject * ) PyStackRef_AsPyObjectSteal ( callable ) , locals ,
3253+ tstate , callable , locals ,
32553254 args , total_args , NULL , frame
32563255 );
32573256 // Manipulate stack directly since we leave using DISPATCH_INLINED().
@@ -3340,7 +3339,7 @@ dummy_func(
33403339 int code_flags = ((PyCodeObject * )PyFunction_GET_CODE (callable_o ))-> co_flags ;
33413340 PyObject * locals = code_flags & CO_OPTIMIZED ? NULL : Py_NewRef (PyFunction_GET_GLOBALS (callable_o ));
33423341 new_frame = _PyEvalFramePushAndInit (
3343- tstate , ( PyFunctionObject * ) PyStackRef_AsPyObjectSteal ( callable ) , locals ,
3342+ tstate , callable , locals ,
33443343 args , total_args , NULL , frame
33453344 );
33463345 // The frame has stolen all the arguments from the stack,
@@ -3475,11 +3474,9 @@ dummy_func(
34753474 }
34763475
34773476 replicate (5 ) pure op (_INIT_CALL_PY_EXACT_ARGS , (callable , self_or_null [1 ], args [oparg ] -- new_frame : _PyInterpreterFrame * )) {
3478- PyObject * callable_o = PyStackRef_AsPyObjectBorrow (callable );
34793477 int has_self = !PyStackRef_IsNull (self_or_null [0 ]);
34803478 STAT_INC (CALL , hit );
3481- PyFunctionObject * func = (PyFunctionObject * )callable_o ;
3482- new_frame = _PyFrame_PushUnchecked (tstate , func , oparg + has_self , frame );
3479+ new_frame = _PyFrame_PushUnchecked (tstate , callable , oparg + has_self , frame );
34833480 _PyStackRef * first_non_self_local = new_frame -> localsplus + has_self ;
34843481 new_frame -> localsplus [0 ] = self_or_null [0 ];
34853482 for (int i = 0 ; i < oparg ; i ++ ) {
@@ -3601,10 +3598,9 @@ dummy_func(
36013598 assert (_PyCode_CODE (_PyFrame_GetCode (shim ))[0 ].op .code == EXIT_INIT_CHECK );
36023599 /* Push self onto stack of shim */
36033600 shim -> localsplus [0 ] = PyStackRef_DUP (self );
3604- PyFunctionObject * init_func = (PyFunctionObject * )PyStackRef_AsPyObjectSteal (init );
36053601 args [-1 ] = self ;
36063602 init_frame = _PyEvalFramePushAndInit (
3607- tstate , init_func , NULL , args - 1 , oparg + 1 , NULL , shim );
3603+ tstate , init , NULL , args - 1 , oparg + 1 , NULL , shim );
36083604 SYNC_SP ();
36093605 if (init_frame == NULL ) {
36103606 _PyEval_FrameClearAndPop (tstate , shim );
@@ -4080,7 +4076,7 @@ dummy_func(
40804076 int code_flags = ((PyCodeObject * )PyFunction_GET_CODE (callable_o ))-> co_flags ;
40814077 PyObject * locals = code_flags & CO_OPTIMIZED ? NULL : Py_NewRef (PyFunction_GET_GLOBALS (callable_o ));
40824078 _PyInterpreterFrame * new_frame = _PyEvalFramePushAndInit (
4083- tstate , ( PyFunctionObject * ) PyStackRef_AsPyObjectSteal ( callable ) , locals ,
4079+ tstate , callable , locals ,
40844080 args , positional_args , kwnames_o , frame
40854081 );
40864082 PyStackRef_CLOSE (kwnames );
@@ -4148,7 +4144,7 @@ dummy_func(
41484144 int code_flags = ((PyCodeObject * )PyFunction_GET_CODE (callable_o ))-> co_flags ;
41494145 PyObject * locals = code_flags & CO_OPTIMIZED ? NULL : Py_NewRef (PyFunction_GET_GLOBALS (callable_o ));
41504146 new_frame = _PyEvalFramePushAndInit (
4151- tstate , ( PyFunctionObject * ) PyStackRef_AsPyObjectSteal ( callable ) , locals ,
4147+ tstate , callable , locals ,
41524148 args , positional_args , kwnames_o , frame
41534149 );
41544150 PyStackRef_CLOSE (kwnames );
@@ -4332,9 +4328,9 @@ dummy_func(
43324328 int code_flags = ((PyCodeObject * )PyFunction_GET_CODE (func ))-> co_flags ;
43334329 PyObject * locals = code_flags & CO_OPTIMIZED ? NULL : Py_NewRef (PyFunction_GET_GLOBALS (func ));
43344330
4335- _PyInterpreterFrame * new_frame = _PyEvalFramePushAndInit_Ex (tstate ,
4336- ( PyFunctionObject * ) PyStackRef_AsPyObjectSteal ( func_st ) , locals ,
4337- nargs , callargs , kwargs , frame );
4331+ _PyInterpreterFrame * new_frame = _PyEvalFramePushAndInit_Ex (
4332+ tstate , func_st , locals ,
4333+ nargs , callargs , kwargs , frame );
43384334 // Need to manually shrink the stack since we exit with DISPATCH_INLINED.
43394335 STACK_SHRINK (oparg + 3 );
43404336 if (new_frame == NULL ) {
@@ -4408,8 +4404,8 @@ dummy_func(
44084404 }
44094405
44104406 inst (RETURN_GENERATOR , (-- res )) {
4411- assert (PyFunction_Check (frame -> f_funcobj ));
4412- PyFunctionObject * func = (PyFunctionObject * )frame -> f_funcobj ;
4407+ assert (PyStackRef_FunctionCheck (frame -> f_funcobj ));
4408+ PyFunctionObject * func = (PyFunctionObject * )PyStackRef_AsPyObjectBorrow ( frame -> f_funcobj ) ;
44134409 PyGenObject * gen = (PyGenObject * )_Py_MakeCoro (func );
44144410 if (gen == NULL ) {
44154411 ERROR_NO_POP ();
@@ -4771,8 +4767,9 @@ dummy_func(
47714767 }
47724768
47734769 tier2 op (_CHECK_FUNCTION , (func_version /2 -- )) {
4774- assert (PyFunction_Check (frame -> f_funcobj ));
4775- DEOPT_IF (((PyFunctionObject * )frame -> f_funcobj )-> func_version != func_version );
4770+ assert (PyStackRef_FunctionCheck (frame -> f_funcobj ));
4771+ PyFunctionObject * func = (PyFunctionObject * )PyStackRef_AsPyObjectBorrow (frame -> f_funcobj );
4772+ DEOPT_IF (func -> func_version != func_version );
47764773 }
47774774
47784775 /* Internal -- for testing executors */
0 commit comments