Skip to content

Commit d2573b6

Browse files
committed
Change all super() to macro() using op(JOIN)
1 parent 1cfa704 commit d2573b6

File tree

2 files changed

+82
-27
lines changed

2 files changed

+82
-27
lines changed

Python/bytecodes.c

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,14 @@ static PyObject *exit_func, *lasti, *val, *retval, *obj, *iter;
8686
static size_t jump;
8787
// Dummy variables for cache effects
8888
static _Py_CODEUNIT when_to_jump_mask, invert, counter, index, hint;
89+
static _Py_CODEUNIT word;
8990
static uint32_t type_version;
9091
// Dummy opcode names for 'op' opcodes
9192
#define _COMPARE_OP_FLOAT 1003
9293
#define _COMPARE_OP_INT 1004
9394
#define _COMPARE_OP_STR 1005
9495
#define _JUMP_IF 1006
96+
#define JOIN 0
9597

9698
static PyObject *
9799
dummy_func(
@@ -115,6 +117,14 @@ dummy_func(
115117
switch (opcode) {
116118

117119
// BEGIN BYTECODES //
120+
121+
op(JOIN, (word/1 --)) {
122+
#ifndef NDEBUG
123+
opcode = _Py_OPCODE(word);
124+
#endif
125+
oparg = _Py_OPARG(word);
126+
}
127+
118128
inst(NOP, (--)) {
119129
}
120130

@@ -154,11 +164,11 @@ dummy_func(
154164
SETLOCAL(oparg, value);
155165
}
156166

157-
super(LOAD_FAST__LOAD_FAST) = LOAD_FAST + LOAD_FAST;
158-
super(LOAD_FAST__LOAD_CONST) = LOAD_FAST + LOAD_CONST;
159-
super(STORE_FAST__LOAD_FAST) = STORE_FAST + LOAD_FAST;
160-
super(STORE_FAST__STORE_FAST) = STORE_FAST + STORE_FAST;
161-
super(LOAD_CONST__LOAD_FAST) = LOAD_CONST + LOAD_FAST;
167+
macro(LOAD_FAST__LOAD_FAST) = LOAD_FAST + JOIN + LOAD_FAST;
168+
macro(LOAD_FAST__LOAD_CONST) = LOAD_FAST + JOIN + LOAD_CONST;
169+
macro(STORE_FAST__LOAD_FAST) = STORE_FAST + JOIN + LOAD_FAST;
170+
macro(STORE_FAST__STORE_FAST) = STORE_FAST + JOIN + STORE_FAST;
171+
macro(LOAD_CONST__LOAD_FAST) = LOAD_CONST + JOIN + LOAD_FAST;
162172

163173
inst(POP_TOP, (value --)) {
164174
Py_DECREF(value);
@@ -2043,7 +2053,7 @@ dummy_func(
20432053
}
20442054
}
20452055
// We're praying that the compiler optimizes the flags manipuations.
2046-
super(COMPARE_OP_FLOAT_JUMP) = _COMPARE_OP_FLOAT + _JUMP_IF;
2056+
macro(COMPARE_OP_FLOAT_JUMP) = _COMPARE_OP_FLOAT + JOIN + _JUMP_IF;
20472057

20482058
// Similar to COMPARE_OP_FLOAT
20492059
op(_COMPARE_OP_INT, (unused/1, when_to_jump_mask/1, left, right -- jump: size_t)) {
@@ -2063,7 +2073,7 @@ dummy_func(
20632073
_Py_DECREF_SPECIALIZED(right, (destructor)PyObject_Free);
20642074
jump = sign_ish & when_to_jump_mask;
20652075
}
2066-
super(COMPARE_OP_INT_JUMP) = _COMPARE_OP_INT + _JUMP_IF;
2076+
macro(COMPARE_OP_INT_JUMP) = _COMPARE_OP_INT + JOIN + _JUMP_IF;
20672077

20682078
// Similar to COMPARE_OP_FLOAT, but for ==, != only
20692079
op(_COMPARE_OP_STR, (unused/1, invert/1, left, right -- jump: size_t)) {
@@ -2080,7 +2090,7 @@ dummy_func(
20802090
assert(invert == 0 || invert == 1);
20812091
jump = res ^ invert;
20822092
}
2083-
super(COMPARE_OP_STR_JUMP) = _COMPARE_OP_STR + _JUMP_IF;
2093+
macro(COMPARE_OP_STR_JUMP) = _COMPARE_OP_STR + JOIN + _JUMP_IF;
20842094

20852095
// stack effect: (__0 -- )
20862096
inst(IS_OP) {

Python/generated_cases.c.h

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

0 commit comments

Comments
 (0)