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
+ instr (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,76 +219,59 @@ 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
- if (res == NULL )
230
+ if (res == NULL ) {
250
231
goto error ;
232
+ }
251
233
}
252
234
253
- // stack effect: ( -- )
254
- inst (UNARY_NEGATIVE ) {
255
- PyObject * value = TOP ();
256
- PyObject * res = PyNumber_Negative (value );
235
+ instr (UNARY_NEGATIVE , (value -- res )) {
236
+ res = PyNumber_Negative (value );
257
237
Py_DECREF (value );
258
- SET_TOP (res );
259
- if (res == NULL )
238
+ if (res == NULL ) {
260
239
goto error ;
240
+ }
261
241
}
262
242
263
- // stack effect: ( -- )
264
- inst (UNARY_NOT ) {
265
- PyObject * value = TOP ();
243
+ instr (UNARY_NOT , (value -- res )) {
266
244
int err = PyObject_IsTrue (value );
267
245
Py_DECREF (value );
268
246
if (err == 0 ) {
269
- Py_INCREF (Py_True );
270
- SET_TOP (Py_True );
271
- DISPATCH ();
247
+ res = Py_True ;
272
248
}
273
249
else if (err > 0 ) {
274
- Py_INCREF (Py_False );
275
- SET_TOP (Py_False );
276
- DISPATCH ();
250
+ res = Py_False ;
277
251
}
278
- STACK_SHRINK (1 );
279
- goto error ;
252
+ else {
253
+ goto error ;
254
+ }
255
+ Py_INCREF (res );
280
256
}
281
257
282
- // stack effect: ( -- )
283
- inst (UNARY_INVERT ) {
284
- PyObject * value = TOP ();
285
- PyObject * res = PyNumber_Invert (value );
258
+ instr (UNARY_INVERT , (value -- res )) {
259
+ res = PyNumber_Invert (value );
286
260
Py_DECREF (value );
287
- SET_TOP (res );
288
- if (res == NULL )
261
+ if (res == NULL ) {
289
262
goto error ;
263
+ }
290
264
}
291
265
292
- // stack effect: (__0 -- )
293
- inst ( BINARY_OP_MULTIPLY_INT ) {
266
+ instr ( BINARY_OP_MULTIPLY_INT , ( left , right -- prod )) {
267
+ // TODO: Don't pop from the stack before DEOPF_IF() calls.
294
268
assert (cframe .use_tracing == 0 );
295
- PyObject * left = SECOND ();
296
- PyObject * right = TOP ();
297
269
DEOPT_IF (!PyLong_CheckExact (left ), BINARY_OP );
298
270
DEOPT_IF (!PyLong_CheckExact (right ), BINARY_OP );
299
271
STAT_INC (BINARY_OP , hit );
300
272
PyObject * prod = _PyLong_Multiply ((PyLongObject * )left , (PyLongObject * )right );
301
- SET_SECOND (prod );
302
273
_Py_DECREF_SPECIALIZED (right , (destructor )PyObject_Free );
303
274
_Py_DECREF_SPECIALIZED (left , (destructor )PyObject_Free );
304
- STACK_SHRINK (1 );
305
275
if (prod == NULL ) {
306
276
goto error ;
307
277
}
0 commit comments