Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
2,220 changes: 1,106 additions & 1,114 deletions 2,220 Include/internal/pycore_uop_ids.h

Large diffs are not rendered by default.

38 changes: 0 additions & 38 deletions 38 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: 1 addition & 2 deletions 3 Lib/test/test_capi/test_opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -3210,8 +3210,7 @@ def f(n):
self.assertEqual(res, TIER2_THRESHOLD)
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.assertIn("_LOAD_CONST_INLINE_BORROW", uops)

def test_store_fast_refcount_elimination(self):
def foo(x):
Expand Down
12 changes: 0 additions & 12 deletions 12 Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -5951,18 +5951,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 114 Python/executor_cases.c.h

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

36 changes: 19 additions & 17 deletions 36 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 suffix)
{
if (sym_matches_type(value, &PyBool_Type)) {
ADD_OP(_NOP, 0, 0);
Expand All @@ -339,7 +332,10 @@ optimize_to_bool(
if (prefix != _NOP) {
ADD_OP(prefix, 0, 0);
}
ADD_OP(load_op, 0, (uintptr_t)load);
ADD_OP(_LOAD_CONST_INLINE_BORROW, 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 suffix)
{
// The cached value may be dead, so we need to do the lookup again... :(
if (type && PyType_Check(type)) {
Expand All @@ -396,7 +392,11 @@ lookup_attr(JitOptContext *ctx, _PyBloomFilter *dependencies, _PyUOpInstruction
if (prefix != _NOP) {
ADD_OP(prefix, 0, 0);
}
ADD_OP(immortal ? immortal_op : mortal_op, 0, (uintptr_t)lookup);
ADD_OP(immortal ? _LOAD_CONST_INLINE_BORROW : _LOAD_CONST_INLINE,
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 +411,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 +440,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 +651,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
Morty Proxy This is a proxified and sanitized view of the page, visit original site.