@@ -808,14 +808,13 @@ dummy_func(
808
808
assert (code -> co_argcount == 2 );
809
809
DEOPT_IF (!_PyThreadState_HasStackSpace (tstate , code -> co_framesize ));
810
810
STAT_INC (BINARY_SUBSCR , hit );
811
- Py_INCREF (getitem );
812
811
}
813
812
814
813
op (_BINARY_SUBSCR_INIT_CALL , (container , sub -- new_frame : _PyInterpreterFrame * )) {
815
814
PyTypeObject * tp = Py_TYPE (PyStackRef_AsPyObjectBorrow (container ));
816
815
PyHeapTypeObject * ht = (PyHeapTypeObject * )tp ;
817
816
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 );
819
818
SYNC_SP ();
820
819
new_frame -> localsplus [0 ] = container ;
821
820
new_frame -> localsplus [1 ] = sub ;
@@ -1666,8 +1665,9 @@ dummy_func(
1666
1665
inst (COPY_FREE_VARS , (-- )) {
1667
1666
/* Copy closure variables to free variables */
1668
1667
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 ;
1671
1671
assert (oparg == co -> co_nfreevars );
1672
1672
int offset = co -> co_nlocalsplus - oparg ;
1673
1673
for (int i = 0 ; i < oparg ; ++ i ) {
@@ -2170,8 +2170,7 @@ dummy_func(
2170
2170
DEOPT_IF (code -> co_argcount != 1 );
2171
2171
DEOPT_IF (!_PyThreadState_HasStackSpace (tstate , code -> co_framesize ));
2172
2172
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 );
2175
2174
new_frame -> localsplus [0 ] = owner ;
2176
2175
}
2177
2176
@@ -2202,8 +2201,8 @@ dummy_func(
2202
2201
STAT_INC (LOAD_ATTR , hit );
2203
2202
2204
2203
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 );
2207
2206
// Manipulate stack directly because we exit with DISPATCH_INLINED().
2208
2207
STACK_SHRINK (1 );
2209
2208
new_frame -> localsplus [0 ] = owner ;
@@ -3251,7 +3250,7 @@ dummy_func(
3251
3250
int code_flags = ((PyCodeObject * )PyFunction_GET_CODE (callable_o ))-> co_flags ;
3252
3251
PyObject * locals = code_flags & CO_OPTIMIZED ? NULL : Py_NewRef (PyFunction_GET_GLOBALS (callable_o ));
3253
3252
_PyInterpreterFrame * new_frame = _PyEvalFramePushAndInit (
3254
- tstate , ( PyFunctionObject * ) PyStackRef_AsPyObjectSteal ( callable ) , locals ,
3253
+ tstate , callable , locals ,
3255
3254
args , total_args , NULL , frame
3256
3255
);
3257
3256
// Manipulate stack directly since we leave using DISPATCH_INLINED().
@@ -3340,7 +3339,7 @@ dummy_func(
3340
3339
int code_flags = ((PyCodeObject * )PyFunction_GET_CODE (callable_o ))-> co_flags ;
3341
3340
PyObject * locals = code_flags & CO_OPTIMIZED ? NULL : Py_NewRef (PyFunction_GET_GLOBALS (callable_o ));
3342
3341
new_frame = _PyEvalFramePushAndInit (
3343
- tstate , ( PyFunctionObject * ) PyStackRef_AsPyObjectSteal ( callable ) , locals ,
3342
+ tstate , callable , locals ,
3344
3343
args , total_args , NULL , frame
3345
3344
);
3346
3345
// The frame has stolen all the arguments from the stack,
@@ -3475,11 +3474,9 @@ dummy_func(
3475
3474
}
3476
3475
3477
3476
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 );
3479
3477
int has_self = !PyStackRef_IsNull (self_or_null [0 ]);
3480
3478
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 );
3483
3480
_PyStackRef * first_non_self_local = new_frame -> localsplus + has_self ;
3484
3481
new_frame -> localsplus [0 ] = self_or_null [0 ];
3485
3482
for (int i = 0 ; i < oparg ; i ++ ) {
@@ -3601,10 +3598,9 @@ dummy_func(
3601
3598
assert (_PyCode_CODE (_PyFrame_GetCode (shim ))[0 ].op .code == EXIT_INIT_CHECK );
3602
3599
/* Push self onto stack of shim */
3603
3600
shim -> localsplus [0 ] = PyStackRef_DUP (self );
3604
- PyFunctionObject * init_func = (PyFunctionObject * )PyStackRef_AsPyObjectSteal (init );
3605
3601
args [-1 ] = self ;
3606
3602
init_frame = _PyEvalFramePushAndInit (
3607
- tstate , init_func , NULL , args - 1 , oparg + 1 , NULL , shim );
3603
+ tstate , init , NULL , args - 1 , oparg + 1 , NULL , shim );
3608
3604
SYNC_SP ();
3609
3605
if (init_frame == NULL ) {
3610
3606
_PyEval_FrameClearAndPop (tstate , shim );
@@ -4080,7 +4076,7 @@ dummy_func(
4080
4076
int code_flags = ((PyCodeObject * )PyFunction_GET_CODE (callable_o ))-> co_flags ;
4081
4077
PyObject * locals = code_flags & CO_OPTIMIZED ? NULL : Py_NewRef (PyFunction_GET_GLOBALS (callable_o ));
4082
4078
_PyInterpreterFrame * new_frame = _PyEvalFramePushAndInit (
4083
- tstate , ( PyFunctionObject * ) PyStackRef_AsPyObjectSteal ( callable ) , locals ,
4079
+ tstate , callable , locals ,
4084
4080
args , positional_args , kwnames_o , frame
4085
4081
);
4086
4082
PyStackRef_CLOSE (kwnames );
@@ -4148,7 +4144,7 @@ dummy_func(
4148
4144
int code_flags = ((PyCodeObject * )PyFunction_GET_CODE (callable_o ))-> co_flags ;
4149
4145
PyObject * locals = code_flags & CO_OPTIMIZED ? NULL : Py_NewRef (PyFunction_GET_GLOBALS (callable_o ));
4150
4146
new_frame = _PyEvalFramePushAndInit (
4151
- tstate , ( PyFunctionObject * ) PyStackRef_AsPyObjectSteal ( callable ) , locals ,
4147
+ tstate , callable , locals ,
4152
4148
args , positional_args , kwnames_o , frame
4153
4149
);
4154
4150
PyStackRef_CLOSE (kwnames );
@@ -4332,9 +4328,9 @@ dummy_func(
4332
4328
int code_flags = ((PyCodeObject * )PyFunction_GET_CODE (func ))-> co_flags ;
4333
4329
PyObject * locals = code_flags & CO_OPTIMIZED ? NULL : Py_NewRef (PyFunction_GET_GLOBALS (func ));
4334
4330
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 );
4338
4334
// Need to manually shrink the stack since we exit with DISPATCH_INLINED.
4339
4335
STACK_SHRINK (oparg + 3 );
4340
4336
if (new_frame == NULL ) {
@@ -4408,8 +4404,8 @@ dummy_func(
4408
4404
}
4409
4405
4410
4406
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 ) ;
4413
4409
PyGenObject * gen = (PyGenObject * )_Py_MakeCoro (func );
4414
4410
if (gen == NULL ) {
4415
4411
ERROR_NO_POP ();
@@ -4771,8 +4767,9 @@ dummy_func(
4771
4767
}
4772
4768
4773
4769
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 );
4776
4773
}
4777
4774
4778
4775
/* Internal -- for testing executors */
0 commit comments