73
73
#define op (name , ...) /* NAME is ignored */
74
74
#define macro (name ) static int MACRO_##name
75
75
#define super (name ) static int SUPER_##name
76
- #define family (name , ...) static int family_##name
76
+ #define family (name , ...) static int family_##name[]
77
77
78
78
#define NAME_ERROR_MSG \
79
79
"name '%.200s' is not defined"
@@ -86,6 +86,7 @@ static PyObject *exit_func, *lasti, *val, *retval, *obj, *iter;
86
86
static size_t jump ;
87
87
// Dummy variables for cache effects
88
88
static _Py_CODEUNIT when_to_jump_mask , invert , counter , index , hint ;
89
+ static _Py_CODEUNIT word ;
89
90
static uint32_t type_version ;
90
91
// Dummy opcode names for 'op' opcodes
91
92
#define _BINARY_OP_INPLACE_ADD_UNICODE_PART_1 1001
@@ -94,6 +95,7 @@ static uint32_t type_version;
94
95
#define _COMPARE_OP_INT 1004
95
96
#define _COMPARE_OP_STR 1005
96
97
#define _JUMP_ON_SIGN 1006
98
+ #define JOIN 0
97
99
98
100
static PyObject *
99
101
dummy_func (
@@ -156,11 +158,18 @@ dummy_func(
156
158
SETLOCAL (oparg , value );
157
159
}
158
160
159
- super (LOAD_FAST__LOAD_FAST ) = LOAD_FAST + LOAD_FAST ;
160
- super (LOAD_FAST__LOAD_CONST ) = LOAD_FAST + LOAD_CONST ;
161
- super (STORE_FAST__LOAD_FAST ) = STORE_FAST + LOAD_FAST ;
162
- super (STORE_FAST__STORE_FAST ) = STORE_FAST + STORE_FAST ;
163
- super (LOAD_CONST__LOAD_FAST ) = LOAD_CONST + LOAD_FAST ;
161
+ op (JOIN , (word /1 -- )) {
162
+ #ifndef NDEBUG
163
+ opcode = _Py_OPCODE (word );
164
+ #endif
165
+ oparg = _Py_OPARG (word );
166
+ }
167
+
168
+ macro (LOAD_FAST__LOAD_FAST ) = LOAD_FAST + JOIN + LOAD_FAST ;
169
+ macro (LOAD_FAST__LOAD_CONST ) = LOAD_FAST + JOIN + LOAD_CONST ;
170
+ macro (STORE_FAST__LOAD_FAST ) = STORE_FAST + JOIN + LOAD_FAST ;
171
+ macro (STORE_FAST__STORE_FAST ) = STORE_FAST + JOIN + STORE_FAST ;
172
+ macro (LOAD_CONST__LOAD_FAST ) = LOAD_CONST + JOIN + LOAD_FAST ;
164
173
165
174
inst (POP_TOP , (value -- )) {
166
175
Py_DECREF (value );
@@ -307,8 +316,8 @@ dummy_func(
307
316
op (_BINARY_OP_INPLACE_ADD_UNICODE_PART_2 , (unused -- )) {
308
317
// The STORE_FAST is already done; oparg is dead.
309
318
}
310
- super (BINARY_OP_INPLACE_ADD_UNICODE ) =
311
- _BINARY_OP_INPLACE_ADD_UNICODE_PART_1 + _BINARY_OP_INPLACE_ADD_UNICODE_PART_2 ;
319
+ macro (BINARY_OP_INPLACE_ADD_UNICODE ) =
320
+ _BINARY_OP_INPLACE_ADD_UNICODE_PART_1 + JOIN + _BINARY_OP_INPLACE_ADD_UNICODE_PART_2 ;
312
321
313
322
inst (BINARY_OP_ADD_FLOAT , (left , right , unused /1 -- sum )) {
314
323
assert (cframe .use_tracing == 0 );
@@ -2042,7 +2051,7 @@ dummy_func(
2042
2051
}
2043
2052
}
2044
2053
// We're praying that the compiler optimizes the flags manipuations.
2045
- super (COMPARE_OP_FLOAT_JUMP ) = _COMPARE_OP_FLOAT + _JUMP_ON_SIGN ;
2054
+ macro (COMPARE_OP_FLOAT_JUMP ) = _COMPARE_OP_FLOAT + JOIN + _JUMP_ON_SIGN ;
2046
2055
2047
2056
// Similar to COMPARE_OP_FLOAT
2048
2057
op (_COMPARE_OP_INT , (unused /1 , left , right , when_to_jump_mask /1 -- jump : size_t )) {
@@ -2062,7 +2071,7 @@ dummy_func(
2062
2071
_Py_DECREF_SPECIALIZED (right , (destructor )PyObject_Free );
2063
2072
jump = sign_ish & when_to_jump_mask ;
2064
2073
}
2065
- super (COMPARE_OP_INT_JUMP ) = _COMPARE_OP_INT + _JUMP_ON_SIGN ;
2074
+ macro (COMPARE_OP_INT_JUMP ) = _COMPARE_OP_INT + JOIN + _JUMP_ON_SIGN ;
2066
2075
2067
2076
// Similar to COMPARE_OP_FLOAT, but for ==, != only
2068
2077
op (_COMPARE_OP_STR , (unused /1 , left , right , invert /1 -- jump : size_t )) {
@@ -2079,7 +2088,7 @@ dummy_func(
2079
2088
assert (invert == 0 || invert == 1 );
2080
2089
jump = res ^ invert ;
2081
2090
}
2082
- super (COMPARE_OP_STR_JUMP ) = _COMPARE_OP_STR + _JUMP_ON_SIGN ;
2091
+ macro (COMPARE_OP_STR_JUMP ) = _COMPARE_OP_STR + JOIN + _JUMP_ON_SIGN ;
2083
2092
2084
2093
// stack effect: (__0 -- )
2085
2094
inst (IS_OP ) {
0 commit comments