Skip to content

Commit 0712642

Browse files
committed
More binary ops, and BINARY_SLICE (which is weird)
1 parent f23b6fb commit 0712642

File tree

2 files changed

+47
-72
lines changed

2 files changed

+47
-72
lines changed

Python/bytecodes.c

Lines changed: 15 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -351,76 +351,51 @@ dummy_func(
351351
JUMPBY(INLINE_CACHE_ENTRIES_BINARY_OP + 1);
352352
}
353353

354-
// stack effect: (__0 -- )
355-
inst(BINARY_OP_ADD_FLOAT) {
354+
inst(BINARY_OP_ADD_FLOAT, (left, right -- sum)) {
356355
assert(cframe.use_tracing == 0);
357-
PyObject *left = SECOND();
358-
PyObject *right = TOP();
359356
DEOPT_IF(!PyFloat_CheckExact(left), BINARY_OP);
360357
DEOPT_IF(Py_TYPE(right) != Py_TYPE(left), BINARY_OP);
361358
STAT_INC(BINARY_OP, hit);
362359
double dsum = ((PyFloatObject *)left)->ob_fval +
363360
((PyFloatObject *)right)->ob_fval;
364-
PyObject *sum = PyFloat_FromDouble(dsum);
365-
SET_SECOND(sum);
361+
sum = PyFloat_FromDouble(dsum);
366362
_Py_DECREF_SPECIALIZED(right, _PyFloat_ExactDealloc);
367363
_Py_DECREF_SPECIALIZED(left, _PyFloat_ExactDealloc);
368-
STACK_SHRINK(1);
369-
if (sum == NULL) {
370-
goto error;
371-
}
364+
ERROR_IF(sum == NULL, error);
372365
JUMPBY(INLINE_CACHE_ENTRIES_BINARY_OP);
373366
}
374367

375-
// stack effect: (__0 -- )
376-
inst(BINARY_OP_ADD_INT) {
368+
inst(BINARY_OP_ADD_INT, (left, right -- sum)) {
377369
assert(cframe.use_tracing == 0);
378-
PyObject *left = SECOND();
379-
PyObject *right = TOP();
380370
DEOPT_IF(!PyLong_CheckExact(left), BINARY_OP);
381371
DEOPT_IF(Py_TYPE(right) != Py_TYPE(left), BINARY_OP);
382372
STAT_INC(BINARY_OP, hit);
383-
PyObject *sum = _PyLong_Add((PyLongObject *)left, (PyLongObject *)right);
384-
SET_SECOND(sum);
373+
sum = _PyLong_Add((PyLongObject *)left, (PyLongObject *)right);
385374
_Py_DECREF_SPECIALIZED(right, (destructor)PyObject_Free);
386375
_Py_DECREF_SPECIALIZED(left, (destructor)PyObject_Free);
387-
STACK_SHRINK(1);
388-
if (sum == NULL) {
389-
goto error;
390-
}
376+
ERROR_IF(sum == NULL, error);
391377
JUMPBY(INLINE_CACHE_ENTRIES_BINARY_OP);
392378
}
393379

394-
// stack effect: (__0 -- )
395-
inst(BINARY_SUBSCR) {
396-
PyObject *sub = POP();
397-
PyObject *container = TOP();
398-
PyObject *res = PyObject_GetItem(container, sub);
380+
inst(BINARY_SUBSCR, (container, sub -- res)) {
381+
res = PyObject_GetItem(container, sub);
399382
Py_DECREF(container);
400383
Py_DECREF(sub);
401-
SET_TOP(res);
402-
if (res == NULL)
403-
goto error;
384+
ERROR_IF(res == NULL, error);
404385
JUMPBY(INLINE_CACHE_ENTRIES_BINARY_SUBSCR);
405386
}
406387

407-
// stack effect: (__0, __1 -- )
408-
inst(BINARY_SLICE) {
409-
PyObject *stop = POP();
410-
PyObject *start = POP();
411-
PyObject *container = TOP();
412-
388+
inst(BINARY_SLICE, (container, start, stop -- res)) {
413389
PyObject *slice = _PyBuildSlice_ConsumeRefs(start, stop);
414390
if (slice == NULL) {
415-
goto error;
391+
res = NULL;
416392
}
417-
PyObject *res = PyObject_GetItem(container, slice);
418-
Py_DECREF(slice);
419-
if (res == NULL) {
420-
goto error;
393+
else {
394+
PyObject *res = PyObject_GetItem(container, slice);
395+
Py_DECREF(slice);
421396
}
422-
SET_TOP(res);
423397
Py_DECREF(container);
398+
ERROR_IF(res == NULL, error);
424399
}
425400

426401
// stack effect: (__0, __1, __2, __3 -- )

Python/generated_cases.c.h

Lines changed: 32 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)