69
69
#define DISPATCH () ((void)0)
70
70
71
71
#define inst (name ) case name:
72
+ #define instr (name , arg ) case name:
72
73
#define family (name ) static int family_##name
73
74
74
75
#define NAME_ERROR_MSG \
@@ -103,58 +104,46 @@ dummy_func(
103
104
and that all operation that succeed call DISPATCH() ! */
104
105
105
106
// BEGIN BYTECODES //
106
- // stack effect: ( -- )
107
- inst (NOP ) {
107
+ instr (NOP , (-- )) {
108
108
}
109
109
110
- // stack effect: ( -- )
111
- inst (RESUME ) {
110
+ instr (RESUME , (-- )) {
112
111
assert (tstate -> cframe == & cframe );
113
112
assert (frame == cframe .current_frame );
114
113
if (_Py_atomic_load_relaxed_int32 (eval_breaker ) && oparg < 2 ) {
115
114
goto handle_eval_breaker ;
116
115
}
117
116
}
118
117
119
- // stack effect: ( -- __0)
120
- inst (LOAD_CLOSURE ) {
118
+ instr (LOAD_CLOSURE , (-- value )) {
121
119
/* We keep LOAD_CLOSURE so that the bytecode stays more readable. */
122
- PyObject * value = GETLOCAL (oparg );
120
+ value = GETLOCAL (oparg );
123
121
if (value == NULL ) {
124
122
goto unbound_local_error ;
125
123
}
126
124
Py_INCREF (value );
127
- PUSH (value );
128
125
}
129
126
130
- // stack effect: ( -- __0)
131
- inst (LOAD_FAST_CHECK ) {
132
- PyObject * value = GETLOCAL (oparg );
127
+ instr (LOAD_FAST_CHECK , (-- value )) {
128
+ value = GETLOCAL (oparg );
133
129
if (value == NULL ) {
134
130
goto unbound_local_error ;
135
131
}
136
132
Py_INCREF (value );
137
- PUSH (value );
138
133
}
139
134
140
- // stack effect: ( -- __0)
141
- inst (LOAD_FAST ) {
142
- PyObject * value = GETLOCAL (oparg );
135
+ instr (LOAD_FAST , (-- value )) {
136
+ value = GETLOCAL (oparg );
143
137
assert (value != NULL );
144
138
Py_INCREF (value );
145
- PUSH (value );
146
139
}
147
140
148
- // stack effect: ( -- __0)
149
- inst (LOAD_CONST ) {
150
- PyObject * value = GETITEM (consts , oparg );
141
+ instr (LOAD_CONST , (-- value )) {
142
+ value = GETITEM (consts , oparg );
151
143
Py_INCREF (value );
152
- PUSH (value );
153
144
}
154
145
155
- // stack effect: (__0 -- )
156
- inst (STORE_FAST ) {
157
- PyObject * value = POP ();
146
+ inst (STORE_FAST , (value -- )) {
158
147
SETLOCAL (oparg , value );
159
148
}
160
149
@@ -220,9 +209,7 @@ dummy_func(
220
209
PUSH (value );
221
210
}
222
211
223
- // stack effect: (__0 -- )
224
- inst (POP_TOP ) {
225
- PyObject * value = POP ();
212
+ instr (POP_TOP , (value -- )) {
226
213
Py_DECREF (value );
227
214
}
228
215
@@ -232,59 +219,43 @@ dummy_func(
232
219
BASIC_PUSH (NULL );
233
220
}
234
221
235
- // stack effect: (__0, __1 -- )
236
- inst (END_FOR ) {
237
- PyObject * value = POP ();
238
- Py_DECREF (value );
239
- value = POP ();
240
- Py_DECREF (value );
222
+ instr (END_FOR , (value1 , value2 -- )) {
223
+ Py_DECREF (value1 );
224
+ Py_DECREF (value2 );
241
225
}
242
226
243
- // stack effect: ( -- )
244
- inst (UNARY_POSITIVE ) {
245
- PyObject * value = TOP ();
246
- PyObject * res = PyNumber_Positive (value );
227
+ instr (UNARY_POSITIVE , (value -- res )) {
228
+ res = PyNumber_Positive (value );
247
229
Py_DECREF (value );
248
- SET_TOP (res );
249
230
if (res == NULL )
250
231
goto error ;
251
232
}
252
233
253
- // stack effect: ( -- )
254
- inst (UNARY_NEGATIVE ) {
255
- PyObject * value = TOP ();
256
- PyObject * res = PyNumber_Negative (value );
234
+ instr (UNARY_NEGATIVE , (value -- res )) {
235
+ res = PyNumber_Negative (value );
257
236
Py_DECREF (value );
258
- SET_TOP (res );
259
237
if (res == NULL )
260
238
goto error ;
261
239
}
262
240
263
- // stack effect: ( -- )
264
- inst (UNARY_NOT ) {
265
- PyObject * value = TOP ();
241
+ instr (UNARY_NOT , (value -- res )) {
266
242
int err = PyObject_IsTrue (value );
267
243
Py_DECREF (value );
268
244
if (err == 0 ) {
269
- Py_INCREF (Py_True );
270
- SET_TOP (Py_True );
271
- DISPATCH ();
245
+ res = Py_True ;
272
246
}
273
247
else if (err > 0 ) {
274
- Py_INCREF (Py_False );
275
- SET_TOP (Py_False );
276
- DISPATCH ();
248
+ res = Py_False ;
277
249
}
278
- STACK_SHRINK (1 );
279
- goto error ;
250
+ else {
251
+ goto error ;
252
+ }
253
+ Py_INCREF (res );
280
254
}
281
255
282
- // stack effect: ( -- )
283
- inst (UNARY_INVERT ) {
284
- PyObject * value = TOP ();
285
- PyObject * res = PyNumber_Invert (value );
256
+ inst (UNARY_INVERT , (value -- res )) {
257
+ res = PyNumber_Invert (value );
286
258
Py_DECREF (value );
287
- SET_TOP (res );
288
259
if (res == NULL )
289
260
goto error ;
290
261
}
0 commit comments