Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
allendowney
GitHub Repository: allendowney/cpython
Path: blob/main/Python/generated_cases.c.h
12 views
1
// This file is generated by Tools/cases_generator/generate_cases.py
2
// from:
3
// Python/bytecodes.c
4
// Do not edit!
5
6
TARGET(NOP) {
7
DISPATCH();
8
}
9
10
TARGET(RESUME) {
11
#line 136 "Python/bytecodes.c"
12
assert(tstate->cframe == &cframe);
13
assert(frame == cframe.current_frame);
14
/* Possibly combine this with eval breaker */
15
if (_PyFrame_GetCode(frame)->_co_instrumentation_version != tstate->interp->monitoring_version) {
16
int err = _Py_Instrument(_PyFrame_GetCode(frame), tstate->interp);
17
if (err) goto error;
18
next_instr--;
19
}
20
else if (_Py_atomic_load_relaxed_int32(&tstate->interp->ceval.eval_breaker) && oparg < 2) {
21
goto handle_eval_breaker;
22
}
23
#line 24 "Python/generated_cases.c.h"
24
DISPATCH();
25
}
26
27
TARGET(INSTRUMENTED_RESUME) {
28
#line 150 "Python/bytecodes.c"
29
/* Possible performance enhancement:
30
* We need to check the eval breaker anyway, can we
31
* combine the instrument verison check and the eval breaker test?
32
*/
33
if (_PyFrame_GetCode(frame)->_co_instrumentation_version != tstate->interp->monitoring_version) {
34
if (_Py_Instrument(_PyFrame_GetCode(frame), tstate->interp)) {
35
goto error;
36
}
37
next_instr--;
38
}
39
else {
40
_PyFrame_SetStackPointer(frame, stack_pointer);
41
int err = _Py_call_instrumentation(
42
tstate, oparg > 0, frame, next_instr-1);
43
stack_pointer = _PyFrame_GetStackPointer(frame);
44
if (err) goto error;
45
if (frame->prev_instr != next_instr-1) {
46
/* Instrumentation has jumped */
47
next_instr = frame->prev_instr;
48
DISPATCH();
49
}
50
if (_Py_atomic_load_relaxed_int32(&tstate->interp->ceval.eval_breaker) && oparg < 2) {
51
goto handle_eval_breaker;
52
}
53
}
54
#line 55 "Python/generated_cases.c.h"
55
DISPATCH();
56
}
57
58
TARGET(LOAD_FAST_CHECK) {
59
PyObject *value;
60
#line 182 "Python/bytecodes.c"
61
value = GETLOCAL(oparg);
62
if (value == NULL) goto unbound_local_error;
63
Py_INCREF(value);
64
#line 65 "Python/generated_cases.c.h"
65
STACK_GROW(1);
66
stack_pointer[-1] = value;
67
DISPATCH();
68
}
69
70
TARGET(LOAD_FAST) {
71
PyObject *value;
72
#line 188 "Python/bytecodes.c"
73
value = GETLOCAL(oparg);
74
assert(value != NULL);
75
Py_INCREF(value);
76
#line 77 "Python/generated_cases.c.h"
77
STACK_GROW(1);
78
stack_pointer[-1] = value;
79
DISPATCH();
80
}
81
82
TARGET(LOAD_FAST_AND_CLEAR) {
83
PyObject *value;
84
#line 194 "Python/bytecodes.c"
85
value = GETLOCAL(oparg);
86
// do not use SETLOCAL here, it decrefs the old value
87
GETLOCAL(oparg) = NULL;
88
#line 89 "Python/generated_cases.c.h"
89
STACK_GROW(1);
90
stack_pointer[-1] = value;
91
DISPATCH();
92
}
93
94
TARGET(LOAD_FAST_LOAD_FAST) {
95
PyObject *value1;
96
PyObject *value2;
97
#line 200 "Python/bytecodes.c"
98
uint32_t oparg1 = oparg >> 4;
99
uint32_t oparg2 = oparg & 15;
100
value1 = GETLOCAL(oparg1);
101
value2 = GETLOCAL(oparg2);
102
Py_INCREF(value1);
103
Py_INCREF(value2);
104
#line 105 "Python/generated_cases.c.h"
105
STACK_GROW(2);
106
stack_pointer[-1] = value2;
107
stack_pointer[-2] = value1;
108
DISPATCH();
109
}
110
111
TARGET(LOAD_CONST) {
112
PyObject *value;
113
#line 209 "Python/bytecodes.c"
114
value = GETITEM(FRAME_CO_CONSTS, oparg);
115
Py_INCREF(value);
116
#line 117 "Python/generated_cases.c.h"
117
STACK_GROW(1);
118
stack_pointer[-1] = value;
119
DISPATCH();
120
}
121
122
TARGET(STORE_FAST) {
123
PyObject *value = stack_pointer[-1];
124
#line 214 "Python/bytecodes.c"
125
SETLOCAL(oparg, value);
126
#line 127 "Python/generated_cases.c.h"
127
STACK_SHRINK(1);
128
DISPATCH();
129
}
130
131
TARGET(STORE_FAST_LOAD_FAST) {
132
PyObject *value1 = stack_pointer[-1];
133
PyObject *value2;
134
#line 222 "Python/bytecodes.c"
135
uint32_t oparg1 = oparg >> 4;
136
uint32_t oparg2 = oparg & 15;
137
SETLOCAL(oparg1, value1);
138
value2 = GETLOCAL(oparg2);
139
Py_INCREF(value2);
140
#line 141 "Python/generated_cases.c.h"
141
stack_pointer[-1] = value2;
142
DISPATCH();
143
}
144
145
TARGET(STORE_FAST_STORE_FAST) {
146
PyObject *value1 = stack_pointer[-1];
147
PyObject *value2 = stack_pointer[-2];
148
#line 230 "Python/bytecodes.c"
149
uint32_t oparg1 = oparg >> 4;
150
uint32_t oparg2 = oparg & 15;
151
SETLOCAL(oparg1, value1);
152
SETLOCAL(oparg2, value2);
153
#line 154 "Python/generated_cases.c.h"
154
STACK_SHRINK(2);
155
DISPATCH();
156
}
157
158
TARGET(POP_TOP) {
159
PyObject *value = stack_pointer[-1];
160
#line 237 "Python/bytecodes.c"
161
#line 162 "Python/generated_cases.c.h"
162
Py_DECREF(value);
163
STACK_SHRINK(1);
164
DISPATCH();
165
}
166
167
TARGET(PUSH_NULL) {
168
PyObject *res;
169
#line 241 "Python/bytecodes.c"
170
res = NULL;
171
#line 172 "Python/generated_cases.c.h"
172
STACK_GROW(1);
173
stack_pointer[-1] = res;
174
DISPATCH();
175
}
176
177
TARGET(END_FOR) {
178
PyObject *_tmp_1 = stack_pointer[-1];
179
PyObject *_tmp_2 = stack_pointer[-2];
180
{
181
PyObject *value = _tmp_1;
182
#line 237 "Python/bytecodes.c"
183
#line 184 "Python/generated_cases.c.h"
184
Py_DECREF(value);
185
}
186
{
187
PyObject *value = _tmp_2;
188
#line 237 "Python/bytecodes.c"
189
#line 190 "Python/generated_cases.c.h"
190
Py_DECREF(value);
191
}
192
STACK_SHRINK(2);
193
DISPATCH();
194
}
195
196
TARGET(INSTRUMENTED_END_FOR) {
197
PyObject *value = stack_pointer[-1];
198
PyObject *receiver = stack_pointer[-2];
199
#line 247 "Python/bytecodes.c"
200
/* Need to create a fake StopIteration error here,
201
* to conform to PEP 380 */
202
if (PyGen_Check(receiver)) {
203
PyErr_SetObject(PyExc_StopIteration, value);
204
if (monitor_stop_iteration(tstate, frame, next_instr-1)) {
205
goto error;
206
}
207
PyErr_SetRaisedException(NULL);
208
}
209
#line 210 "Python/generated_cases.c.h"
210
Py_DECREF(receiver);
211
Py_DECREF(value);
212
STACK_SHRINK(2);
213
DISPATCH();
214
}
215
216
TARGET(END_SEND) {
217
PyObject *value = stack_pointer[-1];
218
PyObject *receiver = stack_pointer[-2];
219
#line 260 "Python/bytecodes.c"
220
Py_DECREF(receiver);
221
#line 222 "Python/generated_cases.c.h"
222
STACK_SHRINK(1);
223
stack_pointer[-1] = value;
224
DISPATCH();
225
}
226
227
TARGET(INSTRUMENTED_END_SEND) {
228
PyObject *value = stack_pointer[-1];
229
PyObject *receiver = stack_pointer[-2];
230
#line 264 "Python/bytecodes.c"
231
if (PyGen_Check(receiver) || PyCoro_CheckExact(receiver)) {
232
PyErr_SetObject(PyExc_StopIteration, value);
233
if (monitor_stop_iteration(tstate, frame, next_instr-1)) {
234
goto error;
235
}
236
PyErr_SetRaisedException(NULL);
237
}
238
Py_DECREF(receiver);
239
#line 240 "Python/generated_cases.c.h"
240
STACK_SHRINK(1);
241
stack_pointer[-1] = value;
242
DISPATCH();
243
}
244
245
TARGET(UNARY_NEGATIVE) {
246
PyObject *value = stack_pointer[-1];
247
PyObject *res;
248
#line 275 "Python/bytecodes.c"
249
res = PyNumber_Negative(value);
250
#line 251 "Python/generated_cases.c.h"
251
Py_DECREF(value);
252
#line 277 "Python/bytecodes.c"
253
if (res == NULL) goto pop_1_error;
254
#line 255 "Python/generated_cases.c.h"
255
stack_pointer[-1] = res;
256
DISPATCH();
257
}
258
259
TARGET(UNARY_NOT) {
260
PyObject *value = stack_pointer[-1];
261
PyObject *res;
262
#line 281 "Python/bytecodes.c"
263
assert(PyBool_Check(value));
264
res = Py_IsFalse(value) ? Py_True : Py_False;
265
#line 266 "Python/generated_cases.c.h"
266
stack_pointer[-1] = res;
267
DISPATCH();
268
}
269
270
TARGET(TO_BOOL) {
271
PREDICTED(TO_BOOL);
272
static_assert(INLINE_CACHE_ENTRIES_TO_BOOL == 3, "incorrect cache size");
273
PyObject *value = stack_pointer[-1];
274
PyObject *res;
275
#line 296 "Python/bytecodes.c"
276
#if ENABLE_SPECIALIZATION
277
_PyToBoolCache *cache = (_PyToBoolCache *)next_instr;
278
if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
279
next_instr--;
280
_Py_Specialize_ToBool(value, next_instr);
281
DISPATCH_SAME_OPARG();
282
}
283
STAT_INC(TO_BOOL, deferred);
284
DECREMENT_ADAPTIVE_COUNTER(cache->counter);
285
#endif /* ENABLE_SPECIALIZATION */
286
int err = PyObject_IsTrue(value);
287
#line 288 "Python/generated_cases.c.h"
288
Py_DECREF(value);
289
#line 308 "Python/bytecodes.c"
290
if (err < 0) goto pop_1_error;
291
res = err ? Py_True : Py_False;
292
#line 293 "Python/generated_cases.c.h"
293
stack_pointer[-1] = res;
294
next_instr += 3;
295
DISPATCH();
296
}
297
298
TARGET(TO_BOOL_BOOL) {
299
PyObject *value = stack_pointer[-1];
300
#line 313 "Python/bytecodes.c"
301
DEOPT_IF(!PyBool_Check(value), TO_BOOL);
302
STAT_INC(TO_BOOL, hit);
303
#line 304 "Python/generated_cases.c.h"
304
next_instr += 3;
305
DISPATCH();
306
}
307
308
TARGET(TO_BOOL_INT) {
309
PyObject *value = stack_pointer[-1];
310
PyObject *res;
311
#line 318 "Python/bytecodes.c"
312
DEOPT_IF(!PyLong_CheckExact(value), TO_BOOL);
313
STAT_INC(TO_BOOL, hit);
314
if (_PyLong_IsZero((PyLongObject *)value)) {
315
assert(_Py_IsImmortal(value));
316
res = Py_False;
317
}
318
else {
319
#line 320 "Python/generated_cases.c.h"
320
Py_DECREF(value);
321
#line 326 "Python/bytecodes.c"
322
res = Py_True;
323
}
324
#line 325 "Python/generated_cases.c.h"
325
stack_pointer[-1] = res;
326
next_instr += 3;
327
DISPATCH();
328
}
329
330
TARGET(TO_BOOL_LIST) {
331
PyObject *value = stack_pointer[-1];
332
PyObject *res;
333
#line 331 "Python/bytecodes.c"
334
DEOPT_IF(!PyList_CheckExact(value), TO_BOOL);
335
STAT_INC(TO_BOOL, hit);
336
res = Py_SIZE(value) ? Py_True : Py_False;
337
#line 338 "Python/generated_cases.c.h"
338
Py_DECREF(value);
339
stack_pointer[-1] = res;
340
next_instr += 3;
341
DISPATCH();
342
}
343
344
TARGET(TO_BOOL_NONE) {
345
PyObject *value = stack_pointer[-1];
346
PyObject *res;
347
#line 338 "Python/bytecodes.c"
348
// This one is a bit weird, because we expect *some* failures:
349
DEOPT_IF(!Py_IsNone(value), TO_BOOL);
350
STAT_INC(TO_BOOL, hit);
351
res = Py_False;
352
#line 353 "Python/generated_cases.c.h"
353
stack_pointer[-1] = res;
354
next_instr += 3;
355
DISPATCH();
356
}
357
358
TARGET(TO_BOOL_STR) {
359
PyObject *value = stack_pointer[-1];
360
PyObject *res;
361
#line 345 "Python/bytecodes.c"
362
DEOPT_IF(!PyUnicode_CheckExact(value), TO_BOOL);
363
STAT_INC(TO_BOOL, hit);
364
if (value == &_Py_STR(empty)) {
365
assert(_Py_IsImmortal(value));
366
res = Py_False;
367
}
368
else {
369
assert(Py_SIZE(value));
370
#line 371 "Python/generated_cases.c.h"
371
Py_DECREF(value);
372
#line 354 "Python/bytecodes.c"
373
res = Py_True;
374
}
375
#line 376 "Python/generated_cases.c.h"
376
stack_pointer[-1] = res;
377
next_instr += 3;
378
DISPATCH();
379
}
380
381
TARGET(TO_BOOL_ALWAYS_TRUE) {
382
PyObject *value = stack_pointer[-1];
383
PyObject *res;
384
uint32_t version = read_u32(&next_instr[1].cache);
385
#line 359 "Python/bytecodes.c"
386
// This one is a bit weird, because we expect *some* failures:
387
assert(version);
388
DEOPT_IF(Py_TYPE(value)->tp_version_tag != version, TO_BOOL);
389
STAT_INC(TO_BOOL, hit);
390
#line 391 "Python/generated_cases.c.h"
391
Py_DECREF(value);
392
#line 364 "Python/bytecodes.c"
393
res = Py_True;
394
#line 395 "Python/generated_cases.c.h"
395
stack_pointer[-1] = res;
396
next_instr += 3;
397
DISPATCH();
398
}
399
400
TARGET(UNARY_INVERT) {
401
PyObject *value = stack_pointer[-1];
402
PyObject *res;
403
#line 368 "Python/bytecodes.c"
404
res = PyNumber_Invert(value);
405
#line 406 "Python/generated_cases.c.h"
406
Py_DECREF(value);
407
#line 370 "Python/bytecodes.c"
408
if (res == NULL) goto pop_1_error;
409
#line 410 "Python/generated_cases.c.h"
410
stack_pointer[-1] = res;
411
DISPATCH();
412
}
413
414
TARGET(BINARY_OP_MULTIPLY_INT) {
415
PyObject *_tmp_1 = stack_pointer[-1];
416
PyObject *_tmp_2 = stack_pointer[-2];
417
{
418
PyObject *right = _tmp_1;
419
PyObject *left = _tmp_2;
420
#line 386 "Python/bytecodes.c"
421
DEOPT_IF(!PyLong_CheckExact(left), BINARY_OP);
422
DEOPT_IF(!PyLong_CheckExact(right), BINARY_OP);
423
#line 424 "Python/generated_cases.c.h"
424
_tmp_2 = left;
425
_tmp_1 = right;
426
}
427
{
428
PyObject *right = _tmp_1;
429
PyObject *left = _tmp_2;
430
PyObject *res;
431
#line 391 "Python/bytecodes.c"
432
STAT_INC(BINARY_OP, hit);
433
res = _PyLong_Multiply((PyLongObject *)left, (PyLongObject *)right);
434
_Py_DECREF_SPECIALIZED(right, (destructor)PyObject_Free);
435
_Py_DECREF_SPECIALIZED(left, (destructor)PyObject_Free);
436
if (res == NULL) goto pop_2_error;
437
#line 438 "Python/generated_cases.c.h"
438
_tmp_2 = res;
439
}
440
next_instr += 1;
441
STACK_SHRINK(1);
442
stack_pointer[-1] = _tmp_2;
443
DISPATCH();
444
}
445
446
TARGET(BINARY_OP_ADD_INT) {
447
PyObject *_tmp_1 = stack_pointer[-1];
448
PyObject *_tmp_2 = stack_pointer[-2];
449
{
450
PyObject *right = _tmp_1;
451
PyObject *left = _tmp_2;
452
#line 386 "Python/bytecodes.c"
453
DEOPT_IF(!PyLong_CheckExact(left), BINARY_OP);
454
DEOPT_IF(!PyLong_CheckExact(right), BINARY_OP);
455
#line 456 "Python/generated_cases.c.h"
456
_tmp_2 = left;
457
_tmp_1 = right;
458
}
459
{
460
PyObject *right = _tmp_1;
461
PyObject *left = _tmp_2;
462
PyObject *res;
463
#line 399 "Python/bytecodes.c"
464
STAT_INC(BINARY_OP, hit);
465
res = _PyLong_Add((PyLongObject *)left, (PyLongObject *)right);
466
_Py_DECREF_SPECIALIZED(right, (destructor)PyObject_Free);
467
_Py_DECREF_SPECIALIZED(left, (destructor)PyObject_Free);
468
if (res == NULL) goto pop_2_error;
469
#line 470 "Python/generated_cases.c.h"
470
_tmp_2 = res;
471
}
472
next_instr += 1;
473
STACK_SHRINK(1);
474
stack_pointer[-1] = _tmp_2;
475
DISPATCH();
476
}
477
478
TARGET(BINARY_OP_SUBTRACT_INT) {
479
PyObject *_tmp_1 = stack_pointer[-1];
480
PyObject *_tmp_2 = stack_pointer[-2];
481
{
482
PyObject *right = _tmp_1;
483
PyObject *left = _tmp_2;
484
#line 386 "Python/bytecodes.c"
485
DEOPT_IF(!PyLong_CheckExact(left), BINARY_OP);
486
DEOPT_IF(!PyLong_CheckExact(right), BINARY_OP);
487
#line 488 "Python/generated_cases.c.h"
488
_tmp_2 = left;
489
_tmp_1 = right;
490
}
491
{
492
PyObject *right = _tmp_1;
493
PyObject *left = _tmp_2;
494
PyObject *res;
495
#line 407 "Python/bytecodes.c"
496
STAT_INC(BINARY_OP, hit);
497
res = _PyLong_Subtract((PyLongObject *)left, (PyLongObject *)right);
498
_Py_DECREF_SPECIALIZED(right, (destructor)PyObject_Free);
499
_Py_DECREF_SPECIALIZED(left, (destructor)PyObject_Free);
500
if (res == NULL) goto pop_2_error;
501
#line 502 "Python/generated_cases.c.h"
502
_tmp_2 = res;
503
}
504
next_instr += 1;
505
STACK_SHRINK(1);
506
stack_pointer[-1] = _tmp_2;
507
DISPATCH();
508
}
509
510
TARGET(BINARY_OP_MULTIPLY_FLOAT) {
511
PyObject *_tmp_1 = stack_pointer[-1];
512
PyObject *_tmp_2 = stack_pointer[-2];
513
{
514
PyObject *right = _tmp_1;
515
PyObject *left = _tmp_2;
516
#line 422 "Python/bytecodes.c"
517
DEOPT_IF(!PyFloat_CheckExact(left), BINARY_OP);
518
DEOPT_IF(!PyFloat_CheckExact(right), BINARY_OP);
519
#line 520 "Python/generated_cases.c.h"
520
_tmp_2 = left;
521
_tmp_1 = right;
522
}
523
{
524
PyObject *right = _tmp_1;
525
PyObject *left = _tmp_2;
526
PyObject *res;
527
#line 427 "Python/bytecodes.c"
528
STAT_INC(BINARY_OP, hit);
529
double dres =
530
((PyFloatObject *)left)->ob_fval *
531
((PyFloatObject *)right)->ob_fval;
532
DECREF_INPUTS_AND_REUSE_FLOAT(left, right, dres, res);
533
#line 534 "Python/generated_cases.c.h"
534
_tmp_2 = res;
535
}
536
next_instr += 1;
537
STACK_SHRINK(1);
538
stack_pointer[-1] = _tmp_2;
539
DISPATCH();
540
}
541
542
TARGET(BINARY_OP_ADD_FLOAT) {
543
PyObject *_tmp_1 = stack_pointer[-1];
544
PyObject *_tmp_2 = stack_pointer[-2];
545
{
546
PyObject *right = _tmp_1;
547
PyObject *left = _tmp_2;
548
#line 422 "Python/bytecodes.c"
549
DEOPT_IF(!PyFloat_CheckExact(left), BINARY_OP);
550
DEOPT_IF(!PyFloat_CheckExact(right), BINARY_OP);
551
#line 552 "Python/generated_cases.c.h"
552
_tmp_2 = left;
553
_tmp_1 = right;
554
}
555
{
556
PyObject *right = _tmp_1;
557
PyObject *left = _tmp_2;
558
PyObject *res;
559
#line 435 "Python/bytecodes.c"
560
STAT_INC(BINARY_OP, hit);
561
double dres =
562
((PyFloatObject *)left)->ob_fval +
563
((PyFloatObject *)right)->ob_fval;
564
DECREF_INPUTS_AND_REUSE_FLOAT(left, right, dres, res);
565
#line 566 "Python/generated_cases.c.h"
566
_tmp_2 = res;
567
}
568
next_instr += 1;
569
STACK_SHRINK(1);
570
stack_pointer[-1] = _tmp_2;
571
DISPATCH();
572
}
573
574
TARGET(BINARY_OP_SUBTRACT_FLOAT) {
575
PyObject *_tmp_1 = stack_pointer[-1];
576
PyObject *_tmp_2 = stack_pointer[-2];
577
{
578
PyObject *right = _tmp_1;
579
PyObject *left = _tmp_2;
580
#line 422 "Python/bytecodes.c"
581
DEOPT_IF(!PyFloat_CheckExact(left), BINARY_OP);
582
DEOPT_IF(!PyFloat_CheckExact(right), BINARY_OP);
583
#line 584 "Python/generated_cases.c.h"
584
_tmp_2 = left;
585
_tmp_1 = right;
586
}
587
{
588
PyObject *right = _tmp_1;
589
PyObject *left = _tmp_2;
590
PyObject *res;
591
#line 443 "Python/bytecodes.c"
592
STAT_INC(BINARY_OP, hit);
593
double dres =
594
((PyFloatObject *)left)->ob_fval -
595
((PyFloatObject *)right)->ob_fval;
596
DECREF_INPUTS_AND_REUSE_FLOAT(left, right, dres, res);
597
#line 598 "Python/generated_cases.c.h"
598
_tmp_2 = res;
599
}
600
next_instr += 1;
601
STACK_SHRINK(1);
602
stack_pointer[-1] = _tmp_2;
603
DISPATCH();
604
}
605
606
TARGET(BINARY_OP_ADD_UNICODE) {
607
PyObject *_tmp_1 = stack_pointer[-1];
608
PyObject *_tmp_2 = stack_pointer[-2];
609
{
610
PyObject *right = _tmp_1;
611
PyObject *left = _tmp_2;
612
#line 458 "Python/bytecodes.c"
613
DEOPT_IF(!PyUnicode_CheckExact(left), BINARY_OP);
614
DEOPT_IF(!PyUnicode_CheckExact(right), BINARY_OP);
615
#line 616 "Python/generated_cases.c.h"
616
_tmp_2 = left;
617
_tmp_1 = right;
618
}
619
{
620
PyObject *right = _tmp_1;
621
PyObject *left = _tmp_2;
622
PyObject *res;
623
#line 463 "Python/bytecodes.c"
624
STAT_INC(BINARY_OP, hit);
625
res = PyUnicode_Concat(left, right);
626
_Py_DECREF_SPECIALIZED(left, _PyUnicode_ExactDealloc);
627
_Py_DECREF_SPECIALIZED(right, _PyUnicode_ExactDealloc);
628
if (res == NULL) goto pop_2_error;
629
#line 630 "Python/generated_cases.c.h"
630
_tmp_2 = res;
631
}
632
next_instr += 1;
633
STACK_SHRINK(1);
634
stack_pointer[-1] = _tmp_2;
635
DISPATCH();
636
}
637
638
TARGET(BINARY_OP_INPLACE_ADD_UNICODE) {
639
PyObject *_tmp_1 = stack_pointer[-1];
640
PyObject *_tmp_2 = stack_pointer[-2];
641
{
642
PyObject *right = _tmp_1;
643
PyObject *left = _tmp_2;
644
#line 458 "Python/bytecodes.c"
645
DEOPT_IF(!PyUnicode_CheckExact(left), BINARY_OP);
646
DEOPT_IF(!PyUnicode_CheckExact(right), BINARY_OP);
647
#line 648 "Python/generated_cases.c.h"
648
_tmp_2 = left;
649
_tmp_1 = right;
650
}
651
{
652
PyObject *right = _tmp_1;
653
PyObject *left = _tmp_2;
654
#line 480 "Python/bytecodes.c"
655
_Py_CODEUNIT true_next = next_instr[INLINE_CACHE_ENTRIES_BINARY_OP];
656
assert(true_next.op.code == STORE_FAST);
657
PyObject **target_local = &GETLOCAL(true_next.op.arg);
658
DEOPT_IF(*target_local != left, BINARY_OP);
659
STAT_INC(BINARY_OP, hit);
660
/* Handle `left = left + right` or `left += right` for str.
661
*
662
* When possible, extend `left` in place rather than
663
* allocating a new PyUnicodeObject. This attempts to avoid
664
* quadratic behavior when one neglects to use str.join().
665
*
666
* If `left` has only two references remaining (one from
667
* the stack, one in the locals), DECREFing `left` leaves
668
* only the locals reference, so PyUnicode_Append knows
669
* that the string is safe to mutate.
670
*/
671
assert(Py_REFCNT(left) >= 2);
672
_Py_DECREF_NO_DEALLOC(left);
673
PyUnicode_Append(target_local, right);
674
_Py_DECREF_SPECIALIZED(right, _PyUnicode_ExactDealloc);
675
if (*target_local == NULL) goto pop_2_error;
676
// The STORE_FAST is already done.
677
SKIP_OVER(INLINE_CACHE_ENTRIES_BINARY_OP + 1);
678
#line 679 "Python/generated_cases.c.h"
679
}
680
STACK_SHRINK(2);
681
DISPATCH();
682
}
683
684
TARGET(BINARY_SUBSCR) {
685
PREDICTED(BINARY_SUBSCR);
686
static_assert(INLINE_CACHE_ENTRIES_BINARY_SUBSCR == 1, "incorrect cache size");
687
PyObject *sub = stack_pointer[-1];
688
PyObject *container = stack_pointer[-2];
689
PyObject *res;
690
#line 517 "Python/bytecodes.c"
691
#if ENABLE_SPECIALIZATION
692
_PyBinarySubscrCache *cache = (_PyBinarySubscrCache *)next_instr;
693
if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
694
next_instr--;
695
_Py_Specialize_BinarySubscr(container, sub, next_instr);
696
DISPATCH_SAME_OPARG();
697
}
698
STAT_INC(BINARY_SUBSCR, deferred);
699
DECREMENT_ADAPTIVE_COUNTER(cache->counter);
700
#endif /* ENABLE_SPECIALIZATION */
701
res = PyObject_GetItem(container, sub);
702
#line 703 "Python/generated_cases.c.h"
703
Py_DECREF(container);
704
Py_DECREF(sub);
705
#line 529 "Python/bytecodes.c"
706
if (res == NULL) goto pop_2_error;
707
#line 708 "Python/generated_cases.c.h"
708
STACK_SHRINK(1);
709
stack_pointer[-1] = res;
710
next_instr += 1;
711
DISPATCH();
712
}
713
714
TARGET(BINARY_SLICE) {
715
PyObject *stop = stack_pointer[-1];
716
PyObject *start = stack_pointer[-2];
717
PyObject *container = stack_pointer[-3];
718
PyObject *res;
719
#line 533 "Python/bytecodes.c"
720
PyObject *slice = _PyBuildSlice_ConsumeRefs(start, stop);
721
// Can't use ERROR_IF() here, because we haven't
722
// DECREF'ed container yet, and we still own slice.
723
if (slice == NULL) {
724
res = NULL;
725
}
726
else {
727
res = PyObject_GetItem(container, slice);
728
Py_DECREF(slice);
729
}
730
Py_DECREF(container);
731
if (res == NULL) goto pop_3_error;
732
#line 733 "Python/generated_cases.c.h"
733
STACK_SHRINK(2);
734
stack_pointer[-1] = res;
735
DISPATCH();
736
}
737
738
TARGET(STORE_SLICE) {
739
PyObject *stop = stack_pointer[-1];
740
PyObject *start = stack_pointer[-2];
741
PyObject *container = stack_pointer[-3];
742
PyObject *v = stack_pointer[-4];
743
#line 548 "Python/bytecodes.c"
744
PyObject *slice = _PyBuildSlice_ConsumeRefs(start, stop);
745
int err;
746
if (slice == NULL) {
747
err = 1;
748
}
749
else {
750
err = PyObject_SetItem(container, slice, v);
751
Py_DECREF(slice);
752
}
753
Py_DECREF(v);
754
Py_DECREF(container);
755
if (err) goto pop_4_error;
756
#line 757 "Python/generated_cases.c.h"
757
STACK_SHRINK(4);
758
DISPATCH();
759
}
760
761
TARGET(BINARY_SUBSCR_LIST_INT) {
762
PyObject *sub = stack_pointer[-1];
763
PyObject *list = stack_pointer[-2];
764
PyObject *res;
765
#line 563 "Python/bytecodes.c"
766
DEOPT_IF(!PyLong_CheckExact(sub), BINARY_SUBSCR);
767
DEOPT_IF(!PyList_CheckExact(list), BINARY_SUBSCR);
768
769
// Deopt unless 0 <= sub < PyList_Size(list)
770
DEOPT_IF(!_PyLong_IsNonNegativeCompact((PyLongObject *)sub), BINARY_SUBSCR);
771
Py_ssize_t index = ((PyLongObject*)sub)->long_value.ob_digit[0];
772
DEOPT_IF(index >= PyList_GET_SIZE(list), BINARY_SUBSCR);
773
STAT_INC(BINARY_SUBSCR, hit);
774
res = PyList_GET_ITEM(list, index);
775
assert(res != NULL);
776
Py_INCREF(res);
777
_Py_DECREF_SPECIALIZED(sub, (destructor)PyObject_Free);
778
Py_DECREF(list);
779
#line 780 "Python/generated_cases.c.h"
780
STACK_SHRINK(1);
781
stack_pointer[-1] = res;
782
next_instr += 1;
783
DISPATCH();
784
}
785
786
TARGET(BINARY_SUBSCR_TUPLE_INT) {
787
PyObject *sub = stack_pointer[-1];
788
PyObject *tuple = stack_pointer[-2];
789
PyObject *res;
790
#line 579 "Python/bytecodes.c"
791
DEOPT_IF(!PyLong_CheckExact(sub), BINARY_SUBSCR);
792
DEOPT_IF(!PyTuple_CheckExact(tuple), BINARY_SUBSCR);
793
794
// Deopt unless 0 <= sub < PyTuple_Size(list)
795
DEOPT_IF(!_PyLong_IsNonNegativeCompact((PyLongObject *)sub), BINARY_SUBSCR);
796
Py_ssize_t index = ((PyLongObject*)sub)->long_value.ob_digit[0];
797
DEOPT_IF(index >= PyTuple_GET_SIZE(tuple), BINARY_SUBSCR);
798
STAT_INC(BINARY_SUBSCR, hit);
799
res = PyTuple_GET_ITEM(tuple, index);
800
assert(res != NULL);
801
Py_INCREF(res);
802
_Py_DECREF_SPECIALIZED(sub, (destructor)PyObject_Free);
803
Py_DECREF(tuple);
804
#line 805 "Python/generated_cases.c.h"
805
STACK_SHRINK(1);
806
stack_pointer[-1] = res;
807
next_instr += 1;
808
DISPATCH();
809
}
810
811
TARGET(BINARY_SUBSCR_DICT) {
812
PyObject *sub = stack_pointer[-1];
813
PyObject *dict = stack_pointer[-2];
814
PyObject *res;
815
#line 595 "Python/bytecodes.c"
816
DEOPT_IF(!PyDict_CheckExact(dict), BINARY_SUBSCR);
817
STAT_INC(BINARY_SUBSCR, hit);
818
res = PyDict_GetItemWithError(dict, sub);
819
if (res == NULL) {
820
if (!_PyErr_Occurred(tstate)) {
821
_PyErr_SetKeyError(sub);
822
}
823
#line 824 "Python/generated_cases.c.h"
824
Py_DECREF(dict);
825
Py_DECREF(sub);
826
#line 603 "Python/bytecodes.c"
827
if (true) goto pop_2_error;
828
}
829
Py_INCREF(res); // Do this before DECREF'ing dict, sub
830
#line 831 "Python/generated_cases.c.h"
831
Py_DECREF(dict);
832
Py_DECREF(sub);
833
STACK_SHRINK(1);
834
stack_pointer[-1] = res;
835
next_instr += 1;
836
DISPATCH();
837
}
838
839
TARGET(BINARY_SUBSCR_GETITEM) {
840
PyObject *sub = stack_pointer[-1];
841
PyObject *container = stack_pointer[-2];
842
#line 610 "Python/bytecodes.c"
843
DEOPT_IF(tstate->interp->eval_frame, BINARY_SUBSCR);
844
PyTypeObject *tp = Py_TYPE(container);
845
DEOPT_IF(!PyType_HasFeature(tp, Py_TPFLAGS_HEAPTYPE), BINARY_SUBSCR);
846
PyHeapTypeObject *ht = (PyHeapTypeObject *)tp;
847
PyObject *cached = ht->_spec_cache.getitem;
848
DEOPT_IF(cached == NULL, BINARY_SUBSCR);
849
assert(PyFunction_Check(cached));
850
PyFunctionObject *getitem = (PyFunctionObject *)cached;
851
uint32_t cached_version = ht->_spec_cache.getitem_version;
852
DEOPT_IF(getitem->func_version != cached_version, BINARY_SUBSCR);
853
PyCodeObject *code = (PyCodeObject *)getitem->func_code;
854
assert(code->co_argcount == 2);
855
DEOPT_IF(!_PyThreadState_HasStackSpace(tstate, code->co_framesize), BINARY_SUBSCR);
856
STAT_INC(BINARY_SUBSCR, hit);
857
Py_INCREF(getitem);
858
_PyInterpreterFrame *new_frame = _PyFrame_PushUnchecked(tstate, getitem, 2);
859
STACK_SHRINK(2);
860
new_frame->localsplus[0] = container;
861
new_frame->localsplus[1] = sub;
862
SKIP_OVER(INLINE_CACHE_ENTRIES_BINARY_SUBSCR);
863
frame->return_offset = 0;
864
DISPATCH_INLINED(new_frame);
865
#line 866 "Python/generated_cases.c.h"
866
}
867
868
TARGET(LIST_APPEND) {
869
PyObject *v = stack_pointer[-1];
870
PyObject *list = stack_pointer[-(2 + (oparg-1))];
871
#line 635 "Python/bytecodes.c"
872
if (_PyList_AppendTakeRef((PyListObject *)list, v) < 0) goto pop_1_error;
873
#line 874 "Python/generated_cases.c.h"
874
STACK_SHRINK(1);
875
DISPATCH();
876
}
877
878
TARGET(SET_ADD) {
879
PyObject *v = stack_pointer[-1];
880
PyObject *set = stack_pointer[-(2 + (oparg-1))];
881
#line 639 "Python/bytecodes.c"
882
int err = PySet_Add(set, v);
883
#line 884 "Python/generated_cases.c.h"
884
Py_DECREF(v);
885
#line 641 "Python/bytecodes.c"
886
if (err) goto pop_1_error;
887
#line 888 "Python/generated_cases.c.h"
888
STACK_SHRINK(1);
889
DISPATCH();
890
}
891
892
TARGET(STORE_SUBSCR) {
893
PREDICTED(STORE_SUBSCR);
894
static_assert(INLINE_CACHE_ENTRIES_STORE_SUBSCR == 1, "incorrect cache size");
895
PyObject *sub = stack_pointer[-1];
896
PyObject *container = stack_pointer[-2];
897
PyObject *v = stack_pointer[-3];
898
uint16_t counter = read_u16(&next_instr[0].cache);
899
#line 651 "Python/bytecodes.c"
900
#if ENABLE_SPECIALIZATION
901
if (ADAPTIVE_COUNTER_IS_ZERO(counter)) {
902
next_instr--;
903
_Py_Specialize_StoreSubscr(container, sub, next_instr);
904
DISPATCH_SAME_OPARG();
905
}
906
STAT_INC(STORE_SUBSCR, deferred);
907
_PyStoreSubscrCache *cache = (_PyStoreSubscrCache *)next_instr;
908
DECREMENT_ADAPTIVE_COUNTER(cache->counter);
909
#else
910
(void)counter; // Unused.
911
#endif /* ENABLE_SPECIALIZATION */
912
/* container[sub] = v */
913
int err = PyObject_SetItem(container, sub, v);
914
#line 915 "Python/generated_cases.c.h"
915
Py_DECREF(v);
916
Py_DECREF(container);
917
Py_DECREF(sub);
918
#line 666 "Python/bytecodes.c"
919
if (err) goto pop_3_error;
920
#line 921 "Python/generated_cases.c.h"
921
STACK_SHRINK(3);
922
next_instr += 1;
923
DISPATCH();
924
}
925
926
TARGET(STORE_SUBSCR_LIST_INT) {
927
PyObject *sub = stack_pointer[-1];
928
PyObject *list = stack_pointer[-2];
929
PyObject *value = stack_pointer[-3];
930
#line 670 "Python/bytecodes.c"
931
DEOPT_IF(!PyLong_CheckExact(sub), STORE_SUBSCR);
932
DEOPT_IF(!PyList_CheckExact(list), STORE_SUBSCR);
933
934
// Ensure nonnegative, zero-or-one-digit ints.
935
DEOPT_IF(!_PyLong_IsNonNegativeCompact((PyLongObject *)sub), STORE_SUBSCR);
936
Py_ssize_t index = ((PyLongObject*)sub)->long_value.ob_digit[0];
937
// Ensure index < len(list)
938
DEOPT_IF(index >= PyList_GET_SIZE(list), STORE_SUBSCR);
939
STAT_INC(STORE_SUBSCR, hit);
940
941
PyObject *old_value = PyList_GET_ITEM(list, index);
942
PyList_SET_ITEM(list, index, value);
943
assert(old_value != NULL);
944
Py_DECREF(old_value);
945
_Py_DECREF_SPECIALIZED(sub, (destructor)PyObject_Free);
946
Py_DECREF(list);
947
#line 948 "Python/generated_cases.c.h"
948
STACK_SHRINK(3);
949
next_instr += 1;
950
DISPATCH();
951
}
952
953
TARGET(STORE_SUBSCR_DICT) {
954
PyObject *sub = stack_pointer[-1];
955
PyObject *dict = stack_pointer[-2];
956
PyObject *value = stack_pointer[-3];
957
#line 689 "Python/bytecodes.c"
958
DEOPT_IF(!PyDict_CheckExact(dict), STORE_SUBSCR);
959
STAT_INC(STORE_SUBSCR, hit);
960
int err = _PyDict_SetItem_Take2((PyDictObject *)dict, sub, value);
961
Py_DECREF(dict);
962
if (err) goto pop_3_error;
963
#line 964 "Python/generated_cases.c.h"
964
STACK_SHRINK(3);
965
next_instr += 1;
966
DISPATCH();
967
}
968
969
TARGET(DELETE_SUBSCR) {
970
PyObject *sub = stack_pointer[-1];
971
PyObject *container = stack_pointer[-2];
972
#line 697 "Python/bytecodes.c"
973
/* del container[sub] */
974
int err = PyObject_DelItem(container, sub);
975
#line 976 "Python/generated_cases.c.h"
976
Py_DECREF(container);
977
Py_DECREF(sub);
978
#line 700 "Python/bytecodes.c"
979
if (err) goto pop_2_error;
980
#line 981 "Python/generated_cases.c.h"
981
STACK_SHRINK(2);
982
DISPATCH();
983
}
984
985
TARGET(CALL_INTRINSIC_1) {
986
PyObject *value = stack_pointer[-1];
987
PyObject *res;
988
#line 704 "Python/bytecodes.c"
989
assert(oparg <= MAX_INTRINSIC_1);
990
res = _PyIntrinsics_UnaryFunctions[oparg](tstate, value);
991
#line 992 "Python/generated_cases.c.h"
992
Py_DECREF(value);
993
#line 707 "Python/bytecodes.c"
994
if (res == NULL) goto pop_1_error;
995
#line 996 "Python/generated_cases.c.h"
996
stack_pointer[-1] = res;
997
DISPATCH();
998
}
999
1000
TARGET(CALL_INTRINSIC_2) {
1001
PyObject *value1 = stack_pointer[-1];
1002
PyObject *value2 = stack_pointer[-2];
1003
PyObject *res;
1004
#line 711 "Python/bytecodes.c"
1005
assert(oparg <= MAX_INTRINSIC_2);
1006
res = _PyIntrinsics_BinaryFunctions[oparg](tstate, value2, value1);
1007
#line 1008 "Python/generated_cases.c.h"
1008
Py_DECREF(value2);
1009
Py_DECREF(value1);
1010
#line 714 "Python/bytecodes.c"
1011
if (res == NULL) goto pop_2_error;
1012
#line 1013 "Python/generated_cases.c.h"
1013
STACK_SHRINK(1);
1014
stack_pointer[-1] = res;
1015
DISPATCH();
1016
}
1017
1018
TARGET(RAISE_VARARGS) {
1019
PyObject **args = (stack_pointer - oparg);
1020
#line 718 "Python/bytecodes.c"
1021
PyObject *cause = NULL, *exc = NULL;
1022
switch (oparg) {
1023
case 2:
1024
cause = args[1];
1025
/* fall through */
1026
case 1:
1027
exc = args[0];
1028
/* fall through */
1029
case 0:
1030
if (do_raise(tstate, exc, cause)) { STACK_SHRINK(oparg); goto exception_unwind; }
1031
break;
1032
default:
1033
_PyErr_SetString(tstate, PyExc_SystemError,
1034
"bad RAISE_VARARGS oparg");
1035
break;
1036
}
1037
if (true) { STACK_SHRINK(oparg); goto error; }
1038
#line 1039 "Python/generated_cases.c.h"
1039
}
1040
1041
TARGET(INTERPRETER_EXIT) {
1042
PyObject *retval = stack_pointer[-1];
1043
#line 738 "Python/bytecodes.c"
1044
assert(frame == &entry_frame);
1045
assert(_PyFrame_IsIncomplete(frame));
1046
/* Restore previous cframe and return. */
1047
tstate->cframe = cframe.previous;
1048
assert(tstate->cframe->current_frame == frame->previous);
1049
assert(!_PyErr_Occurred(tstate));
1050
_Py_LeaveRecursiveCallTstate(tstate);
1051
return retval;
1052
#line 1053 "Python/generated_cases.c.h"
1053
}
1054
1055
TARGET(RETURN_VALUE) {
1056
PyObject *retval = stack_pointer[-1];
1057
#line 749 "Python/bytecodes.c"
1058
STACK_SHRINK(1);
1059
assert(EMPTY());
1060
_PyFrame_SetStackPointer(frame, stack_pointer);
1061
_Py_LeaveRecursiveCallPy(tstate);
1062
assert(frame != &entry_frame);
1063
// GH-99729: We need to unlink the frame *before* clearing it:
1064
_PyInterpreterFrame *dying = frame;
1065
frame = cframe.current_frame = dying->previous;
1066
_PyEvalFrameClearAndPop(tstate, dying);
1067
frame->prev_instr += frame->return_offset;
1068
_PyFrame_StackPush(frame, retval);
1069
goto resume_frame;
1070
#line 1071 "Python/generated_cases.c.h"
1071
}
1072
1073
TARGET(INSTRUMENTED_RETURN_VALUE) {
1074
PyObject *retval = stack_pointer[-1];
1075
#line 764 "Python/bytecodes.c"
1076
int err = _Py_call_instrumentation_arg(
1077
tstate, PY_MONITORING_EVENT_PY_RETURN,
1078
frame, next_instr-1, retval);
1079
if (err) goto error;
1080
STACK_SHRINK(1);
1081
assert(EMPTY());
1082
_PyFrame_SetStackPointer(frame, stack_pointer);
1083
_Py_LeaveRecursiveCallPy(tstate);
1084
assert(frame != &entry_frame);
1085
// GH-99729: We need to unlink the frame *before* clearing it:
1086
_PyInterpreterFrame *dying = frame;
1087
frame = cframe.current_frame = dying->previous;
1088
_PyEvalFrameClearAndPop(tstate, dying);
1089
frame->prev_instr += frame->return_offset;
1090
_PyFrame_StackPush(frame, retval);
1091
goto resume_frame;
1092
#line 1093 "Python/generated_cases.c.h"
1093
}
1094
1095
TARGET(RETURN_CONST) {
1096
#line 783 "Python/bytecodes.c"
1097
PyObject *retval = GETITEM(FRAME_CO_CONSTS, oparg);
1098
Py_INCREF(retval);
1099
assert(EMPTY());
1100
_PyFrame_SetStackPointer(frame, stack_pointer);
1101
_Py_LeaveRecursiveCallPy(tstate);
1102
assert(frame != &entry_frame);
1103
// GH-99729: We need to unlink the frame *before* clearing it:
1104
_PyInterpreterFrame *dying = frame;
1105
frame = cframe.current_frame = dying->previous;
1106
_PyEvalFrameClearAndPop(tstate, dying);
1107
frame->prev_instr += frame->return_offset;
1108
_PyFrame_StackPush(frame, retval);
1109
goto resume_frame;
1110
#line 1111 "Python/generated_cases.c.h"
1111
}
1112
1113
TARGET(INSTRUMENTED_RETURN_CONST) {
1114
#line 799 "Python/bytecodes.c"
1115
PyObject *retval = GETITEM(FRAME_CO_CONSTS, oparg);
1116
int err = _Py_call_instrumentation_arg(
1117
tstate, PY_MONITORING_EVENT_PY_RETURN,
1118
frame, next_instr-1, retval);
1119
if (err) goto error;
1120
Py_INCREF(retval);
1121
assert(EMPTY());
1122
_PyFrame_SetStackPointer(frame, stack_pointer);
1123
_Py_LeaveRecursiveCallPy(tstate);
1124
assert(frame != &entry_frame);
1125
// GH-99729: We need to unlink the frame *before* clearing it:
1126
_PyInterpreterFrame *dying = frame;
1127
frame = cframe.current_frame = dying->previous;
1128
_PyEvalFrameClearAndPop(tstate, dying);
1129
frame->prev_instr += frame->return_offset;
1130
_PyFrame_StackPush(frame, retval);
1131
goto resume_frame;
1132
#line 1133 "Python/generated_cases.c.h"
1133
}
1134
1135
TARGET(GET_AITER) {
1136
PyObject *obj = stack_pointer[-1];
1137
PyObject *iter;
1138
#line 819 "Python/bytecodes.c"
1139
unaryfunc getter = NULL;
1140
PyTypeObject *type = Py_TYPE(obj);
1141
1142
if (type->tp_as_async != NULL) {
1143
getter = type->tp_as_async->am_aiter;
1144
}
1145
1146
if (getter == NULL) {
1147
_PyErr_Format(tstate, PyExc_TypeError,
1148
"'async for' requires an object with "
1149
"__aiter__ method, got %.100s",
1150
type->tp_name);
1151
#line 1152 "Python/generated_cases.c.h"
1152
Py_DECREF(obj);
1153
#line 832 "Python/bytecodes.c"
1154
if (true) goto pop_1_error;
1155
}
1156
1157
iter = (*getter)(obj);
1158
#line 1159 "Python/generated_cases.c.h"
1159
Py_DECREF(obj);
1160
#line 837 "Python/bytecodes.c"
1161
if (iter == NULL) goto pop_1_error;
1162
1163
if (Py_TYPE(iter)->tp_as_async == NULL ||
1164
Py_TYPE(iter)->tp_as_async->am_anext == NULL) {
1165
1166
_PyErr_Format(tstate, PyExc_TypeError,
1167
"'async for' received an object from __aiter__ "
1168
"that does not implement __anext__: %.100s",
1169
Py_TYPE(iter)->tp_name);
1170
Py_DECREF(iter);
1171
if (true) goto pop_1_error;
1172
}
1173
#line 1174 "Python/generated_cases.c.h"
1174
stack_pointer[-1] = iter;
1175
DISPATCH();
1176
}
1177
1178
TARGET(GET_ANEXT) {
1179
PyObject *aiter = stack_pointer[-1];
1180
PyObject *awaitable;
1181
#line 852 "Python/bytecodes.c"
1182
unaryfunc getter = NULL;
1183
PyObject *next_iter = NULL;
1184
PyTypeObject *type = Py_TYPE(aiter);
1185
1186
if (PyAsyncGen_CheckExact(aiter)) {
1187
awaitable = type->tp_as_async->am_anext(aiter);
1188
if (awaitable == NULL) {
1189
goto error;
1190
}
1191
} else {
1192
if (type->tp_as_async != NULL){
1193
getter = type->tp_as_async->am_anext;
1194
}
1195
1196
if (getter != NULL) {
1197
next_iter = (*getter)(aiter);
1198
if (next_iter == NULL) {
1199
goto error;
1200
}
1201
}
1202
else {
1203
_PyErr_Format(tstate, PyExc_TypeError,
1204
"'async for' requires an iterator with "
1205
"__anext__ method, got %.100s",
1206
type->tp_name);
1207
goto error;
1208
}
1209
1210
awaitable = _PyCoro_GetAwaitableIter(next_iter);
1211
if (awaitable == NULL) {
1212
_PyErr_FormatFromCause(
1213
PyExc_TypeError,
1214
"'async for' received an invalid object "
1215
"from __anext__: %.100s",
1216
Py_TYPE(next_iter)->tp_name);
1217
1218
Py_DECREF(next_iter);
1219
goto error;
1220
} else {
1221
Py_DECREF(next_iter);
1222
}
1223
}
1224
#line 1225 "Python/generated_cases.c.h"
1225
STACK_GROW(1);
1226
stack_pointer[-1] = awaitable;
1227
DISPATCH();
1228
}
1229
1230
TARGET(GET_AWAITABLE) {
1231
PyObject *iterable = stack_pointer[-1];
1232
PyObject *iter;
1233
#line 897 "Python/bytecodes.c"
1234
iter = _PyCoro_GetAwaitableIter(iterable);
1235
1236
if (iter == NULL) {
1237
format_awaitable_error(tstate, Py_TYPE(iterable), oparg);
1238
}
1239
1240
#line 1241 "Python/generated_cases.c.h"
1241
Py_DECREF(iterable);
1242
#line 904 "Python/bytecodes.c"
1243
1244
if (iter != NULL && PyCoro_CheckExact(iter)) {
1245
PyObject *yf = _PyGen_yf((PyGenObject*)iter);
1246
if (yf != NULL) {
1247
/* `iter` is a coroutine object that is being
1248
awaited, `yf` is a pointer to the current awaitable
1249
being awaited on. */
1250
Py_DECREF(yf);
1251
Py_CLEAR(iter);
1252
_PyErr_SetString(tstate, PyExc_RuntimeError,
1253
"coroutine is being awaited already");
1254
/* The code below jumps to `error` if `iter` is NULL. */
1255
}
1256
}
1257
1258
if (iter == NULL) goto pop_1_error;
1259
#line 1260 "Python/generated_cases.c.h"
1260
stack_pointer[-1] = iter;
1261
DISPATCH();
1262
}
1263
1264
TARGET(SEND) {
1265
PREDICTED(SEND);
1266
static_assert(INLINE_CACHE_ENTRIES_SEND == 1, "incorrect cache size");
1267
PyObject *v = stack_pointer[-1];
1268
PyObject *receiver = stack_pointer[-2];
1269
PyObject *retval;
1270
#line 928 "Python/bytecodes.c"
1271
#if ENABLE_SPECIALIZATION
1272
_PySendCache *cache = (_PySendCache *)next_instr;
1273
if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
1274
next_instr--;
1275
_Py_Specialize_Send(receiver, next_instr);
1276
DISPATCH_SAME_OPARG();
1277
}
1278
STAT_INC(SEND, deferred);
1279
DECREMENT_ADAPTIVE_COUNTER(cache->counter);
1280
#endif /* ENABLE_SPECIALIZATION */
1281
assert(frame != &entry_frame);
1282
if ((tstate->interp->eval_frame == NULL) &&
1283
(Py_TYPE(receiver) == &PyGen_Type || Py_TYPE(receiver) == &PyCoro_Type) &&
1284
((PyGenObject *)receiver)->gi_frame_state < FRAME_EXECUTING)
1285
{
1286
PyGenObject *gen = (PyGenObject *)receiver;
1287
_PyInterpreterFrame *gen_frame = (_PyInterpreterFrame *)gen->gi_iframe;
1288
frame->return_offset = oparg;
1289
STACK_SHRINK(1);
1290
_PyFrame_StackPush(gen_frame, v);
1291
gen->gi_frame_state = FRAME_EXECUTING;
1292
gen->gi_exc_state.previous_item = tstate->exc_info;
1293
tstate->exc_info = &gen->gi_exc_state;
1294
SKIP_OVER(INLINE_CACHE_ENTRIES_SEND);
1295
DISPATCH_INLINED(gen_frame);
1296
}
1297
if (Py_IsNone(v) && PyIter_Check(receiver)) {
1298
retval = Py_TYPE(receiver)->tp_iternext(receiver);
1299
}
1300
else {
1301
retval = PyObject_CallMethodOneArg(receiver, &_Py_ID(send), v);
1302
}
1303
if (retval == NULL) {
1304
if (_PyErr_ExceptionMatches(tstate, PyExc_StopIteration)
1305
) {
1306
monitor_raise(tstate, frame, next_instr-1);
1307
}
1308
if (_PyGen_FetchStopIterationValue(&retval) == 0) {
1309
assert(retval != NULL);
1310
JUMPBY(oparg);
1311
}
1312
else {
1313
goto error;
1314
}
1315
}
1316
Py_DECREF(v);
1317
#line 1318 "Python/generated_cases.c.h"
1318
stack_pointer[-1] = retval;
1319
next_instr += 1;
1320
DISPATCH();
1321
}
1322
1323
TARGET(SEND_GEN) {
1324
PyObject *v = stack_pointer[-1];
1325
PyObject *receiver = stack_pointer[-2];
1326
#line 977 "Python/bytecodes.c"
1327
DEOPT_IF(tstate->interp->eval_frame, SEND);
1328
PyGenObject *gen = (PyGenObject *)receiver;
1329
DEOPT_IF(Py_TYPE(gen) != &PyGen_Type &&
1330
Py_TYPE(gen) != &PyCoro_Type, SEND);
1331
DEOPT_IF(gen->gi_frame_state >= FRAME_EXECUTING, SEND);
1332
STAT_INC(SEND, hit);
1333
_PyInterpreterFrame *gen_frame = (_PyInterpreterFrame *)gen->gi_iframe;
1334
frame->return_offset = oparg;
1335
STACK_SHRINK(1);
1336
_PyFrame_StackPush(gen_frame, v);
1337
gen->gi_frame_state = FRAME_EXECUTING;
1338
gen->gi_exc_state.previous_item = tstate->exc_info;
1339
tstate->exc_info = &gen->gi_exc_state;
1340
SKIP_OVER(INLINE_CACHE_ENTRIES_SEND);
1341
DISPATCH_INLINED(gen_frame);
1342
#line 1343 "Python/generated_cases.c.h"
1343
}
1344
1345
TARGET(INSTRUMENTED_YIELD_VALUE) {
1346
PyObject *retval = stack_pointer[-1];
1347
#line 995 "Python/bytecodes.c"
1348
assert(frame != &entry_frame);
1349
assert(oparg >= 0); /* make the generator identify this as HAS_ARG */
1350
PyGenObject *gen = _PyFrame_GetGenerator(frame);
1351
gen->gi_frame_state = FRAME_SUSPENDED;
1352
_PyFrame_SetStackPointer(frame, stack_pointer - 1);
1353
int err = _Py_call_instrumentation_arg(
1354
tstate, PY_MONITORING_EVENT_PY_YIELD,
1355
frame, next_instr-1, retval);
1356
if (err) goto error;
1357
tstate->exc_info = gen->gi_exc_state.previous_item;
1358
gen->gi_exc_state.previous_item = NULL;
1359
_Py_LeaveRecursiveCallPy(tstate);
1360
_PyInterpreterFrame *gen_frame = frame;
1361
frame = cframe.current_frame = frame->previous;
1362
gen_frame->previous = NULL;
1363
_PyFrame_StackPush(frame, retval);
1364
goto resume_frame;
1365
#line 1366 "Python/generated_cases.c.h"
1366
}
1367
1368
TARGET(YIELD_VALUE) {
1369
PyObject *retval = stack_pointer[-1];
1370
#line 1015 "Python/bytecodes.c"
1371
// NOTE: It's important that YIELD_VALUE never raises an exception!
1372
// The compiler treats any exception raised here as a failed close()
1373
// or throw() call.
1374
assert(oparg >= 0); /* make the generator identify this as HAS_ARG */
1375
assert(frame != &entry_frame);
1376
PyGenObject *gen = _PyFrame_GetGenerator(frame);
1377
gen->gi_frame_state = FRAME_SUSPENDED;
1378
_PyFrame_SetStackPointer(frame, stack_pointer - 1);
1379
tstate->exc_info = gen->gi_exc_state.previous_item;
1380
gen->gi_exc_state.previous_item = NULL;
1381
_Py_LeaveRecursiveCallPy(tstate);
1382
_PyInterpreterFrame *gen_frame = frame;
1383
frame = cframe.current_frame = frame->previous;
1384
gen_frame->previous = NULL;
1385
_PyFrame_StackPush(frame, retval);
1386
goto resume_frame;
1387
#line 1388 "Python/generated_cases.c.h"
1388
}
1389
1390
TARGET(POP_EXCEPT) {
1391
PyObject *exc_value = stack_pointer[-1];
1392
#line 1034 "Python/bytecodes.c"
1393
_PyErr_StackItem *exc_info = tstate->exc_info;
1394
Py_XSETREF(exc_info->exc_value, exc_value);
1395
#line 1396 "Python/generated_cases.c.h"
1396
STACK_SHRINK(1);
1397
DISPATCH();
1398
}
1399
1400
TARGET(RERAISE) {
1401
PyObject *exc = stack_pointer[-1];
1402
PyObject **values = (stack_pointer - (1 + oparg));
1403
#line 1039 "Python/bytecodes.c"
1404
assert(oparg >= 0 && oparg <= 2);
1405
if (oparg) {
1406
PyObject *lasti = values[0];
1407
if (PyLong_Check(lasti)) {
1408
frame->prev_instr = _PyCode_CODE(_PyFrame_GetCode(frame)) + PyLong_AsLong(lasti);
1409
assert(!_PyErr_Occurred(tstate));
1410
}
1411
else {
1412
assert(PyLong_Check(lasti));
1413
_PyErr_SetString(tstate, PyExc_SystemError, "lasti is not an int");
1414
goto error;
1415
}
1416
}
1417
assert(exc && PyExceptionInstance_Check(exc));
1418
Py_INCREF(exc);
1419
_PyErr_SetRaisedException(tstate, exc);
1420
goto exception_unwind;
1421
#line 1422 "Python/generated_cases.c.h"
1422
}
1423
1424
TARGET(END_ASYNC_FOR) {
1425
PyObject *exc = stack_pointer[-1];
1426
PyObject *awaitable = stack_pointer[-2];
1427
#line 1059 "Python/bytecodes.c"
1428
assert(exc && PyExceptionInstance_Check(exc));
1429
if (PyErr_GivenExceptionMatches(exc, PyExc_StopAsyncIteration)) {
1430
#line 1431 "Python/generated_cases.c.h"
1431
Py_DECREF(awaitable);
1432
Py_DECREF(exc);
1433
#line 1062 "Python/bytecodes.c"
1434
}
1435
else {
1436
Py_INCREF(exc);
1437
_PyErr_SetRaisedException(tstate, exc);
1438
goto exception_unwind;
1439
}
1440
#line 1441 "Python/generated_cases.c.h"
1441
STACK_SHRINK(2);
1442
DISPATCH();
1443
}
1444
1445
TARGET(CLEANUP_THROW) {
1446
PyObject *exc_value = stack_pointer[-1];
1447
PyObject *last_sent_val = stack_pointer[-2];
1448
PyObject *sub_iter = stack_pointer[-3];
1449
PyObject *none;
1450
PyObject *value;
1451
#line 1071 "Python/bytecodes.c"
1452
assert(throwflag);
1453
assert(exc_value && PyExceptionInstance_Check(exc_value));
1454
if (PyErr_GivenExceptionMatches(exc_value, PyExc_StopIteration)) {
1455
value = Py_NewRef(((PyStopIterationObject *)exc_value)->value);
1456
#line 1457 "Python/generated_cases.c.h"
1457
Py_DECREF(sub_iter);
1458
Py_DECREF(last_sent_val);
1459
Py_DECREF(exc_value);
1460
#line 1076 "Python/bytecodes.c"
1461
none = Py_None;
1462
}
1463
else {
1464
_PyErr_SetRaisedException(tstate, Py_NewRef(exc_value));
1465
goto exception_unwind;
1466
}
1467
#line 1468 "Python/generated_cases.c.h"
1468
STACK_SHRINK(1);
1469
stack_pointer[-1] = value;
1470
stack_pointer[-2] = none;
1471
DISPATCH();
1472
}
1473
1474
TARGET(LOAD_ASSERTION_ERROR) {
1475
PyObject *value;
1476
#line 1085 "Python/bytecodes.c"
1477
value = Py_NewRef(PyExc_AssertionError);
1478
#line 1479 "Python/generated_cases.c.h"
1479
STACK_GROW(1);
1480
stack_pointer[-1] = value;
1481
DISPATCH();
1482
}
1483
1484
TARGET(LOAD_BUILD_CLASS) {
1485
PyObject *bc;
1486
#line 1089 "Python/bytecodes.c"
1487
if (PyDict_CheckExact(BUILTINS())) {
1488
bc = _PyDict_GetItemWithError(BUILTINS(),
1489
&_Py_ID(__build_class__));
1490
if (bc == NULL) {
1491
if (!_PyErr_Occurred(tstate)) {
1492
_PyErr_SetString(tstate, PyExc_NameError,
1493
"__build_class__ not found");
1494
}
1495
if (true) goto error;
1496
}
1497
Py_INCREF(bc);
1498
}
1499
else {
1500
bc = PyObject_GetItem(BUILTINS(), &_Py_ID(__build_class__));
1501
if (bc == NULL) {
1502
if (_PyErr_ExceptionMatches(tstate, PyExc_KeyError))
1503
_PyErr_SetString(tstate, PyExc_NameError,
1504
"__build_class__ not found");
1505
if (true) goto error;
1506
}
1507
}
1508
#line 1509 "Python/generated_cases.c.h"
1509
STACK_GROW(1);
1510
stack_pointer[-1] = bc;
1511
DISPATCH();
1512
}
1513
1514
TARGET(STORE_NAME) {
1515
PyObject *v = stack_pointer[-1];
1516
#line 1114 "Python/bytecodes.c"
1517
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg);
1518
PyObject *ns = LOCALS();
1519
int err;
1520
if (ns == NULL) {
1521
_PyErr_Format(tstate, PyExc_SystemError,
1522
"no locals found when storing %R", name);
1523
#line 1524 "Python/generated_cases.c.h"
1524
Py_DECREF(v);
1525
#line 1121 "Python/bytecodes.c"
1526
if (true) goto pop_1_error;
1527
}
1528
if (PyDict_CheckExact(ns))
1529
err = PyDict_SetItem(ns, name, v);
1530
else
1531
err = PyObject_SetItem(ns, name, v);
1532
#line 1533 "Python/generated_cases.c.h"
1533
Py_DECREF(v);
1534
#line 1128 "Python/bytecodes.c"
1535
if (err) goto pop_1_error;
1536
#line 1537 "Python/generated_cases.c.h"
1537
STACK_SHRINK(1);
1538
DISPATCH();
1539
}
1540
1541
TARGET(DELETE_NAME) {
1542
#line 1132 "Python/bytecodes.c"
1543
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg);
1544
PyObject *ns = LOCALS();
1545
int err;
1546
if (ns == NULL) {
1547
_PyErr_Format(tstate, PyExc_SystemError,
1548
"no locals when deleting %R", name);
1549
goto error;
1550
}
1551
err = PyObject_DelItem(ns, name);
1552
// Can't use ERROR_IF here.
1553
if (err != 0) {
1554
format_exc_check_arg(tstate, PyExc_NameError,
1555
NAME_ERROR_MSG,
1556
name);
1557
goto error;
1558
}
1559
#line 1560 "Python/generated_cases.c.h"
1560
DISPATCH();
1561
}
1562
1563
TARGET(UNPACK_SEQUENCE) {
1564
PREDICTED(UNPACK_SEQUENCE);
1565
static_assert(INLINE_CACHE_ENTRIES_UNPACK_SEQUENCE == 1, "incorrect cache size");
1566
PyObject *seq = stack_pointer[-1];
1567
#line 1158 "Python/bytecodes.c"
1568
#if ENABLE_SPECIALIZATION
1569
_PyUnpackSequenceCache *cache = (_PyUnpackSequenceCache *)next_instr;
1570
if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
1571
next_instr--;
1572
_Py_Specialize_UnpackSequence(seq, next_instr, oparg);
1573
DISPATCH_SAME_OPARG();
1574
}
1575
STAT_INC(UNPACK_SEQUENCE, deferred);
1576
DECREMENT_ADAPTIVE_COUNTER(cache->counter);
1577
#endif /* ENABLE_SPECIALIZATION */
1578
PyObject **top = stack_pointer + oparg - 1;
1579
int res = unpack_iterable(tstate, seq, oparg, -1, top);
1580
#line 1581 "Python/generated_cases.c.h"
1581
Py_DECREF(seq);
1582
#line 1171 "Python/bytecodes.c"
1583
if (res == 0) goto pop_1_error;
1584
#line 1585 "Python/generated_cases.c.h"
1585
STACK_SHRINK(1);
1586
STACK_GROW(oparg);
1587
next_instr += 1;
1588
DISPATCH();
1589
}
1590
1591
TARGET(UNPACK_SEQUENCE_TWO_TUPLE) {
1592
PyObject *seq = stack_pointer[-1];
1593
PyObject **values = stack_pointer - (1);
1594
#line 1175 "Python/bytecodes.c"
1595
DEOPT_IF(!PyTuple_CheckExact(seq), UNPACK_SEQUENCE);
1596
DEOPT_IF(PyTuple_GET_SIZE(seq) != 2, UNPACK_SEQUENCE);
1597
assert(oparg == 2);
1598
STAT_INC(UNPACK_SEQUENCE, hit);
1599
values[0] = Py_NewRef(PyTuple_GET_ITEM(seq, 1));
1600
values[1] = Py_NewRef(PyTuple_GET_ITEM(seq, 0));
1601
#line 1602 "Python/generated_cases.c.h"
1602
Py_DECREF(seq);
1603
STACK_SHRINK(1);
1604
STACK_GROW(oparg);
1605
next_instr += 1;
1606
DISPATCH();
1607
}
1608
1609
TARGET(UNPACK_SEQUENCE_TUPLE) {
1610
PyObject *seq = stack_pointer[-1];
1611
PyObject **values = stack_pointer - (1);
1612
#line 1185 "Python/bytecodes.c"
1613
DEOPT_IF(!PyTuple_CheckExact(seq), UNPACK_SEQUENCE);
1614
DEOPT_IF(PyTuple_GET_SIZE(seq) != oparg, UNPACK_SEQUENCE);
1615
STAT_INC(UNPACK_SEQUENCE, hit);
1616
PyObject **items = _PyTuple_ITEMS(seq);
1617
for (int i = oparg; --i >= 0; ) {
1618
*values++ = Py_NewRef(items[i]);
1619
}
1620
#line 1621 "Python/generated_cases.c.h"
1621
Py_DECREF(seq);
1622
STACK_SHRINK(1);
1623
STACK_GROW(oparg);
1624
next_instr += 1;
1625
DISPATCH();
1626
}
1627
1628
TARGET(UNPACK_SEQUENCE_LIST) {
1629
PyObject *seq = stack_pointer[-1];
1630
PyObject **values = stack_pointer - (1);
1631
#line 1196 "Python/bytecodes.c"
1632
DEOPT_IF(!PyList_CheckExact(seq), UNPACK_SEQUENCE);
1633
DEOPT_IF(PyList_GET_SIZE(seq) != oparg, UNPACK_SEQUENCE);
1634
STAT_INC(UNPACK_SEQUENCE, hit);
1635
PyObject **items = _PyList_ITEMS(seq);
1636
for (int i = oparg; --i >= 0; ) {
1637
*values++ = Py_NewRef(items[i]);
1638
}
1639
#line 1640 "Python/generated_cases.c.h"
1640
Py_DECREF(seq);
1641
STACK_SHRINK(1);
1642
STACK_GROW(oparg);
1643
next_instr += 1;
1644
DISPATCH();
1645
}
1646
1647
TARGET(UNPACK_EX) {
1648
PyObject *seq = stack_pointer[-1];
1649
#line 1207 "Python/bytecodes.c"
1650
int totalargs = 1 + (oparg & 0xFF) + (oparg >> 8);
1651
PyObject **top = stack_pointer + totalargs - 1;
1652
int res = unpack_iterable(tstate, seq, oparg & 0xFF, oparg >> 8, top);
1653
#line 1654 "Python/generated_cases.c.h"
1654
Py_DECREF(seq);
1655
#line 1211 "Python/bytecodes.c"
1656
if (res == 0) goto pop_1_error;
1657
#line 1658 "Python/generated_cases.c.h"
1658
STACK_GROW((oparg & 0xFF) + (oparg >> 8));
1659
DISPATCH();
1660
}
1661
1662
TARGET(STORE_ATTR) {
1663
PREDICTED(STORE_ATTR);
1664
static_assert(INLINE_CACHE_ENTRIES_STORE_ATTR == 4, "incorrect cache size");
1665
PyObject *owner = stack_pointer[-1];
1666
PyObject *v = stack_pointer[-2];
1667
uint16_t counter = read_u16(&next_instr[0].cache);
1668
#line 1222 "Python/bytecodes.c"
1669
#if ENABLE_SPECIALIZATION
1670
if (ADAPTIVE_COUNTER_IS_ZERO(counter)) {
1671
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg);
1672
next_instr--;
1673
_Py_Specialize_StoreAttr(owner, next_instr, name);
1674
DISPATCH_SAME_OPARG();
1675
}
1676
STAT_INC(STORE_ATTR, deferred);
1677
_PyAttrCache *cache = (_PyAttrCache *)next_instr;
1678
DECREMENT_ADAPTIVE_COUNTER(cache->counter);
1679
#else
1680
(void)counter; // Unused.
1681
#endif /* ENABLE_SPECIALIZATION */
1682
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg);
1683
int err = PyObject_SetAttr(owner, name, v);
1684
#line 1685 "Python/generated_cases.c.h"
1685
Py_DECREF(v);
1686
Py_DECREF(owner);
1687
#line 1238 "Python/bytecodes.c"
1688
if (err) goto pop_2_error;
1689
#line 1690 "Python/generated_cases.c.h"
1690
STACK_SHRINK(2);
1691
next_instr += 4;
1692
DISPATCH();
1693
}
1694
1695
TARGET(DELETE_ATTR) {
1696
PyObject *owner = stack_pointer[-1];
1697
#line 1242 "Python/bytecodes.c"
1698
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg);
1699
int err = PyObject_SetAttr(owner, name, (PyObject *)NULL);
1700
#line 1701 "Python/generated_cases.c.h"
1701
Py_DECREF(owner);
1702
#line 1245 "Python/bytecodes.c"
1703
if (err) goto pop_1_error;
1704
#line 1705 "Python/generated_cases.c.h"
1705
STACK_SHRINK(1);
1706
DISPATCH();
1707
}
1708
1709
TARGET(STORE_GLOBAL) {
1710
PyObject *v = stack_pointer[-1];
1711
#line 1249 "Python/bytecodes.c"
1712
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg);
1713
int err = PyDict_SetItem(GLOBALS(), name, v);
1714
#line 1715 "Python/generated_cases.c.h"
1715
Py_DECREF(v);
1716
#line 1252 "Python/bytecodes.c"
1717
if (err) goto pop_1_error;
1718
#line 1719 "Python/generated_cases.c.h"
1719
STACK_SHRINK(1);
1720
DISPATCH();
1721
}
1722
1723
TARGET(DELETE_GLOBAL) {
1724
#line 1256 "Python/bytecodes.c"
1725
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg);
1726
int err;
1727
err = PyDict_DelItem(GLOBALS(), name);
1728
// Can't use ERROR_IF here.
1729
if (err != 0) {
1730
if (_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) {
1731
format_exc_check_arg(tstate, PyExc_NameError,
1732
NAME_ERROR_MSG, name);
1733
}
1734
goto error;
1735
}
1736
#line 1737 "Python/generated_cases.c.h"
1737
DISPATCH();
1738
}
1739
1740
TARGET(LOAD_LOCALS) {
1741
PyObject *_tmp_1;
1742
{
1743
PyObject *locals;
1744
#line 1270 "Python/bytecodes.c"
1745
locals = LOCALS();
1746
if (locals == NULL) {
1747
_PyErr_SetString(tstate, PyExc_SystemError,
1748
"no locals found");
1749
if (true) goto error;
1750
}
1751
Py_INCREF(locals);
1752
#line 1753 "Python/generated_cases.c.h"
1753
_tmp_1 = locals;
1754
}
1755
STACK_GROW(1);
1756
stack_pointer[-1] = _tmp_1;
1757
DISPATCH();
1758
}
1759
1760
TARGET(LOAD_NAME) {
1761
PyObject *_tmp_1;
1762
{
1763
PyObject *locals;
1764
#line 1270 "Python/bytecodes.c"
1765
locals = LOCALS();
1766
if (locals == NULL) {
1767
_PyErr_SetString(tstate, PyExc_SystemError,
1768
"no locals found");
1769
if (true) goto error;
1770
}
1771
Py_INCREF(locals);
1772
#line 1773 "Python/generated_cases.c.h"
1773
_tmp_1 = locals;
1774
}
1775
{
1776
PyObject *mod_or_class_dict = _tmp_1;
1777
PyObject *v;
1778
#line 1282 "Python/bytecodes.c"
1779
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg);
1780
if (PyDict_CheckExact(mod_or_class_dict)) {
1781
v = PyDict_GetItemWithError(mod_or_class_dict, name);
1782
if (v != NULL) {
1783
Py_INCREF(v);
1784
}
1785
else if (_PyErr_Occurred(tstate)) {
1786
Py_DECREF(mod_or_class_dict);
1787
goto error;
1788
}
1789
}
1790
else {
1791
v = PyObject_GetItem(mod_or_class_dict, name);
1792
if (v == NULL) {
1793
if (!_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) {
1794
Py_DECREF(mod_or_class_dict);
1795
goto error;
1796
}
1797
_PyErr_Clear(tstate);
1798
}
1799
}
1800
Py_DECREF(mod_or_class_dict);
1801
if (v == NULL) {
1802
v = PyDict_GetItemWithError(GLOBALS(), name);
1803
if (v != NULL) {
1804
Py_INCREF(v);
1805
}
1806
else if (_PyErr_Occurred(tstate)) {
1807
goto error;
1808
}
1809
else {
1810
if (PyDict_CheckExact(BUILTINS())) {
1811
v = PyDict_GetItemWithError(BUILTINS(), name);
1812
if (v == NULL) {
1813
if (!_PyErr_Occurred(tstate)) {
1814
format_exc_check_arg(
1815
tstate, PyExc_NameError,
1816
NAME_ERROR_MSG, name);
1817
}
1818
goto error;
1819
}
1820
Py_INCREF(v);
1821
}
1822
else {
1823
v = PyObject_GetItem(BUILTINS(), name);
1824
if (v == NULL) {
1825
if (_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) {
1826
format_exc_check_arg(
1827
tstate, PyExc_NameError,
1828
NAME_ERROR_MSG, name);
1829
}
1830
goto error;
1831
}
1832
}
1833
}
1834
}
1835
#line 1836 "Python/generated_cases.c.h"
1836
_tmp_1 = v;
1837
}
1838
STACK_GROW(1);
1839
stack_pointer[-1] = _tmp_1;
1840
DISPATCH();
1841
}
1842
1843
TARGET(LOAD_FROM_DICT_OR_GLOBALS) {
1844
PyObject *_tmp_1 = stack_pointer[-1];
1845
{
1846
PyObject *mod_or_class_dict = _tmp_1;
1847
PyObject *v;
1848
#line 1282 "Python/bytecodes.c"
1849
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg);
1850
if (PyDict_CheckExact(mod_or_class_dict)) {
1851
v = PyDict_GetItemWithError(mod_or_class_dict, name);
1852
if (v != NULL) {
1853
Py_INCREF(v);
1854
}
1855
else if (_PyErr_Occurred(tstate)) {
1856
Py_DECREF(mod_or_class_dict);
1857
goto error;
1858
}
1859
}
1860
else {
1861
v = PyObject_GetItem(mod_or_class_dict, name);
1862
if (v == NULL) {
1863
if (!_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) {
1864
Py_DECREF(mod_or_class_dict);
1865
goto error;
1866
}
1867
_PyErr_Clear(tstate);
1868
}
1869
}
1870
Py_DECREF(mod_or_class_dict);
1871
if (v == NULL) {
1872
v = PyDict_GetItemWithError(GLOBALS(), name);
1873
if (v != NULL) {
1874
Py_INCREF(v);
1875
}
1876
else if (_PyErr_Occurred(tstate)) {
1877
goto error;
1878
}
1879
else {
1880
if (PyDict_CheckExact(BUILTINS())) {
1881
v = PyDict_GetItemWithError(BUILTINS(), name);
1882
if (v == NULL) {
1883
if (!_PyErr_Occurred(tstate)) {
1884
format_exc_check_arg(
1885
tstate, PyExc_NameError,
1886
NAME_ERROR_MSG, name);
1887
}
1888
goto error;
1889
}
1890
Py_INCREF(v);
1891
}
1892
else {
1893
v = PyObject_GetItem(BUILTINS(), name);
1894
if (v == NULL) {
1895
if (_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) {
1896
format_exc_check_arg(
1897
tstate, PyExc_NameError,
1898
NAME_ERROR_MSG, name);
1899
}
1900
goto error;
1901
}
1902
}
1903
}
1904
}
1905
#line 1906 "Python/generated_cases.c.h"
1906
_tmp_1 = v;
1907
}
1908
stack_pointer[-1] = _tmp_1;
1909
DISPATCH();
1910
}
1911
1912
TARGET(LOAD_GLOBAL) {
1913
PREDICTED(LOAD_GLOBAL);
1914
static_assert(INLINE_CACHE_ENTRIES_LOAD_GLOBAL == 4, "incorrect cache size");
1915
PyObject *null = NULL;
1916
PyObject *v;
1917
#line 1351 "Python/bytecodes.c"
1918
#if ENABLE_SPECIALIZATION
1919
_PyLoadGlobalCache *cache = (_PyLoadGlobalCache *)next_instr;
1920
if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
1921
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg>>1);
1922
next_instr--;
1923
_Py_Specialize_LoadGlobal(GLOBALS(), BUILTINS(), next_instr, name);
1924
DISPATCH_SAME_OPARG();
1925
}
1926
STAT_INC(LOAD_GLOBAL, deferred);
1927
DECREMENT_ADAPTIVE_COUNTER(cache->counter);
1928
#endif /* ENABLE_SPECIALIZATION */
1929
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg>>1);
1930
if (PyDict_CheckExact(GLOBALS())
1931
&& PyDict_CheckExact(BUILTINS()))
1932
{
1933
v = _PyDict_LoadGlobal((PyDictObject *)GLOBALS(),
1934
(PyDictObject *)BUILTINS(),
1935
name);
1936
if (v == NULL) {
1937
if (!_PyErr_Occurred(tstate)) {
1938
/* _PyDict_LoadGlobal() returns NULL without raising
1939
* an exception if the key doesn't exist */
1940
format_exc_check_arg(tstate, PyExc_NameError,
1941
NAME_ERROR_MSG, name);
1942
}
1943
if (true) goto error;
1944
}
1945
Py_INCREF(v);
1946
}
1947
else {
1948
/* Slow-path if globals or builtins is not a dict */
1949
1950
/* namespace 1: globals */
1951
v = PyObject_GetItem(GLOBALS(), name);
1952
if (v == NULL) {
1953
if (!_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) goto error;
1954
_PyErr_Clear(tstate);
1955
1956
/* namespace 2: builtins */
1957
v = PyObject_GetItem(BUILTINS(), name);
1958
if (v == NULL) {
1959
if (_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) {
1960
format_exc_check_arg(
1961
tstate, PyExc_NameError,
1962
NAME_ERROR_MSG, name);
1963
}
1964
if (true) goto error;
1965
}
1966
}
1967
}
1968
null = NULL;
1969
#line 1970 "Python/generated_cases.c.h"
1970
STACK_GROW(1);
1971
STACK_GROW(((oparg & 1) ? 1 : 0));
1972
stack_pointer[-1] = v;
1973
if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = null; }
1974
next_instr += 4;
1975
DISPATCH();
1976
}
1977
1978
TARGET(LOAD_GLOBAL_MODULE) {
1979
PyObject *null = NULL;
1980
PyObject *res;
1981
uint16_t index = read_u16(&next_instr[1].cache);
1982
uint16_t version = read_u16(&next_instr[2].cache);
1983
#line 1405 "Python/bytecodes.c"
1984
DEOPT_IF(!PyDict_CheckExact(GLOBALS()), LOAD_GLOBAL);
1985
PyDictObject *dict = (PyDictObject *)GLOBALS();
1986
DEOPT_IF(dict->ma_keys->dk_version != version, LOAD_GLOBAL);
1987
assert(DK_IS_UNICODE(dict->ma_keys));
1988
PyDictUnicodeEntry *entries = DK_UNICODE_ENTRIES(dict->ma_keys);
1989
res = entries[index].me_value;
1990
DEOPT_IF(res == NULL, LOAD_GLOBAL);
1991
Py_INCREF(res);
1992
STAT_INC(LOAD_GLOBAL, hit);
1993
null = NULL;
1994
#line 1995 "Python/generated_cases.c.h"
1995
STACK_GROW(1);
1996
STACK_GROW(((oparg & 1) ? 1 : 0));
1997
stack_pointer[-1] = res;
1998
if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = null; }
1999
next_instr += 4;
2000
DISPATCH();
2001
}
2002
2003
TARGET(LOAD_GLOBAL_BUILTIN) {
2004
PyObject *null = NULL;
2005
PyObject *res;
2006
uint16_t index = read_u16(&next_instr[1].cache);
2007
uint16_t mod_version = read_u16(&next_instr[2].cache);
2008
uint16_t bltn_version = read_u16(&next_instr[3].cache);
2009
#line 1418 "Python/bytecodes.c"
2010
DEOPT_IF(!PyDict_CheckExact(GLOBALS()), LOAD_GLOBAL);
2011
DEOPT_IF(!PyDict_CheckExact(BUILTINS()), LOAD_GLOBAL);
2012
PyDictObject *mdict = (PyDictObject *)GLOBALS();
2013
PyDictObject *bdict = (PyDictObject *)BUILTINS();
2014
assert(opcode == LOAD_GLOBAL_BUILTIN);
2015
DEOPT_IF(mdict->ma_keys->dk_version != mod_version, LOAD_GLOBAL);
2016
DEOPT_IF(bdict->ma_keys->dk_version != bltn_version, LOAD_GLOBAL);
2017
assert(DK_IS_UNICODE(bdict->ma_keys));
2018
PyDictUnicodeEntry *entries = DK_UNICODE_ENTRIES(bdict->ma_keys);
2019
res = entries[index].me_value;
2020
DEOPT_IF(res == NULL, LOAD_GLOBAL);
2021
Py_INCREF(res);
2022
STAT_INC(LOAD_GLOBAL, hit);
2023
null = NULL;
2024
#line 2025 "Python/generated_cases.c.h"
2025
STACK_GROW(1);
2026
STACK_GROW(((oparg & 1) ? 1 : 0));
2027
stack_pointer[-1] = res;
2028
if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = null; }
2029
next_instr += 4;
2030
DISPATCH();
2031
}
2032
2033
TARGET(DELETE_FAST) {
2034
#line 1435 "Python/bytecodes.c"
2035
PyObject *v = GETLOCAL(oparg);
2036
if (v == NULL) goto unbound_local_error;
2037
SETLOCAL(oparg, NULL);
2038
#line 2039 "Python/generated_cases.c.h"
2039
DISPATCH();
2040
}
2041
2042
TARGET(MAKE_CELL) {
2043
#line 1441 "Python/bytecodes.c"
2044
// "initial" is probably NULL but not if it's an arg (or set
2045
// via PyFrame_LocalsToFast() before MAKE_CELL has run).
2046
PyObject *initial = GETLOCAL(oparg);
2047
PyObject *cell = PyCell_New(initial);
2048
if (cell == NULL) {
2049
goto resume_with_error;
2050
}
2051
SETLOCAL(oparg, cell);
2052
#line 2053 "Python/generated_cases.c.h"
2053
DISPATCH();
2054
}
2055
2056
TARGET(DELETE_DEREF) {
2057
#line 1452 "Python/bytecodes.c"
2058
PyObject *cell = GETLOCAL(oparg);
2059
PyObject *oldobj = PyCell_GET(cell);
2060
// Can't use ERROR_IF here.
2061
// Fortunately we don't need its superpower.
2062
if (oldobj == NULL) {
2063
format_exc_unbound(tstate, _PyFrame_GetCode(frame), oparg);
2064
goto error;
2065
}
2066
PyCell_SET(cell, NULL);
2067
Py_DECREF(oldobj);
2068
#line 2069 "Python/generated_cases.c.h"
2069
DISPATCH();
2070
}
2071
2072
TARGET(LOAD_FROM_DICT_OR_DEREF) {
2073
PyObject *class_dict = stack_pointer[-1];
2074
PyObject *value;
2075
#line 1465 "Python/bytecodes.c"
2076
PyObject *name;
2077
assert(class_dict);
2078
assert(oparg >= 0 && oparg < _PyFrame_GetCode(frame)->co_nlocalsplus);
2079
name = PyTuple_GET_ITEM(_PyFrame_GetCode(frame)->co_localsplusnames, oparg);
2080
if (PyDict_CheckExact(class_dict)) {
2081
value = PyDict_GetItemWithError(class_dict, name);
2082
if (value != NULL) {
2083
Py_INCREF(value);
2084
}
2085
else if (_PyErr_Occurred(tstate)) {
2086
Py_DECREF(class_dict);
2087
goto error;
2088
}
2089
}
2090
else {
2091
value = PyObject_GetItem(class_dict, name);
2092
if (value == NULL) {
2093
if (!_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) {
2094
Py_DECREF(class_dict);
2095
goto error;
2096
}
2097
_PyErr_Clear(tstate);
2098
}
2099
}
2100
Py_DECREF(class_dict);
2101
if (!value) {
2102
PyObject *cell = GETLOCAL(oparg);
2103
value = PyCell_GET(cell);
2104
if (value == NULL) {
2105
format_exc_unbound(tstate, _PyFrame_GetCode(frame), oparg);
2106
goto error;
2107
}
2108
Py_INCREF(value);
2109
}
2110
#line 2111 "Python/generated_cases.c.h"
2111
stack_pointer[-1] = value;
2112
DISPATCH();
2113
}
2114
2115
TARGET(LOAD_DEREF) {
2116
PyObject *value;
2117
#line 1502 "Python/bytecodes.c"
2118
PyObject *cell = GETLOCAL(oparg);
2119
value = PyCell_GET(cell);
2120
if (value == NULL) {
2121
format_exc_unbound(tstate, _PyFrame_GetCode(frame), oparg);
2122
if (true) goto error;
2123
}
2124
Py_INCREF(value);
2125
#line 2126 "Python/generated_cases.c.h"
2126
STACK_GROW(1);
2127
stack_pointer[-1] = value;
2128
DISPATCH();
2129
}
2130
2131
TARGET(STORE_DEREF) {
2132
PyObject *v = stack_pointer[-1];
2133
#line 1512 "Python/bytecodes.c"
2134
PyObject *cell = GETLOCAL(oparg);
2135
PyObject *oldobj = PyCell_GET(cell);
2136
PyCell_SET(cell, v);
2137
Py_XDECREF(oldobj);
2138
#line 2139 "Python/generated_cases.c.h"
2139
STACK_SHRINK(1);
2140
DISPATCH();
2141
}
2142
2143
TARGET(COPY_FREE_VARS) {
2144
#line 1519 "Python/bytecodes.c"
2145
/* Copy closure variables to free variables */
2146
PyCodeObject *co = _PyFrame_GetCode(frame);
2147
assert(PyFunction_Check(frame->f_funcobj));
2148
PyObject *closure = ((PyFunctionObject *)frame->f_funcobj)->func_closure;
2149
assert(oparg == co->co_nfreevars);
2150
int offset = co->co_nlocalsplus - oparg;
2151
for (int i = 0; i < oparg; ++i) {
2152
PyObject *o = PyTuple_GET_ITEM(closure, i);
2153
frame->localsplus[offset + i] = Py_NewRef(o);
2154
}
2155
#line 2156 "Python/generated_cases.c.h"
2156
DISPATCH();
2157
}
2158
2159
TARGET(BUILD_STRING) {
2160
PyObject **pieces = (stack_pointer - oparg);
2161
PyObject *str;
2162
#line 1532 "Python/bytecodes.c"
2163
str = _PyUnicode_JoinArray(&_Py_STR(empty), pieces, oparg);
2164
#line 2165 "Python/generated_cases.c.h"
2165
for (int _i = oparg; --_i >= 0;) {
2166
Py_DECREF(pieces[_i]);
2167
}
2168
#line 1534 "Python/bytecodes.c"
2169
if (str == NULL) { STACK_SHRINK(oparg); goto error; }
2170
#line 2171 "Python/generated_cases.c.h"
2171
STACK_SHRINK(oparg);
2172
STACK_GROW(1);
2173
stack_pointer[-1] = str;
2174
DISPATCH();
2175
}
2176
2177
TARGET(BUILD_TUPLE) {
2178
PyObject **values = (stack_pointer - oparg);
2179
PyObject *tup;
2180
#line 1538 "Python/bytecodes.c"
2181
tup = _PyTuple_FromArraySteal(values, oparg);
2182
if (tup == NULL) { STACK_SHRINK(oparg); goto error; }
2183
#line 2184 "Python/generated_cases.c.h"
2184
STACK_SHRINK(oparg);
2185
STACK_GROW(1);
2186
stack_pointer[-1] = tup;
2187
DISPATCH();
2188
}
2189
2190
TARGET(BUILD_LIST) {
2191
PyObject **values = (stack_pointer - oparg);
2192
PyObject *list;
2193
#line 1543 "Python/bytecodes.c"
2194
list = _PyList_FromArraySteal(values, oparg);
2195
if (list == NULL) { STACK_SHRINK(oparg); goto error; }
2196
#line 2197 "Python/generated_cases.c.h"
2197
STACK_SHRINK(oparg);
2198
STACK_GROW(1);
2199
stack_pointer[-1] = list;
2200
DISPATCH();
2201
}
2202
2203
TARGET(LIST_EXTEND) {
2204
PyObject *iterable = stack_pointer[-1];
2205
PyObject *list = stack_pointer[-(2 + (oparg-1))];
2206
#line 1548 "Python/bytecodes.c"
2207
PyObject *none_val = _PyList_Extend((PyListObject *)list, iterable);
2208
if (none_val == NULL) {
2209
if (_PyErr_ExceptionMatches(tstate, PyExc_TypeError) &&
2210
(Py_TYPE(iterable)->tp_iter == NULL && !PySequence_Check(iterable)))
2211
{
2212
_PyErr_Clear(tstate);
2213
_PyErr_Format(tstate, PyExc_TypeError,
2214
"Value after * must be an iterable, not %.200s",
2215
Py_TYPE(iterable)->tp_name);
2216
}
2217
#line 2218 "Python/generated_cases.c.h"
2218
Py_DECREF(iterable);
2219
#line 1559 "Python/bytecodes.c"
2220
if (true) goto pop_1_error;
2221
}
2222
assert(Py_IsNone(none_val));
2223
#line 2224 "Python/generated_cases.c.h"
2224
Py_DECREF(iterable);
2225
STACK_SHRINK(1);
2226
DISPATCH();
2227
}
2228
2229
TARGET(SET_UPDATE) {
2230
PyObject *iterable = stack_pointer[-1];
2231
PyObject *set = stack_pointer[-(2 + (oparg-1))];
2232
#line 1566 "Python/bytecodes.c"
2233
int err = _PySet_Update(set, iterable);
2234
#line 2235 "Python/generated_cases.c.h"
2235
Py_DECREF(iterable);
2236
#line 1568 "Python/bytecodes.c"
2237
if (err < 0) goto pop_1_error;
2238
#line 2239 "Python/generated_cases.c.h"
2239
STACK_SHRINK(1);
2240
DISPATCH();
2241
}
2242
2243
TARGET(BUILD_SET) {
2244
PyObject **values = (stack_pointer - oparg);
2245
PyObject *set;
2246
#line 1572 "Python/bytecodes.c"
2247
set = PySet_New(NULL);
2248
if (set == NULL)
2249
goto error;
2250
int err = 0;
2251
for (int i = 0; i < oparg; i++) {
2252
PyObject *item = values[i];
2253
if (err == 0)
2254
err = PySet_Add(set, item);
2255
Py_DECREF(item);
2256
}
2257
if (err != 0) {
2258
Py_DECREF(set);
2259
if (true) { STACK_SHRINK(oparg); goto error; }
2260
}
2261
#line 2262 "Python/generated_cases.c.h"
2262
STACK_SHRINK(oparg);
2263
STACK_GROW(1);
2264
stack_pointer[-1] = set;
2265
DISPATCH();
2266
}
2267
2268
TARGET(BUILD_MAP) {
2269
PyObject **values = (stack_pointer - oparg*2);
2270
PyObject *map;
2271
#line 1589 "Python/bytecodes.c"
2272
map = _PyDict_FromItems(
2273
values, 2,
2274
values+1, 2,
2275
oparg);
2276
if (map == NULL)
2277
goto error;
2278
2279
#line 2280 "Python/generated_cases.c.h"
2280
for (int _i = oparg*2; --_i >= 0;) {
2281
Py_DECREF(values[_i]);
2282
}
2283
#line 1597 "Python/bytecodes.c"
2284
if (map == NULL) { STACK_SHRINK(oparg*2); goto error; }
2285
#line 2286 "Python/generated_cases.c.h"
2286
STACK_SHRINK(oparg*2);
2287
STACK_GROW(1);
2288
stack_pointer[-1] = map;
2289
DISPATCH();
2290
}
2291
2292
TARGET(SETUP_ANNOTATIONS) {
2293
#line 1601 "Python/bytecodes.c"
2294
int err;
2295
PyObject *ann_dict;
2296
if (LOCALS() == NULL) {
2297
_PyErr_Format(tstate, PyExc_SystemError,
2298
"no locals found when setting up annotations");
2299
if (true) goto error;
2300
}
2301
/* check if __annotations__ in locals()... */
2302
if (PyDict_CheckExact(LOCALS())) {
2303
ann_dict = _PyDict_GetItemWithError(LOCALS(),
2304
&_Py_ID(__annotations__));
2305
if (ann_dict == NULL) {
2306
if (_PyErr_Occurred(tstate)) goto error;
2307
/* ...if not, create a new one */
2308
ann_dict = PyDict_New();
2309
if (ann_dict == NULL) goto error;
2310
err = PyDict_SetItem(LOCALS(), &_Py_ID(__annotations__),
2311
ann_dict);
2312
Py_DECREF(ann_dict);
2313
if (err) goto error;
2314
}
2315
}
2316
else {
2317
/* do the same if locals() is not a dict */
2318
ann_dict = PyObject_GetItem(LOCALS(), &_Py_ID(__annotations__));
2319
if (ann_dict == NULL) {
2320
if (!_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) goto error;
2321
_PyErr_Clear(tstate);
2322
ann_dict = PyDict_New();
2323
if (ann_dict == NULL) goto error;
2324
err = PyObject_SetItem(LOCALS(), &_Py_ID(__annotations__),
2325
ann_dict);
2326
Py_DECREF(ann_dict);
2327
if (err) goto error;
2328
}
2329
else {
2330
Py_DECREF(ann_dict);
2331
}
2332
}
2333
#line 2334 "Python/generated_cases.c.h"
2334
DISPATCH();
2335
}
2336
2337
TARGET(BUILD_CONST_KEY_MAP) {
2338
PyObject *keys = stack_pointer[-1];
2339
PyObject **values = (stack_pointer - (1 + oparg));
2340
PyObject *map;
2341
#line 1643 "Python/bytecodes.c"
2342
if (!PyTuple_CheckExact(keys) ||
2343
PyTuple_GET_SIZE(keys) != (Py_ssize_t)oparg) {
2344
_PyErr_SetString(tstate, PyExc_SystemError,
2345
"bad BUILD_CONST_KEY_MAP keys argument");
2346
goto error; // Pop the keys and values.
2347
}
2348
map = _PyDict_FromItems(
2349
&PyTuple_GET_ITEM(keys, 0), 1,
2350
values, 1, oparg);
2351
#line 2352 "Python/generated_cases.c.h"
2352
for (int _i = oparg; --_i >= 0;) {
2353
Py_DECREF(values[_i]);
2354
}
2355
Py_DECREF(keys);
2356
#line 1653 "Python/bytecodes.c"
2357
if (map == NULL) { STACK_SHRINK(oparg); goto pop_1_error; }
2358
#line 2359 "Python/generated_cases.c.h"
2359
STACK_SHRINK(oparg);
2360
stack_pointer[-1] = map;
2361
DISPATCH();
2362
}
2363
2364
TARGET(DICT_UPDATE) {
2365
PyObject *update = stack_pointer[-1];
2366
#line 1657 "Python/bytecodes.c"
2367
PyObject *dict = PEEK(oparg + 1); // update is still on the stack
2368
if (PyDict_Update(dict, update) < 0) {
2369
if (_PyErr_ExceptionMatches(tstate, PyExc_AttributeError)) {
2370
_PyErr_Format(tstate, PyExc_TypeError,
2371
"'%.200s' object is not a mapping",
2372
Py_TYPE(update)->tp_name);
2373
}
2374
#line 2375 "Python/generated_cases.c.h"
2375
Py_DECREF(update);
2376
#line 1665 "Python/bytecodes.c"
2377
if (true) goto pop_1_error;
2378
}
2379
#line 2380 "Python/generated_cases.c.h"
2380
Py_DECREF(update);
2381
STACK_SHRINK(1);
2382
DISPATCH();
2383
}
2384
2385
TARGET(DICT_MERGE) {
2386
PyObject *update = stack_pointer[-1];
2387
#line 1671 "Python/bytecodes.c"
2388
PyObject *dict = PEEK(oparg + 1); // update is still on the stack
2389
2390
if (_PyDict_MergeEx(dict, update, 2) < 0) {
2391
format_kwargs_error(tstate, PEEK(3 + oparg), update);
2392
#line 2393 "Python/generated_cases.c.h"
2393
Py_DECREF(update);
2394
#line 1676 "Python/bytecodes.c"
2395
if (true) goto pop_1_error;
2396
}
2397
#line 2398 "Python/generated_cases.c.h"
2398
Py_DECREF(update);
2399
STACK_SHRINK(1);
2400
DISPATCH();
2401
}
2402
2403
TARGET(MAP_ADD) {
2404
PyObject *value = stack_pointer[-1];
2405
PyObject *key = stack_pointer[-2];
2406
#line 1682 "Python/bytecodes.c"
2407
PyObject *dict = PEEK(oparg + 2); // key, value are still on the stack
2408
assert(PyDict_CheckExact(dict));
2409
/* dict[key] = value */
2410
// Do not DECREF INPUTS because the function steals the references
2411
if (_PyDict_SetItem_Take2((PyDictObject *)dict, key, value) != 0) goto pop_2_error;
2412
#line 2413 "Python/generated_cases.c.h"
2413
STACK_SHRINK(2);
2414
DISPATCH();
2415
}
2416
2417
TARGET(INSTRUMENTED_LOAD_SUPER_ATTR) {
2418
#line 1690 "Python/bytecodes.c"
2419
_PySuperAttrCache *cache = (_PySuperAttrCache *)next_instr;
2420
// cancel out the decrement that will happen in LOAD_SUPER_ATTR; we
2421
// don't want to specialize instrumented instructions
2422
INCREMENT_ADAPTIVE_COUNTER(cache->counter);
2423
GO_TO_INSTRUCTION(LOAD_SUPER_ATTR);
2424
#line 2425 "Python/generated_cases.c.h"
2425
}
2426
2427
TARGET(LOAD_SUPER_ATTR) {
2428
PREDICTED(LOAD_SUPER_ATTR);
2429
static_assert(INLINE_CACHE_ENTRIES_LOAD_SUPER_ATTR == 1, "incorrect cache size");
2430
PyObject *self = stack_pointer[-1];
2431
PyObject *class = stack_pointer[-2];
2432
PyObject *global_super = stack_pointer[-3];
2433
PyObject *res2 = NULL;
2434
PyObject *res;
2435
#line 1704 "Python/bytecodes.c"
2436
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg >> 2);
2437
int load_method = oparg & 1;
2438
#if ENABLE_SPECIALIZATION
2439
_PySuperAttrCache *cache = (_PySuperAttrCache *)next_instr;
2440
if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
2441
next_instr--;
2442
_Py_Specialize_LoadSuperAttr(global_super, class, next_instr, load_method);
2443
DISPATCH_SAME_OPARG();
2444
}
2445
STAT_INC(LOAD_SUPER_ATTR, deferred);
2446
DECREMENT_ADAPTIVE_COUNTER(cache->counter);
2447
#endif /* ENABLE_SPECIALIZATION */
2448
2449
if (opcode == INSTRUMENTED_LOAD_SUPER_ATTR) {
2450
PyObject *arg = oparg & 2 ? class : &_PyInstrumentation_MISSING;
2451
int err = _Py_call_instrumentation_2args(
2452
tstate, PY_MONITORING_EVENT_CALL,
2453
frame, next_instr-1, global_super, arg);
2454
if (err) goto pop_3_error;
2455
}
2456
2457
// we make no attempt to optimize here; specializations should
2458
// handle any case whose performance we care about
2459
PyObject *stack[] = {class, self};
2460
PyObject *super = PyObject_Vectorcall(global_super, stack, oparg & 2, NULL);
2461
if (opcode == INSTRUMENTED_LOAD_SUPER_ATTR) {
2462
PyObject *arg = oparg & 2 ? class : &_PyInstrumentation_MISSING;
2463
if (super == NULL) {
2464
_Py_call_instrumentation_exc2(
2465
tstate, PY_MONITORING_EVENT_C_RAISE,
2466
frame, next_instr-1, global_super, arg);
2467
}
2468
else {
2469
int err = _Py_call_instrumentation_2args(
2470
tstate, PY_MONITORING_EVENT_C_RETURN,
2471
frame, next_instr-1, global_super, arg);
2472
if (err < 0) {
2473
Py_CLEAR(super);
2474
}
2475
}
2476
}
2477
#line 2478 "Python/generated_cases.c.h"
2478
Py_DECREF(global_super);
2479
Py_DECREF(class);
2480
Py_DECREF(self);
2481
#line 1746 "Python/bytecodes.c"
2482
if (super == NULL) goto pop_3_error;
2483
res = PyObject_GetAttr(super, name);
2484
Py_DECREF(super);
2485
if (res == NULL) goto pop_3_error;
2486
#line 2487 "Python/generated_cases.c.h"
2487
STACK_SHRINK(2);
2488
STACK_GROW(((oparg & 1) ? 1 : 0));
2489
stack_pointer[-1] = res;
2490
if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; }
2491
next_instr += 1;
2492
DISPATCH();
2493
}
2494
2495
TARGET(LOAD_SUPER_ATTR_ATTR) {
2496
PyObject *self = stack_pointer[-1];
2497
PyObject *class = stack_pointer[-2];
2498
PyObject *global_super = stack_pointer[-3];
2499
PyObject *res2 = NULL;
2500
PyObject *res;
2501
#line 1765 "Python/bytecodes.c"
2502
assert(!(oparg & 1));
2503
DEOPT_IF(global_super != (PyObject *)&PySuper_Type, LOAD_SUPER_ATTR);
2504
DEOPT_IF(!PyType_Check(class), LOAD_SUPER_ATTR);
2505
STAT_INC(LOAD_SUPER_ATTR, hit);
2506
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg >> 2);
2507
res = _PySuper_Lookup((PyTypeObject *)class, self, name, NULL);
2508
#line 2509 "Python/generated_cases.c.h"
2509
Py_DECREF(global_super);
2510
Py_DECREF(class);
2511
Py_DECREF(self);
2512
#line 1772 "Python/bytecodes.c"
2513
if (res == NULL) goto pop_3_error;
2514
#line 2515 "Python/generated_cases.c.h"
2515
STACK_SHRINK(2);
2516
STACK_GROW(((oparg & 1) ? 1 : 0));
2517
stack_pointer[-1] = res;
2518
if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; }
2519
next_instr += 1;
2520
DISPATCH();
2521
}
2522
2523
TARGET(LOAD_SUPER_ATTR_METHOD) {
2524
PyObject *self = stack_pointer[-1];
2525
PyObject *class = stack_pointer[-2];
2526
PyObject *global_super = stack_pointer[-3];
2527
PyObject *res2;
2528
PyObject *res;
2529
#line 1776 "Python/bytecodes.c"
2530
assert(oparg & 1);
2531
DEOPT_IF(global_super != (PyObject *)&PySuper_Type, LOAD_SUPER_ATTR);
2532
DEOPT_IF(!PyType_Check(class), LOAD_SUPER_ATTR);
2533
STAT_INC(LOAD_SUPER_ATTR, hit);
2534
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg >> 2);
2535
PyTypeObject *cls = (PyTypeObject *)class;
2536
int method_found = 0;
2537
res2 = _PySuper_Lookup(cls, self, name,
2538
cls->tp_getattro == PyObject_GenericGetAttr ? &method_found : NULL);
2539
Py_DECREF(global_super);
2540
Py_DECREF(class);
2541
if (res2 == NULL) {
2542
Py_DECREF(self);
2543
if (true) goto pop_3_error;
2544
}
2545
if (method_found) {
2546
res = self; // transfer ownership
2547
} else {
2548
Py_DECREF(self);
2549
res = res2;
2550
res2 = NULL;
2551
}
2552
#line 2553 "Python/generated_cases.c.h"
2553
STACK_SHRINK(1);
2554
stack_pointer[-1] = res;
2555
stack_pointer[-2] = res2;
2556
next_instr += 1;
2557
DISPATCH();
2558
}
2559
2560
TARGET(LOAD_ATTR) {
2561
PREDICTED(LOAD_ATTR);
2562
static_assert(INLINE_CACHE_ENTRIES_LOAD_ATTR == 9, "incorrect cache size");
2563
PyObject *owner = stack_pointer[-1];
2564
PyObject *res2 = NULL;
2565
PyObject *res;
2566
#line 1815 "Python/bytecodes.c"
2567
#if ENABLE_SPECIALIZATION
2568
_PyAttrCache *cache = (_PyAttrCache *)next_instr;
2569
if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
2570
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg>>1);
2571
next_instr--;
2572
_Py_Specialize_LoadAttr(owner, next_instr, name);
2573
DISPATCH_SAME_OPARG();
2574
}
2575
STAT_INC(LOAD_ATTR, deferred);
2576
DECREMENT_ADAPTIVE_COUNTER(cache->counter);
2577
#endif /* ENABLE_SPECIALIZATION */
2578
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg >> 1);
2579
if (oparg & 1) {
2580
/* Designed to work in tandem with CALL, pushes two values. */
2581
PyObject* meth = NULL;
2582
if (_PyObject_GetMethod(owner, name, &meth)) {
2583
/* We can bypass temporary bound method object.
2584
meth is unbound method and obj is self.
2585
2586
meth | self | arg1 | ... | argN
2587
*/
2588
assert(meth != NULL); // No errors on this branch
2589
res2 = meth;
2590
res = owner; // Transfer ownership
2591
}
2592
else {
2593
/* meth is not an unbound method (but a regular attr, or
2594
something was returned by a descriptor protocol). Set
2595
the second element of the stack to NULL, to signal
2596
CALL that it's not a method call.
2597
2598
NULL | meth | arg1 | ... | argN
2599
*/
2600
#line 2601 "Python/generated_cases.c.h"
2601
Py_DECREF(owner);
2602
#line 1849 "Python/bytecodes.c"
2603
if (meth == NULL) goto pop_1_error;
2604
res2 = NULL;
2605
res = meth;
2606
}
2607
}
2608
else {
2609
/* Classic, pushes one value. */
2610
res = PyObject_GetAttr(owner, name);
2611
#line 2612 "Python/generated_cases.c.h"
2612
Py_DECREF(owner);
2613
#line 1858 "Python/bytecodes.c"
2614
if (res == NULL) goto pop_1_error;
2615
}
2616
#line 2617 "Python/generated_cases.c.h"
2617
STACK_GROW(((oparg & 1) ? 1 : 0));
2618
stack_pointer[-1] = res;
2619
if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; }
2620
next_instr += 9;
2621
DISPATCH();
2622
}
2623
2624
TARGET(LOAD_ATTR_INSTANCE_VALUE) {
2625
PyObject *owner = stack_pointer[-1];
2626
PyObject *res2 = NULL;
2627
PyObject *res;
2628
uint32_t type_version = read_u32(&next_instr[1].cache);
2629
uint16_t index = read_u16(&next_instr[3].cache);
2630
#line 1867 "Python/bytecodes.c"
2631
PyTypeObject *tp = Py_TYPE(owner);
2632
assert(type_version != 0);
2633
DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR);
2634
assert(tp->tp_dictoffset < 0);
2635
assert(tp->tp_flags & Py_TPFLAGS_MANAGED_DICT);
2636
PyDictOrValues dorv = *_PyObject_DictOrValuesPointer(owner);
2637
DEOPT_IF(!_PyDictOrValues_IsValues(dorv), LOAD_ATTR);
2638
res = _PyDictOrValues_GetValues(dorv)->values[index];
2639
DEOPT_IF(res == NULL, LOAD_ATTR);
2640
STAT_INC(LOAD_ATTR, hit);
2641
Py_INCREF(res);
2642
res2 = NULL;
2643
#line 2644 "Python/generated_cases.c.h"
2644
Py_DECREF(owner);
2645
STACK_GROW(((oparg & 1) ? 1 : 0));
2646
stack_pointer[-1] = res;
2647
if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; }
2648
next_instr += 9;
2649
DISPATCH();
2650
}
2651
2652
TARGET(LOAD_ATTR_MODULE) {
2653
PyObject *owner = stack_pointer[-1];
2654
PyObject *res2 = NULL;
2655
PyObject *res;
2656
uint32_t type_version = read_u32(&next_instr[1].cache);
2657
uint16_t index = read_u16(&next_instr[3].cache);
2658
#line 1883 "Python/bytecodes.c"
2659
DEOPT_IF(!PyModule_CheckExact(owner), LOAD_ATTR);
2660
PyDictObject *dict = (PyDictObject *)((PyModuleObject *)owner)->md_dict;
2661
assert(dict != NULL);
2662
DEOPT_IF(dict->ma_keys->dk_version != type_version, LOAD_ATTR);
2663
assert(dict->ma_keys->dk_kind == DICT_KEYS_UNICODE);
2664
assert(index < dict->ma_keys->dk_nentries);
2665
PyDictUnicodeEntry *ep = DK_UNICODE_ENTRIES(dict->ma_keys) + index;
2666
res = ep->me_value;
2667
DEOPT_IF(res == NULL, LOAD_ATTR);
2668
STAT_INC(LOAD_ATTR, hit);
2669
Py_INCREF(res);
2670
res2 = NULL;
2671
#line 2672 "Python/generated_cases.c.h"
2672
Py_DECREF(owner);
2673
STACK_GROW(((oparg & 1) ? 1 : 0));
2674
stack_pointer[-1] = res;
2675
if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; }
2676
next_instr += 9;
2677
DISPATCH();
2678
}
2679
2680
TARGET(LOAD_ATTR_WITH_HINT) {
2681
PyObject *owner = stack_pointer[-1];
2682
PyObject *res2 = NULL;
2683
PyObject *res;
2684
uint32_t type_version = read_u32(&next_instr[1].cache);
2685
uint16_t index = read_u16(&next_instr[3].cache);
2686
#line 1899 "Python/bytecodes.c"
2687
PyTypeObject *tp = Py_TYPE(owner);
2688
assert(type_version != 0);
2689
DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR);
2690
assert(tp->tp_flags & Py_TPFLAGS_MANAGED_DICT);
2691
PyDictOrValues dorv = *_PyObject_DictOrValuesPointer(owner);
2692
DEOPT_IF(_PyDictOrValues_IsValues(dorv), LOAD_ATTR);
2693
PyDictObject *dict = (PyDictObject *)_PyDictOrValues_GetDict(dorv);
2694
DEOPT_IF(dict == NULL, LOAD_ATTR);
2695
assert(PyDict_CheckExact((PyObject *)dict));
2696
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg>>1);
2697
uint16_t hint = index;
2698
DEOPT_IF(hint >= (size_t)dict->ma_keys->dk_nentries, LOAD_ATTR);
2699
if (DK_IS_UNICODE(dict->ma_keys)) {
2700
PyDictUnicodeEntry *ep = DK_UNICODE_ENTRIES(dict->ma_keys) + hint;
2701
DEOPT_IF(ep->me_key != name, LOAD_ATTR);
2702
res = ep->me_value;
2703
}
2704
else {
2705
PyDictKeyEntry *ep = DK_ENTRIES(dict->ma_keys) + hint;
2706
DEOPT_IF(ep->me_key != name, LOAD_ATTR);
2707
res = ep->me_value;
2708
}
2709
DEOPT_IF(res == NULL, LOAD_ATTR);
2710
STAT_INC(LOAD_ATTR, hit);
2711
Py_INCREF(res);
2712
res2 = NULL;
2713
#line 2714 "Python/generated_cases.c.h"
2714
Py_DECREF(owner);
2715
STACK_GROW(((oparg & 1) ? 1 : 0));
2716
stack_pointer[-1] = res;
2717
if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; }
2718
next_instr += 9;
2719
DISPATCH();
2720
}
2721
2722
TARGET(LOAD_ATTR_SLOT) {
2723
PyObject *owner = stack_pointer[-1];
2724
PyObject *res2 = NULL;
2725
PyObject *res;
2726
uint32_t type_version = read_u32(&next_instr[1].cache);
2727
uint16_t index = read_u16(&next_instr[3].cache);
2728
#line 1929 "Python/bytecodes.c"
2729
PyTypeObject *tp = Py_TYPE(owner);
2730
assert(type_version != 0);
2731
DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR);
2732
char *addr = (char *)owner + index;
2733
res = *(PyObject **)addr;
2734
DEOPT_IF(res == NULL, LOAD_ATTR);
2735
STAT_INC(LOAD_ATTR, hit);
2736
Py_INCREF(res);
2737
res2 = NULL;
2738
#line 2739 "Python/generated_cases.c.h"
2739
Py_DECREF(owner);
2740
STACK_GROW(((oparg & 1) ? 1 : 0));
2741
stack_pointer[-1] = res;
2742
if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; }
2743
next_instr += 9;
2744
DISPATCH();
2745
}
2746
2747
TARGET(LOAD_ATTR_CLASS) {
2748
PyObject *cls = stack_pointer[-1];
2749
PyObject *res2 = NULL;
2750
PyObject *res;
2751
uint32_t type_version = read_u32(&next_instr[1].cache);
2752
PyObject *descr = read_obj(&next_instr[5].cache);
2753
#line 1942 "Python/bytecodes.c"
2754
2755
DEOPT_IF(!PyType_Check(cls), LOAD_ATTR);
2756
DEOPT_IF(((PyTypeObject *)cls)->tp_version_tag != type_version,
2757
LOAD_ATTR);
2758
assert(type_version != 0);
2759
2760
STAT_INC(LOAD_ATTR, hit);
2761
res2 = NULL;
2762
res = descr;
2763
assert(res != NULL);
2764
Py_INCREF(res);
2765
#line 2766 "Python/generated_cases.c.h"
2766
Py_DECREF(cls);
2767
STACK_GROW(((oparg & 1) ? 1 : 0));
2768
stack_pointer[-1] = res;
2769
if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; }
2770
next_instr += 9;
2771
DISPATCH();
2772
}
2773
2774
TARGET(LOAD_ATTR_PROPERTY) {
2775
PyObject *owner = stack_pointer[-1];
2776
uint32_t type_version = read_u32(&next_instr[1].cache);
2777
uint32_t func_version = read_u32(&next_instr[3].cache);
2778
PyObject *fget = read_obj(&next_instr[5].cache);
2779
#line 1957 "Python/bytecodes.c"
2780
DEOPT_IF(tstate->interp->eval_frame, LOAD_ATTR);
2781
2782
PyTypeObject *cls = Py_TYPE(owner);
2783
DEOPT_IF(cls->tp_version_tag != type_version, LOAD_ATTR);
2784
assert(type_version != 0);
2785
assert(Py_IS_TYPE(fget, &PyFunction_Type));
2786
PyFunctionObject *f = (PyFunctionObject *)fget;
2787
assert(func_version != 0);
2788
DEOPT_IF(f->func_version != func_version, LOAD_ATTR);
2789
PyCodeObject *code = (PyCodeObject *)f->func_code;
2790
assert(code->co_argcount == 1);
2791
DEOPT_IF(!_PyThreadState_HasStackSpace(tstate, code->co_framesize), LOAD_ATTR);
2792
STAT_INC(LOAD_ATTR, hit);
2793
Py_INCREF(fget);
2794
_PyInterpreterFrame *new_frame = _PyFrame_PushUnchecked(tstate, f, 1);
2795
// Manipulate stack directly because we exit with DISPATCH_INLINED().
2796
SET_TOP(NULL);
2797
int shrink_stack = !(oparg & 1);
2798
STACK_SHRINK(shrink_stack);
2799
new_frame->localsplus[0] = owner;
2800
SKIP_OVER(INLINE_CACHE_ENTRIES_LOAD_ATTR);
2801
frame->return_offset = 0;
2802
DISPATCH_INLINED(new_frame);
2803
#line 2804 "Python/generated_cases.c.h"
2804
}
2805
2806
TARGET(LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN) {
2807
PyObject *owner = stack_pointer[-1];
2808
uint32_t type_version = read_u32(&next_instr[1].cache);
2809
uint32_t func_version = read_u32(&next_instr[3].cache);
2810
PyObject *getattribute = read_obj(&next_instr[5].cache);
2811
#line 1983 "Python/bytecodes.c"
2812
DEOPT_IF(tstate->interp->eval_frame, LOAD_ATTR);
2813
PyTypeObject *cls = Py_TYPE(owner);
2814
DEOPT_IF(cls->tp_version_tag != type_version, LOAD_ATTR);
2815
assert(type_version != 0);
2816
assert(Py_IS_TYPE(getattribute, &PyFunction_Type));
2817
PyFunctionObject *f = (PyFunctionObject *)getattribute;
2818
assert(func_version != 0);
2819
DEOPT_IF(f->func_version != func_version, LOAD_ATTR);
2820
PyCodeObject *code = (PyCodeObject *)f->func_code;
2821
assert(code->co_argcount == 2);
2822
DEOPT_IF(!_PyThreadState_HasStackSpace(tstate, code->co_framesize), LOAD_ATTR);
2823
STAT_INC(LOAD_ATTR, hit);
2824
2825
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg >> 1);
2826
Py_INCREF(f);
2827
_PyInterpreterFrame *new_frame = _PyFrame_PushUnchecked(tstate, f, 2);
2828
// Manipulate stack directly because we exit with DISPATCH_INLINED().
2829
SET_TOP(NULL);
2830
int shrink_stack = !(oparg & 1);
2831
STACK_SHRINK(shrink_stack);
2832
new_frame->localsplus[0] = owner;
2833
new_frame->localsplus[1] = Py_NewRef(name);
2834
SKIP_OVER(INLINE_CACHE_ENTRIES_LOAD_ATTR);
2835
frame->return_offset = 0;
2836
DISPATCH_INLINED(new_frame);
2837
#line 2838 "Python/generated_cases.c.h"
2838
}
2839
2840
TARGET(STORE_ATTR_INSTANCE_VALUE) {
2841
PyObject *owner = stack_pointer[-1];
2842
PyObject *value = stack_pointer[-2];
2843
uint32_t type_version = read_u32(&next_instr[1].cache);
2844
uint16_t index = read_u16(&next_instr[3].cache);
2845
#line 2011 "Python/bytecodes.c"
2846
PyTypeObject *tp = Py_TYPE(owner);
2847
assert(type_version != 0);
2848
DEOPT_IF(tp->tp_version_tag != type_version, STORE_ATTR);
2849
assert(tp->tp_flags & Py_TPFLAGS_MANAGED_DICT);
2850
PyDictOrValues dorv = *_PyObject_DictOrValuesPointer(owner);
2851
DEOPT_IF(!_PyDictOrValues_IsValues(dorv), STORE_ATTR);
2852
STAT_INC(STORE_ATTR, hit);
2853
PyDictValues *values = _PyDictOrValues_GetValues(dorv);
2854
PyObject *old_value = values->values[index];
2855
values->values[index] = value;
2856
if (old_value == NULL) {
2857
_PyDictValues_AddToInsertionOrder(values, index);
2858
}
2859
else {
2860
Py_DECREF(old_value);
2861
}
2862
Py_DECREF(owner);
2863
#line 2864 "Python/generated_cases.c.h"
2864
STACK_SHRINK(2);
2865
next_instr += 4;
2866
DISPATCH();
2867
}
2868
2869
TARGET(STORE_ATTR_WITH_HINT) {
2870
PyObject *owner = stack_pointer[-1];
2871
PyObject *value = stack_pointer[-2];
2872
uint32_t type_version = read_u32(&next_instr[1].cache);
2873
uint16_t hint = read_u16(&next_instr[3].cache);
2874
#line 2031 "Python/bytecodes.c"
2875
PyTypeObject *tp = Py_TYPE(owner);
2876
assert(type_version != 0);
2877
DEOPT_IF(tp->tp_version_tag != type_version, STORE_ATTR);
2878
assert(tp->tp_flags & Py_TPFLAGS_MANAGED_DICT);
2879
PyDictOrValues dorv = *_PyObject_DictOrValuesPointer(owner);
2880
DEOPT_IF(_PyDictOrValues_IsValues(dorv), STORE_ATTR);
2881
PyDictObject *dict = (PyDictObject *)_PyDictOrValues_GetDict(dorv);
2882
DEOPT_IF(dict == NULL, STORE_ATTR);
2883
assert(PyDict_CheckExact((PyObject *)dict));
2884
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg);
2885
DEOPT_IF(hint >= (size_t)dict->ma_keys->dk_nentries, STORE_ATTR);
2886
PyObject *old_value;
2887
uint64_t new_version;
2888
if (DK_IS_UNICODE(dict->ma_keys)) {
2889
PyDictUnicodeEntry *ep = DK_UNICODE_ENTRIES(dict->ma_keys) + hint;
2890
DEOPT_IF(ep->me_key != name, STORE_ATTR);
2891
old_value = ep->me_value;
2892
DEOPT_IF(old_value == NULL, STORE_ATTR);
2893
new_version = _PyDict_NotifyEvent(tstate->interp, PyDict_EVENT_MODIFIED, dict, name, value);
2894
ep->me_value = value;
2895
}
2896
else {
2897
PyDictKeyEntry *ep = DK_ENTRIES(dict->ma_keys) + hint;
2898
DEOPT_IF(ep->me_key != name, STORE_ATTR);
2899
old_value = ep->me_value;
2900
DEOPT_IF(old_value == NULL, STORE_ATTR);
2901
new_version = _PyDict_NotifyEvent(tstate->interp, PyDict_EVENT_MODIFIED, dict, name, value);
2902
ep->me_value = value;
2903
}
2904
Py_DECREF(old_value);
2905
STAT_INC(STORE_ATTR, hit);
2906
/* Ensure dict is GC tracked if it needs to be */
2907
if (!_PyObject_GC_IS_TRACKED(dict) && _PyObject_GC_MAY_BE_TRACKED(value)) {
2908
_PyObject_GC_TRACK(dict);
2909
}
2910
/* PEP 509 */
2911
dict->ma_version_tag = new_version;
2912
Py_DECREF(owner);
2913
#line 2914 "Python/generated_cases.c.h"
2914
STACK_SHRINK(2);
2915
next_instr += 4;
2916
DISPATCH();
2917
}
2918
2919
TARGET(STORE_ATTR_SLOT) {
2920
PyObject *owner = stack_pointer[-1];
2921
PyObject *value = stack_pointer[-2];
2922
uint32_t type_version = read_u32(&next_instr[1].cache);
2923
uint16_t index = read_u16(&next_instr[3].cache);
2924
#line 2072 "Python/bytecodes.c"
2925
PyTypeObject *tp = Py_TYPE(owner);
2926
assert(type_version != 0);
2927
DEOPT_IF(tp->tp_version_tag != type_version, STORE_ATTR);
2928
char *addr = (char *)owner + index;
2929
STAT_INC(STORE_ATTR, hit);
2930
PyObject *old_value = *(PyObject **)addr;
2931
*(PyObject **)addr = value;
2932
Py_XDECREF(old_value);
2933
Py_DECREF(owner);
2934
#line 2935 "Python/generated_cases.c.h"
2935
STACK_SHRINK(2);
2936
next_instr += 4;
2937
DISPATCH();
2938
}
2939
2940
TARGET(COMPARE_OP) {
2941
PREDICTED(COMPARE_OP);
2942
static_assert(INLINE_CACHE_ENTRIES_COMPARE_OP == 1, "incorrect cache size");
2943
PyObject *right = stack_pointer[-1];
2944
PyObject *left = stack_pointer[-2];
2945
PyObject *res;
2946
#line 2091 "Python/bytecodes.c"
2947
#if ENABLE_SPECIALIZATION
2948
_PyCompareOpCache *cache = (_PyCompareOpCache *)next_instr;
2949
if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
2950
next_instr--;
2951
_Py_Specialize_CompareOp(left, right, next_instr, oparg);
2952
DISPATCH_SAME_OPARG();
2953
}
2954
STAT_INC(COMPARE_OP, deferred);
2955
DECREMENT_ADAPTIVE_COUNTER(cache->counter);
2956
#endif /* ENABLE_SPECIALIZATION */
2957
assert((oparg >> 5) <= Py_GE);
2958
res = PyObject_RichCompare(left, right, oparg >> 5);
2959
#line 2960 "Python/generated_cases.c.h"
2960
Py_DECREF(left);
2961
Py_DECREF(right);
2962
#line 2104 "Python/bytecodes.c"
2963
if (res == NULL) goto pop_2_error;
2964
if (oparg & 16) {
2965
int res_bool = PyObject_IsTrue(res);
2966
Py_DECREF(res);
2967
if (res_bool < 0) goto pop_2_error;
2968
res = res_bool ? Py_True : Py_False;
2969
}
2970
#line 2971 "Python/generated_cases.c.h"
2971
STACK_SHRINK(1);
2972
stack_pointer[-1] = res;
2973
next_instr += 1;
2974
DISPATCH();
2975
}
2976
2977
TARGET(COMPARE_OP_FLOAT) {
2978
PyObject *right = stack_pointer[-1];
2979
PyObject *left = stack_pointer[-2];
2980
PyObject *res;
2981
#line 2114 "Python/bytecodes.c"
2982
DEOPT_IF(!PyFloat_CheckExact(left), COMPARE_OP);
2983
DEOPT_IF(!PyFloat_CheckExact(right), COMPARE_OP);
2984
STAT_INC(COMPARE_OP, hit);
2985
double dleft = PyFloat_AS_DOUBLE(left);
2986
double dright = PyFloat_AS_DOUBLE(right);
2987
// 1 if NaN, 2 if <, 4 if >, 8 if ==; this matches low four bits of the oparg
2988
int sign_ish = COMPARISON_BIT(dleft, dright);
2989
_Py_DECREF_SPECIALIZED(left, _PyFloat_ExactDealloc);
2990
_Py_DECREF_SPECIALIZED(right, _PyFloat_ExactDealloc);
2991
res = (sign_ish & oparg) ? Py_True : Py_False;
2992
// It's always a bool, so we don't care about oparg & 16.
2993
#line 2994 "Python/generated_cases.c.h"
2994
STACK_SHRINK(1);
2995
stack_pointer[-1] = res;
2996
next_instr += 1;
2997
DISPATCH();
2998
}
2999
3000
TARGET(COMPARE_OP_INT) {
3001
PyObject *right = stack_pointer[-1];
3002
PyObject *left = stack_pointer[-2];
3003
PyObject *res;
3004
#line 2129 "Python/bytecodes.c"
3005
DEOPT_IF(!PyLong_CheckExact(left), COMPARE_OP);
3006
DEOPT_IF(!PyLong_CheckExact(right), COMPARE_OP);
3007
DEOPT_IF(!_PyLong_IsCompact((PyLongObject *)left), COMPARE_OP);
3008
DEOPT_IF(!_PyLong_IsCompact((PyLongObject *)right), COMPARE_OP);
3009
STAT_INC(COMPARE_OP, hit);
3010
assert(_PyLong_DigitCount((PyLongObject *)left) <= 1 &&
3011
_PyLong_DigitCount((PyLongObject *)right) <= 1);
3012
Py_ssize_t ileft = _PyLong_CompactValue((PyLongObject *)left);
3013
Py_ssize_t iright = _PyLong_CompactValue((PyLongObject *)right);
3014
// 2 if <, 4 if >, 8 if ==; this matches the low 4 bits of the oparg
3015
int sign_ish = COMPARISON_BIT(ileft, iright);
3016
_Py_DECREF_SPECIALIZED(left, (destructor)PyObject_Free);
3017
_Py_DECREF_SPECIALIZED(right, (destructor)PyObject_Free);
3018
res = (sign_ish & oparg) ? Py_True : Py_False;
3019
// It's always a bool, so we don't care about oparg & 16.
3020
#line 3021 "Python/generated_cases.c.h"
3021
STACK_SHRINK(1);
3022
stack_pointer[-1] = res;
3023
next_instr += 1;
3024
DISPATCH();
3025
}
3026
3027
TARGET(COMPARE_OP_STR) {
3028
PyObject *right = stack_pointer[-1];
3029
PyObject *left = stack_pointer[-2];
3030
PyObject *res;
3031
#line 2148 "Python/bytecodes.c"
3032
DEOPT_IF(!PyUnicode_CheckExact(left), COMPARE_OP);
3033
DEOPT_IF(!PyUnicode_CheckExact(right), COMPARE_OP);
3034
STAT_INC(COMPARE_OP, hit);
3035
int eq = _PyUnicode_Equal(left, right);
3036
assert((oparg >> 5) == Py_EQ || (oparg >> 5) == Py_NE);
3037
_Py_DECREF_SPECIALIZED(left, _PyUnicode_ExactDealloc);
3038
_Py_DECREF_SPECIALIZED(right, _PyUnicode_ExactDealloc);
3039
assert(eq == 0 || eq == 1);
3040
assert((oparg & 0xf) == COMPARISON_NOT_EQUALS || (oparg & 0xf) == COMPARISON_EQUALS);
3041
assert(COMPARISON_NOT_EQUALS + 1 == COMPARISON_EQUALS);
3042
res = ((COMPARISON_NOT_EQUALS + eq) & oparg) ? Py_True : Py_False;
3043
// It's always a bool, so we don't care about oparg & 16.
3044
#line 3045 "Python/generated_cases.c.h"
3045
STACK_SHRINK(1);
3046
stack_pointer[-1] = res;
3047
next_instr += 1;
3048
DISPATCH();
3049
}
3050
3051
TARGET(IS_OP) {
3052
PyObject *right = stack_pointer[-1];
3053
PyObject *left = stack_pointer[-2];
3054
PyObject *b;
3055
#line 2163 "Python/bytecodes.c"
3056
int res = Py_Is(left, right) ^ oparg;
3057
#line 3058 "Python/generated_cases.c.h"
3058
Py_DECREF(left);
3059
Py_DECREF(right);
3060
#line 2165 "Python/bytecodes.c"
3061
b = res ? Py_True : Py_False;
3062
#line 3063 "Python/generated_cases.c.h"
3063
STACK_SHRINK(1);
3064
stack_pointer[-1] = b;
3065
DISPATCH();
3066
}
3067
3068
TARGET(CONTAINS_OP) {
3069
PyObject *right = stack_pointer[-1];
3070
PyObject *left = stack_pointer[-2];
3071
PyObject *b;
3072
#line 2169 "Python/bytecodes.c"
3073
int res = PySequence_Contains(right, left);
3074
#line 3075 "Python/generated_cases.c.h"
3075
Py_DECREF(left);
3076
Py_DECREF(right);
3077
#line 2171 "Python/bytecodes.c"
3078
if (res < 0) goto pop_2_error;
3079
b = (res ^ oparg) ? Py_True : Py_False;
3080
#line 3081 "Python/generated_cases.c.h"
3081
STACK_SHRINK(1);
3082
stack_pointer[-1] = b;
3083
DISPATCH();
3084
}
3085
3086
TARGET(CHECK_EG_MATCH) {
3087
PyObject *match_type = stack_pointer[-1];
3088
PyObject *exc_value = stack_pointer[-2];
3089
PyObject *rest;
3090
PyObject *match;
3091
#line 2176 "Python/bytecodes.c"
3092
if (check_except_star_type_valid(tstate, match_type) < 0) {
3093
#line 3094 "Python/generated_cases.c.h"
3094
Py_DECREF(exc_value);
3095
Py_DECREF(match_type);
3096
#line 2178 "Python/bytecodes.c"
3097
if (true) goto pop_2_error;
3098
}
3099
3100
match = NULL;
3101
rest = NULL;
3102
int res = exception_group_match(exc_value, match_type,
3103
&match, &rest);
3104
#line 3105 "Python/generated_cases.c.h"
3105
Py_DECREF(exc_value);
3106
Py_DECREF(match_type);
3107
#line 2186 "Python/bytecodes.c"
3108
if (res < 0) goto pop_2_error;
3109
3110
assert((match == NULL) == (rest == NULL));
3111
if (match == NULL) goto pop_2_error;
3112
3113
if (!Py_IsNone(match)) {
3114
PyErr_SetHandledException(match);
3115
}
3116
#line 3117 "Python/generated_cases.c.h"
3117
stack_pointer[-1] = match;
3118
stack_pointer[-2] = rest;
3119
DISPATCH();
3120
}
3121
3122
TARGET(CHECK_EXC_MATCH) {
3123
PyObject *right = stack_pointer[-1];
3124
PyObject *left = stack_pointer[-2];
3125
PyObject *b;
3126
#line 2197 "Python/bytecodes.c"
3127
assert(PyExceptionInstance_Check(left));
3128
if (check_except_type_valid(tstate, right) < 0) {
3129
#line 3130 "Python/generated_cases.c.h"
3130
Py_DECREF(right);
3131
#line 2200 "Python/bytecodes.c"
3132
if (true) goto pop_1_error;
3133
}
3134
3135
int res = PyErr_GivenExceptionMatches(left, right);
3136
#line 3137 "Python/generated_cases.c.h"
3137
Py_DECREF(right);
3138
#line 2205 "Python/bytecodes.c"
3139
b = res ? Py_True : Py_False;
3140
#line 3141 "Python/generated_cases.c.h"
3141
stack_pointer[-1] = b;
3142
DISPATCH();
3143
}
3144
3145
TARGET(IMPORT_NAME) {
3146
PyObject *fromlist = stack_pointer[-1];
3147
PyObject *level = stack_pointer[-2];
3148
PyObject *res;
3149
#line 2209 "Python/bytecodes.c"
3150
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg);
3151
res = import_name(tstate, frame, name, fromlist, level);
3152
#line 3153 "Python/generated_cases.c.h"
3153
Py_DECREF(level);
3154
Py_DECREF(fromlist);
3155
#line 2212 "Python/bytecodes.c"
3156
if (res == NULL) goto pop_2_error;
3157
#line 3158 "Python/generated_cases.c.h"
3158
STACK_SHRINK(1);
3159
stack_pointer[-1] = res;
3160
DISPATCH();
3161
}
3162
3163
TARGET(IMPORT_FROM) {
3164
PyObject *from = stack_pointer[-1];
3165
PyObject *res;
3166
#line 2216 "Python/bytecodes.c"
3167
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg);
3168
res = import_from(tstate, from, name);
3169
if (res == NULL) goto error;
3170
#line 3171 "Python/generated_cases.c.h"
3171
STACK_GROW(1);
3172
stack_pointer[-1] = res;
3173
DISPATCH();
3174
}
3175
3176
TARGET(JUMP_FORWARD) {
3177
#line 2222 "Python/bytecodes.c"
3178
JUMPBY(oparg);
3179
#line 3180 "Python/generated_cases.c.h"
3180
DISPATCH();
3181
}
3182
3183
TARGET(JUMP_BACKWARD) {
3184
#line 2226 "Python/bytecodes.c"
3185
_Py_CODEUNIT *here = next_instr - 1;
3186
assert(oparg <= INSTR_OFFSET());
3187
JUMPBY(1-oparg);
3188
#if ENABLE_SPECIALIZATION
3189
here[1].cache += (1 << OPTIMIZER_BITS_IN_COUNTER);
3190
if (here[1].cache > tstate->interp->optimizer_backedge_threshold) {
3191
OBJECT_STAT_INC(optimization_attempts);
3192
frame = _PyOptimizer_BackEdge(frame, here, next_instr, stack_pointer);
3193
if (frame == NULL) {
3194
frame = cframe.current_frame;
3195
goto error;
3196
}
3197
assert(frame == cframe.current_frame);
3198
here[1].cache &= ((1 << OPTIMIZER_BITS_IN_COUNTER) -1);
3199
goto resume_frame;
3200
}
3201
#endif /* ENABLE_SPECIALIZATION */
3202
#line 3203 "Python/generated_cases.c.h"
3203
CHECK_EVAL_BREAKER();
3204
DISPATCH();
3205
}
3206
3207
TARGET(ENTER_EXECUTOR) {
3208
#line 2257 "Python/bytecodes.c"
3209
PyCodeObject *code = _PyFrame_GetCode(frame);
3210
_PyExecutorObject *executor = (_PyExecutorObject *)code->co_executors->executors[oparg&255];
3211
Py_INCREF(executor);
3212
frame = executor->execute(executor, frame, stack_pointer);
3213
if (frame == NULL) {
3214
frame = cframe.current_frame;
3215
goto resume_with_error;
3216
}
3217
goto resume_frame;
3218
#line 3219 "Python/generated_cases.c.h"
3219
}
3220
3221
TARGET(POP_JUMP_IF_FALSE) {
3222
PyObject *cond = stack_pointer[-1];
3223
#line 2269 "Python/bytecodes.c"
3224
assert(PyBool_Check(cond));
3225
JUMPBY(oparg * Py_IsFalse(cond));
3226
#line 3227 "Python/generated_cases.c.h"
3227
STACK_SHRINK(1);
3228
DISPATCH();
3229
}
3230
3231
TARGET(POP_JUMP_IF_TRUE) {
3232
PyObject *cond = stack_pointer[-1];
3233
#line 2274 "Python/bytecodes.c"
3234
assert(PyBool_Check(cond));
3235
JUMPBY(oparg * Py_IsTrue(cond));
3236
#line 3237 "Python/generated_cases.c.h"
3237
STACK_SHRINK(1);
3238
DISPATCH();
3239
}
3240
3241
TARGET(POP_JUMP_IF_NOT_NONE) {
3242
PyObject *value = stack_pointer[-1];
3243
#line 2279 "Python/bytecodes.c"
3244
if (!Py_IsNone(value)) {
3245
#line 3246 "Python/generated_cases.c.h"
3246
Py_DECREF(value);
3247
#line 2281 "Python/bytecodes.c"
3248
JUMPBY(oparg);
3249
}
3250
#line 3251 "Python/generated_cases.c.h"
3251
STACK_SHRINK(1);
3252
DISPATCH();
3253
}
3254
3255
TARGET(POP_JUMP_IF_NONE) {
3256
PyObject *value = stack_pointer[-1];
3257
#line 2286 "Python/bytecodes.c"
3258
if (Py_IsNone(value)) {
3259
JUMPBY(oparg);
3260
}
3261
else {
3262
#line 3263 "Python/generated_cases.c.h"
3263
Py_DECREF(value);
3264
#line 2291 "Python/bytecodes.c"
3265
}
3266
#line 3267 "Python/generated_cases.c.h"
3267
STACK_SHRINK(1);
3268
DISPATCH();
3269
}
3270
3271
TARGET(JUMP_BACKWARD_NO_INTERRUPT) {
3272
#line 2295 "Python/bytecodes.c"
3273
/* This bytecode is used in the `yield from` or `await` loop.
3274
* If there is an interrupt, we want it handled in the innermost
3275
* generator or coroutine, so we deliberately do not check it here.
3276
* (see bpo-30039).
3277
*/
3278
JUMPBY(-oparg);
3279
#line 3280 "Python/generated_cases.c.h"
3280
DISPATCH();
3281
}
3282
3283
TARGET(GET_LEN) {
3284
PyObject *obj = stack_pointer[-1];
3285
PyObject *len_o;
3286
#line 2304 "Python/bytecodes.c"
3287
// PUSH(len(TOS))
3288
Py_ssize_t len_i = PyObject_Length(obj);
3289
if (len_i < 0) goto error;
3290
len_o = PyLong_FromSsize_t(len_i);
3291
if (len_o == NULL) goto error;
3292
#line 3293 "Python/generated_cases.c.h"
3293
STACK_GROW(1);
3294
stack_pointer[-1] = len_o;
3295
DISPATCH();
3296
}
3297
3298
TARGET(MATCH_CLASS) {
3299
PyObject *names = stack_pointer[-1];
3300
PyObject *type = stack_pointer[-2];
3301
PyObject *subject = stack_pointer[-3];
3302
PyObject *attrs;
3303
#line 2312 "Python/bytecodes.c"
3304
// Pop TOS and TOS1. Set TOS to a tuple of attributes on success, or
3305
// None on failure.
3306
assert(PyTuple_CheckExact(names));
3307
attrs = match_class(tstate, subject, type, oparg, names);
3308
#line 3309 "Python/generated_cases.c.h"
3309
Py_DECREF(subject);
3310
Py_DECREF(type);
3311
Py_DECREF(names);
3312
#line 2317 "Python/bytecodes.c"
3313
if (attrs) {
3314
assert(PyTuple_CheckExact(attrs)); // Success!
3315
}
3316
else {
3317
if (_PyErr_Occurred(tstate)) goto pop_3_error;
3318
attrs = Py_None; // Failure!
3319
}
3320
#line 3321 "Python/generated_cases.c.h"
3321
STACK_SHRINK(2);
3322
stack_pointer[-1] = attrs;
3323
DISPATCH();
3324
}
3325
3326
TARGET(MATCH_MAPPING) {
3327
PyObject *subject = stack_pointer[-1];
3328
PyObject *res;
3329
#line 2327 "Python/bytecodes.c"
3330
int match = Py_TYPE(subject)->tp_flags & Py_TPFLAGS_MAPPING;
3331
res = match ? Py_True : Py_False;
3332
#line 3333 "Python/generated_cases.c.h"
3333
STACK_GROW(1);
3334
stack_pointer[-1] = res;
3335
DISPATCH();
3336
}
3337
3338
TARGET(MATCH_SEQUENCE) {
3339
PyObject *subject = stack_pointer[-1];
3340
PyObject *res;
3341
#line 2332 "Python/bytecodes.c"
3342
int match = Py_TYPE(subject)->tp_flags & Py_TPFLAGS_SEQUENCE;
3343
res = match ? Py_True : Py_False;
3344
#line 3345 "Python/generated_cases.c.h"
3345
STACK_GROW(1);
3346
stack_pointer[-1] = res;
3347
DISPATCH();
3348
}
3349
3350
TARGET(MATCH_KEYS) {
3351
PyObject *keys = stack_pointer[-1];
3352
PyObject *subject = stack_pointer[-2];
3353
PyObject *values_or_none;
3354
#line 2337 "Python/bytecodes.c"
3355
// On successful match, PUSH(values). Otherwise, PUSH(None).
3356
values_or_none = match_keys(tstate, subject, keys);
3357
if (values_or_none == NULL) goto error;
3358
#line 3359 "Python/generated_cases.c.h"
3359
STACK_GROW(1);
3360
stack_pointer[-1] = values_or_none;
3361
DISPATCH();
3362
}
3363
3364
TARGET(GET_ITER) {
3365
PyObject *iterable = stack_pointer[-1];
3366
PyObject *iter;
3367
#line 2343 "Python/bytecodes.c"
3368
/* before: [obj]; after [getiter(obj)] */
3369
iter = PyObject_GetIter(iterable);
3370
#line 3371 "Python/generated_cases.c.h"
3371
Py_DECREF(iterable);
3372
#line 2346 "Python/bytecodes.c"
3373
if (iter == NULL) goto pop_1_error;
3374
#line 3375 "Python/generated_cases.c.h"
3375
stack_pointer[-1] = iter;
3376
DISPATCH();
3377
}
3378
3379
TARGET(GET_YIELD_FROM_ITER) {
3380
PyObject *iterable = stack_pointer[-1];
3381
PyObject *iter;
3382
#line 2350 "Python/bytecodes.c"
3383
/* before: [obj]; after [getiter(obj)] */
3384
if (PyCoro_CheckExact(iterable)) {
3385
/* `iterable` is a coroutine */
3386
if (!(_PyFrame_GetCode(frame)->co_flags & (CO_COROUTINE | CO_ITERABLE_COROUTINE))) {
3387
/* and it is used in a 'yield from' expression of a
3388
regular generator. */
3389
_PyErr_SetString(tstate, PyExc_TypeError,
3390
"cannot 'yield from' a coroutine object "
3391
"in a non-coroutine generator");
3392
goto error;
3393
}
3394
iter = iterable;
3395
}
3396
else if (PyGen_CheckExact(iterable)) {
3397
iter = iterable;
3398
}
3399
else {
3400
/* `iterable` is not a generator. */
3401
iter = PyObject_GetIter(iterable);
3402
if (iter == NULL) {
3403
goto error;
3404
}
3405
#line 3406 "Python/generated_cases.c.h"
3406
Py_DECREF(iterable);
3407
#line 2373 "Python/bytecodes.c"
3408
}
3409
#line 3410 "Python/generated_cases.c.h"
3410
stack_pointer[-1] = iter;
3411
DISPATCH();
3412
}
3413
3414
TARGET(FOR_ITER) {
3415
PREDICTED(FOR_ITER);
3416
static_assert(INLINE_CACHE_ENTRIES_FOR_ITER == 1, "incorrect cache size");
3417
PyObject *iter = stack_pointer[-1];
3418
PyObject *next;
3419
#line 2391 "Python/bytecodes.c"
3420
#if ENABLE_SPECIALIZATION
3421
_PyForIterCache *cache = (_PyForIterCache *)next_instr;
3422
if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
3423
next_instr--;
3424
_Py_Specialize_ForIter(iter, next_instr, oparg);
3425
DISPATCH_SAME_OPARG();
3426
}
3427
STAT_INC(FOR_ITER, deferred);
3428
DECREMENT_ADAPTIVE_COUNTER(cache->counter);
3429
#endif /* ENABLE_SPECIALIZATION */
3430
/* before: [iter]; after: [iter, iter()] *or* [] (and jump over END_FOR.) */
3431
next = (*Py_TYPE(iter)->tp_iternext)(iter);
3432
if (next == NULL) {
3433
if (_PyErr_Occurred(tstate)) {
3434
if (!_PyErr_ExceptionMatches(tstate, PyExc_StopIteration)) {
3435
goto error;
3436
}
3437
monitor_raise(tstate, frame, next_instr-1);
3438
_PyErr_Clear(tstate);
3439
}
3440
/* iterator ended normally */
3441
assert(next_instr[INLINE_CACHE_ENTRIES_FOR_ITER + oparg].op.code == END_FOR ||
3442
next_instr[INLINE_CACHE_ENTRIES_FOR_ITER + oparg].op.code == INSTRUMENTED_END_FOR);
3443
Py_DECREF(iter);
3444
STACK_SHRINK(1);
3445
SKIP_OVER(INLINE_CACHE_ENTRIES_FOR_ITER);
3446
/* Jump forward oparg, then skip following END_FOR instruction */
3447
JUMPBY(oparg + 1);
3448
DISPATCH();
3449
}
3450
// Common case: no jump, leave it to the code generator
3451
#line 3452 "Python/generated_cases.c.h"
3452
STACK_GROW(1);
3453
stack_pointer[-1] = next;
3454
next_instr += 1;
3455
DISPATCH();
3456
}
3457
3458
TARGET(INSTRUMENTED_FOR_ITER) {
3459
#line 2425 "Python/bytecodes.c"
3460
_Py_CODEUNIT *here = next_instr-1;
3461
_Py_CODEUNIT *target;
3462
PyObject *iter = TOP();
3463
PyObject *next = (*Py_TYPE(iter)->tp_iternext)(iter);
3464
if (next != NULL) {
3465
PUSH(next);
3466
target = next_instr + INLINE_CACHE_ENTRIES_FOR_ITER;
3467
}
3468
else {
3469
if (_PyErr_Occurred(tstate)) {
3470
if (!_PyErr_ExceptionMatches(tstate, PyExc_StopIteration)) {
3471
goto error;
3472
}
3473
monitor_raise(tstate, frame, here);
3474
_PyErr_Clear(tstate);
3475
}
3476
/* iterator ended normally */
3477
assert(next_instr[INLINE_CACHE_ENTRIES_FOR_ITER + oparg].op.code == END_FOR ||
3478
next_instr[INLINE_CACHE_ENTRIES_FOR_ITER + oparg].op.code == INSTRUMENTED_END_FOR);
3479
STACK_SHRINK(1);
3480
Py_DECREF(iter);
3481
/* Skip END_FOR */
3482
target = next_instr + INLINE_CACHE_ENTRIES_FOR_ITER + oparg + 1;
3483
}
3484
INSTRUMENTED_JUMP(here, target, PY_MONITORING_EVENT_BRANCH);
3485
#line 3486 "Python/generated_cases.c.h"
3486
DISPATCH();
3487
}
3488
3489
TARGET(FOR_ITER_LIST) {
3490
PyObject *iter = stack_pointer[-1];
3491
PyObject *next;
3492
#line 2453 "Python/bytecodes.c"
3493
DEOPT_IF(Py_TYPE(iter) != &PyListIter_Type, FOR_ITER);
3494
_PyListIterObject *it = (_PyListIterObject *)iter;
3495
STAT_INC(FOR_ITER, hit);
3496
PyListObject *seq = it->it_seq;
3497
if (seq) {
3498
if (it->it_index < PyList_GET_SIZE(seq)) {
3499
next = Py_NewRef(PyList_GET_ITEM(seq, it->it_index++));
3500
goto end_for_iter_list; // End of this instruction
3501
}
3502
it->it_seq = NULL;
3503
Py_DECREF(seq);
3504
}
3505
Py_DECREF(iter);
3506
STACK_SHRINK(1);
3507
SKIP_OVER(INLINE_CACHE_ENTRIES_FOR_ITER);
3508
/* Jump forward oparg, then skip following END_FOR instruction */
3509
JUMPBY(oparg + 1);
3510
DISPATCH();
3511
end_for_iter_list:
3512
// Common case: no jump, leave it to the code generator
3513
#line 3514 "Python/generated_cases.c.h"
3514
STACK_GROW(1);
3515
stack_pointer[-1] = next;
3516
next_instr += 1;
3517
DISPATCH();
3518
}
3519
3520
TARGET(FOR_ITER_TUPLE) {
3521
PyObject *iter = stack_pointer[-1];
3522
PyObject *next;
3523
#line 2476 "Python/bytecodes.c"
3524
_PyTupleIterObject *it = (_PyTupleIterObject *)iter;
3525
DEOPT_IF(Py_TYPE(it) != &PyTupleIter_Type, FOR_ITER);
3526
STAT_INC(FOR_ITER, hit);
3527
PyTupleObject *seq = it->it_seq;
3528
if (seq) {
3529
if (it->it_index < PyTuple_GET_SIZE(seq)) {
3530
next = Py_NewRef(PyTuple_GET_ITEM(seq, it->it_index++));
3531
goto end_for_iter_tuple; // End of this instruction
3532
}
3533
it->it_seq = NULL;
3534
Py_DECREF(seq);
3535
}
3536
Py_DECREF(iter);
3537
STACK_SHRINK(1);
3538
SKIP_OVER(INLINE_CACHE_ENTRIES_FOR_ITER);
3539
/* Jump forward oparg, then skip following END_FOR instruction */
3540
JUMPBY(oparg + 1);
3541
DISPATCH();
3542
end_for_iter_tuple:
3543
// Common case: no jump, leave it to the code generator
3544
#line 3545 "Python/generated_cases.c.h"
3545
STACK_GROW(1);
3546
stack_pointer[-1] = next;
3547
next_instr += 1;
3548
DISPATCH();
3549
}
3550
3551
TARGET(FOR_ITER_RANGE) {
3552
PyObject *iter = stack_pointer[-1];
3553
PyObject *next;
3554
#line 2499 "Python/bytecodes.c"
3555
_PyRangeIterObject *r = (_PyRangeIterObject *)iter;
3556
DEOPT_IF(Py_TYPE(r) != &PyRangeIter_Type, FOR_ITER);
3557
STAT_INC(FOR_ITER, hit);
3558
if (r->len <= 0) {
3559
STACK_SHRINK(1);
3560
Py_DECREF(r);
3561
SKIP_OVER(INLINE_CACHE_ENTRIES_FOR_ITER);
3562
// Jump over END_FOR instruction.
3563
JUMPBY(oparg + 1);
3564
DISPATCH();
3565
}
3566
long value = r->start;
3567
r->start = value + r->step;
3568
r->len--;
3569
next = PyLong_FromLong(value);
3570
if (next == NULL) {
3571
goto error;
3572
}
3573
#line 3574 "Python/generated_cases.c.h"
3574
STACK_GROW(1);
3575
stack_pointer[-1] = next;
3576
next_instr += 1;
3577
DISPATCH();
3578
}
3579
3580
TARGET(FOR_ITER_GEN) {
3581
PyObject *iter = stack_pointer[-1];
3582
#line 2520 "Python/bytecodes.c"
3583
DEOPT_IF(tstate->interp->eval_frame, FOR_ITER);
3584
PyGenObject *gen = (PyGenObject *)iter;
3585
DEOPT_IF(Py_TYPE(gen) != &PyGen_Type, FOR_ITER);
3586
DEOPT_IF(gen->gi_frame_state >= FRAME_EXECUTING, FOR_ITER);
3587
STAT_INC(FOR_ITER, hit);
3588
_PyInterpreterFrame *gen_frame = (_PyInterpreterFrame *)gen->gi_iframe;
3589
frame->return_offset = oparg;
3590
_PyFrame_StackPush(gen_frame, Py_None);
3591
gen->gi_frame_state = FRAME_EXECUTING;
3592
gen->gi_exc_state.previous_item = tstate->exc_info;
3593
tstate->exc_info = &gen->gi_exc_state;
3594
SKIP_OVER(INLINE_CACHE_ENTRIES_FOR_ITER);
3595
assert(next_instr[oparg].op.code == END_FOR ||
3596
next_instr[oparg].op.code == INSTRUMENTED_END_FOR);
3597
DISPATCH_INLINED(gen_frame);
3598
#line 3599 "Python/generated_cases.c.h"
3599
}
3600
3601
TARGET(BEFORE_ASYNC_WITH) {
3602
PyObject *mgr = stack_pointer[-1];
3603
PyObject *exit;
3604
PyObject *res;
3605
#line 2538 "Python/bytecodes.c"
3606
PyObject *enter = _PyObject_LookupSpecial(mgr, &_Py_ID(__aenter__));
3607
if (enter == NULL) {
3608
if (!_PyErr_Occurred(tstate)) {
3609
_PyErr_Format(tstate, PyExc_TypeError,
3610
"'%.200s' object does not support the "
3611
"asynchronous context manager protocol",
3612
Py_TYPE(mgr)->tp_name);
3613
}
3614
goto error;
3615
}
3616
exit = _PyObject_LookupSpecial(mgr, &_Py_ID(__aexit__));
3617
if (exit == NULL) {
3618
if (!_PyErr_Occurred(tstate)) {
3619
_PyErr_Format(tstate, PyExc_TypeError,
3620
"'%.200s' object does not support the "
3621
"asynchronous context manager protocol "
3622
"(missed __aexit__ method)",
3623
Py_TYPE(mgr)->tp_name);
3624
}
3625
Py_DECREF(enter);
3626
goto error;
3627
}
3628
#line 3629 "Python/generated_cases.c.h"
3629
Py_DECREF(mgr);
3630
#line 2561 "Python/bytecodes.c"
3631
res = _PyObject_CallNoArgs(enter);
3632
Py_DECREF(enter);
3633
if (res == NULL) {
3634
Py_DECREF(exit);
3635
if (true) goto pop_1_error;
3636
}
3637
#line 3638 "Python/generated_cases.c.h"
3638
STACK_GROW(1);
3639
stack_pointer[-1] = res;
3640
stack_pointer[-2] = exit;
3641
DISPATCH();
3642
}
3643
3644
TARGET(BEFORE_WITH) {
3645
PyObject *mgr = stack_pointer[-1];
3646
PyObject *exit;
3647
PyObject *res;
3648
#line 2570 "Python/bytecodes.c"
3649
/* pop the context manager, push its __exit__ and the
3650
* value returned from calling its __enter__
3651
*/
3652
PyObject *enter = _PyObject_LookupSpecial(mgr, &_Py_ID(__enter__));
3653
if (enter == NULL) {
3654
if (!_PyErr_Occurred(tstate)) {
3655
_PyErr_Format(tstate, PyExc_TypeError,
3656
"'%.200s' object does not support the "
3657
"context manager protocol",
3658
Py_TYPE(mgr)->tp_name);
3659
}
3660
goto error;
3661
}
3662
exit = _PyObject_LookupSpecial(mgr, &_Py_ID(__exit__));
3663
if (exit == NULL) {
3664
if (!_PyErr_Occurred(tstate)) {
3665
_PyErr_Format(tstate, PyExc_TypeError,
3666
"'%.200s' object does not support the "
3667
"context manager protocol "
3668
"(missed __exit__ method)",
3669
Py_TYPE(mgr)->tp_name);
3670
}
3671
Py_DECREF(enter);
3672
goto error;
3673
}
3674
#line 3675 "Python/generated_cases.c.h"
3675
Py_DECREF(mgr);
3676
#line 2596 "Python/bytecodes.c"
3677
res = _PyObject_CallNoArgs(enter);
3678
Py_DECREF(enter);
3679
if (res == NULL) {
3680
Py_DECREF(exit);
3681
if (true) goto pop_1_error;
3682
}
3683
#line 3684 "Python/generated_cases.c.h"
3684
STACK_GROW(1);
3685
stack_pointer[-1] = res;
3686
stack_pointer[-2] = exit;
3687
DISPATCH();
3688
}
3689
3690
TARGET(WITH_EXCEPT_START) {
3691
PyObject *val = stack_pointer[-1];
3692
PyObject *lasti = stack_pointer[-3];
3693
PyObject *exit_func = stack_pointer[-4];
3694
PyObject *res;
3695
#line 2605 "Python/bytecodes.c"
3696
/* At the top of the stack are 4 values:
3697
- val: TOP = exc_info()
3698
- unused: SECOND = previous exception
3699
- lasti: THIRD = lasti of exception in exc_info()
3700
- exit_func: FOURTH = the context.__exit__ bound method
3701
We call FOURTH(type(TOP), TOP, GetTraceback(TOP)).
3702
Then we push the __exit__ return value.
3703
*/
3704
PyObject *exc, *tb;
3705
3706
assert(val && PyExceptionInstance_Check(val));
3707
exc = PyExceptionInstance_Class(val);
3708
tb = PyException_GetTraceback(val);
3709
Py_XDECREF(tb);
3710
assert(PyLong_Check(lasti));
3711
(void)lasti; // Shut up compiler warning if asserts are off
3712
PyObject *stack[4] = {NULL, exc, val, tb};
3713
res = PyObject_Vectorcall(exit_func, stack + 1,
3714
3 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL);
3715
if (res == NULL) goto error;
3716
#line 3717 "Python/generated_cases.c.h"
3717
STACK_GROW(1);
3718
stack_pointer[-1] = res;
3719
DISPATCH();
3720
}
3721
3722
TARGET(PUSH_EXC_INFO) {
3723
PyObject *new_exc = stack_pointer[-1];
3724
PyObject *prev_exc;
3725
#line 2644 "Python/bytecodes.c"
3726
_PyErr_StackItem *exc_info = tstate->exc_info;
3727
if (exc_info->exc_value != NULL) {
3728
prev_exc = exc_info->exc_value;
3729
}
3730
else {
3731
prev_exc = Py_None;
3732
}
3733
assert(PyExceptionInstance_Check(new_exc));
3734
exc_info->exc_value = Py_NewRef(new_exc);
3735
#line 3736 "Python/generated_cases.c.h"
3736
STACK_GROW(1);
3737
stack_pointer[-1] = new_exc;
3738
stack_pointer[-2] = prev_exc;
3739
DISPATCH();
3740
}
3741
3742
TARGET(LOAD_ATTR_METHOD_WITH_VALUES) {
3743
PyObject *self = stack_pointer[-1];
3744
PyObject *res2 = NULL;
3745
PyObject *res;
3746
uint32_t type_version = read_u32(&next_instr[1].cache);
3747
uint32_t keys_version = read_u32(&next_instr[3].cache);
3748
PyObject *descr = read_obj(&next_instr[5].cache);
3749
#line 2656 "Python/bytecodes.c"
3750
/* Cached method object */
3751
PyTypeObject *self_cls = Py_TYPE(self);
3752
assert(type_version != 0);
3753
DEOPT_IF(self_cls->tp_version_tag != type_version, LOAD_ATTR);
3754
assert(self_cls->tp_flags & Py_TPFLAGS_MANAGED_DICT);
3755
PyDictOrValues dorv = *_PyObject_DictOrValuesPointer(self);
3756
DEOPT_IF(!_PyDictOrValues_IsValues(dorv), LOAD_ATTR);
3757
PyHeapTypeObject *self_heap_type = (PyHeapTypeObject *)self_cls;
3758
DEOPT_IF(self_heap_type->ht_cached_keys->dk_version !=
3759
keys_version, LOAD_ATTR);
3760
STAT_INC(LOAD_ATTR, hit);
3761
assert(descr != NULL);
3762
res2 = Py_NewRef(descr);
3763
assert(_PyType_HasFeature(Py_TYPE(res2), Py_TPFLAGS_METHOD_DESCRIPTOR));
3764
res = self;
3765
assert(oparg & 1);
3766
#line 3767 "Python/generated_cases.c.h"
3767
STACK_GROW(((oparg & 1) ? 1 : 0));
3768
stack_pointer[-1] = res;
3769
if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; }
3770
next_instr += 9;
3771
DISPATCH();
3772
}
3773
3774
TARGET(LOAD_ATTR_METHOD_NO_DICT) {
3775
PyObject *self = stack_pointer[-1];
3776
PyObject *res2 = NULL;
3777
PyObject *res;
3778
uint32_t type_version = read_u32(&next_instr[1].cache);
3779
PyObject *descr = read_obj(&next_instr[5].cache);
3780
#line 2675 "Python/bytecodes.c"
3781
PyTypeObject *self_cls = Py_TYPE(self);
3782
DEOPT_IF(self_cls->tp_version_tag != type_version, LOAD_ATTR);
3783
assert(self_cls->tp_dictoffset == 0);
3784
STAT_INC(LOAD_ATTR, hit);
3785
assert(descr != NULL);
3786
assert(_PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_METHOD_DESCRIPTOR));
3787
res2 = Py_NewRef(descr);
3788
res = self;
3789
assert(oparg & 1);
3790
#line 3791 "Python/generated_cases.c.h"
3791
STACK_GROW(((oparg & 1) ? 1 : 0));
3792
stack_pointer[-1] = res;
3793
if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; }
3794
next_instr += 9;
3795
DISPATCH();
3796
}
3797
3798
TARGET(LOAD_ATTR_METHOD_LAZY_DICT) {
3799
PyObject *self = stack_pointer[-1];
3800
PyObject *res2 = NULL;
3801
PyObject *res;
3802
uint32_t type_version = read_u32(&next_instr[1].cache);
3803
PyObject *descr = read_obj(&next_instr[5].cache);
3804
#line 2687 "Python/bytecodes.c"
3805
PyTypeObject *self_cls = Py_TYPE(self);
3806
DEOPT_IF(self_cls->tp_version_tag != type_version, LOAD_ATTR);
3807
Py_ssize_t dictoffset = self_cls->tp_dictoffset;
3808
assert(dictoffset > 0);
3809
PyObject *dict = *(PyObject **)((char *)self + dictoffset);
3810
/* This object has a __dict__, just not yet created */
3811
DEOPT_IF(dict != NULL, LOAD_ATTR);
3812
STAT_INC(LOAD_ATTR, hit);
3813
assert(descr != NULL);
3814
assert(_PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_METHOD_DESCRIPTOR));
3815
res2 = Py_NewRef(descr);
3816
res = self;
3817
assert(oparg & 1);
3818
#line 3819 "Python/generated_cases.c.h"
3819
STACK_GROW(((oparg & 1) ? 1 : 0));
3820
stack_pointer[-1] = res;
3821
if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; }
3822
next_instr += 9;
3823
DISPATCH();
3824
}
3825
3826
TARGET(KW_NAMES) {
3827
#line 2703 "Python/bytecodes.c"
3828
assert(kwnames == NULL);
3829
assert(oparg < PyTuple_GET_SIZE(FRAME_CO_CONSTS));
3830
kwnames = GETITEM(FRAME_CO_CONSTS, oparg);
3831
#line 3832 "Python/generated_cases.c.h"
3832
DISPATCH();
3833
}
3834
3835
TARGET(INSTRUMENTED_CALL) {
3836
#line 2709 "Python/bytecodes.c"
3837
int is_meth = PEEK(oparg+2) != NULL;
3838
int total_args = oparg + is_meth;
3839
PyObject *function = PEEK(total_args + 1);
3840
PyObject *arg = total_args == 0 ?
3841
&_PyInstrumentation_MISSING : PEEK(total_args);
3842
int err = _Py_call_instrumentation_2args(
3843
tstate, PY_MONITORING_EVENT_CALL,
3844
frame, next_instr-1, function, arg);
3845
if (err) goto error;
3846
_PyCallCache *cache = (_PyCallCache *)next_instr;
3847
INCREMENT_ADAPTIVE_COUNTER(cache->counter);
3848
GO_TO_INSTRUCTION(CALL);
3849
#line 3850 "Python/generated_cases.c.h"
3850
}
3851
3852
TARGET(CALL) {
3853
PREDICTED(CALL);
3854
static_assert(INLINE_CACHE_ENTRIES_CALL == 3, "incorrect cache size");
3855
PyObject **args = (stack_pointer - oparg);
3856
PyObject *callable = stack_pointer[-(1 + oparg)];
3857
PyObject *method = stack_pointer[-(2 + oparg)];
3858
PyObject *res;
3859
#line 2755 "Python/bytecodes.c"
3860
int is_meth = method != NULL;
3861
int total_args = oparg;
3862
if (is_meth) {
3863
callable = method;
3864
args--;
3865
total_args++;
3866
}
3867
#if ENABLE_SPECIALIZATION
3868
_PyCallCache *cache = (_PyCallCache *)next_instr;
3869
if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
3870
next_instr--;
3871
_Py_Specialize_Call(callable, next_instr, total_args, kwnames);
3872
DISPATCH_SAME_OPARG();
3873
}
3874
STAT_INC(CALL, deferred);
3875
DECREMENT_ADAPTIVE_COUNTER(cache->counter);
3876
#endif /* ENABLE_SPECIALIZATION */
3877
if (!is_meth && Py_TYPE(callable) == &PyMethod_Type) {
3878
is_meth = 1; // For consistenct; it's dead, though
3879
args--;
3880
total_args++;
3881
PyObject *self = ((PyMethodObject *)callable)->im_self;
3882
args[0] = Py_NewRef(self);
3883
method = ((PyMethodObject *)callable)->im_func;
3884
args[-1] = Py_NewRef(method);
3885
Py_DECREF(callable);
3886
callable = method;
3887
}
3888
int positional_args = total_args - KWNAMES_LEN();
3889
// Check if the call can be inlined or not
3890
if (Py_TYPE(callable) == &PyFunction_Type &&
3891
tstate->interp->eval_frame == NULL &&
3892
((PyFunctionObject *)callable)->vectorcall == _PyFunction_Vectorcall)
3893
{
3894
int code_flags = ((PyCodeObject*)PyFunction_GET_CODE(callable))->co_flags;
3895
PyObject *locals = code_flags & CO_OPTIMIZED ? NULL : Py_NewRef(PyFunction_GET_GLOBALS(callable));
3896
_PyInterpreterFrame *new_frame = _PyEvalFramePushAndInit(
3897
tstate, (PyFunctionObject *)callable, locals,
3898
args, positional_args, kwnames
3899
);
3900
kwnames = NULL;
3901
// Manipulate stack directly since we leave using DISPATCH_INLINED().
3902
STACK_SHRINK(oparg + 2);
3903
// The frame has stolen all the arguments from the stack,
3904
// so there is no need to clean them up.
3905
if (new_frame == NULL) {
3906
goto error;
3907
}
3908
SKIP_OVER(INLINE_CACHE_ENTRIES_CALL);
3909
frame->return_offset = 0;
3910
DISPATCH_INLINED(new_frame);
3911
}
3912
/* Callable is not a normal Python function */
3913
res = PyObject_Vectorcall(
3914
callable, args,
3915
positional_args | PY_VECTORCALL_ARGUMENTS_OFFSET,
3916
kwnames);
3917
if (opcode == INSTRUMENTED_CALL) {
3918
PyObject *arg = total_args == 0 ?
3919
&_PyInstrumentation_MISSING : PEEK(total_args);
3920
if (res == NULL) {
3921
_Py_call_instrumentation_exc2(
3922
tstate, PY_MONITORING_EVENT_C_RAISE,
3923
frame, next_instr-1, callable, arg);
3924
}
3925
else {
3926
int err = _Py_call_instrumentation_2args(
3927
tstate, PY_MONITORING_EVENT_C_RETURN,
3928
frame, next_instr-1, callable, arg);
3929
if (err < 0) {
3930
Py_CLEAR(res);
3931
}
3932
}
3933
}
3934
kwnames = NULL;
3935
assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL));
3936
Py_DECREF(callable);
3937
for (int i = 0; i < total_args; i++) {
3938
Py_DECREF(args[i]);
3939
}
3940
if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; }
3941
#line 3942 "Python/generated_cases.c.h"
3942
STACK_SHRINK(oparg);
3943
STACK_SHRINK(1);
3944
stack_pointer[-1] = res;
3945
next_instr += 3;
3946
CHECK_EVAL_BREAKER();
3947
DISPATCH();
3948
}
3949
3950
TARGET(CALL_BOUND_METHOD_EXACT_ARGS) {
3951
PyObject *callable = stack_pointer[-(1 + oparg)];
3952
PyObject *method = stack_pointer[-(2 + oparg)];
3953
#line 2843 "Python/bytecodes.c"
3954
DEOPT_IF(method != NULL, CALL);
3955
DEOPT_IF(Py_TYPE(callable) != &PyMethod_Type, CALL);
3956
STAT_INC(CALL, hit);
3957
PyObject *self = ((PyMethodObject *)callable)->im_self;
3958
PEEK(oparg + 1) = Py_NewRef(self); // callable
3959
PyObject *meth = ((PyMethodObject *)callable)->im_func;
3960
PEEK(oparg + 2) = Py_NewRef(meth); // method
3961
Py_DECREF(callable);
3962
GO_TO_INSTRUCTION(CALL_PY_EXACT_ARGS);
3963
#line 3964 "Python/generated_cases.c.h"
3964
}
3965
3966
TARGET(CALL_PY_EXACT_ARGS) {
3967
PREDICTED(CALL_PY_EXACT_ARGS);
3968
PyObject **args = (stack_pointer - oparg);
3969
PyObject *callable = stack_pointer[-(1 + oparg)];
3970
PyObject *method = stack_pointer[-(2 + oparg)];
3971
uint32_t func_version = read_u32(&next_instr[1].cache);
3972
#line 2855 "Python/bytecodes.c"
3973
assert(kwnames == NULL);
3974
DEOPT_IF(tstate->interp->eval_frame, CALL);
3975
int is_meth = method != NULL;
3976
int argcount = oparg;
3977
if (is_meth) {
3978
callable = method;
3979
args--;
3980
argcount++;
3981
}
3982
DEOPT_IF(!PyFunction_Check(callable), CALL);
3983
PyFunctionObject *func = (PyFunctionObject *)callable;
3984
DEOPT_IF(func->func_version != func_version, CALL);
3985
PyCodeObject *code = (PyCodeObject *)func->func_code;
3986
DEOPT_IF(code->co_argcount != argcount, CALL);
3987
DEOPT_IF(!_PyThreadState_HasStackSpace(tstate, code->co_framesize), CALL);
3988
STAT_INC(CALL, hit);
3989
_PyInterpreterFrame *new_frame = _PyFrame_PushUnchecked(tstate, func, argcount);
3990
for (int i = 0; i < argcount; i++) {
3991
new_frame->localsplus[i] = args[i];
3992
}
3993
// Manipulate stack directly since we leave using DISPATCH_INLINED().
3994
STACK_SHRINK(oparg + 2);
3995
SKIP_OVER(INLINE_CACHE_ENTRIES_CALL);
3996
frame->return_offset = 0;
3997
DISPATCH_INLINED(new_frame);
3998
#line 3999 "Python/generated_cases.c.h"
3999
}
4000
4001
TARGET(CALL_PY_WITH_DEFAULTS) {
4002
PyObject **args = (stack_pointer - oparg);
4003
PyObject *callable = stack_pointer[-(1 + oparg)];
4004
PyObject *method = stack_pointer[-(2 + oparg)];
4005
uint32_t func_version = read_u32(&next_instr[1].cache);
4006
#line 2883 "Python/bytecodes.c"
4007
assert(kwnames == NULL);
4008
DEOPT_IF(tstate->interp->eval_frame, CALL);
4009
int is_meth = method != NULL;
4010
int argcount = oparg;
4011
if (is_meth) {
4012
callable = method;
4013
args--;
4014
argcount++;
4015
}
4016
DEOPT_IF(!PyFunction_Check(callable), CALL);
4017
PyFunctionObject *func = (PyFunctionObject *)callable;
4018
DEOPT_IF(func->func_version != func_version, CALL);
4019
PyCodeObject *code = (PyCodeObject *)func->func_code;
4020
assert(func->func_defaults);
4021
assert(PyTuple_CheckExact(func->func_defaults));
4022
int defcount = (int)PyTuple_GET_SIZE(func->func_defaults);
4023
assert(defcount <= code->co_argcount);
4024
int min_args = code->co_argcount - defcount;
4025
DEOPT_IF(argcount > code->co_argcount, CALL);
4026
DEOPT_IF(argcount < min_args, CALL);
4027
DEOPT_IF(!_PyThreadState_HasStackSpace(tstate, code->co_framesize), CALL);
4028
STAT_INC(CALL, hit);
4029
_PyInterpreterFrame *new_frame = _PyFrame_PushUnchecked(tstate, func, code->co_argcount);
4030
for (int i = 0; i < argcount; i++) {
4031
new_frame->localsplus[i] = args[i];
4032
}
4033
for (int i = argcount; i < code->co_argcount; i++) {
4034
PyObject *def = PyTuple_GET_ITEM(func->func_defaults, i - min_args);
4035
new_frame->localsplus[i] = Py_NewRef(def);
4036
}
4037
// Manipulate stack and cache directly since we leave using DISPATCH_INLINED().
4038
STACK_SHRINK(oparg + 2);
4039
SKIP_OVER(INLINE_CACHE_ENTRIES_CALL);
4040
frame->return_offset = 0;
4041
DISPATCH_INLINED(new_frame);
4042
#line 4043 "Python/generated_cases.c.h"
4043
}
4044
4045
TARGET(CALL_NO_KW_TYPE_1) {
4046
PyObject **args = (stack_pointer - oparg);
4047
PyObject *callable = stack_pointer[-(1 + oparg)];
4048
PyObject *null = stack_pointer[-(2 + oparg)];
4049
PyObject *res;
4050
#line 2921 "Python/bytecodes.c"
4051
assert(kwnames == NULL);
4052
assert(oparg == 1);
4053
DEOPT_IF(null != NULL, CALL);
4054
PyObject *obj = args[0];
4055
DEOPT_IF(callable != (PyObject *)&PyType_Type, CALL);
4056
STAT_INC(CALL, hit);
4057
res = Py_NewRef(Py_TYPE(obj));
4058
Py_DECREF(obj);
4059
Py_DECREF(&PyType_Type); // I.e., callable
4060
#line 4061 "Python/generated_cases.c.h"
4061
STACK_SHRINK(oparg);
4062
STACK_SHRINK(1);
4063
stack_pointer[-1] = res;
4064
next_instr += 3;
4065
DISPATCH();
4066
}
4067
4068
TARGET(CALL_NO_KW_STR_1) {
4069
PyObject **args = (stack_pointer - oparg);
4070
PyObject *callable = stack_pointer[-(1 + oparg)];
4071
PyObject *null = stack_pointer[-(2 + oparg)];
4072
PyObject *res;
4073
#line 2933 "Python/bytecodes.c"
4074
assert(kwnames == NULL);
4075
assert(oparg == 1);
4076
DEOPT_IF(null != NULL, CALL);
4077
DEOPT_IF(callable != (PyObject *)&PyUnicode_Type, CALL);
4078
STAT_INC(CALL, hit);
4079
PyObject *arg = args[0];
4080
res = PyObject_Str(arg);
4081
Py_DECREF(arg);
4082
Py_DECREF(&PyUnicode_Type); // I.e., callable
4083
if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; }
4084
#line 4085 "Python/generated_cases.c.h"
4085
STACK_SHRINK(oparg);
4086
STACK_SHRINK(1);
4087
stack_pointer[-1] = res;
4088
next_instr += 3;
4089
CHECK_EVAL_BREAKER();
4090
DISPATCH();
4091
}
4092
4093
TARGET(CALL_NO_KW_TUPLE_1) {
4094
PyObject **args = (stack_pointer - oparg);
4095
PyObject *callable = stack_pointer[-(1 + oparg)];
4096
PyObject *null = stack_pointer[-(2 + oparg)];
4097
PyObject *res;
4098
#line 2947 "Python/bytecodes.c"
4099
assert(kwnames == NULL);
4100
assert(oparg == 1);
4101
DEOPT_IF(null != NULL, CALL);
4102
DEOPT_IF(callable != (PyObject *)&PyTuple_Type, CALL);
4103
STAT_INC(CALL, hit);
4104
PyObject *arg = args[0];
4105
res = PySequence_Tuple(arg);
4106
Py_DECREF(arg);
4107
Py_DECREF(&PyTuple_Type); // I.e., tuple
4108
if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; }
4109
#line 4110 "Python/generated_cases.c.h"
4110
STACK_SHRINK(oparg);
4111
STACK_SHRINK(1);
4112
stack_pointer[-1] = res;
4113
next_instr += 3;
4114
CHECK_EVAL_BREAKER();
4115
DISPATCH();
4116
}
4117
4118
TARGET(CALL_NO_KW_ALLOC_AND_ENTER_INIT) {
4119
PyObject **args = (stack_pointer - oparg);
4120
PyObject *callable = stack_pointer[-(1 + oparg)];
4121
PyObject *null = stack_pointer[-(2 + oparg)];
4122
#line 2961 "Python/bytecodes.c"
4123
/* This instruction does the following:
4124
* 1. Creates the object (by calling ``object.__new__``)
4125
* 2. Pushes a shim frame to the frame stack (to cleanup after ``__init__``)
4126
* 3. Pushes the frame for ``__init__`` to the frame stack
4127
* */
4128
assert(kwnames == NULL);
4129
_PyCallCache *cache = (_PyCallCache *)next_instr;
4130
DEOPT_IF(null != NULL, CALL);
4131
DEOPT_IF(!PyType_Check(callable), CALL);
4132
PyTypeObject *tp = (PyTypeObject *)callable;
4133
DEOPT_IF(tp->tp_version_tag != read_u32(cache->func_version), CALL);
4134
PyHeapTypeObject *cls = (PyHeapTypeObject *)callable;
4135
PyFunctionObject *init = (PyFunctionObject *)cls->_spec_cache.init;
4136
PyCodeObject *code = (PyCodeObject *)init->func_code;
4137
DEOPT_IF(code->co_argcount != oparg+1, CALL);
4138
DEOPT_IF(!_PyThreadState_HasStackSpace(tstate, code->co_framesize + _Py_InitCleanup.co_framesize), CALL);
4139
STAT_INC(CALL, hit);
4140
PyObject *self = _PyType_NewManagedObject(tp);
4141
if (self == NULL) {
4142
goto error;
4143
}
4144
Py_DECREF(tp);
4145
if (_Py_EnterRecursivePy(tstate)) {
4146
goto exit_unwind;
4147
}
4148
_PyInterpreterFrame *shim = _PyFrame_PushTrampolineUnchecked(
4149
tstate, (PyCodeObject *)&_Py_InitCleanup, 1, 0);
4150
assert(_PyCode_CODE((PyCodeObject *)shim->f_executable)[1].op.code == EXIT_INIT_CHECK);
4151
/* Push self onto stack of shim */
4152
Py_INCREF(self);
4153
shim->localsplus[0] = self;
4154
Py_INCREF(init);
4155
_PyInterpreterFrame *init_frame = _PyFrame_PushUnchecked(tstate, init, oparg+1);
4156
/* Copy self followed by args to __init__ frame */
4157
init_frame->localsplus[0] = self;
4158
for (int i = 0; i < oparg; i++) {
4159
init_frame->localsplus[i+1] = args[i];
4160
}
4161
SKIP_OVER(INLINE_CACHE_ENTRIES_CALL);
4162
frame->prev_instr = next_instr - 1;
4163
frame->return_offset = 0;
4164
STACK_SHRINK(oparg+2);
4165
_PyFrame_SetStackPointer(frame, stack_pointer);
4166
/* Link frames */
4167
init_frame->previous = shim;
4168
shim->previous = frame;
4169
frame = cframe.current_frame = init_frame;
4170
CALL_STAT_INC(inlined_py_calls);
4171
goto start_frame;
4172
#line 4173 "Python/generated_cases.c.h"
4173
}
4174
4175
TARGET(EXIT_INIT_CHECK) {
4176
PyObject *should_be_none = stack_pointer[-1];
4177
#line 3013 "Python/bytecodes.c"
4178
assert(STACK_LEVEL() == 2);
4179
if (should_be_none != Py_None) {
4180
PyErr_Format(PyExc_TypeError,
4181
"__init__() should return None, not '%.200s'",
4182
Py_TYPE(should_be_none)->tp_name);
4183
goto error;
4184
}
4185
#line 4186 "Python/generated_cases.c.h"
4186
STACK_SHRINK(1);
4187
DISPATCH();
4188
}
4189
4190
TARGET(CALL_BUILTIN_CLASS) {
4191
PyObject **args = (stack_pointer - oparg);
4192
PyObject *callable = stack_pointer[-(1 + oparg)];
4193
PyObject *method = stack_pointer[-(2 + oparg)];
4194
PyObject *res;
4195
#line 3023 "Python/bytecodes.c"
4196
int is_meth = method != NULL;
4197
int total_args = oparg;
4198
if (is_meth) {
4199
callable = method;
4200
args--;
4201
total_args++;
4202
}
4203
int kwnames_len = KWNAMES_LEN();
4204
DEOPT_IF(!PyType_Check(callable), CALL);
4205
PyTypeObject *tp = (PyTypeObject *)callable;
4206
DEOPT_IF(tp->tp_vectorcall == NULL, CALL);
4207
STAT_INC(CALL, hit);
4208
res = tp->tp_vectorcall((PyObject *)tp, args,
4209
total_args - kwnames_len, kwnames);
4210
kwnames = NULL;
4211
/* Free the arguments. */
4212
for (int i = 0; i < total_args; i++) {
4213
Py_DECREF(args[i]);
4214
}
4215
Py_DECREF(tp);
4216
if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; }
4217
#line 4218 "Python/generated_cases.c.h"
4218
STACK_SHRINK(oparg);
4219
STACK_SHRINK(1);
4220
stack_pointer[-1] = res;
4221
next_instr += 3;
4222
CHECK_EVAL_BREAKER();
4223
DISPATCH();
4224
}
4225
4226
TARGET(CALL_NO_KW_BUILTIN_O) {
4227
PyObject **args = (stack_pointer - oparg);
4228
PyObject *callable = stack_pointer[-(1 + oparg)];
4229
PyObject *method = stack_pointer[-(2 + oparg)];
4230
PyObject *res;
4231
#line 3048 "Python/bytecodes.c"
4232
/* Builtin METH_O functions */
4233
assert(kwnames == NULL);
4234
int is_meth = method != NULL;
4235
int total_args = oparg;
4236
if (is_meth) {
4237
callable = method;
4238
args--;
4239
total_args++;
4240
}
4241
DEOPT_IF(total_args != 1, CALL);
4242
DEOPT_IF(!PyCFunction_CheckExact(callable), CALL);
4243
DEOPT_IF(PyCFunction_GET_FLAGS(callable) != METH_O, CALL);
4244
STAT_INC(CALL, hit);
4245
PyCFunction cfunc = PyCFunction_GET_FUNCTION(callable);
4246
// This is slower but CPython promises to check all non-vectorcall
4247
// function calls.
4248
if (_Py_EnterRecursiveCallTstate(tstate, " while calling a Python object")) {
4249
goto error;
4250
}
4251
PyObject *arg = args[0];
4252
res = _PyCFunction_TrampolineCall(cfunc, PyCFunction_GET_SELF(callable), arg);
4253
_Py_LeaveRecursiveCallTstate(tstate);
4254
assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL));
4255
4256
Py_DECREF(arg);
4257
Py_DECREF(callable);
4258
if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; }
4259
#line 4260 "Python/generated_cases.c.h"
4260
STACK_SHRINK(oparg);
4261
STACK_SHRINK(1);
4262
stack_pointer[-1] = res;
4263
next_instr += 3;
4264
CHECK_EVAL_BREAKER();
4265
DISPATCH();
4266
}
4267
4268
TARGET(CALL_NO_KW_BUILTIN_FAST) {
4269
PyObject **args = (stack_pointer - oparg);
4270
PyObject *callable = stack_pointer[-(1 + oparg)];
4271
PyObject *method = stack_pointer[-(2 + oparg)];
4272
PyObject *res;
4273
#line 3079 "Python/bytecodes.c"
4274
/* Builtin METH_FASTCALL functions, without keywords */
4275
assert(kwnames == NULL);
4276
int is_meth = method != NULL;
4277
int total_args = oparg;
4278
if (is_meth) {
4279
callable = method;
4280
args--;
4281
total_args++;
4282
}
4283
DEOPT_IF(!PyCFunction_CheckExact(callable), CALL);
4284
DEOPT_IF(PyCFunction_GET_FLAGS(callable) != METH_FASTCALL, CALL);
4285
STAT_INC(CALL, hit);
4286
PyCFunction cfunc = PyCFunction_GET_FUNCTION(callable);
4287
/* res = func(self, args, nargs) */
4288
res = ((_PyCFunctionFast)(void(*)(void))cfunc)(
4289
PyCFunction_GET_SELF(callable),
4290
args,
4291
total_args);
4292
assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL));
4293
4294
/* Free the arguments. */
4295
for (int i = 0; i < total_args; i++) {
4296
Py_DECREF(args[i]);
4297
}
4298
Py_DECREF(callable);
4299
if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; }
4300
/* Not deopting because this doesn't mean our optimization was
4301
wrong. `res` can be NULL for valid reasons. Eg. getattr(x,
4302
'invalid'). In those cases an exception is set, so we must
4303
handle it.
4304
*/
4305
#line 4306 "Python/generated_cases.c.h"
4306
STACK_SHRINK(oparg);
4307
STACK_SHRINK(1);
4308
stack_pointer[-1] = res;
4309
next_instr += 3;
4310
CHECK_EVAL_BREAKER();
4311
DISPATCH();
4312
}
4313
4314
TARGET(CALL_BUILTIN_FAST_WITH_KEYWORDS) {
4315
PyObject **args = (stack_pointer - oparg);
4316
PyObject *callable = stack_pointer[-(1 + oparg)];
4317
PyObject *method = stack_pointer[-(2 + oparg)];
4318
PyObject *res;
4319
#line 3114 "Python/bytecodes.c"
4320
/* Builtin METH_FASTCALL | METH_KEYWORDS functions */
4321
int is_meth = method != NULL;
4322
int total_args = oparg;
4323
if (is_meth) {
4324
callable = method;
4325
args--;
4326
total_args++;
4327
}
4328
DEOPT_IF(!PyCFunction_CheckExact(callable), CALL);
4329
DEOPT_IF(PyCFunction_GET_FLAGS(callable) !=
4330
(METH_FASTCALL | METH_KEYWORDS), CALL);
4331
STAT_INC(CALL, hit);
4332
/* res = func(self, args, nargs, kwnames) */
4333
_PyCFunctionFastWithKeywords cfunc =
4334
(_PyCFunctionFastWithKeywords)(void(*)(void))
4335
PyCFunction_GET_FUNCTION(callable);
4336
res = cfunc(
4337
PyCFunction_GET_SELF(callable),
4338
args,
4339
total_args - KWNAMES_LEN(),
4340
kwnames
4341
);
4342
assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL));
4343
kwnames = NULL;
4344
4345
/* Free the arguments. */
4346
for (int i = 0; i < total_args; i++) {
4347
Py_DECREF(args[i]);
4348
}
4349
Py_DECREF(callable);
4350
if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; }
4351
#line 4352 "Python/generated_cases.c.h"
4352
STACK_SHRINK(oparg);
4353
STACK_SHRINK(1);
4354
stack_pointer[-1] = res;
4355
next_instr += 3;
4356
CHECK_EVAL_BREAKER();
4357
DISPATCH();
4358
}
4359
4360
TARGET(CALL_NO_KW_LEN) {
4361
PyObject **args = (stack_pointer - oparg);
4362
PyObject *callable = stack_pointer[-(1 + oparg)];
4363
PyObject *method = stack_pointer[-(2 + oparg)];
4364
PyObject *res;
4365
#line 3149 "Python/bytecodes.c"
4366
assert(kwnames == NULL);
4367
/* len(o) */
4368
int is_meth = method != NULL;
4369
int total_args = oparg;
4370
if (is_meth) {
4371
callable = method;
4372
args--;
4373
total_args++;
4374
}
4375
DEOPT_IF(total_args != 1, CALL);
4376
PyInterpreterState *interp = _PyInterpreterState_GET();
4377
DEOPT_IF(callable != interp->callable_cache.len, CALL);
4378
STAT_INC(CALL, hit);
4379
PyObject *arg = args[0];
4380
Py_ssize_t len_i = PyObject_Length(arg);
4381
if (len_i < 0) {
4382
goto error;
4383
}
4384
res = PyLong_FromSsize_t(len_i);
4385
assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL));
4386
4387
Py_DECREF(callable);
4388
Py_DECREF(arg);
4389
if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; }
4390
#line 4391 "Python/generated_cases.c.h"
4391
STACK_SHRINK(oparg);
4392
STACK_SHRINK(1);
4393
stack_pointer[-1] = res;
4394
next_instr += 3;
4395
DISPATCH();
4396
}
4397
4398
TARGET(CALL_NO_KW_ISINSTANCE) {
4399
PyObject **args = (stack_pointer - oparg);
4400
PyObject *callable = stack_pointer[-(1 + oparg)];
4401
PyObject *method = stack_pointer[-(2 + oparg)];
4402
PyObject *res;
4403
#line 3176 "Python/bytecodes.c"
4404
assert(kwnames == NULL);
4405
/* isinstance(o, o2) */
4406
int is_meth = method != NULL;
4407
int total_args = oparg;
4408
if (is_meth) {
4409
callable = method;
4410
args--;
4411
total_args++;
4412
}
4413
DEOPT_IF(total_args != 2, CALL);
4414
PyInterpreterState *interp = _PyInterpreterState_GET();
4415
DEOPT_IF(callable != interp->callable_cache.isinstance, CALL);
4416
STAT_INC(CALL, hit);
4417
PyObject *cls = args[1];
4418
PyObject *inst = args[0];
4419
int retval = PyObject_IsInstance(inst, cls);
4420
if (retval < 0) {
4421
goto error;
4422
}
4423
res = PyBool_FromLong(retval);
4424
assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL));
4425
4426
Py_DECREF(inst);
4427
Py_DECREF(cls);
4428
Py_DECREF(callable);
4429
if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; }
4430
#line 4431 "Python/generated_cases.c.h"
4431
STACK_SHRINK(oparg);
4432
STACK_SHRINK(1);
4433
stack_pointer[-1] = res;
4434
next_instr += 3;
4435
DISPATCH();
4436
}
4437
4438
TARGET(CALL_NO_KW_LIST_APPEND) {
4439
PyObject **args = (stack_pointer - oparg);
4440
PyObject *self = stack_pointer[-(1 + oparg)];
4441
PyObject *method = stack_pointer[-(2 + oparg)];
4442
#line 3206 "Python/bytecodes.c"
4443
assert(kwnames == NULL);
4444
assert(oparg == 1);
4445
assert(method != NULL);
4446
PyInterpreterState *interp = _PyInterpreterState_GET();
4447
DEOPT_IF(method != interp->callable_cache.list_append, CALL);
4448
DEOPT_IF(!PyList_Check(self), CALL);
4449
STAT_INC(CALL, hit);
4450
if (_PyList_AppendTakeRef((PyListObject *)self, args[0]) < 0) {
4451
goto pop_1_error; // Since arg is DECREF'ed already
4452
}
4453
Py_DECREF(self);
4454
Py_DECREF(method);
4455
STACK_SHRINK(3);
4456
// CALL + POP_TOP
4457
SKIP_OVER(INLINE_CACHE_ENTRIES_CALL + 1);
4458
assert(next_instr[-1].op.code == POP_TOP);
4459
DISPATCH();
4460
#line 4461 "Python/generated_cases.c.h"
4461
}
4462
4463
TARGET(CALL_NO_KW_METHOD_DESCRIPTOR_O) {
4464
PyObject **args = (stack_pointer - oparg);
4465
PyObject *method = stack_pointer[-(2 + oparg)];
4466
PyObject *res;
4467
#line 3226 "Python/bytecodes.c"
4468
assert(kwnames == NULL);
4469
int is_meth = method != NULL;
4470
int total_args = oparg;
4471
if (is_meth) {
4472
args--;
4473
total_args++;
4474
}
4475
PyMethodDescrObject *callable =
4476
(PyMethodDescrObject *)PEEK(total_args + 1);
4477
DEOPT_IF(total_args != 2, CALL);
4478
DEOPT_IF(!Py_IS_TYPE(callable, &PyMethodDescr_Type), CALL);
4479
PyMethodDef *meth = callable->d_method;
4480
DEOPT_IF(meth->ml_flags != METH_O, CALL);
4481
PyObject *arg = args[1];
4482
PyObject *self = args[0];
4483
DEOPT_IF(!Py_IS_TYPE(self, callable->d_common.d_type), CALL);
4484
STAT_INC(CALL, hit);
4485
PyCFunction cfunc = meth->ml_meth;
4486
// This is slower but CPython promises to check all non-vectorcall
4487
// function calls.
4488
if (_Py_EnterRecursiveCallTstate(tstate, " while calling a Python object")) {
4489
goto error;
4490
}
4491
res = _PyCFunction_TrampolineCall(cfunc, self, arg);
4492
_Py_LeaveRecursiveCallTstate(tstate);
4493
assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL));
4494
Py_DECREF(self);
4495
Py_DECREF(arg);
4496
Py_DECREF(callable);
4497
if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; }
4498
#line 4499 "Python/generated_cases.c.h"
4499
STACK_SHRINK(oparg);
4500
STACK_SHRINK(1);
4501
stack_pointer[-1] = res;
4502
next_instr += 3;
4503
CHECK_EVAL_BREAKER();
4504
DISPATCH();
4505
}
4506
4507
TARGET(CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS) {
4508
PyObject **args = (stack_pointer - oparg);
4509
PyObject *method = stack_pointer[-(2 + oparg)];
4510
PyObject *res;
4511
#line 3260 "Python/bytecodes.c"
4512
int is_meth = method != NULL;
4513
int total_args = oparg;
4514
if (is_meth) {
4515
args--;
4516
total_args++;
4517
}
4518
PyMethodDescrObject *callable =
4519
(PyMethodDescrObject *)PEEK(total_args + 1);
4520
DEOPT_IF(!Py_IS_TYPE(callable, &PyMethodDescr_Type), CALL);
4521
PyMethodDef *meth = callable->d_method;
4522
DEOPT_IF(meth->ml_flags != (METH_FASTCALL|METH_KEYWORDS), CALL);
4523
PyTypeObject *d_type = callable->d_common.d_type;
4524
PyObject *self = args[0];
4525
DEOPT_IF(!Py_IS_TYPE(self, d_type), CALL);
4526
STAT_INC(CALL, hit);
4527
int nargs = total_args - 1;
4528
_PyCFunctionFastWithKeywords cfunc =
4529
(_PyCFunctionFastWithKeywords)(void(*)(void))meth->ml_meth;
4530
res = cfunc(self, args + 1, nargs - KWNAMES_LEN(), kwnames);
4531
assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL));
4532
kwnames = NULL;
4533
4534
/* Free the arguments. */
4535
for (int i = 0; i < total_args; i++) {
4536
Py_DECREF(args[i]);
4537
}
4538
Py_DECREF(callable);
4539
if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; }
4540
#line 4541 "Python/generated_cases.c.h"
4541
STACK_SHRINK(oparg);
4542
STACK_SHRINK(1);
4543
stack_pointer[-1] = res;
4544
next_instr += 3;
4545
CHECK_EVAL_BREAKER();
4546
DISPATCH();
4547
}
4548
4549
TARGET(CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS) {
4550
PyObject **args = (stack_pointer - oparg);
4551
PyObject *method = stack_pointer[-(2 + oparg)];
4552
PyObject *res;
4553
#line 3292 "Python/bytecodes.c"
4554
assert(kwnames == NULL);
4555
assert(oparg == 0 || oparg == 1);
4556
int is_meth = method != NULL;
4557
int total_args = oparg;
4558
if (is_meth) {
4559
args--;
4560
total_args++;
4561
}
4562
DEOPT_IF(total_args != 1, CALL);
4563
PyMethodDescrObject *callable = (PyMethodDescrObject *)SECOND();
4564
DEOPT_IF(!Py_IS_TYPE(callable, &PyMethodDescr_Type), CALL);
4565
PyMethodDef *meth = callable->d_method;
4566
PyObject *self = args[0];
4567
DEOPT_IF(!Py_IS_TYPE(self, callable->d_common.d_type), CALL);
4568
DEOPT_IF(meth->ml_flags != METH_NOARGS, CALL);
4569
STAT_INC(CALL, hit);
4570
PyCFunction cfunc = meth->ml_meth;
4571
// This is slower but CPython promises to check all non-vectorcall
4572
// function calls.
4573
if (_Py_EnterRecursiveCallTstate(tstate, " while calling a Python object")) {
4574
goto error;
4575
}
4576
res = _PyCFunction_TrampolineCall(cfunc, self, NULL);
4577
_Py_LeaveRecursiveCallTstate(tstate);
4578
assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL));
4579
Py_DECREF(self);
4580
Py_DECREF(callable);
4581
if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; }
4582
#line 4583 "Python/generated_cases.c.h"
4583
STACK_SHRINK(oparg);
4584
STACK_SHRINK(1);
4585
stack_pointer[-1] = res;
4586
next_instr += 3;
4587
CHECK_EVAL_BREAKER();
4588
DISPATCH();
4589
}
4590
4591
TARGET(CALL_NO_KW_METHOD_DESCRIPTOR_FAST) {
4592
PyObject **args = (stack_pointer - oparg);
4593
PyObject *method = stack_pointer[-(2 + oparg)];
4594
PyObject *res;
4595
#line 3324 "Python/bytecodes.c"
4596
assert(kwnames == NULL);
4597
int is_meth = method != NULL;
4598
int total_args = oparg;
4599
if (is_meth) {
4600
args--;
4601
total_args++;
4602
}
4603
PyMethodDescrObject *callable =
4604
(PyMethodDescrObject *)PEEK(total_args + 1);
4605
/* Builtin METH_FASTCALL methods, without keywords */
4606
DEOPT_IF(!Py_IS_TYPE(callable, &PyMethodDescr_Type), CALL);
4607
PyMethodDef *meth = callable->d_method;
4608
DEOPT_IF(meth->ml_flags != METH_FASTCALL, CALL);
4609
PyObject *self = args[0];
4610
DEOPT_IF(!Py_IS_TYPE(self, callable->d_common.d_type), CALL);
4611
STAT_INC(CALL, hit);
4612
_PyCFunctionFast cfunc =
4613
(_PyCFunctionFast)(void(*)(void))meth->ml_meth;
4614
int nargs = total_args - 1;
4615
res = cfunc(self, args + 1, nargs);
4616
assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL));
4617
/* Clear the stack of the arguments. */
4618
for (int i = 0; i < total_args; i++) {
4619
Py_DECREF(args[i]);
4620
}
4621
Py_DECREF(callable);
4622
if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; }
4623
#line 4624 "Python/generated_cases.c.h"
4624
STACK_SHRINK(oparg);
4625
STACK_SHRINK(1);
4626
stack_pointer[-1] = res;
4627
next_instr += 3;
4628
CHECK_EVAL_BREAKER();
4629
DISPATCH();
4630
}
4631
4632
TARGET(INSTRUMENTED_CALL_FUNCTION_EX) {
4633
#line 3355 "Python/bytecodes.c"
4634
GO_TO_INSTRUCTION(CALL_FUNCTION_EX);
4635
#line 4636 "Python/generated_cases.c.h"
4636
}
4637
4638
TARGET(CALL_FUNCTION_EX) {
4639
PREDICTED(CALL_FUNCTION_EX);
4640
PyObject *kwargs = (oparg & 1) ? stack_pointer[-(((oparg & 1) ? 1 : 0))] : NULL;
4641
PyObject *callargs = stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))];
4642
PyObject *func = stack_pointer[-(2 + ((oparg & 1) ? 1 : 0))];
4643
PyObject *result;
4644
#line 3359 "Python/bytecodes.c"
4645
// DICT_MERGE is called before this opcode if there are kwargs.
4646
// It converts all dict subtypes in kwargs into regular dicts.
4647
assert(kwargs == NULL || PyDict_CheckExact(kwargs));
4648
if (!PyTuple_CheckExact(callargs)) {
4649
if (check_args_iterable(tstate, func, callargs) < 0) {
4650
goto error;
4651
}
4652
PyObject *tuple = PySequence_Tuple(callargs);
4653
if (tuple == NULL) {
4654
goto error;
4655
}
4656
Py_SETREF(callargs, tuple);
4657
}
4658
assert(PyTuple_CheckExact(callargs));
4659
EVAL_CALL_STAT_INC_IF_FUNCTION(EVAL_CALL_FUNCTION_EX, func);
4660
if (opcode == INSTRUMENTED_CALL_FUNCTION_EX &&
4661
!PyFunction_Check(func) && !PyMethod_Check(func)
4662
) {
4663
PyObject *arg = PyTuple_GET_SIZE(callargs) > 0 ?
4664
PyTuple_GET_ITEM(callargs, 0) : Py_None;
4665
int err = _Py_call_instrumentation_2args(
4666
tstate, PY_MONITORING_EVENT_CALL,
4667
frame, next_instr-1, func, arg);
4668
if (err) goto error;
4669
result = PyObject_Call(func, callargs, kwargs);
4670
if (result == NULL) {
4671
_Py_call_instrumentation_exc2(
4672
tstate, PY_MONITORING_EVENT_C_RAISE,
4673
frame, next_instr-1, func, arg);
4674
}
4675
else {
4676
int err = _Py_call_instrumentation_2args(
4677
tstate, PY_MONITORING_EVENT_C_RETURN,
4678
frame, next_instr-1, func, arg);
4679
if (err < 0) {
4680
Py_CLEAR(result);
4681
}
4682
}
4683
}
4684
else {
4685
if (Py_TYPE(func) == &PyFunction_Type &&
4686
tstate->interp->eval_frame == NULL &&
4687
((PyFunctionObject *)func)->vectorcall == _PyFunction_Vectorcall) {
4688
assert(PyTuple_CheckExact(callargs));
4689
Py_ssize_t nargs = PyTuple_GET_SIZE(callargs);
4690
int code_flags = ((PyCodeObject *)PyFunction_GET_CODE(func))->co_flags;
4691
PyObject *locals = code_flags & CO_OPTIMIZED ? NULL : Py_NewRef(PyFunction_GET_GLOBALS(func));
4692
4693
_PyInterpreterFrame *new_frame = _PyEvalFramePushAndInit_Ex(tstate,
4694
(PyFunctionObject *)func, locals,
4695
nargs, callargs, kwargs);
4696
// Need to manually shrink the stack since we exit with DISPATCH_INLINED.
4697
STACK_SHRINK(oparg + 3);
4698
if (new_frame == NULL) {
4699
goto error;
4700
}
4701
frame->return_offset = 0;
4702
DISPATCH_INLINED(new_frame);
4703
}
4704
result = PyObject_Call(func, callargs, kwargs);
4705
}
4706
#line 4707 "Python/generated_cases.c.h"
4707
Py_DECREF(func);
4708
Py_DECREF(callargs);
4709
Py_XDECREF(kwargs);
4710
#line 3421 "Python/bytecodes.c"
4711
assert(PEEK(3 + (oparg & 1)) == NULL);
4712
if (result == NULL) { STACK_SHRINK(((oparg & 1) ? 1 : 0)); goto pop_3_error; }
4713
#line 4714 "Python/generated_cases.c.h"
4714
STACK_SHRINK(((oparg & 1) ? 1 : 0));
4715
STACK_SHRINK(2);
4716
stack_pointer[-1] = result;
4717
CHECK_EVAL_BREAKER();
4718
DISPATCH();
4719
}
4720
4721
TARGET(MAKE_FUNCTION) {
4722
PyObject *codeobj = stack_pointer[-1];
4723
PyObject *func;
4724
#line 3427 "Python/bytecodes.c"
4725
4726
PyFunctionObject *func_obj = (PyFunctionObject *)
4727
PyFunction_New(codeobj, GLOBALS());
4728
4729
Py_DECREF(codeobj);
4730
if (func_obj == NULL) {
4731
goto error;
4732
}
4733
4734
func_obj->func_version = ((PyCodeObject *)codeobj)->co_version;
4735
func = (PyObject *)func_obj;
4736
#line 4737 "Python/generated_cases.c.h"
4737
stack_pointer[-1] = func;
4738
DISPATCH();
4739
}
4740
4741
TARGET(SET_FUNCTION_ATTRIBUTE) {
4742
PyObject *func = stack_pointer[-1];
4743
PyObject *attr = stack_pointer[-2];
4744
#line 3441 "Python/bytecodes.c"
4745
assert(PyFunction_Check(func));
4746
PyFunctionObject *func_obj = (PyFunctionObject *)func;
4747
switch(oparg) {
4748
case MAKE_FUNCTION_CLOSURE:
4749
assert(func_obj->func_closure == NULL);
4750
func_obj->func_closure = attr;
4751
break;
4752
case MAKE_FUNCTION_ANNOTATIONS:
4753
assert(func_obj->func_annotations == NULL);
4754
func_obj->func_annotations = attr;
4755
break;
4756
case MAKE_FUNCTION_KWDEFAULTS:
4757
assert(PyDict_CheckExact(attr));
4758
assert(func_obj->func_kwdefaults == NULL);
4759
func_obj->func_kwdefaults = attr;
4760
break;
4761
case MAKE_FUNCTION_DEFAULTS:
4762
assert(PyTuple_CheckExact(attr));
4763
assert(func_obj->func_defaults == NULL);
4764
func_obj->func_defaults = attr;
4765
break;
4766
default:
4767
Py_UNREACHABLE();
4768
}
4769
#line 4770 "Python/generated_cases.c.h"
4770
STACK_SHRINK(1);
4771
stack_pointer[-1] = func;
4772
DISPATCH();
4773
}
4774
4775
TARGET(RETURN_GENERATOR) {
4776
#line 3468 "Python/bytecodes.c"
4777
assert(PyFunction_Check(frame->f_funcobj));
4778
PyFunctionObject *func = (PyFunctionObject *)frame->f_funcobj;
4779
PyGenObject *gen = (PyGenObject *)_Py_MakeCoro(func);
4780
if (gen == NULL) {
4781
goto error;
4782
}
4783
assert(EMPTY());
4784
_PyFrame_SetStackPointer(frame, stack_pointer);
4785
_PyInterpreterFrame *gen_frame = (_PyInterpreterFrame *)gen->gi_iframe;
4786
_PyFrame_Copy(frame, gen_frame);
4787
assert(frame->frame_obj == NULL);
4788
gen->gi_frame_state = FRAME_CREATED;
4789
gen_frame->owner = FRAME_OWNED_BY_GENERATOR;
4790
_Py_LeaveRecursiveCallPy(tstate);
4791
assert(frame != &entry_frame);
4792
_PyInterpreterFrame *prev = frame->previous;
4793
_PyThreadState_PopFrame(tstate, frame);
4794
frame = cframe.current_frame = prev;
4795
_PyFrame_StackPush(frame, (PyObject *)gen);
4796
goto resume_frame;
4797
#line 4798 "Python/generated_cases.c.h"
4798
}
4799
4800
TARGET(BUILD_SLICE) {
4801
PyObject *step = (oparg == 3) ? stack_pointer[-(((oparg == 3) ? 1 : 0))] : NULL;
4802
PyObject *stop = stack_pointer[-(1 + ((oparg == 3) ? 1 : 0))];
4803
PyObject *start = stack_pointer[-(2 + ((oparg == 3) ? 1 : 0))];
4804
PyObject *slice;
4805
#line 3491 "Python/bytecodes.c"
4806
slice = PySlice_New(start, stop, step);
4807
#line 4808 "Python/generated_cases.c.h"
4808
Py_DECREF(start);
4809
Py_DECREF(stop);
4810
Py_XDECREF(step);
4811
#line 3493 "Python/bytecodes.c"
4812
if (slice == NULL) { STACK_SHRINK(((oparg == 3) ? 1 : 0)); goto pop_2_error; }
4813
#line 4814 "Python/generated_cases.c.h"
4814
STACK_SHRINK(((oparg == 3) ? 1 : 0));
4815
STACK_SHRINK(1);
4816
stack_pointer[-1] = slice;
4817
DISPATCH();
4818
}
4819
4820
TARGET(CONVERT_VALUE) {
4821
PyObject *value = stack_pointer[-1];
4822
PyObject *result;
4823
#line 3497 "Python/bytecodes.c"
4824
convertion_func_ptr conv_fn;
4825
assert(oparg >= FVC_STR && oparg <= FVC_ASCII);
4826
conv_fn = CONVERSION_FUNCTIONS[oparg];
4827
result = conv_fn(value);
4828
Py_DECREF(value);
4829
if (result == NULL) goto pop_1_error;
4830
#line 4831 "Python/generated_cases.c.h"
4831
stack_pointer[-1] = result;
4832
DISPATCH();
4833
}
4834
4835
TARGET(FORMAT_SIMPLE) {
4836
PyObject *value = stack_pointer[-1];
4837
PyObject *res;
4838
#line 3506 "Python/bytecodes.c"
4839
/* If value is a unicode object, then we know the result
4840
* of format(value) is value itself. */
4841
if (!PyUnicode_CheckExact(value)) {
4842
res = PyObject_Format(value, NULL);
4843
Py_DECREF(value);
4844
if (res == NULL) goto pop_1_error;
4845
}
4846
else {
4847
res = value;
4848
}
4849
#line 4850 "Python/generated_cases.c.h"
4850
stack_pointer[-1] = res;
4851
DISPATCH();
4852
}
4853
4854
TARGET(FORMAT_WITH_SPEC) {
4855
PyObject *fmt_spec = stack_pointer[-1];
4856
PyObject *value = stack_pointer[-2];
4857
PyObject *res;
4858
#line 3519 "Python/bytecodes.c"
4859
res = PyObject_Format(value, fmt_spec);
4860
Py_DECREF(value);
4861
Py_DECREF(fmt_spec);
4862
if (res == NULL) goto pop_2_error;
4863
#line 4864 "Python/generated_cases.c.h"
4864
STACK_SHRINK(1);
4865
stack_pointer[-1] = res;
4866
DISPATCH();
4867
}
4868
4869
TARGET(COPY) {
4870
PyObject *bottom = stack_pointer[-(1 + (oparg-1))];
4871
PyObject *top;
4872
#line 3526 "Python/bytecodes.c"
4873
assert(oparg > 0);
4874
top = Py_NewRef(bottom);
4875
#line 4876 "Python/generated_cases.c.h"
4876
STACK_GROW(1);
4877
stack_pointer[-1] = top;
4878
DISPATCH();
4879
}
4880
4881
TARGET(BINARY_OP) {
4882
PREDICTED(BINARY_OP);
4883
static_assert(INLINE_CACHE_ENTRIES_BINARY_OP == 1, "incorrect cache size");
4884
PyObject *rhs = stack_pointer[-1];
4885
PyObject *lhs = stack_pointer[-2];
4886
PyObject *res;
4887
#line 3531 "Python/bytecodes.c"
4888
#if ENABLE_SPECIALIZATION
4889
_PyBinaryOpCache *cache = (_PyBinaryOpCache *)next_instr;
4890
if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
4891
next_instr--;
4892
_Py_Specialize_BinaryOp(lhs, rhs, next_instr, oparg, &GETLOCAL(0));
4893
DISPATCH_SAME_OPARG();
4894
}
4895
STAT_INC(BINARY_OP, deferred);
4896
DECREMENT_ADAPTIVE_COUNTER(cache->counter);
4897
#endif /* ENABLE_SPECIALIZATION */
4898
assert(0 <= oparg);
4899
assert((unsigned)oparg < Py_ARRAY_LENGTH(binary_ops));
4900
assert(binary_ops[oparg]);
4901
res = binary_ops[oparg](lhs, rhs);
4902
#line 4903 "Python/generated_cases.c.h"
4903
Py_DECREF(lhs);
4904
Py_DECREF(rhs);
4905
#line 3546 "Python/bytecodes.c"
4906
if (res == NULL) goto pop_2_error;
4907
#line 4908 "Python/generated_cases.c.h"
4908
STACK_SHRINK(1);
4909
stack_pointer[-1] = res;
4910
next_instr += 1;
4911
DISPATCH();
4912
}
4913
4914
TARGET(SWAP) {
4915
PyObject *top = stack_pointer[-1];
4916
PyObject *bottom = stack_pointer[-(2 + (oparg-2))];
4917
#line 3551 "Python/bytecodes.c"
4918
assert(oparg >= 2);
4919
#line 4920 "Python/generated_cases.c.h"
4920
stack_pointer[-1] = bottom;
4921
stack_pointer[-(2 + (oparg-2))] = top;
4922
DISPATCH();
4923
}
4924
4925
TARGET(INSTRUMENTED_INSTRUCTION) {
4926
#line 3555 "Python/bytecodes.c"
4927
int next_opcode = _Py_call_instrumentation_instruction(
4928
tstate, frame, next_instr-1);
4929
if (next_opcode < 0) goto error;
4930
next_instr--;
4931
if (_PyOpcode_Caches[next_opcode]) {
4932
_PyBinaryOpCache *cache = (_PyBinaryOpCache *)(next_instr+1);
4933
INCREMENT_ADAPTIVE_COUNTER(cache->counter);
4934
}
4935
assert(next_opcode > 0 && next_opcode < 256);
4936
opcode = next_opcode;
4937
DISPATCH_GOTO();
4938
#line 4939 "Python/generated_cases.c.h"
4939
}
4940
4941
TARGET(INSTRUMENTED_JUMP_FORWARD) {
4942
#line 3569 "Python/bytecodes.c"
4943
INSTRUMENTED_JUMP(next_instr-1, next_instr+oparg, PY_MONITORING_EVENT_JUMP);
4944
#line 4945 "Python/generated_cases.c.h"
4945
DISPATCH();
4946
}
4947
4948
TARGET(INSTRUMENTED_JUMP_BACKWARD) {
4949
#line 3573 "Python/bytecodes.c"
4950
INSTRUMENTED_JUMP(next_instr-1, next_instr+1-oparg, PY_MONITORING_EVENT_JUMP);
4951
#line 4952 "Python/generated_cases.c.h"
4952
CHECK_EVAL_BREAKER();
4953
DISPATCH();
4954
}
4955
4956
TARGET(INSTRUMENTED_POP_JUMP_IF_TRUE) {
4957
#line 3578 "Python/bytecodes.c"
4958
PyObject *cond = POP();
4959
assert(PyBool_Check(cond));
4960
_Py_CODEUNIT *here = next_instr - 1;
4961
int offset = Py_IsTrue(cond) * oparg;
4962
INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH);
4963
#line 4964 "Python/generated_cases.c.h"
4964
DISPATCH();
4965
}
4966
4967
TARGET(INSTRUMENTED_POP_JUMP_IF_FALSE) {
4968
#line 3586 "Python/bytecodes.c"
4969
PyObject *cond = POP();
4970
assert(PyBool_Check(cond));
4971
_Py_CODEUNIT *here = next_instr - 1;
4972
int offset = Py_IsFalse(cond) * oparg;
4973
INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH);
4974
#line 4975 "Python/generated_cases.c.h"
4975
DISPATCH();
4976
}
4977
4978
TARGET(INSTRUMENTED_POP_JUMP_IF_NONE) {
4979
#line 3594 "Python/bytecodes.c"
4980
PyObject *value = POP();
4981
_Py_CODEUNIT *here = next_instr-1;
4982
int offset;
4983
if (Py_IsNone(value)) {
4984
offset = oparg;
4985
}
4986
else {
4987
Py_DECREF(value);
4988
offset = 0;
4989
}
4990
INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH);
4991
#line 4992 "Python/generated_cases.c.h"
4992
DISPATCH();
4993
}
4994
4995
TARGET(INSTRUMENTED_POP_JUMP_IF_NOT_NONE) {
4996
#line 3608 "Python/bytecodes.c"
4997
PyObject *value = POP();
4998
_Py_CODEUNIT *here = next_instr-1;
4999
int offset;
5000
if (Py_IsNone(value)) {
5001
offset = 0;
5002
}
5003
else {
5004
Py_DECREF(value);
5005
offset = oparg;
5006
}
5007
INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH);
5008
#line 5009 "Python/generated_cases.c.h"
5009
DISPATCH();
5010
}
5011
5012
TARGET(EXTENDED_ARG) {
5013
#line 3622 "Python/bytecodes.c"
5014
assert(oparg);
5015
opcode = next_instr->op.code;
5016
oparg = oparg << 8 | next_instr->op.arg;
5017
PRE_DISPATCH_GOTO();
5018
DISPATCH_GOTO();
5019
#line 5020 "Python/generated_cases.c.h"
5020
}
5021
5022
TARGET(CACHE) {
5023
#line 3630 "Python/bytecodes.c"
5024
assert(0 && "Executing a cache.");
5025
Py_UNREACHABLE();
5026
#line 5027 "Python/generated_cases.c.h"
5027
}
5028
5029
TARGET(RESERVED) {
5030
#line 3635 "Python/bytecodes.c"
5031
assert(0 && "Executing RESERVED instruction.");
5032
Py_UNREACHABLE();
5033
#line 5034 "Python/generated_cases.c.h"
5034
}
5035
5036