Branch data Line data Source code
1 : : // This file contains instruction definitions.
2 : : // It is read by Tools/cases_generator/generate_cases.py
3 : : // to generate Python/generated_cases.c.h.
4 : : // Note that there is some dummy C code at the top and bottom of the file
5 : : // to fool text editors like VS Code into believing this is valid C code.
6 : : // The actual instruction definitions start at // BEGIN BYTECODES //.
7 : : // See Tools/cases_generator/README.md for more information.
8 : :
9 : : #include "Python.h"
10 : : #include "pycore_abstract.h" // _PyIndex_Check()
11 : : #include "pycore_call.h" // _PyObject_FastCallDictTstate()
12 : : #include "pycore_ceval.h" // _PyEval_SignalAsyncExc()
13 : : #include "pycore_code.h"
14 : : #include "pycore_function.h"
15 : : #include "pycore_intrinsics.h"
16 : : #include "pycore_long.h" // _PyLong_GetZero()
17 : : #include "pycore_object.h" // _PyObject_GC_TRACK()
18 : : #include "pycore_moduleobject.h" // PyModuleObject
19 : : #include "pycore_opcode.h" // EXTRA_CASES
20 : : #include "pycore_pyerrors.h" // _PyErr_GetRaisedException()
21 : : #include "pycore_pymem.h" // _PyMem_IsPtrFreed()
22 : : #include "pycore_pystate.h" // _PyInterpreterState_GET()
23 : : #include "pycore_range.h" // _PyRangeIterObject
24 : : #include "pycore_sliceobject.h" // _PyBuildSlice_ConsumeRefs
25 : : #include "pycore_sysmodule.h" // _PySys_Audit()
26 : : #include "pycore_tuple.h" // _PyTuple_ITEMS()
27 : : #include "pycore_emscripten_signal.h" // _Py_CHECK_EMSCRIPTEN_SIGNALS
28 : :
29 : : #include "pycore_dict.h"
30 : : #include "dictobject.h"
31 : : #include "pycore_frame.h"
32 : : #include "opcode.h"
33 : : #include "pydtrace.h"
34 : : #include "setobject.h"
35 : : #include "structmember.h" // struct PyMemberDef, T_OFFSET_EX
36 : :
37 : : #define USE_COMPUTED_GOTOS 0
38 : : #include "ceval_macros.h"
39 : :
40 : : /* Flow control macros */
41 : : #define DEOPT_IF(cond, instname) ((void)0)
42 : : #define ERROR_IF(cond, labelname) ((void)0)
43 : : #define GO_TO_INSTRUCTION(instname) ((void)0)
44 : : #define PREDICT(opname) ((void)0)
45 : :
46 : : #define inst(name, ...) case name:
47 : : #define op(name, ...) /* NAME is ignored */
48 : : #define macro(name) static int MACRO_##name
49 : : #define super(name) static int SUPER_##name
50 : : #define family(name, ...) static int family_##name
51 : :
52 : : // Dummy variables for stack effects.
53 : : static PyObject *value, *value1, *value2, *left, *right, *res, *sum, *prod, *sub;
54 : : static PyObject *container, *start, *stop, *v, *lhs, *rhs, *res2;
55 : : static PyObject *list, *tuple, *dict, *owner, *set, *str, *tup, *map, *keys;
56 : : static PyObject *exit_func, *lasti, *val, *retval, *obj, *iter;
57 : : static PyObject *aiter, *awaitable, *iterable, *w, *exc_value, *bc;
58 : : static PyObject *orig, *excs, *update, *b, *fromlist, *level, *from;
59 : : static PyObject **pieces, **values;
60 : : static size_t jump;
61 : : // Dummy variables for cache effects
62 : : static uint16_t invert, counter, index, hint;
63 : : static uint32_t type_version;
64 : :
65 : : static PyObject *
66 : : dummy_func(
67 : : PyThreadState *tstate,
68 : : _PyInterpreterFrame *frame,
69 : : unsigned char opcode,
70 : : unsigned int oparg,
71 : : _Py_atomic_int * const eval_breaker,
72 : : _PyCFrame cframe,
73 : : _Py_CODEUNIT *next_instr,
74 : : PyObject **stack_pointer,
75 : : PyObject *kwnames,
76 : : int throwflag,
77 : : binaryfunc binary_ops[]
78 : : )
79 : : {
80 : : _PyInterpreterFrame entry_frame;
81 : :
82 : : switch (opcode) {
83 : :
84 : : // BEGIN BYTECODES //
85 : : inst(NOP, (--)) {
86 : : }
87 : :
88 : : inst(RESUME, (--)) {
89 : : assert(tstate->cframe == &cframe);
90 : : assert(frame == cframe.current_frame);
91 [ + + + - ]: 4035495 : if (_Py_atomic_load_relaxed_int32(eval_breaker) && oparg < 2) {
92 : 59 : goto handle_eval_breaker;
93 : : }
94 : : }
95 : :
96 : : inst(LOAD_CLOSURE, (-- value)) {
97 : : /* We keep LOAD_CLOSURE so that the bytecode stays more readable. */
98 : 46173 : value = GETLOCAL(oparg);
99 [ - + ]: 46173 : ERROR_IF(value == NULL, unbound_local_error);
100 : 46173 : Py_INCREF(value);
101 : : }
102 : :
103 : : inst(LOAD_FAST_CHECK, (-- value)) {
104 : 3012 : value = GETLOCAL(oparg);
105 [ - + ]: 3012 : ERROR_IF(value == NULL, unbound_local_error);
106 : 3012 : Py_INCREF(value);
107 : : }
108 : :
109 : : inst(LOAD_FAST, (-- value)) {
110 : 36525549 : value = GETLOCAL(oparg);
111 : : assert(value != NULL);
112 : 29914039 : Py_INCREF(value);
113 : : }
114 : :
115 : : inst(LOAD_CONST, (-- value)) {
116 : 5687217 : value = GETITEM(frame->f_code->co_consts, oparg);
117 : 5687217 : Py_INCREF(value);
118 : : }
119 : :
120 : : inst(STORE_FAST, (value --)) {
121 [ + + + + : 10025372 : SETLOCAL(oparg, value);
+ + + + +
+ + + + +
+ + ]
122 : : }
123 : :
124 : : super(LOAD_FAST__LOAD_FAST) = LOAD_FAST + LOAD_FAST;
125 : : super(LOAD_FAST__LOAD_CONST) = LOAD_FAST + LOAD_CONST;
126 : : super(STORE_FAST__LOAD_FAST) = STORE_FAST + LOAD_FAST;
127 : : super(STORE_FAST__STORE_FAST) = STORE_FAST + STORE_FAST;
128 : : super(LOAD_CONST__LOAD_FAST) = LOAD_CONST + LOAD_FAST;
129 : :
130 : : inst(POP_TOP, (value --)) {
131 : : DECREF_INPUTS();
132 : : }
133 : :
134 : : inst(PUSH_NULL, (-- res)) {
135 : 1841863 : res = NULL;
136 : : }
137 : :
138 : : macro(END_FOR) = POP_TOP + POP_TOP;
139 : :
140 : : inst(UNARY_NEGATIVE, (value -- res)) {
141 : 45079 : res = PyNumber_Negative(value);
142 : : DECREF_INPUTS();
143 [ - + ]: 45079 : ERROR_IF(res == NULL, error);
144 : : }
145 : :
146 : : inst(UNARY_NOT, (value -- res)) {
147 : 636 : int err = PyObject_IsTrue(value);
148 : : DECREF_INPUTS();
149 [ - + ]: 636 : ERROR_IF(err < 0, error);
150 [ + + ]: 636 : if (err == 0) {
151 : 353 : res = Py_True;
152 : : }
153 : : else {
154 : 283 : res = Py_False;
155 : : }
156 : 636 : Py_INCREF(res);
157 : : }
158 : :
159 : : inst(UNARY_INVERT, (value -- res)) {
160 : 18211 : res = PyNumber_Invert(value);
161 : : DECREF_INPUTS();
162 [ - + ]: 18211 : ERROR_IF(res == NULL, error);
163 : : }
164 : :
165 : : family(binary_op, INLINE_CACHE_ENTRIES_BINARY_OP) = {
166 : : BINARY_OP,
167 : : BINARY_OP_ADD_FLOAT,
168 : : BINARY_OP_ADD_INT,
169 : : BINARY_OP_ADD_UNICODE,
170 : : // BINARY_OP_INPLACE_ADD_UNICODE, // This is an odd duck.
171 : : BINARY_OP_MULTIPLY_FLOAT,
172 : : BINARY_OP_MULTIPLY_INT,
173 : : BINARY_OP_SUBTRACT_FLOAT,
174 : : BINARY_OP_SUBTRACT_INT,
175 : : };
176 : :
177 : :
178 : : inst(BINARY_OP_MULTIPLY_INT, (unused/1, left, right -- prod)) {
179 : : assert(cframe.use_tracing == 0);
180 [ + + ]: 439353 : DEOPT_IF(!PyLong_CheckExact(left), BINARY_OP);
181 [ + + ]: 439279 : DEOPT_IF(!PyLong_CheckExact(right), BINARY_OP);
182 : : STAT_INC(BINARY_OP, hit);
183 : 439275 : prod = _PyLong_Multiply((PyLongObject *)left, (PyLongObject *)right);
184 [ + + ]: 439275 : _Py_DECREF_SPECIALIZED(right, (destructor)PyObject_Free);
185 [ + + ]: 439275 : _Py_DECREF_SPECIALIZED(left, (destructor)PyObject_Free);
186 [ - + ]: 439275 : ERROR_IF(prod == NULL, error);
187 : : }
188 : :
189 : : inst(BINARY_OP_MULTIPLY_FLOAT, (unused/1, left, right -- prod)) {
190 : : assert(cframe.use_tracing == 0);
191 [ + + ]: 602046 : DEOPT_IF(!PyFloat_CheckExact(left), BINARY_OP);
192 [ - + ]: 602045 : DEOPT_IF(!PyFloat_CheckExact(right), BINARY_OP);
193 : : STAT_INC(BINARY_OP, hit);
194 : 602045 : double dprod = ((PyFloatObject *)left)->ob_fval *
195 : 602045 : ((PyFloatObject *)right)->ob_fval;
196 [ + + - + : 602045 : DECREF_INPUTS_AND_REUSE_FLOAT(left, right, dprod, prod);
+ + - + ]
197 : : }
198 : :
199 : : inst(BINARY_OP_SUBTRACT_INT, (unused/1, left, right -- sub)) {
200 : : assert(cframe.use_tracing == 0);
201 [ - + ]: 1662277 : DEOPT_IF(!PyLong_CheckExact(left), BINARY_OP);
202 [ - + ]: 1662277 : DEOPT_IF(!PyLong_CheckExact(right), BINARY_OP);
203 : : STAT_INC(BINARY_OP, hit);
204 : 1662277 : sub = _PyLong_Subtract((PyLongObject *)left, (PyLongObject *)right);
205 [ + + ]: 1662277 : _Py_DECREF_SPECIALIZED(right, (destructor)PyObject_Free);
206 [ + + ]: 1662277 : _Py_DECREF_SPECIALIZED(left, (destructor)PyObject_Free);
207 [ - + ]: 1662277 : ERROR_IF(sub == NULL, error);
208 : : }
209 : :
210 : : inst(BINARY_OP_SUBTRACT_FLOAT, (unused/1, left, right -- sub)) {
211 : : assert(cframe.use_tracing == 0);
212 [ - + ]: 655270 : DEOPT_IF(!PyFloat_CheckExact(left), BINARY_OP);
213 [ + + ]: 655270 : DEOPT_IF(!PyFloat_CheckExact(right), BINARY_OP);
214 : : STAT_INC(BINARY_OP, hit);
215 : 654271 : double dsub = ((PyFloatObject *)left)->ob_fval - ((PyFloatObject *)right)->ob_fval;
216 [ + + + + : 654271 : DECREF_INPUTS_AND_REUSE_FLOAT(left, right, dsub, sub);
+ + - + ]
217 : : }
218 : :
219 : : inst(BINARY_OP_ADD_UNICODE, (unused/1, left, right -- res)) {
220 : : assert(cframe.use_tracing == 0);
221 [ - + ]: 92351 : DEOPT_IF(!PyUnicode_CheckExact(left), BINARY_OP);
222 [ - + ]: 92351 : DEOPT_IF(Py_TYPE(right) != Py_TYPE(left), BINARY_OP);
223 : : STAT_INC(BINARY_OP, hit);
224 : 92351 : res = PyUnicode_Concat(left, right);
225 [ + + ]: 92351 : _Py_DECREF_SPECIALIZED(left, _PyUnicode_ExactDealloc);
226 [ + + ]: 92351 : _Py_DECREF_SPECIALIZED(right, _PyUnicode_ExactDealloc);
227 [ - + ]: 92351 : ERROR_IF(res == NULL, error);
228 : : }
229 : :
230 : : // This is a subtle one. It's a super-instruction for
231 : : // BINARY_OP_ADD_UNICODE followed by STORE_FAST
232 : : // where the store goes into the left argument.
233 : : // So the inputs are the same as for all BINARY_OP
234 : : // specializations, but there is no output.
235 : : // At the end we just skip over the STORE_FAST.
236 : : inst(BINARY_OP_INPLACE_ADD_UNICODE, (left, right --)) {
237 : : assert(cframe.use_tracing == 0);
238 [ - + ]: 2293 : DEOPT_IF(!PyUnicode_CheckExact(left), BINARY_OP);
239 [ - + ]: 2240 : DEOPT_IF(Py_TYPE(right) != Py_TYPE(left), BINARY_OP);
240 : 2240 : _Py_CODEUNIT true_next = next_instr[INLINE_CACHE_ENTRIES_BINARY_OP];
241 : : assert(true_next.op.code == STORE_FAST ||
242 : : true_next.op.code == STORE_FAST__LOAD_FAST);
243 : 2240 : PyObject **target_local = &GETLOCAL(true_next.op.arg);
244 [ + + ]: 2240 : DEOPT_IF(*target_local != left, BINARY_OP);
245 : : STAT_INC(BINARY_OP, hit);
246 : : /* Handle `left = left + right` or `left += right` for str.
247 : : *
248 : : * When possible, extend `left` in place rather than
249 : : * allocating a new PyUnicodeObject. This attempts to avoid
250 : : * quadratic behavior when one neglects to use str.join().
251 : : *
252 : : * If `left` has only two references remaining (one from
253 : : * the stack, one in the locals), DECREFing `left` leaves
254 : : * only the locals reference, so PyUnicode_Append knows
255 : : * that the string is safe to mutate.
256 : : */
257 : : assert(Py_REFCNT(left) >= 2);
258 : 2187 : _Py_DECREF_NO_DEALLOC(left);
259 : 2187 : PyUnicode_Append(target_local, right);
260 [ + + ]: 2187 : _Py_DECREF_SPECIALIZED(right, _PyUnicode_ExactDealloc);
261 [ - + ]: 2187 : ERROR_IF(*target_local == NULL, error);
262 : : // The STORE_FAST is already done.
263 : 2187 : JUMPBY(INLINE_CACHE_ENTRIES_BINARY_OP + 1);
264 : : }
265 : :
266 : : inst(BINARY_OP_ADD_FLOAT, (unused/1, left, right -- sum)) {
267 : : assert(cframe.use_tracing == 0);
268 [ + + ]: 201021 : DEOPT_IF(!PyFloat_CheckExact(left), BINARY_OP);
269 [ - + ]: 200022 : DEOPT_IF(Py_TYPE(right) != Py_TYPE(left), BINARY_OP);
270 : : STAT_INC(BINARY_OP, hit);
271 : 200022 : double dsum = ((PyFloatObject *)left)->ob_fval +
272 : 200022 : ((PyFloatObject *)right)->ob_fval;
273 [ + + + - : 200022 : DECREF_INPUTS_AND_REUSE_FLOAT(left, right, dsum, sum);
- + - + ]
274 : : }
275 : :
276 : : inst(BINARY_OP_ADD_INT, (unused/1, left, right -- sum)) {
277 : : assert(cframe.use_tracing == 0);
278 [ - + ]: 1310070 : DEOPT_IF(!PyLong_CheckExact(left), BINARY_OP);
279 [ + + ]: 1310070 : DEOPT_IF(Py_TYPE(right) != Py_TYPE(left), BINARY_OP);
280 : : STAT_INC(BINARY_OP, hit);
281 : 1310038 : sum = _PyLong_Add((PyLongObject *)left, (PyLongObject *)right);
282 [ + + ]: 1310038 : _Py_DECREF_SPECIALIZED(right, (destructor)PyObject_Free);
283 [ + + ]: 1310038 : _Py_DECREF_SPECIALIZED(left, (destructor)PyObject_Free);
284 [ - + ]: 1310038 : ERROR_IF(sum == NULL, error);
285 : : }
286 : :
287 : : family(binary_subscr, INLINE_CACHE_ENTRIES_BINARY_SUBSCR) = {
288 : : BINARY_SUBSCR,
289 : : BINARY_SUBSCR_DICT,
290 : : BINARY_SUBSCR_GETITEM,
291 : : BINARY_SUBSCR_LIST_INT,
292 : : BINARY_SUBSCR_TUPLE_INT,
293 : : };
294 : :
295 : : inst(BINARY_SUBSCR, (unused/4, container, sub -- res)) {
296 : : #if ENABLE_SPECIALIZATION
297 : 114248 : _PyBinarySubscrCache *cache = (_PyBinarySubscrCache *)next_instr;
298 [ + + ]: 114248 : if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
299 : : assert(cframe.use_tracing == 0);
300 : 1443 : next_instr--;
301 : 1443 : _Py_Specialize_BinarySubscr(container, sub, next_instr);
302 : 1443 : DISPATCH_SAME_OPARG();
303 : : }
304 : : STAT_INC(BINARY_SUBSCR, deferred);
305 : 112805 : DECREMENT_ADAPTIVE_COUNTER(cache->counter);
306 : : #endif /* ENABLE_SPECIALIZATION */
307 : 112805 : res = PyObject_GetItem(container, sub);
308 : : DECREF_INPUTS();
309 [ + + ]: 112805 : ERROR_IF(res == NULL, error);
310 : : }
311 : :
312 : : inst(BINARY_SLICE, (container, start, stop -- res)) {
313 : 81347 : PyObject *slice = _PyBuildSlice_ConsumeRefs(start, stop);
314 : : // Can't use ERROR_IF() here, because we haven't
315 : : // DECREF'ed container yet, and we still own slice.
316 [ - + ]: 81347 : if (slice == NULL) {
317 : 0 : res = NULL;
318 : : }
319 : : else {
320 : 81347 : res = PyObject_GetItem(container, slice);
321 [ + - ]: 81347 : Py_DECREF(slice);
322 : : }
323 [ + + ]: 81347 : Py_DECREF(container);
324 [ - + ]: 81347 : ERROR_IF(res == NULL, error);
325 : : }
326 : :
327 : : inst(STORE_SLICE, (v, container, start, stop -- )) {
328 : 46 : PyObject *slice = _PyBuildSlice_ConsumeRefs(start, stop);
329 : : int err;
330 [ - + ]: 46 : if (slice == NULL) {
331 : 0 : err = 1;
332 : : }
333 : : else {
334 : 46 : err = PyObject_SetItem(container, slice, v);
335 [ + - ]: 46 : Py_DECREF(slice);
336 : : }
337 [ + + ]: 46 : Py_DECREF(v);
338 [ - + ]: 46 : Py_DECREF(container);
339 [ - + ]: 46 : ERROR_IF(err, error);
340 : : }
341 : :
342 : : inst(BINARY_SUBSCR_LIST_INT, (unused/4, list, sub -- res)) {
343 : : assert(cframe.use_tracing == 0);
344 [ - + ]: 538690 : DEOPT_IF(!PyLong_CheckExact(sub), BINARY_SUBSCR);
345 [ - + ]: 538690 : DEOPT_IF(!PyList_CheckExact(list), BINARY_SUBSCR);
346 : :
347 : : // Deopt unless 0 <= sub < PyList_Size(list)
348 [ - + ]: 538690 : DEOPT_IF(!_PyLong_IsPositiveSingleDigit(sub), BINARY_SUBSCR);
349 : : assert(((PyLongObject *)_PyLong_GetZero())->long_value.ob_digit[0] == 0);
350 : 538690 : Py_ssize_t index = ((PyLongObject*)sub)->long_value.ob_digit[0];
351 [ + + ]: 538690 : DEOPT_IF(index >= PyList_GET_SIZE(list), BINARY_SUBSCR);
352 : : STAT_INC(BINARY_SUBSCR, hit);
353 : 538155 : res = PyList_GET_ITEM(list, index);
354 : : assert(res != NULL);
355 : 538155 : Py_INCREF(res);
356 [ + + ]: 538155 : _Py_DECREF_SPECIALIZED(sub, (destructor)PyObject_Free);
357 [ + + ]: 538155 : Py_DECREF(list);
358 : : }
359 : :
360 : : inst(BINARY_SUBSCR_TUPLE_INT, (unused/4, tuple, sub -- res)) {
361 : : assert(cframe.use_tracing == 0);
362 [ - + ]: 12648 : DEOPT_IF(!PyLong_CheckExact(sub), BINARY_SUBSCR);
363 [ - + ]: 12648 : DEOPT_IF(!PyTuple_CheckExact(tuple), BINARY_SUBSCR);
364 : :
365 : : // Deopt unless 0 <= sub < PyTuple_Size(list)
366 [ - + ]: 12648 : DEOPT_IF(!_PyLong_IsPositiveSingleDigit(sub), BINARY_SUBSCR);
367 : : assert(((PyLongObject *)_PyLong_GetZero())->long_value.ob_digit[0] == 0);
368 : 12648 : Py_ssize_t index = ((PyLongObject*)sub)->long_value.ob_digit[0];
369 [ - + ]: 12648 : DEOPT_IF(index >= PyTuple_GET_SIZE(tuple), BINARY_SUBSCR);
370 : : STAT_INC(BINARY_SUBSCR, hit);
371 : 12648 : res = PyTuple_GET_ITEM(tuple, index);
372 : : assert(res != NULL);
373 : 12648 : Py_INCREF(res);
374 [ - + ]: 12648 : _Py_DECREF_SPECIALIZED(sub, (destructor)PyObject_Free);
375 [ + + ]: 12648 : Py_DECREF(tuple);
376 : : }
377 : :
378 : : inst(BINARY_SUBSCR_DICT, (unused/4, dict, sub -- res)) {
379 : : assert(cframe.use_tracing == 0);
380 [ - + ]: 24503 : DEOPT_IF(!PyDict_CheckExact(dict), BINARY_SUBSCR);
381 : : STAT_INC(BINARY_SUBSCR, hit);
382 : 24503 : res = PyDict_GetItemWithError(dict, sub);
383 [ + + ]: 24503 : if (res == NULL) {
384 [ + - ]: 1336 : if (!_PyErr_Occurred(tstate)) {
385 : 1336 : _PyErr_SetKeyError(sub);
386 : : }
387 : : DECREF_INPUTS();
388 : 1336 : ERROR_IF(true, error);
389 : : }
390 : 23167 : Py_INCREF(res); // Do this before DECREF'ing dict, sub
391 : : DECREF_INPUTS();
392 : : }
393 : :
394 : : inst(BINARY_SUBSCR_GETITEM, (unused/1, type_version/2, func_version/1, container, sub -- unused)) {
395 : 2025 : PyTypeObject *tp = Py_TYPE(container);
396 [ - + ]: 2025 : DEOPT_IF(tp->tp_version_tag != type_version, BINARY_SUBSCR);
397 : : assert(tp->tp_flags & Py_TPFLAGS_HEAPTYPE);
398 : 2025 : PyObject *cached = ((PyHeapTypeObject *)tp)->_spec_cache.getitem;
399 : : assert(PyFunction_Check(cached));
400 : 2025 : PyFunctionObject *getitem = (PyFunctionObject *)cached;
401 [ - + ]: 2025 : DEOPT_IF(getitem->func_version != func_version, BINARY_SUBSCR);
402 : 2025 : PyCodeObject *code = (PyCodeObject *)getitem->func_code;
403 : : assert(code->co_argcount == 2);
404 [ - + ]: 2025 : DEOPT_IF(!_PyThreadState_HasStackSpace(tstate, code->co_framesize), BINARY_SUBSCR);
405 : : STAT_INC(BINARY_SUBSCR, hit);
406 : 2025 : Py_INCREF(getitem);
407 : 2025 : _PyInterpreterFrame *new_frame = _PyFrame_PushUnchecked(tstate, getitem, 2);
408 : 2025 : STACK_SHRINK(2);
409 : 2025 : new_frame->localsplus[0] = container;
410 : 2025 : new_frame->localsplus[1] = sub;
411 : 2025 : JUMPBY(INLINE_CACHE_ENTRIES_BINARY_SUBSCR);
412 : 2025 : DISPATCH_INLINED(new_frame);
413 : : }
414 : :
415 : : inst(LIST_APPEND, (list, unused[oparg-1], v -- list, unused[oparg-1])) {
416 [ - + ]: 411909 : ERROR_IF(_PyList_AppendTakeRef((PyListObject *)list, v) < 0, error);
417 : : PREDICT(JUMP_BACKWARD);
418 : : }
419 : :
420 : : inst(SET_ADD, (set, unused[oparg-1], v -- set, unused[oparg-1])) {
421 : 51 : int err = PySet_Add(set, v);
422 : : DECREF_INPUTS();
423 [ - + ]: 51 : ERROR_IF(err, error);
424 : : PREDICT(JUMP_BACKWARD);
425 : : }
426 : :
427 : : family(store_subscr, INLINE_CACHE_ENTRIES_STORE_SUBSCR) = {
428 : : STORE_SUBSCR,
429 : : STORE_SUBSCR_DICT,
430 : : STORE_SUBSCR_LIST_INT,
431 : : };
432 : :
433 : : inst(STORE_SUBSCR, (counter/1, v, container, sub -- )) {
434 : : #if ENABLE_SPECIALIZATION
435 [ + + ]: 6909 : if (ADAPTIVE_COUNTER_IS_ZERO(counter)) {
436 : : assert(cframe.use_tracing == 0);
437 : 565 : next_instr--;
438 : 565 : _Py_Specialize_StoreSubscr(container, sub, next_instr);
439 : 565 : DISPATCH_SAME_OPARG();
440 : : }
441 : : STAT_INC(STORE_SUBSCR, deferred);
442 : 6344 : _PyStoreSubscrCache *cache = (_PyStoreSubscrCache *)next_instr;
443 : 6344 : DECREMENT_ADAPTIVE_COUNTER(cache->counter);
444 : : #else
445 : : (void)counter; // Unused.
446 : : #endif /* ENABLE_SPECIALIZATION */
447 : : /* container[sub] = v */
448 : 6344 : int err = PyObject_SetItem(container, sub, v);
449 : : DECREF_INPUTS();
450 [ + + ]: 6344 : ERROR_IF(err, error);
451 : : }
452 : :
453 : : inst(STORE_SUBSCR_LIST_INT, (unused/1, value, list, sub -- )) {
454 : : assert(cframe.use_tracing == 0);
455 [ - + ]: 519769 : DEOPT_IF(!PyLong_CheckExact(sub), STORE_SUBSCR);
456 [ - + ]: 519769 : DEOPT_IF(!PyList_CheckExact(list), STORE_SUBSCR);
457 : :
458 : : // Ensure nonnegative, zero-or-one-digit ints.
459 [ - + ]: 519769 : DEOPT_IF(!_PyLong_IsPositiveSingleDigit(sub), STORE_SUBSCR);
460 : 519769 : Py_ssize_t index = ((PyLongObject*)sub)->long_value.ob_digit[0];
461 : : // Ensure index < len(list)
462 [ - + ]: 519769 : DEOPT_IF(index >= PyList_GET_SIZE(list), STORE_SUBSCR);
463 : : STAT_INC(STORE_SUBSCR, hit);
464 : :
465 : 519769 : PyObject *old_value = PyList_GET_ITEM(list, index);
466 : 519769 : PyList_SET_ITEM(list, index, value);
467 : : assert(old_value != NULL);
468 [ + + ]: 519769 : Py_DECREF(old_value);
469 [ - + ]: 519769 : _Py_DECREF_SPECIALIZED(sub, (destructor)PyObject_Free);
470 [ - + ]: 519769 : Py_DECREF(list);
471 : : }
472 : :
473 : : inst(STORE_SUBSCR_DICT, (unused/1, value, dict, sub -- )) {
474 : : assert(cframe.use_tracing == 0);
475 [ - + ]: 101571 : DEOPT_IF(!PyDict_CheckExact(dict), STORE_SUBSCR);
476 : : STAT_INC(STORE_SUBSCR, hit);
477 : 101571 : int err = _PyDict_SetItem_Take2((PyDictObject *)dict, sub, value);
478 [ - + ]: 101571 : Py_DECREF(dict);
479 [ - + ]: 101571 : ERROR_IF(err, error);
480 : : }
481 : :
482 : : inst(DELETE_SUBSCR, (container, sub --)) {
483 : : /* del container[sub] */
484 : 1235 : int err = PyObject_DelItem(container, sub);
485 : : DECREF_INPUTS();
486 [ + + ]: 1235 : ERROR_IF(err, error);
487 : : }
488 : :
489 : : inst(CALL_INTRINSIC_1, (value -- res)) {
490 : : assert(oparg <= MAX_INTRINSIC_1);
491 : 3351 : res = _PyIntrinsics_UnaryFunctions[oparg](tstate, value);
492 : : DECREF_INPUTS();
493 [ - + ]: 3351 : ERROR_IF(res == NULL, error);
494 : : }
495 : :
496 : : inst(CALL_INTRINSIC_2, (value2, value1 -- res)) {
497 : : assert(oparg <= MAX_INTRINSIC_2);
498 : 0 : res = _PyIntrinsics_BinaryFunctions[oparg](tstate, value2, value1);
499 : : DECREF_INPUTS();
500 [ # # ]: 0 : ERROR_IF(res == NULL, error);
501 : : }
502 : :
503 : : inst(RAISE_VARARGS, (args[oparg] -- )) {
504 : 413 : PyObject *cause = NULL, *exc = NULL;
505 [ + + + - ]: 413 : switch (oparg) {
506 : 93 : case 2:
507 : 93 : cause = args[1];
508 : : /* fall through */
509 : 411 : case 1:
510 : 411 : exc = args[0];
511 : : /* fall through */
512 : 413 : case 0:
513 [ + + ]: 413 : ERROR_IF(do_raise(tstate, exc, cause), exception_unwind);
514 : 411 : break;
515 : 0 : default:
516 : 0 : _PyErr_SetString(tstate, PyExc_SystemError,
517 : : "bad RAISE_VARARGS oparg");
518 : 0 : break;
519 : : }
520 : 411 : ERROR_IF(true, error);
521 : : }
522 : :
523 : : inst(INTERPRETER_EXIT, (retval --)) {
524 : : assert(frame == &entry_frame);
525 : : assert(_PyFrame_IsIncomplete(frame));
526 : 1673510 : STACK_SHRINK(1); // Since we're not going to DISPATCH()
527 : : assert(EMPTY());
528 : : /* Restore previous cframe and return. */
529 : 1673510 : tstate->cframe = cframe.previous;
530 : 1673510 : tstate->cframe->use_tracing = cframe.use_tracing;
531 : : assert(tstate->cframe->current_frame == frame->previous);
532 : : assert(!_PyErr_Occurred(tstate));
533 : 1673510 : _Py_LeaveRecursiveCallTstate(tstate);
534 : 1673510 : return retval;
535 : : }
536 : :
537 : : inst(RETURN_VALUE, (retval --)) {
538 : 2531207 : STACK_SHRINK(1);
539 : : assert(EMPTY());
540 : 2531207 : _PyFrame_SetStackPointer(frame, stack_pointer);
541 [ - + - - : 2531207 : TRACE_FUNCTION_EXIT();
- - ]
542 [ - + ]: 2531207 : DTRACE_FUNCTION_EXIT();
543 : 2531207 : _Py_LeaveRecursiveCallPy(tstate);
544 : : assert(frame != &entry_frame);
545 : : // GH-99729: We need to unlink the frame *before* clearing it:
546 : 2531207 : _PyInterpreterFrame *dying = frame;
547 : 2531207 : frame = cframe.current_frame = dying->previous;
548 : 2531207 : _PyEvalFrameClearAndPop(tstate, dying);
549 : 2531207 : _PyFrame_StackPush(frame, retval);
550 : 2531207 : goto resume_frame;
551 : : }
552 : :
553 : : inst(RETURN_CONST, (--)) {
554 : 1073392 : PyObject *retval = GETITEM(frame->f_code->co_consts, oparg);
555 : 1073392 : Py_INCREF(retval);
556 : : assert(EMPTY());
557 : 1073392 : _PyFrame_SetStackPointer(frame, stack_pointer);
558 [ - + - - : 1073392 : TRACE_FUNCTION_EXIT();
- - ]
559 [ - + ]: 1073392 : DTRACE_FUNCTION_EXIT();
560 : 1073392 : _Py_LeaveRecursiveCallPy(tstate);
561 : : assert(frame != &entry_frame);
562 : : // GH-99729: We need to unlink the frame *before* clearing it:
563 : 1073392 : _PyInterpreterFrame *dying = frame;
564 : 1073392 : frame = cframe.current_frame = dying->previous;
565 : 1073392 : _PyEvalFrameClearAndPop(tstate, dying);
566 : 1073392 : _PyFrame_StackPush(frame, retval);
567 : 1073392 : goto resume_frame;
568 : : }
569 : :
570 : : inst(GET_AITER, (obj -- iter)) {
571 : 0 : unaryfunc getter = NULL;
572 : 0 : PyTypeObject *type = Py_TYPE(obj);
573 : :
574 [ # # ]: 0 : if (type->tp_as_async != NULL) {
575 : 0 : getter = type->tp_as_async->am_aiter;
576 : : }
577 : :
578 [ # # ]: 0 : if (getter == NULL) {
579 : 0 : _PyErr_Format(tstate, PyExc_TypeError,
580 : : "'async for' requires an object with "
581 : : "__aiter__ method, got %.100s",
582 : : type->tp_name);
583 : : DECREF_INPUTS();
584 : 0 : ERROR_IF(true, error);
585 : : }
586 : :
587 : 0 : iter = (*getter)(obj);
588 : : DECREF_INPUTS();
589 [ # # ]: 0 : ERROR_IF(iter == NULL, error);
590 : :
591 [ # # ]: 0 : if (Py_TYPE(iter)->tp_as_async == NULL ||
592 [ # # ]: 0 : Py_TYPE(iter)->tp_as_async->am_anext == NULL) {
593 : :
594 : 0 : _PyErr_Format(tstate, PyExc_TypeError,
595 : : "'async for' received an object from __aiter__ "
596 : : "that does not implement __anext__: %.100s",
597 : 0 : Py_TYPE(iter)->tp_name);
598 [ # # ]: 0 : Py_DECREF(iter);
599 : 0 : ERROR_IF(true, error);
600 : : }
601 : : }
602 : :
603 : : inst(GET_ANEXT, (aiter -- aiter, awaitable)) {
604 : 0 : unaryfunc getter = NULL;
605 : 0 : PyObject *next_iter = NULL;
606 : 0 : PyTypeObject *type = Py_TYPE(aiter);
607 : :
608 [ # # ]: 0 : if (PyAsyncGen_CheckExact(aiter)) {
609 : 0 : awaitable = type->tp_as_async->am_anext(aiter);
610 [ # # ]: 0 : if (awaitable == NULL) {
611 : 0 : goto error;
612 : : }
613 : : } else {
614 [ # # ]: 0 : if (type->tp_as_async != NULL){
615 : 0 : getter = type->tp_as_async->am_anext;
616 : : }
617 : :
618 [ # # ]: 0 : if (getter != NULL) {
619 : 0 : next_iter = (*getter)(aiter);
620 [ # # ]: 0 : if (next_iter == NULL) {
621 : 0 : goto error;
622 : : }
623 : : }
624 : : else {
625 : 0 : _PyErr_Format(tstate, PyExc_TypeError,
626 : : "'async for' requires an iterator with "
627 : : "__anext__ method, got %.100s",
628 : : type->tp_name);
629 : 0 : goto error;
630 : : }
631 : :
632 : 0 : awaitable = _PyCoro_GetAwaitableIter(next_iter);
633 [ # # ]: 0 : if (awaitable == NULL) {
634 : 0 : _PyErr_FormatFromCause(
635 : : PyExc_TypeError,
636 : : "'async for' received an invalid object "
637 : : "from __anext__: %.100s",
638 : 0 : Py_TYPE(next_iter)->tp_name);
639 : :
640 [ # # ]: 0 : Py_DECREF(next_iter);
641 : 0 : goto error;
642 : : } else {
643 [ # # ]: 0 : Py_DECREF(next_iter);
644 : : }
645 : : }
646 : :
647 : : PREDICT(LOAD_CONST);
648 : : }
649 : :
650 : : inst(GET_AWAITABLE, (iterable -- iter)) {
651 : 0 : iter = _PyCoro_GetAwaitableIter(iterable);
652 : :
653 [ # # ]: 0 : if (iter == NULL) {
654 : 0 : format_awaitable_error(tstate, Py_TYPE(iterable), oparg);
655 : : }
656 : :
657 : : DECREF_INPUTS();
658 : :
659 [ # # # # ]: 0 : if (iter != NULL && PyCoro_CheckExact(iter)) {
660 : 0 : PyObject *yf = _PyGen_yf((PyGenObject*)iter);
661 [ # # ]: 0 : if (yf != NULL) {
662 : : /* `iter` is a coroutine object that is being
663 : : awaited, `yf` is a pointer to the current awaitable
664 : : being awaited on. */
665 [ # # ]: 0 : Py_DECREF(yf);
666 [ # # # # ]: 0 : Py_CLEAR(iter);
667 : 0 : _PyErr_SetString(tstate, PyExc_RuntimeError,
668 : : "coroutine is being awaited already");
669 : : /* The code below jumps to `error` if `iter` is NULL. */
670 : : }
671 : : }
672 : :
673 [ # # ]: 0 : ERROR_IF(iter == NULL, error);
674 : :
675 : : PREDICT(LOAD_CONST);
676 : : }
677 : :
678 : : family(for_iter, INLINE_CACHE_ENTRIES_FOR_ITER) = {
679 : : SEND,
680 : : SEND_GEN,
681 : : };
682 : :
683 : : inst(SEND, (unused/1, receiver, v -- receiver, retval)) {
684 : : #if ENABLE_SPECIALIZATION
685 : 36 : _PySendCache *cache = (_PySendCache *)next_instr;
686 [ + + ]: 36 : if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
687 : : assert(cframe.use_tracing == 0);
688 : 10 : next_instr--;
689 : 10 : _Py_Specialize_Send(receiver, next_instr);
690 : 10 : DISPATCH_SAME_OPARG();
691 : : }
692 : : STAT_INC(SEND, deferred);
693 : 26 : DECREMENT_ADAPTIVE_COUNTER(cache->counter);
694 : : #endif /* ENABLE_SPECIALIZATION */
695 : : assert(frame != &entry_frame);
696 [ + - + - ]: 26 : if (Py_IsNone(v) && PyIter_Check(receiver)) {
697 : 26 : retval = Py_TYPE(receiver)->tp_iternext(receiver);
698 : : }
699 : : else {
700 : 0 : retval = PyObject_CallMethodOneArg(receiver, &_Py_ID(send), v);
701 : : }
702 [ + + ]: 26 : if (retval == NULL) {
703 [ - + ]: 7 : if (tstate->c_tracefunc != NULL
704 [ # # ]: 0 : && _PyErr_ExceptionMatches(tstate, PyExc_StopIteration))
705 : 0 : call_exc_trace(tstate->c_tracefunc, tstate->c_traceobj, tstate, frame);
706 [ + - ]: 7 : if (_PyGen_FetchStopIterationValue(&retval) == 0) {
707 : : assert(retval != NULL);
708 : 7 : JUMPBY(oparg);
709 : : }
710 : : else {
711 : : assert(retval == NULL);
712 : 0 : goto error;
713 : : }
714 : : }
715 : : else {
716 : : assert(retval != NULL);
717 : : }
718 [ - + ]: 26 : Py_DECREF(v);
719 : : }
720 : :
721 : : inst(SEND_GEN, (unused/1, receiver, v -- receiver)) {
722 : : assert(cframe.use_tracing == 0);
723 : 351 : PyGenObject *gen = (PyGenObject *)receiver;
724 [ - + - - ]: 351 : DEOPT_IF(Py_TYPE(gen) != &PyGen_Type &&
725 : : Py_TYPE(gen) != &PyCoro_Type, SEND);
726 [ - + ]: 351 : DEOPT_IF(gen->gi_frame_state >= FRAME_EXECUTING, SEND);
727 : : STAT_INC(SEND, hit);
728 : 351 : _PyInterpreterFrame *gen_frame = (_PyInterpreterFrame *)gen->gi_iframe;
729 : 351 : frame->yield_offset = oparg;
730 : 351 : STACK_SHRINK(1);
731 : 351 : _PyFrame_StackPush(gen_frame, v);
732 : 351 : gen->gi_frame_state = FRAME_EXECUTING;
733 : 351 : gen->gi_exc_state.previous_item = tstate->exc_info;
734 : 351 : tstate->exc_info = &gen->gi_exc_state;
735 : 351 : JUMPBY(INLINE_CACHE_ENTRIES_SEND + oparg);
736 : 351 : DISPATCH_INLINED(gen_frame);
737 : : }
738 : :
739 : : inst(YIELD_VALUE, (retval -- unused)) {
740 : : // NOTE: It's important that YIELD_VALUE never raises an exception!
741 : : // The compiler treats any exception raised here as a failed close()
742 : : // or throw() call.
743 : : assert(frame != &entry_frame);
744 : 429374 : PyGenObject *gen = _PyFrame_GetGenerator(frame);
745 : 429374 : gen->gi_frame_state = FRAME_SUSPENDED;
746 : 429374 : _PyFrame_SetStackPointer(frame, stack_pointer - 1);
747 [ - + - - : 429374 : TRACE_FUNCTION_EXIT();
- - ]
748 [ - + ]: 429374 : DTRACE_FUNCTION_EXIT();
749 : 429374 : tstate->exc_info = gen->gi_exc_state.previous_item;
750 : 429374 : gen->gi_exc_state.previous_item = NULL;
751 : 429374 : _Py_LeaveRecursiveCallPy(tstate);
752 : 429374 : _PyInterpreterFrame *gen_frame = frame;
753 : 429374 : frame = cframe.current_frame = frame->previous;
754 : 429374 : gen_frame->previous = NULL;
755 : 429374 : frame->prev_instr -= frame->yield_offset;
756 : 429374 : _PyFrame_StackPush(frame, retval);
757 : 429374 : goto resume_frame;
758 : : }
759 : :
760 : : inst(POP_EXCEPT, (exc_value -- )) {
761 : 101972 : _PyErr_StackItem *exc_info = tstate->exc_info;
762 [ + - + + ]: 101972 : Py_XSETREF(exc_info->exc_value, exc_value);
763 : : }
764 : :
765 : : inst(RERAISE, (values[oparg], exc -- values[oparg])) {
766 : : assert(oparg >= 0 && oparg <= 2);
767 [ + + ]: 2415 : if (oparg) {
768 : 2324 : PyObject *lasti = values[0];
769 [ + - ]: 2324 : if (PyLong_Check(lasti)) {
770 : 2324 : frame->prev_instr = _PyCode_CODE(frame->f_code) + PyLong_AsLong(lasti);
771 : : assert(!_PyErr_Occurred(tstate));
772 : : }
773 : : else {
774 : : assert(PyLong_Check(lasti));
775 : 0 : _PyErr_SetString(tstate, PyExc_SystemError, "lasti is not an int");
776 : 0 : goto error;
777 : : }
778 : : }
779 : : assert(exc && PyExceptionInstance_Check(exc));
780 : 2415 : Py_INCREF(exc);
781 : 2415 : _PyErr_SetRaisedException(tstate, exc);
782 : 2415 : goto exception_unwind;
783 : : }
784 : :
785 : : inst(END_ASYNC_FOR, (awaitable, exc -- )) {
786 : : assert(exc && PyExceptionInstance_Check(exc));
787 [ # # ]: 0 : if (PyErr_GivenExceptionMatches(exc, PyExc_StopAsyncIteration)) {
788 : : DECREF_INPUTS();
789 : : }
790 : : else {
791 : 0 : Py_INCREF(exc);
792 : 0 : _PyErr_SetRaisedException(tstate, exc);
793 : 0 : goto exception_unwind;
794 : : }
795 : : }
796 : :
797 : : inst(CLEANUP_THROW, (sub_iter, last_sent_val, exc_value -- none, value)) {
798 : : assert(throwflag);
799 : : assert(exc_value && PyExceptionInstance_Check(exc_value));
800 [ # # ]: 0 : if (PyErr_GivenExceptionMatches(exc_value, PyExc_StopIteration)) {
801 : 0 : value = Py_NewRef(((PyStopIterationObject *)exc_value)->value);
802 : : DECREF_INPUTS();
803 : 0 : none = Py_NewRef(Py_None);
804 : : }
805 : : else {
806 : 0 : _PyErr_SetRaisedException(tstate, Py_NewRef(exc_value));
807 : 0 : goto exception_unwind;
808 : : }
809 : : }
810 : :
811 : : inst(LOAD_ASSERTION_ERROR, ( -- value)) {
812 : 0 : value = Py_NewRef(PyExc_AssertionError);
813 : : }
814 : :
815 : : inst(LOAD_BUILD_CLASS, ( -- bc)) {
816 [ + - ]: 3141 : if (PyDict_CheckExact(BUILTINS())) {
817 : 3141 : bc = _PyDict_GetItemWithError(BUILTINS(),
818 : : &_Py_ID(__build_class__));
819 [ - + ]: 3141 : if (bc == NULL) {
820 [ # # ]: 0 : if (!_PyErr_Occurred(tstate)) {
821 : 0 : _PyErr_SetString(tstate, PyExc_NameError,
822 : : "__build_class__ not found");
823 : : }
824 : 0 : ERROR_IF(true, error);
825 : : }
826 : 3141 : Py_INCREF(bc);
827 : : }
828 : : else {
829 : 0 : bc = PyObject_GetItem(BUILTINS(), &_Py_ID(__build_class__));
830 [ # # ]: 0 : if (bc == NULL) {
831 [ # # ]: 0 : if (_PyErr_ExceptionMatches(tstate, PyExc_KeyError))
832 : 0 : _PyErr_SetString(tstate, PyExc_NameError,
833 : : "__build_class__ not found");
834 : 0 : ERROR_IF(true, error);
835 : : }
836 : : }
837 : : }
838 : :
839 : : inst(STORE_NAME, (v -- )) {
840 : 54214 : PyObject *name = GETITEM(frame->f_code->co_names, oparg);
841 : 54214 : PyObject *ns = LOCALS();
842 : : int err;
843 [ - + ]: 54214 : if (ns == NULL) {
844 : 0 : _PyErr_Format(tstate, PyExc_SystemError,
845 : : "no locals found when storing %R", name);
846 : : DECREF_INPUTS();
847 : 0 : ERROR_IF(true, error);
848 : : }
849 [ + + ]: 54214 : if (PyDict_CheckExact(ns))
850 : 53897 : err = PyDict_SetItem(ns, name, v);
851 : : else
852 : 317 : err = PyObject_SetItem(ns, name, v);
853 : : DECREF_INPUTS();
854 [ - + ]: 54214 : ERROR_IF(err, error);
855 : : }
856 : :
857 : : inst(DELETE_NAME, (--)) {
858 : 514 : PyObject *name = GETITEM(frame->f_code->co_names, oparg);
859 : 514 : PyObject *ns = LOCALS();
860 : : int err;
861 [ - + ]: 514 : if (ns == NULL) {
862 : 0 : _PyErr_Format(tstate, PyExc_SystemError,
863 : : "no locals when deleting %R", name);
864 : 0 : goto error;
865 : : }
866 : 514 : err = PyObject_DelItem(ns, name);
867 : : // Can't use ERROR_IF here.
868 [ - + ]: 514 : if (err != 0) {
869 : 0 : format_exc_check_arg(tstate, PyExc_NameError,
870 : : NAME_ERROR_MSG,
871 : : name);
872 : 0 : goto error;
873 : : }
874 : : }
875 : :
876 : : family(unpack_sequence, INLINE_CACHE_ENTRIES_UNPACK_SEQUENCE) = {
877 : : UNPACK_SEQUENCE,
878 : : UNPACK_SEQUENCE_TWO_TUPLE,
879 : : UNPACK_SEQUENCE_TUPLE,
880 : : UNPACK_SEQUENCE_LIST,
881 : : };
882 : :
883 : : inst(UNPACK_SEQUENCE, (unused/1, seq -- unused[oparg])) {
884 : : #if ENABLE_SPECIALIZATION
885 : 1203 : _PyUnpackSequenceCache *cache = (_PyUnpackSequenceCache *)next_instr;
886 [ + + ]: 1203 : if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
887 : : assert(cframe.use_tracing == 0);
888 : 532 : next_instr--;
889 : 532 : _Py_Specialize_UnpackSequence(seq, next_instr, oparg);
890 : 532 : DISPATCH_SAME_OPARG();
891 : : }
892 : : STAT_INC(UNPACK_SEQUENCE, deferred);
893 : 671 : DECREMENT_ADAPTIVE_COUNTER(cache->counter);
894 : : #endif /* ENABLE_SPECIALIZATION */
895 : 671 : PyObject **top = stack_pointer + oparg - 1;
896 : 671 : int res = unpack_iterable(tstate, seq, oparg, -1, top);
897 : : DECREF_INPUTS();
898 [ - + ]: 671 : ERROR_IF(res == 0, error);
899 : : }
900 : :
901 : : inst(UNPACK_SEQUENCE_TWO_TUPLE, (unused/1, seq -- values[oparg])) {
902 [ - + ]: 1690349 : DEOPT_IF(!PyTuple_CheckExact(seq), UNPACK_SEQUENCE);
903 [ - + ]: 1690349 : DEOPT_IF(PyTuple_GET_SIZE(seq) != 2, UNPACK_SEQUENCE);
904 : : assert(oparg == 2);
905 : : STAT_INC(UNPACK_SEQUENCE, hit);
906 : 1690349 : values[0] = Py_NewRef(PyTuple_GET_ITEM(seq, 1));
907 [ + + ]: 1690349 : values[1] = Py_NewRef(PyTuple_GET_ITEM(seq, 0));
908 : : DECREF_INPUTS();
909 : : }
910 : :
911 : : inst(UNPACK_SEQUENCE_TUPLE, (unused/1, seq -- values[oparg])) {
912 [ - + ]: 11126 : DEOPT_IF(!PyTuple_CheckExact(seq), UNPACK_SEQUENCE);
913 [ - + ]: 11126 : DEOPT_IF(PyTuple_GET_SIZE(seq) != oparg, UNPACK_SEQUENCE);
914 : : STAT_INC(UNPACK_SEQUENCE, hit);
915 : 11126 : PyObject **items = _PyTuple_ITEMS(seq);
916 [ + + ]: 50885 : for (int i = oparg; --i >= 0; ) {
917 : 39759 : *values++ = Py_NewRef(items[i]);
918 : : }
919 : : DECREF_INPUTS();
920 : : }
921 : :
922 : : inst(UNPACK_SEQUENCE_LIST, (unused/1, seq -- values[oparg])) {
923 [ - + ]: 5127 : DEOPT_IF(!PyList_CheckExact(seq), UNPACK_SEQUENCE);
924 [ - + ]: 5127 : DEOPT_IF(PyList_GET_SIZE(seq) != oparg, UNPACK_SEQUENCE);
925 : : STAT_INC(UNPACK_SEQUENCE, hit);
926 : 5127 : PyObject **items = _PyList_ITEMS(seq);
927 [ + + ]: 20050 : for (int i = oparg; --i >= 0; ) {
928 : 14923 : *values++ = Py_NewRef(items[i]);
929 : : }
930 : : DECREF_INPUTS();
931 : : }
932 : :
933 : : inst(UNPACK_EX, (seq -- unused[oparg & 0xFF], unused, unused[oparg >> 8])) {
934 : 1994 : int totalargs = 1 + (oparg & 0xFF) + (oparg >> 8);
935 : 1994 : PyObject **top = stack_pointer + totalargs - 1;
936 : 1994 : int res = unpack_iterable(tstate, seq, oparg & 0xFF, oparg >> 8, top);
937 : : DECREF_INPUTS();
938 [ - + ]: 1994 : ERROR_IF(res == 0, error);
939 : : }
940 : :
941 : : family(store_attr, INLINE_CACHE_ENTRIES_STORE_ATTR) = {
942 : : STORE_ATTR,
943 : : STORE_ATTR_INSTANCE_VALUE,
944 : : STORE_ATTR_SLOT,
945 : : STORE_ATTR_WITH_HINT,
946 : : };
947 : :
948 : : inst(STORE_ATTR, (counter/1, unused/3, v, owner --)) {
949 : : #if ENABLE_SPECIALIZATION
950 [ + + ]: 450233 : if (ADAPTIVE_COUNTER_IS_ZERO(counter)) {
951 : : assert(cframe.use_tracing == 0);
952 : 9307 : PyObject *name = GETITEM(frame->f_code->co_names, oparg);
953 : 9307 : next_instr--;
954 : 9307 : _Py_Specialize_StoreAttr(owner, next_instr, name);
955 : 9307 : DISPATCH_SAME_OPARG();
956 : : }
957 : : STAT_INC(STORE_ATTR, deferred);
958 : 440926 : _PyAttrCache *cache = (_PyAttrCache *)next_instr;
959 : 440926 : DECREMENT_ADAPTIVE_COUNTER(cache->counter);
960 : : #else
961 : : (void)counter; // Unused.
962 : : #endif /* ENABLE_SPECIALIZATION */
963 : 440926 : PyObject *name = GETITEM(frame->f_code->co_names, oparg);
964 : 440926 : int err = PyObject_SetAttr(owner, name, v);
965 : : DECREF_INPUTS();
966 [ - + ]: 440926 : ERROR_IF(err, error);
967 : : }
968 : :
969 : : inst(DELETE_ATTR, (owner --)) {
970 : 292839 : PyObject *name = GETITEM(frame->f_code->co_names, oparg);
971 : 292839 : int err = PyObject_SetAttr(owner, name, (PyObject *)NULL);
972 : : DECREF_INPUTS();
973 [ - + ]: 292839 : ERROR_IF(err, error);
974 : : }
975 : :
976 : : inst(STORE_GLOBAL, (v --)) {
977 : 1270 : PyObject *name = GETITEM(frame->f_code->co_names, oparg);
978 : 1270 : int err = PyDict_SetItem(GLOBALS(), name, v);
979 : : DECREF_INPUTS();
980 [ - + ]: 1270 : ERROR_IF(err, error);
981 : : }
982 : :
983 : : inst(DELETE_GLOBAL, (--)) {
984 : 0 : PyObject *name = GETITEM(frame->f_code->co_names, oparg);
985 : : int err;
986 : 0 : err = PyDict_DelItem(GLOBALS(), name);
987 : : // Can't use ERROR_IF here.
988 [ # # ]: 0 : if (err != 0) {
989 [ # # ]: 0 : if (_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) {
990 : 0 : format_exc_check_arg(tstate, PyExc_NameError,
991 : : NAME_ERROR_MSG, name);
992 : : }
993 : 0 : goto error;
994 : : }
995 : : }
996 : :
997 : : inst(LOAD_NAME, ( -- v)) {
998 : 35562 : PyObject *name = GETITEM(frame->f_code->co_names, oparg);
999 : 35562 : PyObject *locals = LOCALS();
1000 [ - + ]: 35562 : if (locals == NULL) {
1001 : 0 : _PyErr_Format(tstate, PyExc_SystemError,
1002 : : "no locals when loading %R", name);
1003 : 0 : goto error;
1004 : : }
1005 [ + + ]: 35562 : if (PyDict_CheckExact(locals)) {
1006 : 35456 : v = PyDict_GetItemWithError(locals, name);
1007 [ + + ]: 35456 : if (v != NULL) {
1008 : 23685 : Py_INCREF(v);
1009 : : }
1010 [ - + ]: 11771 : else if (_PyErr_Occurred(tstate)) {
1011 : 0 : goto error;
1012 : : }
1013 : : }
1014 : : else {
1015 : 106 : v = PyObject_GetItem(locals, name);
1016 [ + + ]: 106 : if (v == NULL) {
1017 [ - + ]: 90 : if (!_PyErr_ExceptionMatches(tstate, PyExc_KeyError))
1018 : 0 : goto error;
1019 : 90 : _PyErr_Clear(tstate);
1020 : : }
1021 : : }
1022 [ + + ]: 35562 : if (v == NULL) {
1023 : 11861 : v = PyDict_GetItemWithError(GLOBALS(), name);
1024 [ + + ]: 11861 : if (v != NULL) {
1025 : 5523 : Py_INCREF(v);
1026 : : }
1027 [ - + ]: 6338 : else if (_PyErr_Occurred(tstate)) {
1028 : 0 : goto error;
1029 : : }
1030 : : else {
1031 [ + - ]: 6338 : if (PyDict_CheckExact(BUILTINS())) {
1032 : 6338 : v = PyDict_GetItemWithError(BUILTINS(), name);
1033 [ + + ]: 6338 : if (v == NULL) {
1034 [ + - ]: 1 : if (!_PyErr_Occurred(tstate)) {
1035 : 1 : format_exc_check_arg(
1036 : : tstate, PyExc_NameError,
1037 : : NAME_ERROR_MSG, name);
1038 : : }
1039 : 1 : goto error;
1040 : : }
1041 : 6337 : Py_INCREF(v);
1042 : : }
1043 : : else {
1044 : 0 : v = PyObject_GetItem(BUILTINS(), name);
1045 [ # # ]: 0 : if (v == NULL) {
1046 [ # # ]: 0 : if (_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) {
1047 : 0 : format_exc_check_arg(
1048 : : tstate, PyExc_NameError,
1049 : : NAME_ERROR_MSG, name);
1050 : : }
1051 : 0 : goto error;
1052 : : }
1053 : : }
1054 : : }
1055 : : }
1056 : : }
1057 : :
1058 : : family(load_global, INLINE_CACHE_ENTRIES_LOAD_GLOBAL) = {
1059 : : LOAD_GLOBAL,
1060 : : LOAD_GLOBAL_MODULE,
1061 : : LOAD_GLOBAL_BUILTIN,
1062 : : };
1063 : :
1064 : : inst(LOAD_GLOBAL, (unused/1, unused/1, unused/1, unused/1 -- null if (oparg & 1), v)) {
1065 : : #if ENABLE_SPECIALIZATION
1066 : 74883 : _PyLoadGlobalCache *cache = (_PyLoadGlobalCache *)next_instr;
1067 [ + + ]: 74883 : if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
1068 : : assert(cframe.use_tracing == 0);
1069 : 11080 : PyObject *name = GETITEM(frame->f_code->co_names, oparg>>1);
1070 : 11080 : next_instr--;
1071 : 11080 : _Py_Specialize_LoadGlobal(GLOBALS(), BUILTINS(), next_instr, name);
1072 : 11080 : DISPATCH_SAME_OPARG();
1073 : : }
1074 : : STAT_INC(LOAD_GLOBAL, deferred);
1075 : 63803 : DECREMENT_ADAPTIVE_COUNTER(cache->counter);
1076 : : #endif /* ENABLE_SPECIALIZATION */
1077 : 63803 : PyObject *name = GETITEM(frame->f_code->co_names, oparg>>1);
1078 [ + - ]: 63803 : if (PyDict_CheckExact(GLOBALS())
1079 [ + - ]: 63803 : && PyDict_CheckExact(BUILTINS()))
1080 : : {
1081 : 63803 : v = _PyDict_LoadGlobal((PyDictObject *)GLOBALS(),
1082 : 63803 : (PyDictObject *)BUILTINS(),
1083 : : name);
1084 [ - + ]: 63803 : if (v == NULL) {
1085 [ # # ]: 0 : if (!_PyErr_Occurred(tstate)) {
1086 : : /* _PyDict_LoadGlobal() returns NULL without raising
1087 : : * an exception if the key doesn't exist */
1088 : 0 : format_exc_check_arg(tstate, PyExc_NameError,
1089 : : NAME_ERROR_MSG, name);
1090 : : }
1091 : 0 : ERROR_IF(true, error);
1092 : : }
1093 : 63803 : Py_INCREF(v);
1094 : : }
1095 : : else {
1096 : : /* Slow-path if globals or builtins is not a dict */
1097 : :
1098 : : /* namespace 1: globals */
1099 : 0 : v = PyObject_GetItem(GLOBALS(), name);
1100 [ # # ]: 0 : if (v == NULL) {
1101 [ # # ]: 0 : ERROR_IF(!_PyErr_ExceptionMatches(tstate, PyExc_KeyError), error);
1102 : 0 : _PyErr_Clear(tstate);
1103 : :
1104 : : /* namespace 2: builtins */
1105 : 0 : v = PyObject_GetItem(BUILTINS(), name);
1106 [ # # ]: 0 : if (v == NULL) {
1107 [ # # ]: 0 : if (_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) {
1108 : 0 : format_exc_check_arg(
1109 : : tstate, PyExc_NameError,
1110 : : NAME_ERROR_MSG, name);
1111 : : }
1112 : 0 : ERROR_IF(true, error);
1113 : : }
1114 : : }
1115 : : }
1116 [ + + ]: 63803 : null = NULL;
1117 : : }
1118 : :
1119 : : inst(LOAD_GLOBAL_MODULE, (unused/1, index/1, version/1, unused/1 -- null if (oparg & 1), res)) {
1120 : : assert(cframe.use_tracing == 0);
1121 [ - + ]: 4127977 : DEOPT_IF(!PyDict_CheckExact(GLOBALS()), LOAD_GLOBAL);
1122 : 4127977 : PyDictObject *dict = (PyDictObject *)GLOBALS();
1123 [ + + ]: 4127977 : DEOPT_IF(dict->ma_keys->dk_version != version, LOAD_GLOBAL);
1124 : : assert(DK_IS_UNICODE(dict->ma_keys));
1125 : 4109990 : PyDictUnicodeEntry *entries = DK_UNICODE_ENTRIES(dict->ma_keys);
1126 : 4109990 : res = entries[index].me_value;
1127 [ - + ]: 4109990 : DEOPT_IF(res == NULL, LOAD_GLOBAL);
1128 : 4109990 : Py_INCREF(res);
1129 : : STAT_INC(LOAD_GLOBAL, hit);
1130 [ + + ]: 4109990 : null = NULL;
1131 : : }
1132 : :
1133 : : inst(LOAD_GLOBAL_BUILTIN, (unused/1, index/1, mod_version/1, bltn_version/1 -- null if (oparg & 1), res)) {
1134 : : assert(cframe.use_tracing == 0);
1135 [ - + ]: 3589529 : DEOPT_IF(!PyDict_CheckExact(GLOBALS()), LOAD_GLOBAL);
1136 [ - + ]: 3589529 : DEOPT_IF(!PyDict_CheckExact(BUILTINS()), LOAD_GLOBAL);
1137 : 3589529 : PyDictObject *mdict = (PyDictObject *)GLOBALS();
1138 : 3589529 : PyDictObject *bdict = (PyDictObject *)BUILTINS();
1139 [ + + ]: 3589529 : DEOPT_IF(mdict->ma_keys->dk_version != mod_version, LOAD_GLOBAL);
1140 [ + + ]: 3573477 : DEOPT_IF(bdict->ma_keys->dk_version != bltn_version, LOAD_GLOBAL);
1141 : : assert(DK_IS_UNICODE(bdict->ma_keys));
1142 : 3561513 : PyDictUnicodeEntry *entries = DK_UNICODE_ENTRIES(bdict->ma_keys);
1143 : 3561513 : res = entries[index].me_value;
1144 [ - + ]: 3561513 : DEOPT_IF(res == NULL, LOAD_GLOBAL);
1145 : 3561513 : Py_INCREF(res);
1146 : : STAT_INC(LOAD_GLOBAL, hit);
1147 [ + + ]: 3561513 : null = NULL;
1148 : : }
1149 : :
1150 : : inst(DELETE_FAST, (--)) {
1151 : 85 : PyObject *v = GETLOCAL(oparg);
1152 [ - + ]: 85 : ERROR_IF(v == NULL, unbound_local_error);
1153 [ + - - + ]: 85 : SETLOCAL(oparg, NULL);
1154 : : }
1155 : :
1156 : : inst(MAKE_CELL, (--)) {
1157 : : // "initial" is probably NULL but not if it's an arg (or set
1158 : : // via PyFrame_LocalsToFast() before MAKE_CELL has run).
1159 : 43879 : PyObject *initial = GETLOCAL(oparg);
1160 : 43879 : PyObject *cell = PyCell_New(initial);
1161 [ - + ]: 43879 : if (cell == NULL) {
1162 : 0 : goto resume_with_error;
1163 : : }
1164 [ + + - + ]: 43879 : SETLOCAL(oparg, cell);
1165 : : }
1166 : :
1167 : : inst(DELETE_DEREF, (--)) {
1168 : 0 : PyObject *cell = GETLOCAL(oparg);
1169 : 0 : PyObject *oldobj = PyCell_GET(cell);
1170 : : // Can't use ERROR_IF here.
1171 : : // Fortunately we don't need its superpower.
1172 [ # # ]: 0 : if (oldobj == NULL) {
1173 : 0 : format_exc_unbound(tstate, frame->f_code, oparg);
1174 : 0 : goto error;
1175 : : }
1176 : 0 : PyCell_SET(cell, NULL);
1177 [ # # ]: 0 : Py_DECREF(oldobj);
1178 : : }
1179 : :
1180 : : inst(LOAD_CLASSDEREF, ( -- value)) {
1181 : 14 : PyObject *name, *locals = LOCALS();
1182 : : assert(locals);
1183 : : assert(oparg >= 0 && oparg < frame->f_code->co_nlocalsplus);
1184 : 14 : name = PyTuple_GET_ITEM(frame->f_code->co_localsplusnames, oparg);
1185 [ + - ]: 14 : if (PyDict_CheckExact(locals)) {
1186 : 14 : value = PyDict_GetItemWithError(locals, name);
1187 [ - + ]: 14 : if (value != NULL) {
1188 : 0 : Py_INCREF(value);
1189 : : }
1190 [ - + ]: 14 : else if (_PyErr_Occurred(tstate)) {
1191 : 0 : goto error;
1192 : : }
1193 : : }
1194 : : else {
1195 : 0 : value = PyObject_GetItem(locals, name);
1196 [ # # ]: 0 : if (value == NULL) {
1197 [ # # ]: 0 : if (!_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) {
1198 : 0 : goto error;
1199 : : }
1200 : 0 : _PyErr_Clear(tstate);
1201 : : }
1202 : : }
1203 [ + - ]: 14 : if (!value) {
1204 : 14 : PyObject *cell = GETLOCAL(oparg);
1205 : 14 : value = PyCell_GET(cell);
1206 [ - + ]: 14 : if (value == NULL) {
1207 : 0 : format_exc_unbound(tstate, frame->f_code, oparg);
1208 : 0 : goto error;
1209 : : }
1210 : 14 : Py_INCREF(value);
1211 : : }
1212 : : }
1213 : :
1214 : : inst(LOAD_DEREF, ( -- value)) {
1215 : 1415494 : PyObject *cell = GETLOCAL(oparg);
1216 : 1415494 : value = PyCell_GET(cell);
1217 [ - + ]: 1415494 : if (value == NULL) {
1218 : 0 : format_exc_unbound(tstate, frame->f_code, oparg);
1219 : 0 : ERROR_IF(true, error);
1220 : : }
1221 : 1415494 : Py_INCREF(value);
1222 : : }
1223 : :
1224 : : inst(STORE_DEREF, (v --)) {
1225 : 19694 : PyObject *cell = GETLOCAL(oparg);
1226 : 19694 : PyObject *oldobj = PyCell_GET(cell);
1227 : 19694 : PyCell_SET(cell, v);
1228 [ + + + + ]: 19694 : Py_XDECREF(oldobj);
1229 : : }
1230 : :
1231 : : inst(COPY_FREE_VARS, (--)) {
1232 : : /* Copy closure variables to free variables */
1233 : 736039 : PyCodeObject *co = frame->f_code;
1234 : : assert(PyFunction_Check(frame->f_funcobj));
1235 : 736039 : PyObject *closure = ((PyFunctionObject *)frame->f_funcobj)->func_closure;
1236 : : assert(oparg == co->co_nfreevars);
1237 : 736039 : int offset = co->co_nlocalsplus - oparg;
1238 [ + + ]: 2753237 : for (int i = 0; i < oparg; ++i) {
1239 : 2017198 : PyObject *o = PyTuple_GET_ITEM(closure, i);
1240 : 2017198 : frame->localsplus[offset + i] = Py_NewRef(o);
1241 : : }
1242 : : }
1243 : :
1244 : : inst(BUILD_STRING, (pieces[oparg] -- str)) {
1245 : 342034 : str = _PyUnicode_JoinArray(&_Py_STR(empty), pieces, oparg);
1246 : : DECREF_INPUTS();
1247 [ - + ]: 342034 : ERROR_IF(str == NULL, error);
1248 : : }
1249 : :
1250 : : inst(BUILD_TUPLE, (values[oparg] -- tup)) {
1251 : 278852 : tup = _PyTuple_FromArraySteal(values, oparg);
1252 [ - + ]: 278852 : ERROR_IF(tup == NULL, error);
1253 : : }
1254 : :
1255 : : inst(BUILD_LIST, (values[oparg] -- list)) {
1256 : 165891 : list = _PyList_FromArraySteal(values, oparg);
1257 [ - + ]: 165891 : ERROR_IF(list == NULL, error);
1258 : : }
1259 : :
1260 : : inst(LIST_EXTEND, (list, unused[oparg-1], iterable -- list, unused[oparg-1])) {
1261 : 2739 : PyObject *none_val = _PyList_Extend((PyListObject *)list, iterable);
1262 [ - + ]: 2739 : if (none_val == NULL) {
1263 [ # # ]: 0 : if (_PyErr_ExceptionMatches(tstate, PyExc_TypeError) &&
1264 [ # # # # ]: 0 : (Py_TYPE(iterable)->tp_iter == NULL && !PySequence_Check(iterable)))
1265 : : {
1266 : 0 : _PyErr_Clear(tstate);
1267 : 0 : _PyErr_Format(tstate, PyExc_TypeError,
1268 : : "Value after * must be an iterable, not %.200s",
1269 : 0 : Py_TYPE(iterable)->tp_name);
1270 : : }
1271 : : DECREF_INPUTS();
1272 : 0 : ERROR_IF(true, error);
1273 : : }
1274 [ - + ]: 2739 : Py_DECREF(none_val);
1275 : : DECREF_INPUTS();
1276 : : }
1277 : :
1278 : : inst(SET_UPDATE, (set, unused[oparg-1], iterable -- set, unused[oparg-1])) {
1279 : 10 : int err = _PySet_Update(set, iterable);
1280 : : DECREF_INPUTS();
1281 [ - + ]: 10 : ERROR_IF(err < 0, error);
1282 : : }
1283 : :
1284 : : inst(BUILD_SET, (values[oparg] -- set)) {
1285 : 374 : set = PySet_New(NULL);
1286 [ - + ]: 374 : if (set == NULL)
1287 : 0 : goto error;
1288 : 374 : int err = 0;
1289 [ + + ]: 1256 : for (int i = 0; i < oparg; i++) {
1290 : 882 : PyObject *item = values[i];
1291 [ + - ]: 882 : if (err == 0)
1292 : 882 : err = PySet_Add(set, item);
1293 [ - + ]: 882 : Py_DECREF(item);
1294 : : }
1295 [ - + ]: 374 : if (err != 0) {
1296 [ # # ]: 0 : Py_DECREF(set);
1297 : 0 : ERROR_IF(true, error);
1298 : : }
1299 : : }
1300 : :
1301 : : inst(BUILD_MAP, (values[oparg*2] -- map)) {
1302 : 120365 : map = _PyDict_FromItems(
1303 : : values, 2,
1304 : 120365 : values+1, 2,
1305 : : oparg);
1306 [ - + ]: 120365 : if (map == NULL)
1307 : 0 : goto error;
1308 : :
1309 : : DECREF_INPUTS();
1310 [ - + ]: 120365 : ERROR_IF(map == NULL, error);
1311 : : }
1312 : :
1313 : : inst(SETUP_ANNOTATIONS, (--)) {
1314 : : int err;
1315 : : PyObject *ann_dict;
1316 [ - + ]: 1 : if (LOCALS() == NULL) {
1317 : 0 : _PyErr_Format(tstate, PyExc_SystemError,
1318 : : "no locals found when setting up annotations");
1319 : 0 : ERROR_IF(true, error);
1320 : : }
1321 : : /* check if __annotations__ in locals()... */
1322 [ + - ]: 1 : if (PyDict_CheckExact(LOCALS())) {
1323 : 1 : ann_dict = _PyDict_GetItemWithError(LOCALS(),
1324 : : &_Py_ID(__annotations__));
1325 [ + - ]: 1 : if (ann_dict == NULL) {
1326 [ - + ]: 1 : ERROR_IF(_PyErr_Occurred(tstate), error);
1327 : : /* ...if not, create a new one */
1328 : 1 : ann_dict = PyDict_New();
1329 [ - + ]: 1 : ERROR_IF(ann_dict == NULL, error);
1330 : 1 : err = PyDict_SetItem(LOCALS(), &_Py_ID(__annotations__),
1331 : : ann_dict);
1332 [ - + ]: 1 : Py_DECREF(ann_dict);
1333 [ - + ]: 1 : ERROR_IF(err, error);
1334 : : }
1335 : : }
1336 : : else {
1337 : : /* do the same if locals() is not a dict */
1338 : 0 : ann_dict = PyObject_GetItem(LOCALS(), &_Py_ID(__annotations__));
1339 [ # # ]: 0 : if (ann_dict == NULL) {
1340 [ # # ]: 0 : ERROR_IF(!_PyErr_ExceptionMatches(tstate, PyExc_KeyError), error);
1341 : 0 : _PyErr_Clear(tstate);
1342 : 0 : ann_dict = PyDict_New();
1343 [ # # ]: 0 : ERROR_IF(ann_dict == NULL, error);
1344 : 0 : err = PyObject_SetItem(LOCALS(), &_Py_ID(__annotations__),
1345 : : ann_dict);
1346 [ # # ]: 0 : Py_DECREF(ann_dict);
1347 [ # # ]: 0 : ERROR_IF(err, error);
1348 : : }
1349 : : else {
1350 [ # # ]: 0 : Py_DECREF(ann_dict);
1351 : : }
1352 : : }
1353 : : }
1354 : :
1355 : : inst(BUILD_CONST_KEY_MAP, (values[oparg], keys -- map)) {
1356 [ + - ]: 1911 : if (!PyTuple_CheckExact(keys) ||
1357 [ - + ]: 1911 : PyTuple_GET_SIZE(keys) != (Py_ssize_t)oparg) {
1358 : 0 : _PyErr_SetString(tstate, PyExc_SystemError,
1359 : : "bad BUILD_CONST_KEY_MAP keys argument");
1360 : 0 : goto error; // Pop the keys and values.
1361 : : }
1362 : 1911 : map = _PyDict_FromItems(
1363 : 1911 : &PyTuple_GET_ITEM(keys, 0), 1,
1364 : : values, 1, oparg);
1365 : : DECREF_INPUTS();
1366 [ - + ]: 1911 : ERROR_IF(map == NULL, error);
1367 : : }
1368 : :
1369 : : inst(DICT_UPDATE, (update --)) {
1370 : 750 : PyObject *dict = PEEK(oparg + 1); // update is still on the stack
1371 [ - + ]: 750 : if (PyDict_Update(dict, update) < 0) {
1372 [ # # ]: 0 : if (_PyErr_ExceptionMatches(tstate, PyExc_AttributeError)) {
1373 : 0 : _PyErr_Format(tstate, PyExc_TypeError,
1374 : : "'%.200s' object is not a mapping",
1375 : 0 : Py_TYPE(update)->tp_name);
1376 : : }
1377 : : DECREF_INPUTS();
1378 : 0 : ERROR_IF(true, error);
1379 : : }
1380 : : DECREF_INPUTS();
1381 : : }
1382 : :
1383 : : inst(DICT_MERGE, (update --)) {
1384 : 102304 : PyObject *dict = PEEK(oparg + 1); // update is still on the stack
1385 : :
1386 [ - + ]: 102304 : if (_PyDict_MergeEx(dict, update, 2) < 0) {
1387 : 0 : format_kwargs_error(tstate, PEEK(3 + oparg), update);
1388 : : DECREF_INPUTS();
1389 : 0 : ERROR_IF(true, error);
1390 : : }
1391 : : DECREF_INPUTS();
1392 : : PREDICT(CALL_FUNCTION_EX);
1393 : : }
1394 : :
1395 : : inst(MAP_ADD, (key, value --)) {
1396 : 13896 : PyObject *dict = PEEK(oparg + 2); // key, value are still on the stack
1397 : : assert(PyDict_CheckExact(dict));
1398 : : /* dict[key] = value */
1399 : : // Do not DECREF INPUTS because the function steals the references
1400 [ - + ]: 13896 : ERROR_IF(_PyDict_SetItem_Take2((PyDictObject *)dict, key, value) != 0, error);
1401 : : PREDICT(JUMP_BACKWARD);
1402 : : }
1403 : :
1404 : : family(load_attr, INLINE_CACHE_ENTRIES_LOAD_ATTR) = {
1405 : : LOAD_ATTR,
1406 : : LOAD_ATTR_INSTANCE_VALUE,
1407 : : LOAD_ATTR_MODULE,
1408 : : LOAD_ATTR_WITH_HINT,
1409 : : LOAD_ATTR_SLOT,
1410 : : LOAD_ATTR_CLASS,
1411 : : LOAD_ATTR_PROPERTY,
1412 : : LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN,
1413 : : LOAD_ATTR_METHOD_WITH_VALUES,
1414 : : LOAD_ATTR_METHOD_NO_DICT,
1415 : : LOAD_ATTR_METHOD_LAZY_DICT,
1416 : : };
1417 : :
1418 : : inst(LOAD_ATTR, (unused/9, owner -- res2 if (oparg & 1), res)) {
1419 : : #if ENABLE_SPECIALIZATION
1420 : 1891903 : _PyAttrCache *cache = (_PyAttrCache *)next_instr;
1421 [ + + ]: 1891903 : if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
1422 : : assert(cframe.use_tracing == 0);
1423 : 17862 : PyObject *name = GETITEM(frame->f_code->co_names, oparg>>1);
1424 : 17862 : next_instr--;
1425 : 17862 : _Py_Specialize_LoadAttr(owner, next_instr, name);
1426 : 17862 : DISPATCH_SAME_OPARG();
1427 : : }
1428 : : STAT_INC(LOAD_ATTR, deferred);
1429 : 1874041 : DECREMENT_ADAPTIVE_COUNTER(cache->counter);
1430 : : #endif /* ENABLE_SPECIALIZATION */
1431 : 1874041 : PyObject *name = GETITEM(frame->f_code->co_names, oparg >> 1);
1432 [ + + ]: 1874041 : if (oparg & 1) {
1433 : : /* Designed to work in tandem with CALL, pushes two values. */
1434 : 470512 : PyObject* meth = NULL;
1435 [ + + ]: 470512 : if (_PyObject_GetMethod(owner, name, &meth)) {
1436 : : /* We can bypass temporary bound method object.
1437 : : meth is unbound method and obj is self.
1438 : :
1439 : : meth | self | arg1 | ... | argN
1440 : : */
1441 : : assert(meth != NULL); // No errors on this branch
1442 : 213574 : res2 = meth;
1443 : 213574 : res = owner; // Transfer ownership
1444 : : }
1445 : : else {
1446 : : /* meth is not an unbound method (but a regular attr, or
1447 : : something was returned by a descriptor protocol). Set
1448 : : the second element of the stack to NULL, to signal
1449 : : CALL that it's not a method call.
1450 : :
1451 : : NULL | meth | arg1 | ... | argN
1452 : : */
1453 : : DECREF_INPUTS();
1454 [ + + ]: 256938 : ERROR_IF(meth == NULL, error);
1455 : 256889 : res2 = NULL;
1456 : 256889 : res = meth;
1457 : : }
1458 : : }
1459 : : else {
1460 : : /* Classic, pushes one value. */
1461 : 1403529 : res = PyObject_GetAttr(owner, name);
1462 : : DECREF_INPUTS();
1463 [ + + ]: 1403529 : ERROR_IF(res == NULL, error);
1464 : : }
1465 : : }
1466 : :
1467 : : inst(LOAD_ATTR_INSTANCE_VALUE, (unused/1, type_version/2, index/1, unused/5, owner -- res2 if (oparg & 1), res)) {
1468 : : assert(cframe.use_tracing == 0);
1469 : 1481398 : PyTypeObject *tp = Py_TYPE(owner);
1470 : : assert(type_version != 0);
1471 [ + + ]: 1481398 : DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR);
1472 : : assert(tp->tp_dictoffset < 0);
1473 : : assert(tp->tp_flags & Py_TPFLAGS_MANAGED_DICT);
1474 : 1480650 : PyDictOrValues dorv = *_PyObject_DictOrValuesPointer(owner);
1475 [ + + ]: 1480650 : DEOPT_IF(!_PyDictOrValues_IsValues(dorv), LOAD_ATTR);
1476 : 1480649 : res = _PyDictOrValues_GetValues(dorv)->values[index];
1477 [ - + ]: 1480649 : DEOPT_IF(res == NULL, LOAD_ATTR);
1478 : : STAT_INC(LOAD_ATTR, hit);
1479 : 1480649 : Py_INCREF(res);
1480 [ - + ]: 1480649 : res2 = NULL;
1481 : : DECREF_INPUTS();
1482 : : }
1483 : :
1484 : : inst(LOAD_ATTR_MODULE, (unused/1, type_version/2, index/1, unused/5, owner -- res2 if (oparg & 1), res)) {
1485 : : assert(cframe.use_tracing == 0);
1486 [ - + ]: 1473626 : DEOPT_IF(!PyModule_CheckExact(owner), LOAD_ATTR);
1487 : 1473626 : PyDictObject *dict = (PyDictObject *)((PyModuleObject *)owner)->md_dict;
1488 : : assert(dict != NULL);
1489 [ + + ]: 1473626 : DEOPT_IF(dict->ma_keys->dk_version != type_version, LOAD_ATTR);
1490 : : assert(dict->ma_keys->dk_kind == DICT_KEYS_UNICODE);
1491 : : assert(index < dict->ma_keys->dk_nentries);
1492 : 1462832 : PyDictUnicodeEntry *ep = DK_UNICODE_ENTRIES(dict->ma_keys) + index;
1493 : 1462832 : res = ep->me_value;
1494 [ - + ]: 1462832 : DEOPT_IF(res == NULL, LOAD_ATTR);
1495 : : STAT_INC(LOAD_ATTR, hit);
1496 : 1462832 : Py_INCREF(res);
1497 [ - + ]: 1462832 : res2 = NULL;
1498 : : DECREF_INPUTS();
1499 : : }
1500 : :
1501 : : inst(LOAD_ATTR_WITH_HINT, (unused/1, type_version/2, index/1, unused/5, owner -- res2 if (oparg & 1), res)) {
1502 : : assert(cframe.use_tracing == 0);
1503 : 227690 : PyTypeObject *tp = Py_TYPE(owner);
1504 : : assert(type_version != 0);
1505 [ + + ]: 227690 : DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR);
1506 : : assert(tp->tp_flags & Py_TPFLAGS_MANAGED_DICT);
1507 : 227598 : PyDictOrValues dorv = *_PyObject_DictOrValuesPointer(owner);
1508 [ + + ]: 227598 : DEOPT_IF(_PyDictOrValues_IsValues(dorv), LOAD_ATTR);
1509 : 227562 : PyDictObject *dict = (PyDictObject *)_PyDictOrValues_GetDict(dorv);
1510 [ - + ]: 227562 : DEOPT_IF(dict == NULL, LOAD_ATTR);
1511 : : assert(PyDict_CheckExact((PyObject *)dict));
1512 : 227562 : PyObject *name = GETITEM(frame->f_code->co_names, oparg>>1);
1513 : 227562 : uint16_t hint = index;
1514 [ - + ]: 227562 : DEOPT_IF(hint >= (size_t)dict->ma_keys->dk_nentries, LOAD_ATTR);
1515 [ + - ]: 227562 : if (DK_IS_UNICODE(dict->ma_keys)) {
1516 : 227562 : PyDictUnicodeEntry *ep = DK_UNICODE_ENTRIES(dict->ma_keys) + hint;
1517 [ - + ]: 227562 : DEOPT_IF(ep->me_key != name, LOAD_ATTR);
1518 : 227562 : res = ep->me_value;
1519 : : }
1520 : : else {
1521 : 0 : PyDictKeyEntry *ep = DK_ENTRIES(dict->ma_keys) + hint;
1522 [ # # ]: 0 : DEOPT_IF(ep->me_key != name, LOAD_ATTR);
1523 : 0 : res = ep->me_value;
1524 : : }
1525 [ + + ]: 227562 : DEOPT_IF(res == NULL, LOAD_ATTR);
1526 : : STAT_INC(LOAD_ATTR, hit);
1527 : 59 : Py_INCREF(res);
1528 [ - + ]: 59 : res2 = NULL;
1529 : : DECREF_INPUTS();
1530 : : }
1531 : :
1532 : : inst(LOAD_ATTR_SLOT, (unused/1, type_version/2, index/1, unused/5, owner -- res2 if (oparg & 1), res)) {
1533 : : assert(cframe.use_tracing == 0);
1534 : 375316 : PyTypeObject *tp = Py_TYPE(owner);
1535 : : assert(type_version != 0);
1536 [ + + ]: 375316 : DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR);
1537 : 374991 : char *addr = (char *)owner + index;
1538 : 374991 : res = *(PyObject **)addr;
1539 [ + + ]: 374991 : DEOPT_IF(res == NULL, LOAD_ATTR);
1540 : : STAT_INC(LOAD_ATTR, hit);
1541 : 374910 : Py_INCREF(res);
1542 [ - + ]: 374910 : res2 = NULL;
1543 : : DECREF_INPUTS();
1544 : : }
1545 : :
1546 : : inst(LOAD_ATTR_CLASS, (unused/1, type_version/2, unused/2, descr/4, cls -- res2 if (oparg & 1), res)) {
1547 : : assert(cframe.use_tracing == 0);
1548 : :
1549 [ - + ]: 376321 : DEOPT_IF(!PyType_Check(cls), LOAD_ATTR);
1550 [ + + ]: 376321 : DEOPT_IF(((PyTypeObject *)cls)->tp_version_tag != type_version,
1551 : : LOAD_ATTR);
1552 : : assert(type_version != 0);
1553 : :
1554 : : STAT_INC(LOAD_ATTR, hit);
1555 : 376319 : res2 = NULL;
1556 : 376319 : res = descr;
1557 : : assert(res != NULL);
1558 : 376319 : Py_INCREF(res);
1559 : : DECREF_INPUTS();
1560 : : }
1561 : :
1562 : : inst(LOAD_ATTR_PROPERTY, (unused/1, type_version/2, func_version/2, fget/4, owner -- unused if (oparg & 1), unused)) {
1563 : : assert(cframe.use_tracing == 0);
1564 [ - + ]: 41965 : DEOPT_IF(tstate->interp->eval_frame, LOAD_ATTR);
1565 : :
1566 : 41965 : PyTypeObject *cls = Py_TYPE(owner);
1567 [ - + ]: 41965 : DEOPT_IF(cls->tp_version_tag != type_version, LOAD_ATTR);
1568 : : assert(type_version != 0);
1569 : : assert(Py_IS_TYPE(fget, &PyFunction_Type));
1570 : 41965 : PyFunctionObject *f = (PyFunctionObject *)fget;
1571 : : assert(func_version != 0);
1572 [ - + ]: 41965 : DEOPT_IF(f->func_version != func_version, LOAD_ATTR);
1573 : 41965 : PyCodeObject *code = (PyCodeObject *)f->func_code;
1574 : : assert(code->co_argcount == 1);
1575 [ - + ]: 41965 : DEOPT_IF(!_PyThreadState_HasStackSpace(tstate, code->co_framesize), LOAD_ATTR);
1576 : : STAT_INC(LOAD_ATTR, hit);
1577 : 41965 : Py_INCREF(fget);
1578 : 41965 : _PyInterpreterFrame *new_frame = _PyFrame_PushUnchecked(tstate, f, 1);
1579 : : // Manipulate stack directly because we exit with DISPATCH_INLINED().
1580 : 41965 : SET_TOP(NULL);
1581 : 41965 : int shrink_stack = !(oparg & 1);
1582 : 41965 : STACK_SHRINK(shrink_stack);
1583 : 41965 : new_frame->localsplus[0] = owner;
1584 : 41965 : JUMPBY(INLINE_CACHE_ENTRIES_LOAD_ATTR);
1585 : 41965 : DISPATCH_INLINED(new_frame);
1586 : : }
1587 : :
1588 : : inst(LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN, (unused/1, type_version/2, func_version/2, getattribute/4, owner -- unused if (oparg & 1), unused)) {
1589 : : assert(cframe.use_tracing == 0);
1590 [ # # ]: 0 : DEOPT_IF(tstate->interp->eval_frame, LOAD_ATTR);
1591 : 0 : PyTypeObject *cls = Py_TYPE(owner);
1592 [ # # ]: 0 : DEOPT_IF(cls->tp_version_tag != type_version, LOAD_ATTR);
1593 : : assert(type_version != 0);
1594 : : assert(Py_IS_TYPE(getattribute, &PyFunction_Type));
1595 : 0 : PyFunctionObject *f = (PyFunctionObject *)getattribute;
1596 : : assert(func_version != 0);
1597 [ # # ]: 0 : DEOPT_IF(f->func_version != func_version, LOAD_ATTR);
1598 : 0 : PyCodeObject *code = (PyCodeObject *)f->func_code;
1599 : : assert(code->co_argcount == 2);
1600 [ # # ]: 0 : DEOPT_IF(!_PyThreadState_HasStackSpace(tstate, code->co_framesize), LOAD_ATTR);
1601 : : STAT_INC(LOAD_ATTR, hit);
1602 : :
1603 : 0 : PyObject *name = GETITEM(frame->f_code->co_names, oparg >> 1);
1604 : 0 : Py_INCREF(f);
1605 : 0 : _PyInterpreterFrame *new_frame = _PyFrame_PushUnchecked(tstate, f, 2);
1606 : : // Manipulate stack directly because we exit with DISPATCH_INLINED().
1607 : 0 : SET_TOP(NULL);
1608 : 0 : int shrink_stack = !(oparg & 1);
1609 : 0 : STACK_SHRINK(shrink_stack);
1610 : 0 : new_frame->localsplus[0] = owner;
1611 : 0 : new_frame->localsplus[1] = Py_NewRef(name);
1612 : 0 : JUMPBY(INLINE_CACHE_ENTRIES_LOAD_ATTR);
1613 : 0 : DISPATCH_INLINED(new_frame);
1614 : : }
1615 : :
1616 : : inst(STORE_ATTR_INSTANCE_VALUE, (unused/1, type_version/2, index/1, value, owner --)) {
1617 : : assert(cframe.use_tracing == 0);
1618 : 842732 : PyTypeObject *tp = Py_TYPE(owner);
1619 : : assert(type_version != 0);
1620 [ + + ]: 842732 : DEOPT_IF(tp->tp_version_tag != type_version, STORE_ATTR);
1621 : : assert(tp->tp_flags & Py_TPFLAGS_MANAGED_DICT);
1622 : 841574 : PyDictOrValues dorv = *_PyObject_DictOrValuesPointer(owner);
1623 [ - + ]: 841574 : DEOPT_IF(!_PyDictOrValues_IsValues(dorv), STORE_ATTR);
1624 : : STAT_INC(STORE_ATTR, hit);
1625 : 841574 : PyDictValues *values = _PyDictOrValues_GetValues(dorv);
1626 : 841574 : PyObject *old_value = values->values[index];
1627 : 841574 : values->values[index] = value;
1628 [ + + ]: 841574 : if (old_value == NULL) {
1629 : 569356 : _PyDictValues_AddToInsertionOrder(values, index);
1630 : : }
1631 : : else {
1632 [ + + ]: 272218 : Py_DECREF(old_value);
1633 : : }
1634 [ - + ]: 841574 : Py_DECREF(owner);
1635 : : }
1636 : :
1637 : : inst(STORE_ATTR_WITH_HINT, (unused/1, type_version/2, hint/1, value, owner --)) {
1638 : : assert(cframe.use_tracing == 0);
1639 : 319989 : PyTypeObject *tp = Py_TYPE(owner);
1640 : : assert(type_version != 0);
1641 [ + + ]: 319989 : DEOPT_IF(tp->tp_version_tag != type_version, STORE_ATTR);
1642 : : assert(tp->tp_flags & Py_TPFLAGS_MANAGED_DICT);
1643 : 318684 : PyDictOrValues dorv = *_PyObject_DictOrValuesPointer(owner);
1644 [ - + ]: 318684 : DEOPT_IF(_PyDictOrValues_IsValues(dorv), STORE_ATTR);
1645 : 318684 : PyDictObject *dict = (PyDictObject *)_PyDictOrValues_GetDict(dorv);
1646 [ - + ]: 318684 : DEOPT_IF(dict == NULL, STORE_ATTR);
1647 : : assert(PyDict_CheckExact((PyObject *)dict));
1648 : 318684 : PyObject *name = GETITEM(frame->f_code->co_names, oparg);
1649 [ - + ]: 318684 : DEOPT_IF(hint >= (size_t)dict->ma_keys->dk_nentries, STORE_ATTR);
1650 : : PyObject *old_value;
1651 : : uint64_t new_version;
1652 [ + - ]: 318684 : if (DK_IS_UNICODE(dict->ma_keys)) {
1653 : 318684 : PyDictUnicodeEntry *ep = DK_UNICODE_ENTRIES(dict->ma_keys) + hint;
1654 [ - + ]: 318684 : DEOPT_IF(ep->me_key != name, STORE_ATTR);
1655 : 318684 : old_value = ep->me_value;
1656 [ + - ]: 318684 : DEOPT_IF(old_value == NULL, STORE_ATTR);
1657 : 0 : new_version = _PyDict_NotifyEvent(tstate->interp, PyDict_EVENT_MODIFIED, dict, name, value);
1658 : 0 : ep->me_value = value;
1659 : : }
1660 : : else {
1661 : 0 : PyDictKeyEntry *ep = DK_ENTRIES(dict->ma_keys) + hint;
1662 [ # # ]: 0 : DEOPT_IF(ep->me_key != name, STORE_ATTR);
1663 : 0 : old_value = ep->me_value;
1664 [ # # ]: 0 : DEOPT_IF(old_value == NULL, STORE_ATTR);
1665 : 0 : new_version = _PyDict_NotifyEvent(tstate->interp, PyDict_EVENT_MODIFIED, dict, name, value);
1666 : 0 : ep->me_value = value;
1667 : : }
1668 [ # # ]: 0 : Py_DECREF(old_value);
1669 : : STAT_INC(STORE_ATTR, hit);
1670 : : /* Ensure dict is GC tracked if it needs to be */
1671 [ # # # # ]: 0 : if (!_PyObject_GC_IS_TRACKED(dict) && _PyObject_GC_MAY_BE_TRACKED(value)) {
1672 : 0 : _PyObject_GC_TRACK(dict);
1673 : : }
1674 : : /* PEP 509 */
1675 : 0 : dict->ma_version_tag = new_version;
1676 [ # # ]: 0 : Py_DECREF(owner);
1677 : : }
1678 : :
1679 : : inst(STORE_ATTR_SLOT, (unused/1, type_version/2, index/1, value, owner --)) {
1680 : : assert(cframe.use_tracing == 0);
1681 : 266076 : PyTypeObject *tp = Py_TYPE(owner);
1682 : : assert(type_version != 0);
1683 [ + + ]: 266076 : DEOPT_IF(tp->tp_version_tag != type_version, STORE_ATTR);
1684 : 266015 : char *addr = (char *)owner + index;
1685 : : STAT_INC(STORE_ATTR, hit);
1686 : 266015 : PyObject *old_value = *(PyObject **)addr;
1687 : 266015 : *(PyObject **)addr = value;
1688 [ + + - + ]: 266015 : Py_XDECREF(old_value);
1689 [ - + ]: 266015 : Py_DECREF(owner);
1690 : : }
1691 : :
1692 : : inst(COMPARE_OP, (unused/1, left, right -- res)) {
1693 : : STAT_INC(COMPARE_OP, deferred);
1694 : : assert((oparg >> 4) <= Py_GE);
1695 : 163293 : res = PyObject_RichCompare(left, right, oparg>>4);
1696 : : DECREF_INPUTS();
1697 [ - + ]: 163293 : ERROR_IF(res == NULL, error);
1698 : : }
1699 : :
1700 : : // No cache size here, since this is a family of super-instructions.
1701 : : family(compare_and_branch) = {
1702 : : COMPARE_AND_BRANCH,
1703 : : COMPARE_AND_BRANCH_FLOAT,
1704 : : COMPARE_AND_BRANCH_INT,
1705 : : COMPARE_AND_BRANCH_STR,
1706 : : };
1707 : :
1708 : : inst(COMPARE_AND_BRANCH, (unused/2, left, right -- )) {
1709 : : #if ENABLE_SPECIALIZATION
1710 : 143382 : _PyCompareOpCache *cache = (_PyCompareOpCache *)next_instr;
1711 [ + + ]: 143382 : if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
1712 : : assert(cframe.use_tracing == 0);
1713 : 3834 : next_instr--;
1714 : 3834 : _Py_Specialize_CompareAndBranch(left, right, next_instr, oparg);
1715 : 3834 : DISPATCH_SAME_OPARG();
1716 : : }
1717 : : STAT_INC(COMPARE_AND_BRANCH, deferred);
1718 : 139548 : DECREMENT_ADAPTIVE_COUNTER(cache->counter);
1719 : : #endif /* ENABLE_SPECIALIZATION */
1720 : : assert((oparg >> 4) <= Py_GE);
1721 : 139548 : PyObject *cond = PyObject_RichCompare(left, right, oparg>>4);
1722 : : DECREF_INPUTS();
1723 [ - + ]: 139548 : ERROR_IF(cond == NULL, error);
1724 : : assert(next_instr[1].op.code == POP_JUMP_IF_FALSE ||
1725 : : next_instr[1].op.code == POP_JUMP_IF_TRUE);
1726 : 139548 : bool jump_on_true = next_instr[1].op.code == POP_JUMP_IF_TRUE;
1727 : 139548 : int offset = next_instr[1].op.arg;
1728 : 139548 : int err = PyObject_IsTrue(cond);
1729 [ - + ]: 139548 : Py_DECREF(cond);
1730 [ - + ]: 139548 : ERROR_IF(err < 0, error);
1731 [ + + ]: 139548 : if (jump_on_true == (err != 0)) {
1732 : 123969 : JUMPBY(offset);
1733 : : }
1734 : : }
1735 : :
1736 : : inst(COMPARE_AND_BRANCH_FLOAT, (unused/2, left, right -- )) {
1737 : : assert(cframe.use_tracing == 0);
1738 [ + + ]: 92283 : DEOPT_IF(!PyFloat_CheckExact(left), COMPARE_AND_BRANCH);
1739 [ + + ]: 92055 : DEOPT_IF(!PyFloat_CheckExact(right), COMPARE_AND_BRANCH);
1740 : : STAT_INC(COMPARE_AND_BRANCH, hit);
1741 : 91957 : double dleft = PyFloat_AS_DOUBLE(left);
1742 : 91957 : double dright = PyFloat_AS_DOUBLE(right);
1743 : : // 1 if NaN, 2 if <, 4 if >, 8 if ==; this matches low four bits of the oparg
1744 [ + + ]: 91957 : int sign_ish = COMPARISON_BIT(dleft, dright);
1745 [ + + ]: 91957 : _Py_DECREF_SPECIALIZED(left, _PyFloat_ExactDealloc);
1746 [ - + ]: 91957 : _Py_DECREF_SPECIALIZED(right, _PyFloat_ExactDealloc);
1747 [ + + ]: 91957 : if (sign_ish & oparg) {
1748 : 89905 : int offset = next_instr[1].op.arg;
1749 : 89905 : JUMPBY(offset);
1750 : : }
1751 : : }
1752 : :
1753 : : // Similar to COMPARE_AND_BRANCH_FLOAT
1754 : : inst(COMPARE_AND_BRANCH_INT, (unused/2, left, right -- )) {
1755 : : assert(cframe.use_tracing == 0);
1756 [ - + ]: 2025806 : DEOPT_IF(!PyLong_CheckExact(left), COMPARE_AND_BRANCH);
1757 [ - + ]: 2025806 : DEOPT_IF(!PyLong_CheckExact(right), COMPARE_AND_BRANCH);
1758 [ + + ]: 2025806 : DEOPT_IF((size_t)(Py_SIZE(left) + 1) > 2, COMPARE_AND_BRANCH);
1759 [ + + ]: 1993166 : DEOPT_IF((size_t)(Py_SIZE(right) + 1) > 2, COMPARE_AND_BRANCH);
1760 : : STAT_INC(COMPARE_AND_BRANCH, hit);
1761 : : assert(Py_ABS(Py_SIZE(left)) <= 1 && Py_ABS(Py_SIZE(right)) <= 1);
1762 : 1993163 : Py_ssize_t ileft = Py_SIZE(left) * ((PyLongObject *)left)->long_value.ob_digit[0];
1763 : 1993163 : Py_ssize_t iright = Py_SIZE(right) * ((PyLongObject *)right)->long_value.ob_digit[0];
1764 : : // 2 if <, 4 if >, 8 if ==; this matches the low 4 bits of the oparg
1765 [ + + ]: 1993163 : int sign_ish = COMPARISON_BIT(ileft, iright);
1766 [ + + ]: 1993163 : _Py_DECREF_SPECIALIZED(left, (destructor)PyObject_Free);
1767 [ + + ]: 1993163 : _Py_DECREF_SPECIALIZED(right, (destructor)PyObject_Free);
1768 [ + + ]: 1993163 : if (sign_ish & oparg) {
1769 : 1499413 : int offset = next_instr[1].op.arg;
1770 : 1499413 : JUMPBY(offset);
1771 : : }
1772 : : }
1773 : :
1774 : : // Similar to COMPARE_AND_BRANCH_FLOAT, but for ==, != only
1775 : : inst(COMPARE_AND_BRANCH_STR, (unused/2, left, right -- )) {
1776 : : assert(cframe.use_tracing == 0);
1777 [ + + ]: 34573 : DEOPT_IF(!PyUnicode_CheckExact(left), COMPARE_AND_BRANCH);
1778 [ + + ]: 34481 : DEOPT_IF(!PyUnicode_CheckExact(right), COMPARE_AND_BRANCH);
1779 : : STAT_INC(COMPARE_AND_BRANCH, hit);
1780 : 34391 : int res = _PyUnicode_Equal(left, right);
1781 : : assert((oparg >>4) == Py_EQ || (oparg >>4) == Py_NE);
1782 [ + + ]: 34391 : _Py_DECREF_SPECIALIZED(left, _PyUnicode_ExactDealloc);
1783 [ + + ]: 34391 : _Py_DECREF_SPECIALIZED(right, _PyUnicode_ExactDealloc);
1784 : : assert(res == 0 || res == 1);
1785 : : assert((oparg & 0xf) == COMPARISON_NOT_EQUALS || (oparg & 0xf) == COMPARISON_EQUALS);
1786 : : assert(COMPARISON_NOT_EQUALS + 1 == COMPARISON_EQUALS);
1787 [ + + ]: 34391 : if ((res + COMPARISON_NOT_EQUALS) & oparg) {
1788 : 30448 : int offset = next_instr[1].op.arg;
1789 : 30448 : JUMPBY(offset);
1790 : : }
1791 : : }
1792 : :
1793 : : inst(IS_OP, (left, right -- b)) {
1794 [ + + ]: 242056 : int res = Py_Is(left, right) ^ oparg;
1795 : : DECREF_INPUTS();
1796 [ + + ]: 242056 : b = Py_NewRef(res ? Py_True : Py_False);
1797 : : }
1798 : :
1799 : : inst(CONTAINS_OP, (left, right -- b)) {
1800 : 66972 : int res = PySequence_Contains(right, left);
1801 : : DECREF_INPUTS();
1802 [ - + ]: 66972 : ERROR_IF(res < 0, error);
1803 [ + + ]: 66972 : b = Py_NewRef((res^oparg) ? Py_True : Py_False);
1804 : : }
1805 : :
1806 : : inst(CHECK_EG_MATCH, (exc_value, match_type -- rest, match)) {
1807 [ # # ]: 0 : if (check_except_star_type_valid(tstate, match_type) < 0) {
1808 : : DECREF_INPUTS();
1809 : 0 : ERROR_IF(true, error);
1810 : : }
1811 : :
1812 : 0 : match = NULL;
1813 : 0 : rest = NULL;
1814 : 0 : int res = exception_group_match(exc_value, match_type,
1815 : : &match, &rest);
1816 : : DECREF_INPUTS();
1817 [ # # ]: 0 : ERROR_IF(res < 0, error);
1818 : :
1819 : : assert((match == NULL) == (rest == NULL));
1820 [ # # ]: 0 : ERROR_IF(match == NULL, error);
1821 : :
1822 [ # # ]: 0 : if (!Py_IsNone(match)) {
1823 : 0 : PyErr_SetExcInfo(NULL, Py_NewRef(match), NULL);
1824 : : }
1825 : : }
1826 : :
1827 : : inst(CHECK_EXC_MATCH, (left, right -- left, b)) {
1828 : : assert(PyExceptionInstance_Check(left));
1829 [ - + ]: 101696 : if (check_except_type_valid(tstate, right) < 0) {
1830 : : DECREF_INPUTS();
1831 : 0 : ERROR_IF(true, error);
1832 : : }
1833 : :
1834 : 101696 : int res = PyErr_GivenExceptionMatches(left, right);
1835 : : DECREF_INPUTS();
1836 [ + + ]: 101696 : b = Py_NewRef(res ? Py_True : Py_False);
1837 : : }
1838 : :
1839 : : inst(IMPORT_NAME, (level, fromlist -- res)) {
1840 : 3157 : PyObject *name = GETITEM(frame->f_code->co_names, oparg);
1841 : 3157 : res = import_name(tstate, frame, name, fromlist, level);
1842 : : DECREF_INPUTS();
1843 [ + + ]: 3157 : ERROR_IF(res == NULL, error);
1844 : : }
1845 : :
1846 : : inst(IMPORT_FROM, (from -- from, res)) {
1847 : 2022 : PyObject *name = GETITEM(frame->f_code->co_names, oparg);
1848 : 2022 : res = import_from(tstate, from, name);
1849 [ + + ]: 2022 : ERROR_IF(res == NULL, error);
1850 : : }
1851 : :
1852 : : inst(JUMP_FORWARD, (--)) {
1853 : 101239 : JUMPBY(oparg);
1854 : : }
1855 : :
1856 : : inst(JUMP_BACKWARD, (--)) {
1857 : : assert(oparg < INSTR_OFFSET());
1858 [ + + ]: 3172588 : JUMPBY(-oparg);
1859 : : CHECK_EVAL_BREAKER();
1860 : : }
1861 : :
1862 : : inst(POP_JUMP_IF_FALSE, (cond -- )) {
1863 [ + + ]: 1257996 : if (Py_IsTrue(cond)) {
1864 : 930004 : _Py_DECREF_NO_DEALLOC(cond);
1865 : : }
1866 [ + + ]: 327992 : else if (Py_IsFalse(cond)) {
1867 : 250633 : _Py_DECREF_NO_DEALLOC(cond);
1868 : 250633 : JUMPBY(oparg);
1869 : : }
1870 : : else {
1871 : 77359 : int err = PyObject_IsTrue(cond);
1872 : : DECREF_INPUTS();
1873 [ + + ]: 77359 : if (err == 0) {
1874 : 38757 : JUMPBY(oparg);
1875 : : }
1876 : : else {
1877 [ - + ]: 38602 : ERROR_IF(err < 0, error);
1878 : : }
1879 : : }
1880 : : }
1881 : :
1882 : : inst(POP_JUMP_IF_TRUE, (cond -- )) {
1883 [ + + ]: 667438 : if (Py_IsFalse(cond)) {
1884 : 32082 : _Py_DECREF_NO_DEALLOC(cond);
1885 : : }
1886 [ + + ]: 635356 : else if (Py_IsTrue(cond)) {
1887 : 103126 : _Py_DECREF_NO_DEALLOC(cond);
1888 : 103126 : JUMPBY(oparg);
1889 : : }
1890 : : else {
1891 : 532230 : int err = PyObject_IsTrue(cond);
1892 : : DECREF_INPUTS();
1893 [ + + ]: 532230 : if (err > 0) {
1894 : 514831 : JUMPBY(oparg);
1895 : : }
1896 : : else {
1897 [ - + ]: 17399 : ERROR_IF(err < 0, error);
1898 : : }
1899 : : }
1900 : : }
1901 : :
1902 : : inst(POP_JUMP_IF_NOT_NONE, (value -- )) {
1903 [ + + ]: 513172 : if (!Py_IsNone(value)) {
1904 : : DECREF_INPUTS();
1905 : 146583 : JUMPBY(oparg);
1906 : : }
1907 : : else {
1908 : 366589 : _Py_DECREF_NO_DEALLOC(value);
1909 : : }
1910 : : }
1911 : :
1912 : : inst(POP_JUMP_IF_NONE, (value -- )) {
1913 [ + + ]: 186654 : if (Py_IsNone(value)) {
1914 : 162760 : _Py_DECREF_NO_DEALLOC(value);
1915 : 162760 : JUMPBY(oparg);
1916 : : }
1917 : : else {
1918 : : DECREF_INPUTS();
1919 : : }
1920 : : }
1921 : :
1922 : : inst(JUMP_IF_FALSE_OR_POP, (cond -- cond if (jump))) {
1923 : 99575 : bool jump = false;
1924 : : int err;
1925 [ + + ]: 99575 : if (Py_IsTrue(cond)) {
1926 : 85386 : _Py_DECREF_NO_DEALLOC(cond);
1927 : : }
1928 [ + + ]: 14189 : else if (Py_IsFalse(cond)) {
1929 : 12041 : JUMPBY(oparg);
1930 : 12041 : jump = true;
1931 : : }
1932 : : else {
1933 : 2148 : err = PyObject_IsTrue(cond);
1934 [ + + ]: 2148 : if (err > 0) {
1935 [ + + ]: 959 : Py_DECREF(cond);
1936 : : }
1937 [ + - ]: 1189 : else if (err == 0) {
1938 : 1189 : JUMPBY(oparg);
1939 : 1189 : jump = true;
1940 : : }
1941 : : else {
1942 : 0 : goto error;
1943 : : }
1944 : : }
1945 : : }
1946 : :
1947 : : inst(JUMP_IF_TRUE_OR_POP, (cond -- cond if (jump))) {
1948 : 18928 : bool jump = false;
1949 : : int err;
1950 [ + + ]: 18928 : if (Py_IsFalse(cond)) {
1951 : 1098 : _Py_DECREF_NO_DEALLOC(cond);
1952 : : }
1953 [ + + ]: 17830 : else if (Py_IsTrue(cond)) {
1954 : 167 : JUMPBY(oparg);
1955 : 167 : jump = true;
1956 : : }
1957 : : else {
1958 : 17663 : err = PyObject_IsTrue(cond);
1959 [ + + ]: 17663 : if (err > 0) {
1960 : 16845 : JUMPBY(oparg);
1961 : 16845 : jump = true;
1962 : : }
1963 [ + - ]: 818 : else if (err == 0) {
1964 [ - + ]: 818 : Py_DECREF(cond);
1965 : : }
1966 : : else {
1967 : 0 : goto error;
1968 : : }
1969 : : }
1970 : : }
1971 : :
1972 : : inst(JUMP_BACKWARD_NO_INTERRUPT, (--)) {
1973 : : /* This bytecode is used in the `yield from` or `await` loop.
1974 : : * If there is an interrupt, we want it handled in the innermost
1975 : : * generator or coroutine, so we deliberately do not check it here.
1976 : : * (see bpo-30039).
1977 : : */
1978 : 339 : JUMPBY(-oparg);
1979 : : }
1980 : :
1981 : : inst(GET_LEN, (obj -- obj, len_o)) {
1982 : : // PUSH(len(TOS))
1983 : 408 : Py_ssize_t len_i = PyObject_Length(obj);
1984 [ - + ]: 408 : ERROR_IF(len_i < 0, error);
1985 : 408 : len_o = PyLong_FromSsize_t(len_i);
1986 [ - + ]: 408 : ERROR_IF(len_o == NULL, error);
1987 : : }
1988 : :
1989 : : inst(MATCH_CLASS, (subject, type, names -- attrs)) {
1990 : : // Pop TOS and TOS1. Set TOS to a tuple of attributes on success, or
1991 : : // None on failure.
1992 : : assert(PyTuple_CheckExact(names));
1993 : 26 : attrs = match_class(tstate, subject, type, oparg, names);
1994 : : DECREF_INPUTS();
1995 [ + + ]: 26 : if (attrs) {
1996 : : assert(PyTuple_CheckExact(attrs)); // Success!
1997 : : }
1998 : : else {
1999 [ - + ]: 16 : ERROR_IF(_PyErr_Occurred(tstate), error); // Error!
2000 : 16 : attrs = Py_NewRef(Py_None); // Failure!
2001 : : }
2002 : : }
2003 : :
2004 : : inst(MATCH_MAPPING, (subject -- subject, res)) {
2005 : 0 : int match = Py_TYPE(subject)->tp_flags & Py_TPFLAGS_MAPPING;
2006 [ # # ]: 0 : res = Py_NewRef(match ? Py_True : Py_False);
2007 : : PREDICT(POP_JUMP_IF_FALSE);
2008 : : }
2009 : :
2010 : : inst(MATCH_SEQUENCE, (subject -- subject, res)) {
2011 : 509 : int match = Py_TYPE(subject)->tp_flags & Py_TPFLAGS_SEQUENCE;
2012 [ + - ]: 509 : res = Py_NewRef(match ? Py_True : Py_False);
2013 : : PREDICT(POP_JUMP_IF_FALSE);
2014 : : }
2015 : :
2016 : : inst(MATCH_KEYS, (subject, keys -- subject, keys, values_or_none)) {
2017 : : // On successful match, PUSH(values). Otherwise, PUSH(None).
2018 : 0 : values_or_none = match_keys(tstate, subject, keys);
2019 [ # # ]: 0 : ERROR_IF(values_or_none == NULL, error);
2020 : : }
2021 : :
2022 : : inst(GET_ITER, (iterable -- iter)) {
2023 : : /* before: [obj]; after [getiter(obj)] */
2024 : 1629120 : iter = PyObject_GetIter(iterable);
2025 : : DECREF_INPUTS();
2026 [ - + ]: 1629120 : ERROR_IF(iter == NULL, error);
2027 : : }
2028 : :
2029 : : inst(GET_YIELD_FROM_ITER, (iterable -- iter)) {
2030 : : /* before: [obj]; after [getiter(obj)] */
2031 [ - + ]: 38 : if (PyCoro_CheckExact(iterable)) {
2032 : : /* `iterable` is a coroutine */
2033 [ # # ]: 0 : if (!(frame->f_code->co_flags & (CO_COROUTINE | CO_ITERABLE_COROUTINE))) {
2034 : : /* and it is used in a 'yield from' expression of a
2035 : : regular generator. */
2036 : 0 : _PyErr_SetString(tstate, PyExc_TypeError,
2037 : : "cannot 'yield from' a coroutine object "
2038 : : "in a non-coroutine generator");
2039 : 0 : goto error;
2040 : : }
2041 : 0 : iter = iterable;
2042 : : }
2043 [ + + ]: 38 : else if (PyGen_CheckExact(iterable)) {
2044 : 27 : iter = iterable;
2045 : : }
2046 : : else {
2047 : : /* `iterable` is not a generator. */
2048 : 11 : iter = PyObject_GetIter(iterable);
2049 [ - + ]: 11 : if (iter == NULL) {
2050 : 0 : goto error;
2051 : : }
2052 : : DECREF_INPUTS();
2053 : : }
2054 : : PREDICT(LOAD_CONST);
2055 : : }
2056 : :
2057 : : // Most members of this family are "secretly" super-instructions.
2058 : : // When the loop is exhausted, they jump, and the jump target is
2059 : : // always END_FOR, which pops two values off the stack.
2060 : : // This is optimized by skipping that instruction and combining
2061 : : // its effect (popping 'iter' instead of pushing 'next'.)
2062 : :
2063 : : family(for_iter, INLINE_CACHE_ENTRIES_FOR_ITER) = {
2064 : : FOR_ITER,
2065 : : FOR_ITER_LIST,
2066 : : FOR_ITER_TUPLE,
2067 : : FOR_ITER_RANGE,
2068 : : FOR_ITER_GEN,
2069 : : };
2070 : :
2071 : : inst(FOR_ITER, (unused/1, iter -- iter, next)) {
2072 : : #if ENABLE_SPECIALIZATION
2073 : 3537147 : _PyForIterCache *cache = (_PyForIterCache *)next_instr;
2074 [ + + ]: 3537147 : if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
2075 : : assert(cframe.use_tracing == 0);
2076 : 3275 : next_instr--;
2077 : 3275 : _Py_Specialize_ForIter(iter, next_instr, oparg);
2078 : 3275 : DISPATCH_SAME_OPARG();
2079 : : }
2080 : : STAT_INC(FOR_ITER, deferred);
2081 : 3533872 : DECREMENT_ADAPTIVE_COUNTER(cache->counter);
2082 : : #endif /* ENABLE_SPECIALIZATION */
2083 : : /* before: [iter]; after: [iter, iter()] *or* [] (and jump over END_FOR.) */
2084 : 3533872 : next = (*Py_TYPE(iter)->tp_iternext)(iter);
2085 [ + + ]: 3533872 : if (next == NULL) {
2086 [ - + ]: 1598645 : if (_PyErr_Occurred(tstate)) {
2087 [ # # ]: 0 : if (!_PyErr_ExceptionMatches(tstate, PyExc_StopIteration)) {
2088 : 0 : goto error;
2089 : : }
2090 [ # # ]: 0 : else if (tstate->c_tracefunc != NULL) {
2091 : 0 : call_exc_trace(tstate->c_tracefunc, tstate->c_traceobj, tstate, frame);
2092 : : }
2093 : 0 : _PyErr_Clear(tstate);
2094 : : }
2095 : : /* iterator ended normally */
2096 : : assert(next_instr[INLINE_CACHE_ENTRIES_FOR_ITER + oparg].op.code == END_FOR);
2097 [ + + ]: 1598645 : Py_DECREF(iter);
2098 : 1598645 : STACK_SHRINK(1);
2099 : : /* Jump forward oparg, then skip following END_FOR instruction */
2100 : 1598645 : JUMPBY(INLINE_CACHE_ENTRIES_FOR_ITER + oparg + 1);
2101 : 1598645 : DISPATCH();
2102 : : }
2103 : : // Common case: no jump, leave it to the code generator
2104 : : }
2105 : :
2106 : : inst(FOR_ITER_LIST, (unused/1, iter -- iter, next)) {
2107 : : assert(cframe.use_tracing == 0);
2108 [ + + ]: 586273 : DEOPT_IF(Py_TYPE(iter) != &PyListIter_Type, FOR_ITER);
2109 : 585806 : _PyListIterObject *it = (_PyListIterObject *)iter;
2110 : : STAT_INC(FOR_ITER, hit);
2111 : 585806 : PyListObject *seq = it->it_seq;
2112 [ + - ]: 585806 : if (seq) {
2113 [ + + ]: 585806 : if (it->it_index < PyList_GET_SIZE(seq)) {
2114 : 578555 : next = Py_NewRef(PyList_GET_ITEM(seq, it->it_index++));
2115 : 578555 : goto end_for_iter_list; // End of this instruction
2116 : : }
2117 : 7251 : it->it_seq = NULL;
2118 [ + + ]: 7251 : Py_DECREF(seq);
2119 : : }
2120 [ + + ]: 7251 : Py_DECREF(iter);
2121 : 7251 : STACK_SHRINK(1);
2122 : : /* Jump forward oparg, then skip following END_FOR instruction */
2123 : 7251 : JUMPBY(INLINE_CACHE_ENTRIES_FOR_ITER + oparg + 1);
2124 : 7251 : DISPATCH();
2125 : 578555 : end_for_iter_list:
2126 : : // Common case: no jump, leave it to the code generator
2127 : : }
2128 : :
2129 : : inst(FOR_ITER_TUPLE, (unused/1, iter -- iter, next)) {
2130 : : assert(cframe.use_tracing == 0);
2131 : 31091 : _PyTupleIterObject *it = (_PyTupleIterObject *)iter;
2132 [ + + ]: 31091 : DEOPT_IF(Py_TYPE(it) != &PyTupleIter_Type, FOR_ITER);
2133 : : STAT_INC(FOR_ITER, hit);
2134 : 30993 : PyTupleObject *seq = it->it_seq;
2135 [ + - ]: 30993 : if (seq) {
2136 [ + + ]: 30993 : if (it->it_index < PyTuple_GET_SIZE(seq)) {
2137 : 21063 : next = Py_NewRef(PyTuple_GET_ITEM(seq, it->it_index++));
2138 : 21063 : goto end_for_iter_tuple; // End of this instruction
2139 : : }
2140 : 9930 : it->it_seq = NULL;
2141 [ + + ]: 9930 : Py_DECREF(seq);
2142 : : }
2143 [ + + ]: 9930 : Py_DECREF(iter);
2144 : 9930 : STACK_SHRINK(1);
2145 : : /* Jump forward oparg, then skip following END_FOR instruction */
2146 : 9930 : JUMPBY(INLINE_CACHE_ENTRIES_FOR_ITER + oparg + 1);
2147 : 9930 : DISPATCH();
2148 : 21063 : end_for_iter_tuple:
2149 : : // Common case: no jump, leave it to the code generator
2150 : : }
2151 : :
2152 : : inst(FOR_ITER_RANGE, (unused/1, iter -- iter, next)) {
2153 : : assert(cframe.use_tracing == 0);
2154 : 594262 : _PyRangeIterObject *r = (_PyRangeIterObject *)iter;
2155 [ + + ]: 594262 : DEOPT_IF(Py_TYPE(r) != &PyRangeIter_Type, FOR_ITER);
2156 : : STAT_INC(FOR_ITER, hit);
2157 [ + + ]: 594209 : if (r->len <= 0) {
2158 : 6989 : STACK_SHRINK(1);
2159 [ + + ]: 6989 : Py_DECREF(r);
2160 : : // Jump over END_FOR instruction.
2161 : 6989 : JUMPBY(INLINE_CACHE_ENTRIES_FOR_ITER + oparg + 1);
2162 : 6989 : DISPATCH();
2163 : : }
2164 : 587220 : long value = r->start;
2165 : 587220 : r->start = value + r->step;
2166 : 587220 : r->len--;
2167 : 587220 : next = PyLong_FromLong(value);
2168 [ - + ]: 587220 : if (next == NULL) {
2169 : 0 : goto error;
2170 : : }
2171 : : }
2172 : :
2173 : : inst(FOR_ITER_GEN, (unused/1, iter -- iter, unused)) {
2174 : : assert(cframe.use_tracing == 0);
2175 : 5388 : PyGenObject *gen = (PyGenObject *)iter;
2176 [ - + ]: 5388 : DEOPT_IF(Py_TYPE(gen) != &PyGen_Type, FOR_ITER);
2177 [ - + ]: 5388 : DEOPT_IF(gen->gi_frame_state >= FRAME_EXECUTING, FOR_ITER);
2178 : : STAT_INC(FOR_ITER, hit);
2179 : 5388 : _PyInterpreterFrame *gen_frame = (_PyInterpreterFrame *)gen->gi_iframe;
2180 : 5388 : frame->yield_offset = oparg;
2181 : 5388 : _PyFrame_StackPush(gen_frame, Py_NewRef(Py_None));
2182 : 5388 : gen->gi_frame_state = FRAME_EXECUTING;
2183 : 5388 : gen->gi_exc_state.previous_item = tstate->exc_info;
2184 : 5388 : tstate->exc_info = &gen->gi_exc_state;
2185 : 5388 : JUMPBY(INLINE_CACHE_ENTRIES_FOR_ITER + oparg);
2186 : : assert(next_instr->op.code == END_FOR);
2187 : 5388 : DISPATCH_INLINED(gen_frame);
2188 : : }
2189 : :
2190 : : inst(BEFORE_ASYNC_WITH, (mgr -- exit, res)) {
2191 : 0 : PyObject *enter = _PyObject_LookupSpecial(mgr, &_Py_ID(__aenter__));
2192 [ # # ]: 0 : if (enter == NULL) {
2193 [ # # ]: 0 : if (!_PyErr_Occurred(tstate)) {
2194 : 0 : _PyErr_Format(tstate, PyExc_TypeError,
2195 : : "'%.200s' object does not support the "
2196 : : "asynchronous context manager protocol",
2197 : 0 : Py_TYPE(mgr)->tp_name);
2198 : : }
2199 : 0 : goto error;
2200 : : }
2201 : 0 : exit = _PyObject_LookupSpecial(mgr, &_Py_ID(__aexit__));
2202 [ # # ]: 0 : if (exit == NULL) {
2203 [ # # ]: 0 : if (!_PyErr_Occurred(tstate)) {
2204 : 0 : _PyErr_Format(tstate, PyExc_TypeError,
2205 : : "'%.200s' object does not support the "
2206 : : "asynchronous context manager protocol "
2207 : : "(missed __aexit__ method)",
2208 : 0 : Py_TYPE(mgr)->tp_name);
2209 : : }
2210 [ # # ]: 0 : Py_DECREF(enter);
2211 : 0 : goto error;
2212 : : }
2213 : : DECREF_INPUTS();
2214 : 0 : res = _PyObject_CallNoArgs(enter);
2215 [ # # ]: 0 : Py_DECREF(enter);
2216 [ # # ]: 0 : if (res == NULL) {
2217 [ # # ]: 0 : Py_DECREF(exit);
2218 : 0 : ERROR_IF(true, error);
2219 : : }
2220 : : PREDICT(GET_AWAITABLE);
2221 : : }
2222 : :
2223 : : inst(BEFORE_WITH, (mgr -- exit, res)) {
2224 : : /* pop the context manager, push its __exit__ and the
2225 : : * value returned from calling its __enter__
2226 : : */
2227 : 106669 : PyObject *enter = _PyObject_LookupSpecial(mgr, &_Py_ID(__enter__));
2228 [ - + ]: 106669 : if (enter == NULL) {
2229 [ # # ]: 0 : if (!_PyErr_Occurred(tstate)) {
2230 : 0 : _PyErr_Format(tstate, PyExc_TypeError,
2231 : : "'%.200s' object does not support the "
2232 : : "context manager protocol",
2233 : 0 : Py_TYPE(mgr)->tp_name);
2234 : : }
2235 : 0 : goto error;
2236 : : }
2237 : 106669 : exit = _PyObject_LookupSpecial(mgr, &_Py_ID(__exit__));
2238 [ - + ]: 106669 : if (exit == NULL) {
2239 [ # # ]: 0 : if (!_PyErr_Occurred(tstate)) {
2240 : 0 : _PyErr_Format(tstate, PyExc_TypeError,
2241 : : "'%.200s' object does not support the "
2242 : : "context manager protocol "
2243 : : "(missed __exit__ method)",
2244 : 0 : Py_TYPE(mgr)->tp_name);
2245 : : }
2246 [ # # ]: 0 : Py_DECREF(enter);
2247 : 0 : goto error;
2248 : : }
2249 : : DECREF_INPUTS();
2250 : 106669 : res = _PyObject_CallNoArgs(enter);
2251 [ + - ]: 106669 : Py_DECREF(enter);
2252 [ - + ]: 106669 : if (res == NULL) {
2253 [ # # ]: 0 : Py_DECREF(exit);
2254 : 0 : ERROR_IF(true, error);
2255 : : }
2256 : : }
2257 : :
2258 : : inst(WITH_EXCEPT_START, (exit_func, lasti, unused, val -- exit_func, lasti, unused, val, res)) {
2259 : : /* At the top of the stack are 4 values:
2260 : : - val: TOP = exc_info()
2261 : : - unused: SECOND = previous exception
2262 : : - lasti: THIRD = lasti of exception in exc_info()
2263 : : - exit_func: FOURTH = the context.__exit__ bound method
2264 : : We call FOURTH(type(TOP), TOP, GetTraceback(TOP)).
2265 : : Then we push the __exit__ return value.
2266 : : */
2267 : : PyObject *exc, *tb;
2268 : :
2269 : : assert(val && PyExceptionInstance_Check(val));
2270 : 293 : exc = PyExceptionInstance_Class(val);
2271 : 293 : tb = PyException_GetTraceback(val);
2272 [ + - - + ]: 293 : Py_XDECREF(tb);
2273 : : assert(PyLong_Check(lasti));
2274 : : (void)lasti; // Shut up compiler warning if asserts are off
2275 : 293 : PyObject *stack[4] = {NULL, exc, val, tb};
2276 : 293 : res = PyObject_Vectorcall(exit_func, stack + 1,
2277 : : 3 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL);
2278 [ - + ]: 293 : ERROR_IF(res == NULL, error);
2279 : : }
2280 : :
2281 : : inst(PUSH_EXC_INFO, (new_exc -- prev_exc, new_exc)) {
2282 : 101972 : _PyErr_StackItem *exc_info = tstate->exc_info;
2283 [ + + ]: 101972 : if (exc_info->exc_value != NULL) {
2284 : 56209 : prev_exc = exc_info->exc_value;
2285 : : }
2286 : : else {
2287 : 45763 : prev_exc = Py_NewRef(Py_None);
2288 : : }
2289 : : assert(PyExceptionInstance_Check(new_exc));
2290 : 101972 : exc_info->exc_value = Py_NewRef(new_exc);
2291 : : }
2292 : :
2293 : : inst(LOAD_ATTR_METHOD_WITH_VALUES, (unused/1, type_version/2, keys_version/2, descr/4, self -- res2 if (oparg & 1), res)) {
2294 : : /* Cached method object */
2295 : : assert(cframe.use_tracing == 0);
2296 : 894487 : PyTypeObject *self_cls = Py_TYPE(self);
2297 : : assert(type_version != 0);
2298 [ + + ]: 894487 : DEOPT_IF(self_cls->tp_version_tag != type_version, LOAD_ATTR);
2299 : : assert(self_cls->tp_flags & Py_TPFLAGS_MANAGED_DICT);
2300 : 893214 : PyDictOrValues dorv = *_PyObject_DictOrValuesPointer(self);
2301 [ - + ]: 893214 : DEOPT_IF(!_PyDictOrValues_IsValues(dorv), LOAD_ATTR);
2302 : 893214 : PyHeapTypeObject *self_heap_type = (PyHeapTypeObject *)self_cls;
2303 [ + + ]: 893214 : DEOPT_IF(self_heap_type->ht_cached_keys->dk_version !=
2304 : : keys_version, LOAD_ATTR);
2305 : : STAT_INC(LOAD_ATTR, hit);
2306 : : assert(descr != NULL);
2307 : 893123 : res2 = Py_NewRef(descr);
2308 : : assert(_PyType_HasFeature(Py_TYPE(res2), Py_TPFLAGS_METHOD_DESCRIPTOR));
2309 [ + - ]: 893123 : res = self;
2310 : : assert(oparg & 1);
2311 : : }
2312 : :
2313 : : inst(LOAD_ATTR_METHOD_NO_DICT, (unused/1, type_version/2, unused/2, descr/4, self -- res2 if (oparg & 1), res)) {
2314 : : assert(cframe.use_tracing == 0);
2315 : 2507024 : PyTypeObject *self_cls = Py_TYPE(self);
2316 [ - + ]: 2507024 : DEOPT_IF(self_cls->tp_version_tag != type_version, LOAD_ATTR);
2317 : : assert(self_cls->tp_dictoffset == 0);
2318 : : STAT_INC(LOAD_ATTR, hit);
2319 : : assert(descr != NULL);
2320 : : assert(_PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_METHOD_DESCRIPTOR));
2321 : 2507024 : res2 = Py_NewRef(descr);
2322 [ + - ]: 2507024 : res = self;
2323 : : assert(oparg & 1);
2324 : : }
2325 : :
2326 : : inst(LOAD_ATTR_METHOD_LAZY_DICT, (unused/1, type_version/2, unused/2, descr/4, self -- res2 if (oparg & 1), res)) {
2327 : : assert(cframe.use_tracing == 0);
2328 : 919 : PyTypeObject *self_cls = Py_TYPE(self);
2329 [ + + ]: 919 : DEOPT_IF(self_cls->tp_version_tag != type_version, LOAD_ATTR);
2330 : 770 : Py_ssize_t dictoffset = self_cls->tp_dictoffset;
2331 : : assert(dictoffset > 0);
2332 : 770 : PyObject *dict = *(PyObject **)((char *)self + dictoffset);
2333 : : /* This object has a __dict__, just not yet created */
2334 [ - + ]: 770 : DEOPT_IF(dict != NULL, LOAD_ATTR);
2335 : : STAT_INC(LOAD_ATTR, hit);
2336 : : assert(descr != NULL);
2337 : : assert(_PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_METHOD_DESCRIPTOR));
2338 : 770 : res2 = Py_NewRef(descr);
2339 [ + - ]: 770 : res = self;
2340 : : assert(oparg & 1);
2341 : : }
2342 : :
2343 : : inst(KW_NAMES, (--)) {
2344 : : assert(kwnames == NULL);
2345 : : assert(oparg < PyTuple_GET_SIZE(frame->f_code->co_consts));
2346 : 175409 : kwnames = GETITEM(frame->f_code->co_consts, oparg);
2347 : : }
2348 : :
2349 : : // Cache layout: counter/1, func_version/2, min_args/1
2350 : : // Neither CALL_INTRINSIC_1/2 nor CALL_FUNCTION_EX are members!
2351 : : family(call, INLINE_CACHE_ENTRIES_CALL) = {
2352 : : CALL,
2353 : : CALL_BOUND_METHOD_EXACT_ARGS,
2354 : : CALL_PY_EXACT_ARGS,
2355 : : CALL_PY_WITH_DEFAULTS,
2356 : : CALL_NO_KW_TYPE_1,
2357 : : CALL_NO_KW_STR_1,
2358 : : CALL_NO_KW_TUPLE_1,
2359 : : CALL_BUILTIN_CLASS,
2360 : : CALL_NO_KW_BUILTIN_O,
2361 : : CALL_NO_KW_BUILTIN_FAST,
2362 : : CALL_BUILTIN_FAST_WITH_KEYWORDS,
2363 : : CALL_NO_KW_LEN,
2364 : : CALL_NO_KW_ISINSTANCE,
2365 : : CALL_NO_KW_LIST_APPEND,
2366 : : CALL_NO_KW_METHOD_DESCRIPTOR_O,
2367 : : CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS,
2368 : : CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS,
2369 : : CALL_NO_KW_METHOD_DESCRIPTOR_FAST,
2370 : : };
2371 : :
2372 : : // On entry, the stack is either
2373 : : // [NULL, callable, arg1, arg2, ...]
2374 : : // or
2375 : : // [method, self, arg1, arg2, ...]
2376 : : // (Some args may be keywords, see KW_NAMES, which sets 'kwnames'.)
2377 : : // On exit, the stack is [result].
2378 : : // When calling Python, inline the call using DISPATCH_INLINED().
2379 : : inst(CALL, (unused/1, unused/2, unused/1, method, callable, args[oparg] -- res)) {
2380 : 3688976 : int is_meth = method != NULL;
2381 : 3688976 : int total_args = oparg;
2382 [ + + ]: 3688976 : if (is_meth) {
2383 : 1857459 : callable = method;
2384 : 1857459 : args--;
2385 : 1857459 : total_args++;
2386 : : }
2387 : : #if ENABLE_SPECIALIZATION
2388 : 3688976 : _PyCallCache *cache = (_PyCallCache *)next_instr;
2389 [ + + ]: 3688976 : if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
2390 : : assert(cframe.use_tracing == 0);
2391 : 21614 : next_instr--;
2392 : 21614 : _Py_Specialize_Call(callable, next_instr, total_args, kwnames);
2393 : 21614 : DISPATCH_SAME_OPARG();
2394 : : }
2395 : : STAT_INC(CALL, deferred);
2396 : 3667362 : DECREMENT_ADAPTIVE_COUNTER(cache->counter);
2397 : : #endif /* ENABLE_SPECIALIZATION */
2398 [ + + + + ]: 3667362 : if (!is_meth && Py_TYPE(callable) == &PyMethod_Type) {
2399 : 153357 : is_meth = 1; // For consistenct; it's dead, though
2400 : 153357 : args--;
2401 : 153357 : total_args++;
2402 : 153357 : PyObject *self = ((PyMethodObject *)callable)->im_self;
2403 : 153357 : args[0] = Py_NewRef(self);
2404 : 153357 : method = ((PyMethodObject *)callable)->im_func;
2405 : 153357 : args[-1] = Py_NewRef(method);
2406 [ + + ]: 153357 : Py_DECREF(callable);
2407 : 153357 : callable = method;
2408 : : }
2409 [ + + ]: 3667362 : int positional_args = total_args - KWNAMES_LEN();
2410 : : // Check if the call can be inlined or not
2411 [ + + ]: 3667362 : if (Py_TYPE(callable) == &PyFunction_Type &&
2412 [ + - ]: 293906 : tstate->interp->eval_frame == NULL &&
2413 [ + - ]: 293906 : ((PyFunctionObject *)callable)->vectorcall == _PyFunction_Vectorcall)
2414 : : {
2415 : 293906 : int code_flags = ((PyCodeObject*)PyFunction_GET_CODE(callable))->co_flags;
2416 [ - + ]: 293906 : PyObject *locals = code_flags & CO_OPTIMIZED ? NULL : Py_NewRef(PyFunction_GET_GLOBALS(callable));
2417 : 293906 : _PyInterpreterFrame *new_frame = _PyEvalFramePushAndInit(
2418 : : tstate, (PyFunctionObject *)callable, locals,
2419 : : args, positional_args, kwnames
2420 : : );
2421 : 293906 : kwnames = NULL;
2422 : : // Manipulate stack directly since we leave using DISPATCH_INLINED().
2423 : 293906 : STACK_SHRINK(oparg + 2);
2424 : : // The frame has stolen all the arguments from the stack,
2425 : : // so there is no need to clean them up.
2426 [ - + ]: 293906 : if (new_frame == NULL) {
2427 : 0 : goto error;
2428 : : }
2429 : 293906 : JUMPBY(INLINE_CACHE_ENTRIES_CALL);
2430 : 293906 : DISPATCH_INLINED(new_frame);
2431 : : }
2432 : : /* Callable is not a normal Python function */
2433 [ - + ]: 3373456 : if (cframe.use_tracing) {
2434 : 0 : res = trace_call_function(
2435 : : tstate, callable, args,
2436 : : positional_args, kwnames);
2437 : : }
2438 : : else {
2439 : 3373456 : res = PyObject_Vectorcall(
2440 : : callable, args,
2441 : : positional_args | PY_VECTORCALL_ARGUMENTS_OFFSET,
2442 : : kwnames);
2443 : : }
2444 : 3373456 : kwnames = NULL;
2445 : : assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL));
2446 [ + + ]: 3373456 : Py_DECREF(callable);
2447 [ + + ]: 8655777 : for (int i = 0; i < total_args; i++) {
2448 [ + + ]: 5282321 : Py_DECREF(args[i]);
2449 : : }
2450 [ + + ]: 3373456 : ERROR_IF(res == NULL, error);
2451 : : CHECK_EVAL_BREAKER();
2452 : : }
2453 : :
2454 : : // Start out with [NULL, bound_method, arg1, arg2, ...]
2455 : : // Transform to [callable, self, arg1, arg2, ...]
2456 : : // Then fall through to CALL_PY_EXACT_ARGS
2457 : : inst(CALL_BOUND_METHOD_EXACT_ARGS, (unused/1, unused/2, unused/1, method, callable, unused[oparg] -- unused)) {
2458 [ + + ]: 671078 : DEOPT_IF(method != NULL, CALL);
2459 [ - + ]: 569357 : DEOPT_IF(Py_TYPE(callable) != &PyMethod_Type, CALL);
2460 : : STAT_INC(CALL, hit);
2461 : 569357 : PyObject *self = ((PyMethodObject *)callable)->im_self;
2462 : 569357 : PEEK(oparg + 1) = Py_NewRef(self); // callable
2463 : 569357 : PyObject *meth = ((PyMethodObject *)callable)->im_func;
2464 : 569357 : PEEK(oparg + 2) = Py_NewRef(meth); // method
2465 [ + + ]: 569357 : Py_DECREF(callable);
2466 : 569357 : GO_TO_INSTRUCTION(CALL_PY_EXACT_ARGS);
2467 : : }
2468 : :
2469 : : inst(CALL_PY_EXACT_ARGS, (unused/1, func_version/2, unused/1, method, callable, args[oparg] -- unused)) {
2470 : : assert(kwnames == NULL);
2471 [ - + ]: 1931482 : DEOPT_IF(tstate->interp->eval_frame, CALL);
2472 : 1931482 : int is_meth = method != NULL;
2473 : 1931482 : int argcount = oparg;
2474 [ + + ]: 1931482 : if (is_meth) {
2475 : 1316183 : callable = method;
2476 : 1316183 : args--;
2477 : 1316183 : argcount++;
2478 : : }
2479 [ + + ]: 1931482 : DEOPT_IF(!PyFunction_Check(callable), CALL);
2480 : 1930934 : PyFunctionObject *func = (PyFunctionObject *)callable;
2481 [ + + ]: 1930934 : DEOPT_IF(func->func_version != func_version, CALL);
2482 : 1917451 : PyCodeObject *code = (PyCodeObject *)func->func_code;
2483 [ - + ]: 1917451 : DEOPT_IF(code->co_argcount != argcount, CALL);
2484 [ - + ]: 1917451 : DEOPT_IF(!_PyThreadState_HasStackSpace(tstate, code->co_framesize), CALL);
2485 : : STAT_INC(CALL, hit);
2486 : 1917451 : _PyInterpreterFrame *new_frame = _PyFrame_PushUnchecked(tstate, func, argcount);
2487 [ + + ]: 6127110 : for (int i = 0; i < argcount; i++) {
2488 : 4209659 : new_frame->localsplus[i] = args[i];
2489 : : }
2490 : : // Manipulate stack directly since we leave using DISPATCH_INLINED().
2491 : 1917451 : STACK_SHRINK(oparg + 2);
2492 : 1917451 : JUMPBY(INLINE_CACHE_ENTRIES_CALL);
2493 : 1917451 : DISPATCH_INLINED(new_frame);
2494 : : }
2495 : :
2496 : : inst(CALL_PY_WITH_DEFAULTS, (unused/1, func_version/2, min_args/1, method, callable, args[oparg] -- unused)) {
2497 : : assert(kwnames == NULL);
2498 [ - + ]: 222502 : DEOPT_IF(tstate->interp->eval_frame, CALL);
2499 : 222502 : int is_meth = method != NULL;
2500 : 222502 : int argcount = oparg;
2501 [ + + ]: 222502 : if (is_meth) {
2502 : 214989 : callable = method;
2503 : 214989 : args--;
2504 : 214989 : argcount++;
2505 : : }
2506 [ - + ]: 222502 : DEOPT_IF(!PyFunction_Check(callable), CALL);
2507 : 222502 : PyFunctionObject *func = (PyFunctionObject *)callable;
2508 [ - + ]: 222502 : DEOPT_IF(func->func_version != func_version, CALL);
2509 : 222502 : PyCodeObject *code = (PyCodeObject *)func->func_code;
2510 [ - + ]: 222502 : DEOPT_IF(argcount > code->co_argcount, CALL);
2511 [ - + ]: 222502 : DEOPT_IF(argcount < min_args, CALL);
2512 [ - + ]: 222502 : DEOPT_IF(!_PyThreadState_HasStackSpace(tstate, code->co_framesize), CALL);
2513 : : STAT_INC(CALL, hit);
2514 : 222502 : _PyInterpreterFrame *new_frame = _PyFrame_PushUnchecked(tstate, func, code->co_argcount);
2515 [ + + ]: 856571 : for (int i = 0; i < argcount; i++) {
2516 : 634069 : new_frame->localsplus[i] = args[i];
2517 : : }
2518 [ + + ]: 445406 : for (int i = argcount; i < code->co_argcount; i++) {
2519 : 222904 : PyObject *def = PyTuple_GET_ITEM(func->func_defaults, i - min_args);
2520 : 222904 : new_frame->localsplus[i] = Py_NewRef(def);
2521 : : }
2522 : : // Manipulate stack and cache directly since we leave using DISPATCH_INLINED().
2523 : 222502 : STACK_SHRINK(oparg + 2);
2524 : 222502 : JUMPBY(INLINE_CACHE_ENTRIES_CALL);
2525 : 222502 : DISPATCH_INLINED(new_frame);
2526 : : }
2527 : :
2528 : : inst(CALL_NO_KW_TYPE_1, (unused/1, unused/2, unused/1, null, callable, args[oparg] -- res)) {
2529 : : assert(kwnames == NULL);
2530 : : assert(cframe.use_tracing == 0);
2531 : : assert(oparg == 1);
2532 [ - + ]: 597184 : DEOPT_IF(null != NULL, CALL);
2533 : 597184 : PyObject *obj = args[0];
2534 [ - + ]: 597184 : DEOPT_IF(callable != (PyObject *)&PyType_Type, CALL);
2535 : : STAT_INC(CALL, hit);
2536 : 597184 : res = Py_NewRef(Py_TYPE(obj));
2537 [ - + ]: 597184 : Py_DECREF(obj);
2538 [ - + ]: 597184 : Py_DECREF(&PyType_Type); // I.e., callable
2539 : : }
2540 : :
2541 : : inst(CALL_NO_KW_STR_1, (unused/1, unused/2, unused/1, null, callable, args[oparg] -- res)) {
2542 : : assert(kwnames == NULL);
2543 : : assert(cframe.use_tracing == 0);
2544 : : assert(oparg == 1);
2545 [ - + ]: 262860 : DEOPT_IF(null != NULL, CALL);
2546 [ - + ]: 262860 : DEOPT_IF(callable != (PyObject *)&PyUnicode_Type, CALL);
2547 : : STAT_INC(CALL, hit);
2548 : 262860 : PyObject *arg = args[0];
2549 : 262860 : res = PyObject_Str(arg);
2550 [ - + ]: 262860 : Py_DECREF(arg);
2551 [ - + ]: 262860 : Py_DECREF(&PyUnicode_Type); // I.e., callable
2552 [ - + ]: 262860 : ERROR_IF(res == NULL, error);
2553 : : CHECK_EVAL_BREAKER();
2554 : : }
2555 : :
2556 : : inst(CALL_NO_KW_TUPLE_1, (unused/1, unused/2, unused/1, null, callable, args[oparg] -- res)) {
2557 : : assert(kwnames == NULL);
2558 : : assert(oparg == 1);
2559 [ - + ]: 10082 : DEOPT_IF(null != NULL, CALL);
2560 [ - + ]: 10082 : DEOPT_IF(callable != (PyObject *)&PyTuple_Type, CALL);
2561 : : STAT_INC(CALL, hit);
2562 : 10082 : PyObject *arg = args[0];
2563 : 10082 : res = PySequence_Tuple(arg);
2564 [ + + ]: 10082 : Py_DECREF(arg);
2565 [ - + ]: 10082 : Py_DECREF(&PyTuple_Type); // I.e., tuple
2566 [ - + ]: 10082 : ERROR_IF(res == NULL, error);
2567 : : CHECK_EVAL_BREAKER();
2568 : : }
2569 : :
2570 : : inst(CALL_BUILTIN_CLASS, (unused/1, unused/2, unused/1, method, callable, args[oparg] -- res)) {
2571 : 358271 : int is_meth = method != NULL;
2572 : 358271 : int total_args = oparg;
2573 [ - + ]: 358271 : if (is_meth) {
2574 : 0 : callable = method;
2575 : 0 : args--;
2576 : 0 : total_args++;
2577 : : }
2578 [ + + ]: 358271 : int kwnames_len = KWNAMES_LEN();
2579 [ - + ]: 358271 : DEOPT_IF(!PyType_Check(callable), CALL);
2580 : 358271 : PyTypeObject *tp = (PyTypeObject *)callable;
2581 [ - + ]: 358271 : DEOPT_IF(tp->tp_vectorcall == NULL, CALL);
2582 : : STAT_INC(CALL, hit);
2583 : 358271 : res = tp->tp_vectorcall((PyObject *)tp, args,
2584 : 358271 : total_args - kwnames_len, kwnames);
2585 : 358271 : kwnames = NULL;
2586 : : /* Free the arguments. */
2587 [ + + ]: 994967 : for (int i = 0; i < total_args; i++) {
2588 [ + + ]: 636696 : Py_DECREF(args[i]);
2589 : : }
2590 [ - + ]: 358271 : Py_DECREF(tp);
2591 [ - + ]: 358271 : ERROR_IF(res == NULL, error);
2592 : : CHECK_EVAL_BREAKER();
2593 : : }
2594 : :
2595 : : inst(CALL_NO_KW_BUILTIN_O, (unused/1, unused/2, unused/1, method, callable, args[oparg] -- res)) {
2596 : : assert(cframe.use_tracing == 0);
2597 : : /* Builtin METH_O functions */
2598 : : assert(kwnames == NULL);
2599 : 1570932 : int is_meth = method != NULL;
2600 : 1570932 : int total_args = oparg;
2601 [ - + ]: 1570932 : if (is_meth) {
2602 : 0 : callable = method;
2603 : 0 : args--;
2604 : 0 : total_args++;
2605 : : }
2606 [ - + ]: 1570932 : DEOPT_IF(total_args != 1, CALL);
2607 [ - + ]: 1570932 : DEOPT_IF(!PyCFunction_CheckExact(callable), CALL);
2608 [ + + ]: 1570932 : DEOPT_IF(PyCFunction_GET_FLAGS(callable) != METH_O, CALL);
2609 : : STAT_INC(CALL, hit);
2610 : 1570384 : PyCFunction cfunc = PyCFunction_GET_FUNCTION(callable);
2611 : : // This is slower but CPython promises to check all non-vectorcall
2612 : : // function calls.
2613 [ - + ]: 1570384 : if (_Py_EnterRecursiveCallTstate(tstate, " while calling a Python object")) {
2614 : 0 : goto error;
2615 : : }
2616 : 1570384 : PyObject *arg = args[0];
2617 : 1570384 : res = _PyCFunction_TrampolineCall(cfunc, PyCFunction_GET_SELF(callable), arg);
2618 : 1570384 : _Py_LeaveRecursiveCallTstate(tstate);
2619 : : assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL));
2620 : :
2621 [ + + ]: 1570384 : Py_DECREF(arg);
2622 [ + + ]: 1570384 : Py_DECREF(callable);
2623 [ + + ]: 1570384 : ERROR_IF(res == NULL, error);
2624 : : CHECK_EVAL_BREAKER();
2625 : : }
2626 : :
2627 : : inst(CALL_NO_KW_BUILTIN_FAST, (unused/1, unused/2, unused/1, method, callable, args[oparg] -- res)) {
2628 : : assert(cframe.use_tracing == 0);
2629 : : /* Builtin METH_FASTCALL functions, without keywords */
2630 : : assert(kwnames == NULL);
2631 : 1210517 : int is_meth = method != NULL;
2632 : 1210517 : int total_args = oparg;
2633 [ - + ]: 1210517 : if (is_meth) {
2634 : 0 : callable = method;
2635 : 0 : args--;
2636 : 0 : total_args++;
2637 : : }
2638 [ - + ]: 1210517 : DEOPT_IF(!PyCFunction_CheckExact(callable), CALL);
2639 [ + + ]: 1210517 : DEOPT_IF(PyCFunction_GET_FLAGS(callable) != METH_FASTCALL, CALL);
2640 : : STAT_INC(CALL, hit);
2641 : 1210370 : PyCFunction cfunc = PyCFunction_GET_FUNCTION(callable);
2642 : : /* res = func(self, args, nargs) */
2643 : 1210370 : res = ((_PyCFunctionFast)(void(*)(void))cfunc)(
2644 : : PyCFunction_GET_SELF(callable),
2645 : : args,
2646 : : total_args);
2647 : : assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL));
2648 : :
2649 : : /* Free the arguments. */
2650 [ + + ]: 3546933 : for (int i = 0; i < total_args; i++) {
2651 [ + + ]: 2336563 : Py_DECREF(args[i]);
2652 : : }
2653 [ + + ]: 1210370 : Py_DECREF(callable);
2654 [ + + ]: 1210370 : ERROR_IF(res == NULL, error);
2655 : : /* Not deopting because this doesn't mean our optimization was
2656 : : wrong. `res` can be NULL for valid reasons. Eg. getattr(x,
2657 : : 'invalid'). In those cases an exception is set, so we must
2658 : : handle it.
2659 : : */
2660 : : CHECK_EVAL_BREAKER();
2661 : : }
2662 : :
2663 : : inst(CALL_BUILTIN_FAST_WITH_KEYWORDS, (unused/1, unused/2, unused/1, method, callable, args[oparg] -- res)) {
2664 : : assert(cframe.use_tracing == 0);
2665 : : /* Builtin METH_FASTCALL | METH_KEYWORDS functions */
2666 : 12250 : int is_meth = method != NULL;
2667 : 12250 : int total_args = oparg;
2668 [ - + ]: 12250 : if (is_meth) {
2669 : 0 : callable = method;
2670 : 0 : args--;
2671 : 0 : total_args++;
2672 : : }
2673 [ - + ]: 12250 : DEOPT_IF(!PyCFunction_CheckExact(callable), CALL);
2674 [ + + ]: 12250 : DEOPT_IF(PyCFunction_GET_FLAGS(callable) !=
2675 : : (METH_FASTCALL | METH_KEYWORDS), CALL);
2676 : : STAT_INC(CALL, hit);
2677 : : /* res = func(self, args, nargs, kwnames) */
2678 : : _PyCFunctionFastWithKeywords cfunc =
2679 : : (_PyCFunctionFastWithKeywords)(void(*)(void))
2680 : 11111 : PyCFunction_GET_FUNCTION(callable);
2681 : 11111 : res = cfunc(
2682 : : PyCFunction_GET_SELF(callable),
2683 : : args,
2684 [ + + ]: 11111 : total_args - KWNAMES_LEN(),
2685 : : kwnames
2686 : : );
2687 : : assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL));
2688 : 11111 : kwnames = NULL;
2689 : :
2690 : : /* Free the arguments. */
2691 [ + + ]: 24415 : for (int i = 0; i < total_args; i++) {
2692 [ + + ]: 13304 : Py_DECREF(args[i]);
2693 : : }
2694 [ - + ]: 11111 : Py_DECREF(callable);
2695 [ + + ]: 11111 : ERROR_IF(res == NULL, error);
2696 : : CHECK_EVAL_BREAKER();
2697 : : }
2698 : :
2699 : : inst(CALL_NO_KW_LEN, (unused/1, unused/2, unused/1, method, callable, args[oparg] -- res)) {
2700 : : assert(cframe.use_tracing == 0);
2701 : : assert(kwnames == NULL);
2702 : : /* len(o) */
2703 : 44344 : int is_meth = method != NULL;
2704 : 44344 : int total_args = oparg;
2705 [ - + ]: 44344 : if (is_meth) {
2706 : 0 : callable = method;
2707 : 0 : args--;
2708 : 0 : total_args++;
2709 : : }
2710 [ - + ]: 44344 : DEOPT_IF(total_args != 1, CALL);
2711 : 44344 : PyInterpreterState *interp = _PyInterpreterState_GET();
2712 [ - + ]: 44344 : DEOPT_IF(callable != interp->callable_cache.len, CALL);
2713 : : STAT_INC(CALL, hit);
2714 : 44344 : PyObject *arg = args[0];
2715 : 44344 : Py_ssize_t len_i = PyObject_Length(arg);
2716 [ - + ]: 44344 : if (len_i < 0) {
2717 : 0 : goto error;
2718 : : }
2719 : 44344 : res = PyLong_FromSsize_t(len_i);
2720 : : assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL));
2721 : :
2722 [ - + ]: 44344 : Py_DECREF(callable);
2723 [ + + ]: 44344 : Py_DECREF(arg);
2724 [ - + ]: 44344 : ERROR_IF(res == NULL, error);
2725 : : }
2726 : :
2727 : : inst(CALL_NO_KW_ISINSTANCE, (unused/1, unused/2, unused/1, method, callable, args[oparg] -- res)) {
2728 : : assert(cframe.use_tracing == 0);
2729 : : assert(kwnames == NULL);
2730 : : /* isinstance(o, o2) */
2731 : 588295 : int is_meth = method != NULL;
2732 : 588295 : int total_args = oparg;
2733 [ - + ]: 588295 : if (is_meth) {
2734 : 0 : callable = method;
2735 : 0 : args--;
2736 : 0 : total_args++;
2737 : : }
2738 [ - + ]: 588295 : DEOPT_IF(total_args != 2, CALL);
2739 : 588295 : PyInterpreterState *interp = _PyInterpreterState_GET();
2740 [ - + ]: 588295 : DEOPT_IF(callable != interp->callable_cache.isinstance, CALL);
2741 : : STAT_INC(CALL, hit);
2742 : 588295 : PyObject *cls = args[1];
2743 : 588295 : PyObject *inst = args[0];
2744 : 588295 : int retval = PyObject_IsInstance(inst, cls);
2745 [ - + ]: 588295 : if (retval < 0) {
2746 : 0 : goto error;
2747 : : }
2748 : 588295 : res = PyBool_FromLong(retval);
2749 : : assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL));
2750 : :
2751 [ - + ]: 588295 : Py_DECREF(inst);
2752 [ + + ]: 588295 : Py_DECREF(cls);
2753 [ - + ]: 588295 : Py_DECREF(callable);
2754 [ - + ]: 588295 : ERROR_IF(res == NULL, error);
2755 : : }
2756 : :
2757 : : // This is secretly a super-instruction
2758 : : inst(CALL_NO_KW_LIST_APPEND, (unused/1, unused/2, unused/1, method, self, args[oparg] -- unused)) {
2759 : : assert(cframe.use_tracing == 0);
2760 : : assert(kwnames == NULL);
2761 : : assert(oparg == 1);
2762 : : assert(method != NULL);
2763 : 498519 : PyInterpreterState *interp = _PyInterpreterState_GET();
2764 [ - + ]: 498519 : DEOPT_IF(method != interp->callable_cache.list_append, CALL);
2765 [ - + ]: 498519 : DEOPT_IF(!PyList_Check(self), CALL);
2766 : : STAT_INC(CALL, hit);
2767 [ - + ]: 498519 : if (_PyList_AppendTakeRef((PyListObject *)self, args[0]) < 0) {
2768 : 0 : goto pop_1_error; // Since arg is DECREF'ed already
2769 : : }
2770 [ - + ]: 498519 : Py_DECREF(self);
2771 [ - + ]: 498519 : Py_DECREF(method);
2772 : 498519 : STACK_SHRINK(3);
2773 : : // CALL + POP_TOP
2774 : 498519 : JUMPBY(INLINE_CACHE_ENTRIES_CALL + 1);
2775 : : assert(next_instr[-1].op.code == POP_TOP);
2776 : 498519 : DISPATCH();
2777 : : }
2778 : :
2779 : : inst(CALL_NO_KW_METHOD_DESCRIPTOR_O, (unused/1, unused/2, unused/1, method, unused, args[oparg] -- res)) {
2780 : : assert(kwnames == NULL);
2781 : 237456 : int is_meth = method != NULL;
2782 : 237456 : int total_args = oparg;
2783 [ + - ]: 237456 : if (is_meth) {
2784 : 237456 : args--;
2785 : 237456 : total_args++;
2786 : : }
2787 : 237456 : PyMethodDescrObject *callable =
2788 : 237456 : (PyMethodDescrObject *)PEEK(total_args + 1);
2789 [ - + ]: 237456 : DEOPT_IF(total_args != 2, CALL);
2790 [ - + ]: 237456 : DEOPT_IF(!Py_IS_TYPE(callable, &PyMethodDescr_Type), CALL);
2791 : 237456 : PyMethodDef *meth = callable->d_method;
2792 [ - + ]: 237456 : DEOPT_IF(meth->ml_flags != METH_O, CALL);
2793 : 237456 : PyObject *arg = args[1];
2794 : 237456 : PyObject *self = args[0];
2795 [ + + ]: 237456 : DEOPT_IF(!Py_IS_TYPE(self, callable->d_common.d_type), CALL);
2796 : : STAT_INC(CALL, hit);
2797 : 87921 : PyCFunction cfunc = meth->ml_meth;
2798 : : // This is slower but CPython promises to check all non-vectorcall
2799 : : // function calls.
2800 [ - + ]: 87921 : if (_Py_EnterRecursiveCallTstate(tstate, " while calling a Python object")) {
2801 : 0 : goto error;
2802 : : }
2803 : 87921 : res = _PyCFunction_TrampolineCall(cfunc, self, arg);
2804 : 87921 : _Py_LeaveRecursiveCallTstate(tstate);
2805 : : assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL));
2806 [ - + ]: 87921 : Py_DECREF(self);
2807 [ + + ]: 87921 : Py_DECREF(arg);
2808 [ - + ]: 87921 : Py_DECREF(callable);
2809 [ + + ]: 87921 : ERROR_IF(res == NULL, error);
2810 : : CHECK_EVAL_BREAKER();
2811 : : }
2812 : :
2813 : : inst(CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS, (unused/1, unused/2, unused/1, method, unused, args[oparg] -- res)) {
2814 : 20601 : int is_meth = method != NULL;
2815 : 20601 : int total_args = oparg;
2816 [ + - ]: 20601 : if (is_meth) {
2817 : 20601 : args--;
2818 : 20601 : total_args++;
2819 : : }
2820 : 20601 : PyMethodDescrObject *callable =
2821 : 20601 : (PyMethodDescrObject *)PEEK(total_args + 1);
2822 [ - + ]: 20601 : DEOPT_IF(!Py_IS_TYPE(callable, &PyMethodDescr_Type), CALL);
2823 : 20601 : PyMethodDef *meth = callable->d_method;
2824 [ - + ]: 20601 : DEOPT_IF(meth->ml_flags != (METH_FASTCALL|METH_KEYWORDS), CALL);
2825 : 20601 : PyTypeObject *d_type = callable->d_common.d_type;
2826 : 20601 : PyObject *self = args[0];
2827 [ - + ]: 20601 : DEOPT_IF(!Py_IS_TYPE(self, d_type), CALL);
2828 : : STAT_INC(CALL, hit);
2829 : 20601 : int nargs = total_args - 1;
2830 : 20601 : _PyCFunctionFastWithKeywords cfunc =
2831 : : (_PyCFunctionFastWithKeywords)(void(*)(void))meth->ml_meth;
2832 [ - + ]: 20601 : res = cfunc(self, args + 1, nargs - KWNAMES_LEN(), kwnames);
2833 : : assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL));
2834 : 20601 : kwnames = NULL;
2835 : :
2836 : : /* Free the arguments. */
2837 [ + + ]: 56413 : for (int i = 0; i < total_args; i++) {
2838 [ + + ]: 35812 : Py_DECREF(args[i]);
2839 : : }
2840 [ - + ]: 20601 : Py_DECREF(callable);
2841 [ - + ]: 20601 : ERROR_IF(res == NULL, error);
2842 : : CHECK_EVAL_BREAKER();
2843 : : }
2844 : :
2845 : : inst(CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS, (unused/1, unused/2, unused/1, method, unused, args[oparg] -- res)) {
2846 : : assert(kwnames == NULL);
2847 : : assert(oparg == 0 || oparg == 1);
2848 : 298114 : int is_meth = method != NULL;
2849 : 298114 : int total_args = oparg;
2850 [ + + ]: 298114 : if (is_meth) {
2851 : 298058 : args--;
2852 : 298058 : total_args++;
2853 : : }
2854 [ - + ]: 298114 : DEOPT_IF(total_args != 1, CALL);
2855 : 298114 : PyMethodDescrObject *callable = (PyMethodDescrObject *)SECOND();
2856 [ - + ]: 298114 : DEOPT_IF(!Py_IS_TYPE(callable, &PyMethodDescr_Type), CALL);
2857 : 298114 : PyMethodDef *meth = callable->d_method;
2858 : 298114 : PyObject *self = args[0];
2859 [ + + ]: 298114 : DEOPT_IF(!Py_IS_TYPE(self, callable->d_common.d_type), CALL);
2860 [ - + ]: 296088 : DEOPT_IF(meth->ml_flags != METH_NOARGS, CALL);
2861 : : STAT_INC(CALL, hit);
2862 : 296088 : PyCFunction cfunc = meth->ml_meth;
2863 : : // This is slower but CPython promises to check all non-vectorcall
2864 : : // function calls.
2865 [ - + ]: 296088 : if (_Py_EnterRecursiveCallTstate(tstate, " while calling a Python object")) {
2866 : 0 : goto error;
2867 : : }
2868 : 296088 : res = _PyCFunction_TrampolineCall(cfunc, self, NULL);
2869 : 296088 : _Py_LeaveRecursiveCallTstate(tstate);
2870 : : assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL));
2871 [ + + ]: 296088 : Py_DECREF(self);
2872 [ - + ]: 296088 : Py_DECREF(callable);
2873 [ + + ]: 296088 : ERROR_IF(res == NULL, error);
2874 : : CHECK_EVAL_BREAKER();
2875 : : }
2876 : :
2877 : : inst(CALL_NO_KW_METHOD_DESCRIPTOR_FAST, (unused/1, unused/2, unused/1, method, unused, args[oparg] -- res)) {
2878 : : assert(kwnames == NULL);
2879 : 164246 : int is_meth = method != NULL;
2880 : 164246 : int total_args = oparg;
2881 [ + + ]: 164246 : if (is_meth) {
2882 : 164190 : args--;
2883 : 164190 : total_args++;
2884 : : }
2885 : 164246 : PyMethodDescrObject *callable =
2886 : 164246 : (PyMethodDescrObject *)PEEK(total_args + 1);
2887 : : /* Builtin METH_FASTCALL methods, without keywords */
2888 [ - + ]: 164246 : DEOPT_IF(!Py_IS_TYPE(callable, &PyMethodDescr_Type), CALL);
2889 : 164246 : PyMethodDef *meth = callable->d_method;
2890 [ - + ]: 164246 : DEOPT_IF(meth->ml_flags != METH_FASTCALL, CALL);
2891 : 164246 : PyObject *self = args[0];
2892 [ + + ]: 164246 : DEOPT_IF(!Py_IS_TYPE(self, callable->d_common.d_type), CALL);
2893 : : STAT_INC(CALL, hit);
2894 : 164029 : _PyCFunctionFast cfunc =
2895 : : (_PyCFunctionFast)(void(*)(void))meth->ml_meth;
2896 : 164029 : int nargs = total_args - 1;
2897 : 164029 : res = cfunc(self, args + 1, nargs);
2898 : : assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL));
2899 : : /* Clear the stack of the arguments. */
2900 [ + + ]: 491170 : for (int i = 0; i < total_args; i++) {
2901 [ + + ]: 327141 : Py_DECREF(args[i]);
2902 : : }
2903 [ - + ]: 164029 : Py_DECREF(callable);
2904 [ + + ]: 164029 : ERROR_IF(res == NULL, error);
2905 : : CHECK_EVAL_BREAKER();
2906 : : }
2907 : :
2908 : : inst(CALL_FUNCTION_EX, (unused, func, callargs, kwargs if (oparg & 1) -- result)) {
2909 : 103224 : if (oparg & 1) {
2910 : : // DICT_MERGE is called before this opcode if there are kwargs.
2911 : : // It converts all dict subtypes in kwargs into regular dicts.
2912 : : assert(PyDict_CheckExact(kwargs));
2913 : : }
2914 [ + + ]: 103224 : if (!PyTuple_CheckExact(callargs)) {
2915 [ - + ]: 302 : if (check_args_iterable(tstate, func, callargs) < 0) {
2916 : 0 : goto error;
2917 : : }
2918 : 302 : PyObject *tuple = PySequence_Tuple(callargs);
2919 [ - + ]: 302 : if (tuple == NULL) {
2920 : 0 : goto error;
2921 : : }
2922 [ + + ]: 302 : Py_SETREF(callargs, tuple);
2923 : : }
2924 : : assert(PyTuple_CheckExact(callargs));
2925 : :
2926 : 103224 : result = do_call_core(tstate, func, callargs, kwargs, cframe.use_tracing);
2927 : : DECREF_INPUTS();
2928 : :
2929 : : assert(PEEK(3 + (oparg & 1)) == NULL);
2930 [ + + ]: 103224 : ERROR_IF(result == NULL, error);
2931 : : CHECK_EVAL_BREAKER();
2932 : : }
2933 : :
2934 : : inst(MAKE_FUNCTION, (defaults if (oparg & 0x01),
2935 : : kwdefaults if (oparg & 0x02),
2936 : : annotations if (oparg & 0x04),
2937 : : closure if (oparg & 0x08),
2938 : : codeobj -- func)) {
2939 : :
2940 : : PyFunctionObject *func_obj = (PyFunctionObject *)
2941 : 197280 : PyFunction_New(codeobj, GLOBALS());
2942 : :
2943 [ - + ]: 197280 : Py_DECREF(codeobj);
2944 [ - + ]: 197280 : if (func_obj == NULL) {
2945 : 0 : goto error;
2946 : : }
2947 : :
2948 [ + + ]: 197280 : if (oparg & 0x08) {
2949 : : assert(PyTuple_CheckExact(closure));
2950 : 25355 : func_obj->func_closure = closure;
2951 : : }
2952 [ + + ]: 197280 : if (oparg & 0x04) {
2953 : : assert(PyTuple_CheckExact(annotations));
2954 : 18213 : func_obj->func_annotations = annotations;
2955 : : }
2956 [ + + ]: 197280 : if (oparg & 0x02) {
2957 : : assert(PyDict_CheckExact(kwdefaults));
2958 : 688 : func_obj->func_kwdefaults = kwdefaults;
2959 : : }
2960 [ + + ]: 197280 : if (oparg & 0x01) {
2961 : : assert(PyTuple_CheckExact(defaults));
2962 : 4932 : func_obj->func_defaults = defaults;
2963 : : }
2964 : :
2965 : 197280 : func_obj->func_version = ((PyCodeObject *)codeobj)->co_version;
2966 : 197280 : func = (PyObject *)func_obj;
2967 : : }
2968 : :
2969 : : inst(RETURN_GENERATOR, (--)) {
2970 : : assert(PyFunction_Check(frame->f_funcobj));
2971 : 122420 : PyFunctionObject *func = (PyFunctionObject *)frame->f_funcobj;
2972 : 122420 : PyGenObject *gen = (PyGenObject *)_Py_MakeCoro(func);
2973 [ - + ]: 122420 : if (gen == NULL) {
2974 : 0 : goto error;
2975 : : }
2976 : : assert(EMPTY());
2977 : 122420 : _PyFrame_SetStackPointer(frame, stack_pointer);
2978 : 122420 : _PyInterpreterFrame *gen_frame = (_PyInterpreterFrame *)gen->gi_iframe;
2979 : 122420 : _PyFrame_Copy(frame, gen_frame);
2980 : : assert(frame->frame_obj == NULL);
2981 : 122420 : gen->gi_frame_state = FRAME_CREATED;
2982 : 122420 : gen_frame->owner = FRAME_OWNED_BY_GENERATOR;
2983 : 122420 : _Py_LeaveRecursiveCallPy(tstate);
2984 : : assert(frame != &entry_frame);
2985 : 122420 : _PyInterpreterFrame *prev = frame->previous;
2986 : 122420 : _PyThreadState_PopFrame(tstate, frame);
2987 : 122420 : frame = cframe.current_frame = prev;
2988 : 122420 : _PyFrame_StackPush(frame, (PyObject *)gen);
2989 : 122420 : goto resume_frame;
2990 : : }
2991 : :
2992 : : inst(BUILD_SLICE, (start, stop, step if (oparg == 3) -- slice)) {
2993 : 1181 : slice = PySlice_New(start, stop, step);
2994 : : DECREF_INPUTS();
2995 [ - + ]: 1181 : ERROR_IF(slice == NULL, error);
2996 : : }
2997 : :
2998 : : inst(FORMAT_VALUE, (value, fmt_spec if ((oparg & FVS_MASK) == FVS_HAVE_SPEC) -- result)) {
2999 : : /* Handles f-string value formatting. */
3000 : : PyObject *(*conv_fn)(PyObject *);
3001 : 362437 : int which_conversion = oparg & FVC_MASK;
3002 : :
3003 : : /* See if any conversion is specified. */
3004 [ + + + - : 362437 : switch (which_conversion) {
- ]
3005 : 358656 : case FVC_NONE: conv_fn = NULL; break;
3006 : 2924 : case FVC_STR: conv_fn = PyObject_Str; break;
3007 : 857 : case FVC_REPR: conv_fn = PyObject_Repr; break;
3008 : 0 : case FVC_ASCII: conv_fn = PyObject_ASCII; break;
3009 : 0 : default:
3010 : 0 : _PyErr_Format(tstate, PyExc_SystemError,
3011 : : "unexpected conversion flag %d",
3012 : : which_conversion);
3013 : 0 : goto error;
3014 : : }
3015 : :
3016 : : /* If there's a conversion function, call it and replace
3017 : : value with that result. Otherwise, just use value,
3018 : : without conversion. */
3019 [ + + ]: 362437 : if (conv_fn != NULL) {
3020 : 3781 : result = conv_fn(value);
3021 [ - + ]: 3781 : Py_DECREF(value);
3022 [ - + ]: 3781 : if (result == NULL) {
3023 [ # # # # ]: 0 : Py_XDECREF(fmt_spec);
3024 : 0 : ERROR_IF(true, error);
3025 : : }
3026 : 3781 : value = result;
3027 : : }
3028 : :
3029 : : /* If value is a unicode object, and there's no fmt_spec,
3030 : : then we know the result of format(value) is value
3031 : : itself. In that case, skip calling format(). I plan to
3032 : : move this optimization in to PyObject_Format()
3033 : : itself. */
3034 [ + + + - ]: 362437 : if (PyUnicode_CheckExact(value) && fmt_spec == NULL) {
3035 : : /* Do nothing, just transfer ownership to result. */
3036 : 58397 : result = value;
3037 : : } else {
3038 : : /* Actually call format(). */
3039 : 304040 : result = PyObject_Format(value, fmt_spec);
3040 : : DECREF_INPUTS();
3041 [ - + ]: 304040 : ERROR_IF(result == NULL, error);
3042 : : }
3043 : : }
3044 : :
3045 : : inst(COPY, (bottom, unused[oparg-1] -- bottom, unused[oparg-1], top)) {
3046 : : assert(oparg > 0);
3047 : 225025 : top = Py_NewRef(bottom);
3048 : : }
3049 : :
3050 : : inst(BINARY_OP, (unused/1, lhs, rhs -- res)) {
3051 : : #if ENABLE_SPECIALIZATION
3052 : 2224339 : _PyBinaryOpCache *cache = (_PyBinaryOpCache *)next_instr;
3053 [ + + ]: 2224339 : if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
3054 : : assert(cframe.use_tracing == 0);
3055 : 3401 : next_instr--;
3056 : 3401 : _Py_Specialize_BinaryOp(lhs, rhs, next_instr, oparg, &GETLOCAL(0));
3057 : 3401 : DISPATCH_SAME_OPARG();
3058 : : }
3059 : : STAT_INC(BINARY_OP, deferred);
3060 : 2220938 : DECREMENT_ADAPTIVE_COUNTER(cache->counter);
3061 : : #endif /* ENABLE_SPECIALIZATION */
3062 : : assert(0 <= oparg);
3063 : : assert((unsigned)oparg < Py_ARRAY_LENGTH(binary_ops));
3064 : : assert(binary_ops[oparg]);
3065 : 2220938 : res = binary_ops[oparg](lhs, rhs);
3066 : : DECREF_INPUTS();
3067 [ + + ]: 2220938 : ERROR_IF(res == NULL, error);
3068 : : }
3069 : :
3070 : : inst(SWAP, (bottom, unused[oparg-2], top --
3071 : : top, unused[oparg-2], bottom)) {
3072 : : assert(oparg >= 2);
3073 : : }
3074 : :
3075 : : inst(EXTENDED_ARG, (--)) {
3076 : : assert(oparg);
3077 : : assert(cframe.use_tracing == 0);
3078 : 92853 : opcode = next_instr->op.code;
3079 : 92853 : oparg = oparg << 8 | next_instr->op.arg;
3080 : : PRE_DISPATCH_GOTO();
3081 : 92853 : DISPATCH_GOTO();
3082 : : }
3083 : :
3084 : : inst(CACHE, (--)) {
3085 : 0 : Py_UNREACHABLE();
3086 : : }
3087 : :
3088 : :
3089 : : // END BYTECODES //
3090 : :
3091 : : }
3092 : : dispatch_opcode:
3093 : : error:
3094 : : exception_unwind:
3095 : : exit_unwind:
3096 : : handle_eval_breaker:
3097 : : resume_frame:
3098 : : resume_with_error:
3099 : : start_frame:
3100 : : unbound_local_error:
3101 : : ;
3102 : : }
3103 : :
3104 : : // Future families go below this point //
3105 : :
3106 : : family(store_fast) = { STORE_FAST, STORE_FAST__LOAD_FAST, STORE_FAST__STORE_FAST };
|