@@ -138,125 +138,6 @@ static PyObject* dummy_func(
138138
139139 switch (opcode ) {
140140 // BEGIN BYTECODES //
141-
142- override inst (
143- LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN ,
144- (unused / 1 ,
145- type_version / 2 ,
146- func_version / 2 ,
147- getattribute / 4 ,
148- owner -- unused )) {
149- PyObject * owner_o = PyStackRef_AsPyObjectBorrow (owner );
150-
151- assert ((oparg & 1 ) == 0 );
152- DEOPT_IF (IS_PEP523_HOOKED (tstate ));
153- PyTypeObject * cls = Py_TYPE (owner_o );
154- assert (type_version != 0 );
155- DEOPT_IF (
156- FT_ATOMIC_LOAD_UINT_RELAXED (cls -> tp_version_tag ) != type_version );
157- assert (Py_IS_TYPE (getattribute , & PyFunction_Type ));
158- PyFunctionObject * f = (PyFunctionObject * )getattribute ;
159- assert (func_version != 0 );
160- DEOPT_IF (f -> func_version != func_version );
161- PyCodeObject * code = (PyCodeObject * )f -> func_code ;
162- assert (code -> co_argcount == 2 );
163- DEOPT_IF (!_PyThreadState_HasStackSpace (tstate , code -> co_framesize ));
164- STAT_INC (LOAD_ATTR , hit );
165-
166- PyObject * name = GETITEM (FRAME_CO_NAMES , oparg >> 1 );
167- _PyInterpreterFrame * new_frame = _PyFrame_PushUnchecked (
168- tstate , PyStackRef_FromPyObjectNew (f ), 2 , frame );
169- new_frame -> localsplus [0 ] = owner ;
170- DEAD (owner );
171- // Manipulate stack directly because we exit with DISPATCH_INLINED().
172- SYNC_SP ();
173- new_frame -> localsplus [1 ] = PyStackRef_FromPyObjectNew (name );
174- frame -> return_offset = INSTRUCTION_SIZE ;
175- DISPATCH_INLINED (new_frame );
176- }
177-
178- override op (_DO_CALL , (callable , self_or_null , args [oparg ]-- res )) {
179- PyObject * callable_o = PyStackRef_AsPyObjectBorrow (callable );
180-
181- // oparg counts all of the args, but *not* self:
182- int total_args = oparg ;
183- _PyStackRef * arguments = args ;
184- if (!PyStackRef_IsNull (self_or_null )) {
185- arguments -- ;
186- total_args ++ ;
187- }
188- // Check if the call can be inlined or not
189- if (Py_TYPE (callable_o ) == & PyFunction_Type &&
190- !IS_PEP523_HOOKED (tstate ) &&
191- ((PyFunctionObject * )callable_o )-> vectorcall ==
192- _PyFunction_Vectorcall ) {
193- int code_flags =
194- ((PyCodeObject * )PyFunction_GET_CODE (callable_o ))-> co_flags ;
195- PyObject * locals = code_flags & CO_OPTIMIZED
196- ? NULL
197- : Py_NewRef (PyFunction_GET_GLOBALS (callable_o ));
198- _PyInterpreterFrame * new_frame = _PyEvalFramePushAndInit (
199- tstate , callable , locals , arguments , total_args , NULL , frame );
200- DEAD (args );
201- DEAD (self_or_null );
202- DEAD (callable );
203- // Manipulate stack directly since we leave using DISPATCH_INLINED().
204- SYNC_SP ();
205- // The frame has stolen all the arguments from the stack,
206- // so there is no need to clean them up.
207- if (new_frame == NULL ) {
208- ERROR_NO_POP ();
209- }
210- frame -> return_offset = INSTRUCTION_SIZE ;
211- DISPATCH_INLINED (new_frame );
212- }
213- /* Callable is not a normal Python function */
214- STACKREFS_TO_PYOBJECTS (arguments , total_args , args_o );
215- if (CONVERSION_FAILED (args_o )) {
216- DECREF_INPUTS ();
217- ERROR_IF (true);
218- }
219- PyObject * res_o = PyObject_Vectorcall (
220- callable_o ,
221- args_o ,
222- total_args | PY_VECTORCALL_ARGUMENTS_OFFSET ,
223- NULL );
224- STACKREFS_TO_PYOBJECTS_CLEANUP (args_o );
225- if (opcode == INSTRUMENTED_CALL ) {
226- PyObject * arg = total_args == 0
227- ? & _PyInstrumentation_MISSING
228- : PyStackRef_AsPyObjectBorrow (arguments [0 ]);
229- if (res_o == NULL ) {
230- _Py_call_instrumentation_exc2 (
231- tstate ,
232- PY_MONITORING_EVENT_C_RAISE ,
233- frame ,
234- this_instr ,
235- callable_o ,
236- arg );
237- } else {
238- int err = _Py_call_instrumentation_2args (
239- tstate ,
240- PY_MONITORING_EVENT_C_RETURN ,
241- frame ,
242- this_instr ,
243- callable_o ,
244- arg );
245- if (err < 0 ) {
246- Py_CLEAR (res_o );
247- }
248- }
249- }
250- assert ((res_o != NULL ) ^ (_PyErr_Occurred (tstate ) != NULL ));
251- DECREF_INPUTS ();
252- ERROR_IF (res_o == NULL );
253- res = PyStackRef_FromPyObjectSteal (res_o );
254- }
255-
256- override op (_CHECK_PEP_523 , (-- )) {
257- DEOPT_IF (IS_PEP523_HOOKED (tstate ));
258- }
259-
260141 override op (_PUSH_FRAME , (new_frame -- )) {
261142 // Write it out explicitly because it's subtly different.
262143 // Eventually this should be the only occurrence of this code.
@@ -277,231 +158,6 @@ static PyObject* dummy_func(
277158 LLTRACE_RESUME_FRAME ();
278159 }
279160
280- override op (
281- _DO_CALL_KW , (callable , self_or_null , args [oparg ], kwnames -- res )) {
282- PyObject * callable_o = PyStackRef_AsPyObjectBorrow (callable );
283- PyObject * kwnames_o = PyStackRef_AsPyObjectBorrow (kwnames );
284-
285- // oparg counts all of the args, but *not* self:
286- int total_args = oparg ;
287- _PyStackRef * arguments = args ;
288- if (!PyStackRef_IsNull (self_or_null )) {
289- arguments -- ;
290- total_args ++ ;
291- }
292- int positional_args = total_args - (int )PyTuple_GET_SIZE (kwnames_o );
293- // Check if the call can be inlined or not
294- if (Py_TYPE (callable_o ) == & PyFunction_Type &&
295- !IS_PEP523_HOOKED (tstate ) &&
296- ((PyFunctionObject * )callable_o )-> vectorcall ==
297- _PyFunction_Vectorcall ) {
298- int code_flags =
299- ((PyCodeObject * )PyFunction_GET_CODE (callable_o ))-> co_flags ;
300- PyObject * locals = code_flags & CO_OPTIMIZED
301- ? NULL
302- : Py_NewRef (PyFunction_GET_GLOBALS (callable_o ));
303- _PyInterpreterFrame * new_frame = _PyEvalFramePushAndInit (
304- tstate ,
305- callable ,
306- locals ,
307- arguments ,
308- positional_args ,
309- kwnames_o ,
310- frame );
311- DEAD (args );
312- DEAD (self_or_null );
313- DEAD (callable );
314- PyStackRef_CLOSE (kwnames );
315- // Sync stack explicitly since we leave using DISPATCH_INLINED().
316- SYNC_SP ();
317- // The frame has stolen all the arguments from the stack,
318- // so there is no need to clean them up.
319- if (new_frame == NULL ) {
320- ERROR_NO_POP ();
321- }
322- assert (INSTRUCTION_SIZE == 1 + INLINE_CACHE_ENTRIES_CALL_KW );
323- frame -> return_offset = INSTRUCTION_SIZE ;
324- DISPATCH_INLINED (new_frame );
325- }
326- /* Callable is not a normal Python function */
327- STACKREFS_TO_PYOBJECTS (arguments , total_args , args_o );
328- if (CONVERSION_FAILED (args_o )) {
329- DECREF_INPUTS ();
330- ERROR_IF (true);
331- }
332- PyObject * res_o = PyObject_Vectorcall (
333- callable_o ,
334- args_o ,
335- positional_args | PY_VECTORCALL_ARGUMENTS_OFFSET ,
336- kwnames_o );
337- STACKREFS_TO_PYOBJECTS_CLEANUP (args_o );
338- if (opcode == INSTRUMENTED_CALL_KW ) {
339- PyObject * arg = total_args == 0
340- ? & _PyInstrumentation_MISSING
341- : PyStackRef_AsPyObjectBorrow (arguments [0 ]);
342- if (res_o == NULL ) {
343- _Py_call_instrumentation_exc2 (
344- tstate ,
345- PY_MONITORING_EVENT_C_RAISE ,
346- frame ,
347- this_instr ,
348- callable_o ,
349- arg );
350- } else {
351- int err = _Py_call_instrumentation_2args (
352- tstate ,
353- PY_MONITORING_EVENT_C_RETURN ,
354- frame ,
355- this_instr ,
356- callable_o ,
357- arg );
358- if (err < 0 ) {
359- Py_CLEAR (res_o );
360- }
361- }
362- }
363- DECREF_INPUTS ();
364- ERROR_IF (res_o == NULL );
365- res = PyStackRef_FromPyObjectSteal (res_o );
366- }
367-
368- override op (
369- _DO_CALL_FUNCTION_EX ,
370- (func_st , null , callargs_st , kwargs_st -- result )) {
371- (void )null ;
372- PyObject * func = PyStackRef_AsPyObjectBorrow (func_st );
373-
374- // DICT_MERGE is called before this opcode if there are kwargs.
375- // It converts all dict subtypes in kwargs into regular dicts.
376- EVAL_CALL_STAT_INC_IF_FUNCTION (EVAL_CALL_FUNCTION_EX , func );
377- PyObject * result_o ;
378- assert (!_PyErr_Occurred (tstate ));
379- if (opcode == INSTRUMENTED_CALL_FUNCTION_EX ) {
380- PyObject * callargs = PyStackRef_AsPyObjectBorrow (callargs_st );
381- PyObject * kwargs = PyStackRef_AsPyObjectBorrow (kwargs_st );
382- assert (kwargs == NULL || PyDict_CheckExact (kwargs ));
383- assert (PyTuple_CheckExact (callargs ));
384- PyObject * arg = PyTuple_GET_SIZE (callargs ) > 0
385- ? PyTuple_GET_ITEM (callargs , 0 )
386- : & _PyInstrumentation_MISSING ;
387- int err = _Py_call_instrumentation_2args (
388- tstate , PY_MONITORING_EVENT_CALL , frame , this_instr , func , arg );
389- if (err ) {
390- ERROR_NO_POP ();
391- }
392- result_o = PyObject_Call (func , callargs , kwargs );
393-
394- if (!PyFunction_Check (func ) && !PyMethod_Check (func )) {
395- if (result_o == NULL ) {
396- _Py_call_instrumentation_exc2 (
397- tstate ,
398- PY_MONITORING_EVENT_C_RAISE ,
399- frame ,
400- this_instr ,
401- func ,
402- arg );
403- } else {
404- int err = _Py_call_instrumentation_2args (
405- tstate ,
406- PY_MONITORING_EVENT_C_RETURN ,
407- frame ,
408- this_instr ,
409- func ,
410- arg );
411- if (err < 0 ) {
412- Py_CLEAR (result_o );
413- }
414- }
415- }
416- } else {
417- if (Py_TYPE (func ) == & PyFunction_Type && !IS_PEP523_HOOKED (tstate ) &&
418- ((PyFunctionObject * )func )-> vectorcall == _PyFunction_Vectorcall ) {
419- PyObject * callargs = PyStackRef_AsPyObjectSteal (callargs_st );
420- assert (PyTuple_CheckExact (callargs ));
421- PyObject * kwargs = PyStackRef_IsNull (kwargs_st )
422- ? NULL
423- : PyStackRef_AsPyObjectSteal (kwargs_st );
424- assert (kwargs == NULL || PyDict_CheckExact (kwargs ));
425- Py_ssize_t nargs = PyTuple_GET_SIZE (callargs );
426- int code_flags = ((PyCodeObject * )PyFunction_GET_CODE (func ))-> co_flags ;
427- PyObject * locals = code_flags & CO_OPTIMIZED
428- ? NULL
429- : Py_NewRef (PyFunction_GET_GLOBALS (func ));
430-
431- _PyInterpreterFrame * new_frame = _PyEvalFramePushAndInit_Ex (
432- tstate , func_st , locals , nargs , callargs , kwargs , frame );
433- // Need to sync the stack since we exit with DISPATCH_INLINED.
434- INPUTS_DEAD ();
435- SYNC_SP ();
436- if (new_frame == NULL ) {
437- ERROR_NO_POP ();
438- }
439- assert (INSTRUCTION_SIZE == 1 + INLINE_CACHE_ENTRIES_CALL_FUNCTION_EX );
440- frame -> return_offset = INSTRUCTION_SIZE ;
441- DISPATCH_INLINED (new_frame );
442- }
443- PyObject * callargs = PyStackRef_AsPyObjectBorrow (callargs_st );
444- assert (PyTuple_CheckExact (callargs ));
445- PyObject * kwargs = PyStackRef_AsPyObjectBorrow (kwargs_st );
446- assert (kwargs == NULL || PyDict_CheckExact (kwargs ));
447- result_o = PyObject_Call (func , callargs , kwargs );
448- }
449- PyStackRef_XCLOSE (kwargs_st );
450- PyStackRef_CLOSE (callargs_st );
451- DEAD (null );
452- PyStackRef_CLOSE (func_st );
453- ERROR_IF (result_o == NULL );
454- result = PyStackRef_FromPyObjectSteal (result_o );
455- }
456-
457- override op (_SEND , (receiver , v -- receiver , retval )) {
458- PyObject * receiver_o = PyStackRef_AsPyObjectBorrow (receiver );
459- PyObject * retval_o ;
460- assert (frame -> owner != FRAME_OWNED_BY_INTERPRETER );
461- if (!IS_PEP523_HOOKED (tstate ) &&
462- (Py_TYPE (receiver_o ) == & PyGen_Type || Py_TYPE (receiver_o ) == & PyCoro_Type ) &&
463- gen_try_set_executing ((PyGenObject * )receiver_o ))
464- {
465- PyGenObject * gen = (PyGenObject * )receiver_o ;
466- _PyInterpreterFrame * gen_frame = & gen -> gi_iframe ;
467- _PyFrame_StackPush (gen_frame , PyStackRef_MakeHeapSafe (v ));
468- DEAD (v );
469- SYNC_SP ();
470- gen -> gi_exc_state .previous_item = tstate -> exc_info ;
471- tstate -> exc_info = & gen -> gi_exc_state ;
472- assert (INSTRUCTION_SIZE + oparg <= UINT16_MAX );
473- frame -> return_offset = (uint16_t )(INSTRUCTION_SIZE + oparg );
474- assert (gen_frame -> previous == NULL );
475- gen_frame -> previous = frame ;
476- DISPATCH_INLINED (gen_frame );
477- }
478- if (PyStackRef_IsNone (v ) && PyIter_Check (receiver_o )) {
479- retval_o = Py_TYPE (receiver_o )-> tp_iternext (receiver_o );
480- }
481- else {
482- retval_o = PyObject_CallMethodOneArg (receiver_o ,
483- & _Py_ID (send ),
484- PyStackRef_AsPyObjectBorrow (v ));
485- }
486- if (retval_o == NULL ) {
487- int matches = _PyErr_ExceptionMatches (tstate , PyExc_StopIteration );
488- if (matches ) {
489- _PyEval_MonitorRaise (tstate , frame , this_instr );
490- }
491- int err = _PyGen_FetchStopIterationValue (& retval_o );
492- if (err == 0 ) {
493- assert (retval_o != NULL );
494- JUMPBY (oparg );
495- }
496- else {
497- PyStackRef_CLOSE (v );
498- ERROR_IF (true);
499- }
500- }
501- PyStackRef_CLOSE (v );
502- retval = PyStackRef_FromPyObjectSteal (retval_o );
503- }
504-
505161 override inst (GET_ANEXT , (aiter -- aiter , awaitable )) {
506162 // CX: Use modified version of _PyEval_GetANext to handle JIT generators
507163 PyObject * awaitable_o =
0 commit comments