Skip to content

Commit c7e53fb

Browse files
committed
Refactor JIT reference remove unique
1 parent fb1d227 commit c7e53fb

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

Include/internal/pycore_optimizer.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,15 @@ PyJitRef_StripReferenceInfo(JitOptRef ref)
269269
return PyJitRef_Wrap(PyJitRef_Unwrap(ref));
270270
}
271271

272+
static inline JitOptRef
273+
PyJitRef_RemoveUnique(JitOptRef ref)
274+
{
275+
if (PyJitRef_IsUnique(ref)) {
276+
ref = PyJitRef_StripReferenceInfo(ref);
277+
}
278+
return ref;
279+
}
280+
272281
static inline JitOptRef
273282
PyJitRef_Borrow(JitOptRef ref)
274283
{

Python/optimizer_bytecodes.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,29 +92,24 @@ dummy_func(void) {
9292
if (sym_is_null(value)) {
9393
ctx->done = true;
9494
}
95-
if (PyJitRef_IsUnique(value)) {
96-
value = PyJitRef_StripReferenceInfo(value);
97-
}
95+
value = PyJitRef_RemoveUnique(value);
9896
}
9997

10098
op(_LOAD_FAST, (-- value)) {
10199
value = GETLOCAL(oparg);
102-
if (PyJitRef_IsUnique(value)) {
103-
value = PyJitRef_StripReferenceInfo(value);
104-
}
100+
value = PyJitRef_RemoveUnique(value);
105101
}
106102

107103
op(_LOAD_FAST_BORROW, (-- value)) {
108104
value = PyJitRef_Borrow(GETLOCAL(oparg));
105+
assert(!PyJitRef_IsUnique(value));
109106
}
110107

111108
op(_LOAD_FAST_AND_CLEAR, (-- value)) {
112109
value = GETLOCAL(oparg);
113110
JitOptRef temp = sym_new_null(ctx);
114111
GETLOCAL(oparg) = temp;
115-
if (PyJitRef_IsUnique(value)) {
116-
value = PyJitRef_StripReferenceInfo(value);
117-
}
112+
value = PyJitRef_RemoveUnique(value);
118113
}
119114

120115
op(_STORE_ATTR_INSTANCE_VALUE, (offset/1, value, owner -- o)) {
@@ -130,6 +125,7 @@ dummy_func(void) {
130125
op(_SWAP_FAST, (value -- trash)) {
131126
JitOptRef tmp = GETLOCAL(oparg);
132127
GETLOCAL(oparg) = value;
128+
// GETLOCAL(oparg) = PyJitRef_RemoveUnique(value);
133129
trash = tmp;
134130
}
135131

@@ -696,7 +692,7 @@ dummy_func(void) {
696692

697693
op(_COPY, (bottom, unused[oparg-1] -- bottom, unused[oparg-1], top)) {
698694
assert(oparg > 0);
699-
bottom = PyJitRef_IsUnique(bottom) ? PyJitRef_StripReferenceInfo(bottom) : bottom;
695+
bottom = PyJitRef_RemoveUnique(bottom);
700696
top = bottom;
701697
}
702698

Python/optimizer_cases.c.h

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

0 commit comments

Comments
 (0)