Skip to content
Merged
2,218 changes: 1,105 additions & 1,113 deletions Include/internal/pycore_uop_ids.h

Large diffs are not rendered by default.

38 changes: 0 additions & 38 deletions Include/internal/pycore_uop_metadata.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Lib/test/test_capi/test_opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -3211,7 +3211,8 @@ def f(n):
uops = get_opnames(ex)
self.assertNotIn("_LOAD_ATTR_METHOD_NO_DICT", uops)
self.assertNotIn("_INSERT_1_LOAD_CONST_INLINE", uops)
self.assertIn("_INSERT_1_LOAD_CONST_INLINE_BORROW", uops)
self.assertNotIn("_INSERT_1_LOAD_CONST_INLINE_BORROW", uops)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove this line and the one above.
There is no point in asserting that a non-existent uop isn't present.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, bit of a brainfart when I wrote that.

self.assertIn("_LOAD_CONST_INLINE_BORROW", uops)

def test_store_fast_refcount_elimination(self):
def foo(x):
Expand Down
12 changes: 0 additions & 12 deletions Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -5946,18 +5946,6 @@ dummy_func(
value = PyStackRef_FromPyObjectBorrow(ptr);
}

tier2 op(_INSERT_1_LOAD_CONST_INLINE, (ptr/4, left -- res, l)) {
res = PyStackRef_FromPyObjectNew(ptr);
l = left;
INPUTS_DEAD();
}

tier2 op(_INSERT_1_LOAD_CONST_INLINE_BORROW, (ptr/4, left -- res, l)) {
res = PyStackRef_FromPyObjectBorrow(ptr);
l = left;
INPUTS_DEAD();
}

tier2 op(_INSERT_2_LOAD_CONST_INLINE_BORROW, (ptr/4, left, right -- res, l, r)) {
res = PyStackRef_FromPyObjectBorrow(ptr);
l = left;
Expand Down
114 changes: 0 additions & 114 deletions Python/executor_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 16 additions & 15 deletions Python/optimizer_analysis.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,7 @@ type_watcher_callback(PyTypeObject* type)
}

static PyObject *
convert_global_to_const(_PyUOpInstruction *inst, PyObject *obj,
uint16_t immortal_op, uint16_t mortal_op)
convert_global_to_const(_PyUOpInstruction *inst, PyObject *obj)
{
assert(inst->opcode == _LOAD_GLOBAL_MODULE || inst->opcode == _LOAD_GLOBAL_BUILTINS || inst->opcode == _LOAD_ATTR_MODULE);
assert(PyDict_CheckExact(obj));
Expand All @@ -178,15 +177,9 @@ convert_global_to_const(_PyUOpInstruction *inst, PyObject *obj,
return NULL;
}
if (_Py_IsImmortal(res)) {
inst->opcode = immortal_op;
inst->opcode = _LOAD_CONST_INLINE_BORROW;
} else {
inst->opcode = mortal_op;
}
if (inst->opcode == _LOAD_CONST_INLINE_BORROW || inst->opcode == _LOAD_CONST_INLINE) {
if (inst->oparg & 1) {
assert(inst[1].opcode == _PUSH_NULL_CONDITIONAL);
assert(inst[1].oparg & 1);
}
inst->opcode = _LOAD_CONST_INLINE;
}
inst->operand0 = (uint64_t)res;
return res;
Expand Down Expand Up @@ -326,7 +319,7 @@ optimize_to_bool(
JitOptContext *ctx,
JitOptRef value,
JitOptRef *result_ptr,
uint16_t prefix, uint16_t load_op)
uint16_t prefix, uint16_t load_op, uint16_t suffix)
{
if (sym_matches_type(value, &PyBool_Type)) {
ADD_OP(_NOP, 0, 0);
Expand All @@ -340,6 +333,9 @@ optimize_to_bool(
ADD_OP(prefix, 0, 0);
}
ADD_OP(load_op, 0, (uintptr_t)load);
if (suffix != _NOP) {
ADD_OP(suffix, 2, 0);
}
*result_ptr = sym_new_const(ctx, load);
return 1;
}
Expand Down Expand Up @@ -386,7 +382,7 @@ eliminate_pop_guard(_PyUOpInstruction *this_instr, JitOptContext *ctx, bool exit
static JitOptRef
lookup_attr(JitOptContext *ctx, _PyBloomFilter *dependencies, _PyUOpInstruction *this_instr,
PyTypeObject *type, PyObject *name,
uint16_t prefix, uint16_t immortal_op, uint16_t mortal_op)
uint16_t prefix, uint16_t immortal_op, uint16_t mortal_op, uint16_t suffix)
{
// The cached value may be dead, so we need to do the lookup again... :(
if (type && PyType_Check(type)) {
Expand All @@ -397,6 +393,9 @@ lookup_attr(JitOptContext *ctx, _PyBloomFilter *dependencies, _PyUOpInstruction
ADD_OP(prefix, 0, 0);
}
ADD_OP(immortal ? immortal_op : mortal_op, 0, (uintptr_t)lookup);
if (suffix != _NOP) {
ADD_OP(suffix, 2, 0);
}
PyType_Watch(TYPE_WATCHER_ID, (PyObject *)type);
_Py_BloomFilter_Add(dependencies, type);
return sym_new_const(ctx, lookup);
Expand All @@ -411,7 +410,8 @@ static JitOptRef
lookup_super_attr(JitOptContext *ctx, _PyBloomFilter *dependencies,
_PyUOpInstruction *this_instr,
PyTypeObject *su_type, PyTypeObject *obj_type,
PyObject *name, uint16_t immortal, uint16_t mortal)
PyObject *name,
uint16_t immortal, uint16_t mortal, uint16_t suffix)
{
if (su_type == NULL || obj_type == NULL) {
return sym_new_not_null(ctx);
Expand Down Expand Up @@ -439,6 +439,9 @@ lookup_super_attr(JitOptContext *ctx, _PyBloomFilter *dependencies,
ADD_OP(_POP_TOP, 0, 0);
ADD_OP(_POP_TOP, 0, 0);
ADD_OP(opcode, 0, (uintptr_t)lookup);
if (suffix != _NOP) {
ADD_OP(suffix, 2, 0);
}
PyType_Watch(TYPE_WATCHER_ID, (PyObject *)su_type);
_Py_BloomFilter_Add(dependencies, su_type);
PyType_Watch(TYPE_WATCHER_ID, (PyObject *)obj_type);
Expand Down Expand Up @@ -647,8 +650,6 @@ const uint16_t op_without_push[MAX_UOP_ID + 1] = {
[_COPY] = _NOP,
[_LOAD_CONST_INLINE] = _NOP,
[_LOAD_CONST_INLINE_BORROW] = _NOP,
[_INSERT_1_LOAD_CONST_INLINE] = _POP_TOP_LOAD_CONST_INLINE,
[_INSERT_1_LOAD_CONST_INLINE_BORROW] = _POP_TOP_LOAD_CONST_INLINE_BORROW,
[_LOAD_FAST] = _NOP,
[_LOAD_FAST_BORROW] = _NOP,
[_LOAD_SMALL_INT] = _NOP,
Expand Down
Loading
Loading