@@ -342,18 +342,16 @@ dummy_func(
342
342
};
343
343
344
344
inst (BINARY_SUBSCR , (unused /4 , container , sub -- unused )) {
345
- _PyMutex_lock (& _PyRuntime .mutex );
346
345
_PyBinarySubscrCache * cache = (_PyBinarySubscrCache * )next_instr ;
347
- if (ADAPTIVE_COUNTER_IS_ZERO (cache -> counter )) {
346
+ if (DECREMENT_ADAPTIVE_COUNTER (& cache -> counter )) {
347
+ _PyMutex_lock (& _PyRuntime .mutex );
348
348
assert (cframe .use_tracing == 0 );
349
349
next_instr -- ;
350
350
_Py_Specialize_BinarySubscr (container , sub , next_instr );
351
351
_PyMutex_unlock (& _PyRuntime .mutex );
352
352
DISPATCH_SAME_OPARG ();
353
353
}
354
354
STAT_INC (BINARY_SUBSCR , deferred );
355
- DECREMENT_ADAPTIVE_COUNTER (cache -> counter );
356
- _PyMutex_unlock (& _PyRuntime .mutex );
357
355
GO_TO_INSTRUCTION (BINARY_SUBSCR_GENERIC );
358
356
}
359
357
@@ -490,18 +488,16 @@ dummy_func(
490
488
};
491
489
492
490
inst (STORE_SUBSCR , (unused /1 , unused , container , sub -- )) {
493
- _PyMutex_lock (& _PyRuntime .mutex );
494
491
_PyStoreSubscrCache * cache = (_PyStoreSubscrCache * )next_instr ;
495
- if (ADAPTIVE_COUNTER_IS_ZERO (cache -> counter )) {
492
+ if (DECREMENT_ADAPTIVE_COUNTER (& cache -> counter )) {
493
+ _PyMutex_lock (& _PyRuntime .mutex );
496
494
assert (cframe .use_tracing == 0 );
497
495
next_instr -- ;
498
496
_Py_Specialize_StoreSubscr (container , sub , next_instr );
499
497
_PyMutex_unlock (& _PyRuntime .mutex );
500
498
DISPATCH_SAME_OPARG ();
501
499
}
502
500
STAT_INC (STORE_SUBSCR , deferred );
503
- DECREMENT_ADAPTIVE_COUNTER (cache -> counter );
504
- _PyMutex_unlock (& _PyRuntime .mutex );
505
501
GO_TO_INSTRUCTION (STORE_SUBSCR_GENERIC );
506
502
}
507
503
@@ -928,9 +924,9 @@ dummy_func(
928
924
929
925
// stack effect: (__0 -- __array[oparg])
930
926
inst (UNPACK_SEQUENCE ) {
931
- _PyMutex_lock (& _PyRuntime .mutex );
932
927
_PyUnpackSequenceCache * cache = (_PyUnpackSequenceCache * )next_instr ;
933
- if (ADAPTIVE_COUNTER_IS_ZERO (cache -> counter )) {
928
+ if (DECREMENT_ADAPTIVE_COUNTER (& cache -> counter )) {
929
+ _PyMutex_lock (& _PyRuntime .mutex );
934
930
assert (cframe .use_tracing == 0 );
935
931
PyObject * seq = TOP ();
936
932
next_instr -- ;
@@ -939,8 +935,6 @@ dummy_func(
939
935
DISPATCH_SAME_OPARG ();
940
936
}
941
937
STAT_INC (UNPACK_SEQUENCE , deferred );
942
- DECREMENT_ADAPTIVE_COUNTER (cache -> counter );
943
- _PyMutex_unlock (& _PyRuntime .mutex );
944
938
GO_TO_INSTRUCTION (UNPACK_SEQUENCE_GENERIC );
945
939
}
946
940
@@ -1021,9 +1015,9 @@ dummy_func(
1021
1015
};
1022
1016
1023
1017
inst (STORE_ATTR , (unused /1 , unused /3 , unused , owner -- )) {
1024
- _PyMutex_lock (& _PyRuntime .mutex );
1025
1018
_PyAttrCache * cache = (_PyAttrCache * )next_instr ;
1026
- if (ADAPTIVE_COUNTER_IS_ZERO (cache -> counter )) {
1019
+ if (DECREMENT_ADAPTIVE_COUNTER (& cache -> counter )) {
1020
+ _PyMutex_lock (& _PyRuntime .mutex );
1027
1021
assert (cframe .use_tracing == 0 );
1028
1022
PyObject * name = GETITEM (names , oparg );
1029
1023
next_instr -- ;
@@ -1032,8 +1026,6 @@ dummy_func(
1032
1026
DISPATCH_SAME_OPARG ();
1033
1027
}
1034
1028
STAT_INC (STORE_ATTR , deferred );
1035
- DECREMENT_ADAPTIVE_COUNTER (cache -> counter );
1036
- _PyMutex_unlock (& _PyRuntime .mutex );
1037
1029
GO_TO_INSTRUCTION (STORE_ATTR_GENERIC );
1038
1030
}
1039
1031
@@ -1136,9 +1128,9 @@ dummy_func(
1136
1128
1137
1129
// error: LOAD_GLOBAL has irregular stack effect
1138
1130
inst (LOAD_GLOBAL ) {
1139
- _PyMutex_lock (& _PyRuntime .mutex );
1140
1131
_PyLoadGlobalCache * cache = (_PyLoadGlobalCache * )next_instr ;
1141
- if (ADAPTIVE_COUNTER_IS_ZERO (cache -> counter )) {
1132
+ if (DECREMENT_ADAPTIVE_COUNTER (& cache -> counter )) {
1133
+ _PyMutex_lock (& _PyRuntime .mutex );
1142
1134
assert (cframe .use_tracing == 0 );
1143
1135
PyObject * name = GETITEM (names , oparg >>1 );
1144
1136
next_instr -- ;
@@ -1147,8 +1139,6 @@ dummy_func(
1147
1139
DISPATCH_SAME_OPARG ();
1148
1140
}
1149
1141
STAT_INC (LOAD_GLOBAL , deferred );
1150
- DECREMENT_ADAPTIVE_COUNTER (cache -> counter );
1151
- _PyMutex_unlock (& _PyRuntime .mutex );
1152
1142
GO_TO_INSTRUCTION (LOAD_GLOBAL_GENERIC );
1153
1143
}
1154
1144
@@ -1537,9 +1527,9 @@ dummy_func(
1537
1527
1538
1528
// error: LOAD_ATTR has irregular stack effect
1539
1529
inst (LOAD_ATTR ) {
1540
- _PyMutex_lock (& _PyRuntime .mutex );
1541
1530
_PyAttrCache * cache = (_PyAttrCache * )next_instr ;
1542
- if (ADAPTIVE_COUNTER_IS_ZERO (cache -> counter )) {
1531
+ if (DECREMENT_ADAPTIVE_COUNTER (& cache -> counter )) {
1532
+ _PyMutex_lock (& _PyRuntime .mutex );
1543
1533
assert (cframe .use_tracing == 0 );
1544
1534
PyObject * owner = TOP ();
1545
1535
PyObject * name = GETITEM (names , oparg >>1 );
@@ -1549,8 +1539,6 @@ dummy_func(
1549
1539
DISPATCH_SAME_OPARG ();
1550
1540
}
1551
1541
STAT_INC (LOAD_ATTR , deferred );
1552
- DECREMENT_ADAPTIVE_COUNTER (cache -> counter );
1553
- _PyMutex_unlock (& _PyRuntime .mutex );
1554
1542
GO_TO_INSTRUCTION (LOAD_ATTR_GENERIC );
1555
1543
}
1556
1544
@@ -1885,18 +1873,16 @@ dummy_func(
1885
1873
};
1886
1874
1887
1875
inst (COMPARE_OP , (unused /2 , left , right -- unused )) {
1888
- _PyMutex_lock (& _PyRuntime .mutex );
1889
1876
_PyCompareOpCache * cache = (_PyCompareOpCache * )next_instr ;
1890
- if (ADAPTIVE_COUNTER_IS_ZERO (cache -> counter )) {
1877
+ if (DECREMENT_ADAPTIVE_COUNTER (& cache -> counter )) {
1878
+ _PyMutex_lock (& _PyRuntime .mutex );
1891
1879
assert (cframe .use_tracing == 0 );
1892
1880
next_instr -- ;
1893
1881
_Py_Specialize_CompareOp (left , right , next_instr , oparg );
1894
1882
_PyMutex_unlock (& _PyRuntime .mutex );
1895
1883
DISPATCH_SAME_OPARG ();
1896
1884
}
1897
1885
STAT_INC (COMPARE_OP , deferred );
1898
- DECREMENT_ADAPTIVE_COUNTER (cache -> counter );
1899
- _PyMutex_unlock (& _PyRuntime .mutex );
1900
1886
GO_TO_INSTRUCTION (COMPARE_OP_GENERIC );
1901
1887
}
1902
1888
@@ -2301,18 +2287,16 @@ dummy_func(
2301
2287
2302
2288
// stack effect: ( -- __0)
2303
2289
inst (FOR_ITER ) {
2304
- _PyMutex_lock (& _PyRuntime .mutex );
2305
2290
_PyForIterCache * cache = (_PyForIterCache * )next_instr ;
2306
- if (ADAPTIVE_COUNTER_IS_ZERO (cache -> counter )) {
2291
+ if (DECREMENT_ADAPTIVE_COUNTER (& cache -> counter )) {
2292
+ _PyMutex_lock (& _PyRuntime .mutex );
2307
2293
assert (cframe .use_tracing == 0 );
2308
2294
next_instr -- ;
2309
2295
_Py_Specialize_ForIter (TOP (), next_instr , oparg );
2310
2296
_PyMutex_unlock (& _PyRuntime .mutex );
2311
2297
DISPATCH_SAME_OPARG ();
2312
2298
}
2313
2299
STAT_INC (FOR_ITER , deferred );
2314
- DECREMENT_ADAPTIVE_COUNTER (cache -> counter );
2315
- _PyMutex_unlock (& _PyRuntime .mutex );
2316
2300
GO_TO_INSTRUCTION (FOR_ITER_GENERIC );
2317
2301
}
2318
2302
@@ -2636,9 +2620,9 @@ dummy_func(
2636
2620
2637
2621
// stack effect: (__0, __array[oparg] -- )
2638
2622
inst (CALL ) {
2639
- _PyMutex_lock (& _PyRuntime .mutex );
2640
2623
_PyCallCache * cache = (_PyCallCache * )next_instr ;
2641
- if (ADAPTIVE_COUNTER_IS_ZERO (cache -> counter )) {
2624
+ if (DECREMENT_ADAPTIVE_COUNTER (& cache -> counter )) {
2625
+ _PyMutex_lock (& _PyRuntime .mutex );
2642
2626
assert (cframe .use_tracing == 0 );
2643
2627
int is_meth = is_method (stack_pointer , oparg );
2644
2628
int nargs = oparg + is_meth ;
@@ -2649,8 +2633,6 @@ dummy_func(
2649
2633
DISPATCH_SAME_OPARG ();
2650
2634
}
2651
2635
STAT_INC (CALL , deferred );
2652
- DECREMENT_ADAPTIVE_COUNTER (cache -> counter );
2653
- _PyMutex_unlock (& _PyRuntime .mutex );
2654
2636
GO_TO_INSTRUCTION (CALL_GENERIC );
2655
2637
}
2656
2638
@@ -3393,18 +3375,16 @@ dummy_func(
3393
3375
}
3394
3376
3395
3377
inst (BINARY_OP , (unused /1 , lhs , rhs -- unused )) {
3396
- _PyMutex_lock (& _PyRuntime .mutex );
3397
3378
_PyBinaryOpCache * cache = (_PyBinaryOpCache * )next_instr ;
3398
- if (ADAPTIVE_COUNTER_IS_ZERO (cache -> counter )) {
3379
+ if (DECREMENT_ADAPTIVE_COUNTER (& cache -> counter )) {
3380
+ _PyMutex_lock (& _PyRuntime .mutex );
3399
3381
assert (cframe .use_tracing == 0 );
3400
3382
next_instr -- ;
3401
3383
_Py_Specialize_BinaryOp (lhs , rhs , next_instr , oparg , & GETLOCAL (0 ));
3402
3384
_PyMutex_unlock (& _PyRuntime .mutex );
3403
3385
DISPATCH_SAME_OPARG ();
3404
3386
}
3405
3387
STAT_INC (BINARY_OP , deferred );
3406
- DECREMENT_ADAPTIVE_COUNTER (cache -> counter );
3407
- _PyMutex_unlock (& _PyRuntime .mutex );
3408
3388
GO_TO_INSTRUCTION (BINARY_OP_GENERIC );
3409
3389
}
3410
3390
0 commit comments