Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-115999: Don't take a reason in unspecialize #127030

Merged
merged 2 commits into from
Nov 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions Python/specialize.c
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ specialize(_Py_CODEUNIT *instr, uint8_t specialized_opcode)
}

static inline void
unspecialize(_Py_CODEUNIT *instr, int reason)
unspecialize(_Py_CODEUNIT *instr)
{
assert(!PyErr_Occurred());
uint8_t opcode = FT_ATOMIC_LOAD_UINT8_RELAXED(instr->op.code);
Expand All @@ -729,7 +729,6 @@ unspecialize(_Py_CODEUNIT *instr, int reason)
SPECIALIZATION_FAIL(generic_opcode, SPEC_FAIL_OTHER);
return;
}
SPECIALIZATION_FAIL(generic_opcode, reason);
_Py_BackoffCounter *counter = (_Py_BackoffCounter *)instr + 1;
_Py_BackoffCounter cur = load_counter(counter);
set_counter(counter, adaptive_counter_backoff(cur));
Expand Down Expand Up @@ -2243,6 +2242,7 @@ _Py_Specialize_CallKw(_PyStackRef callable_st, _Py_CODEUNIT *instr, int nargs)
}
}

#ifdef Py_STATS
static int
binary_op_fail_kind(int oparg, PyObject *lhs, PyObject *rhs)
{
Expand Down Expand Up @@ -2310,6 +2310,7 @@ binary_op_fail_kind(int oparg, PyObject *lhs, PyObject *rhs)
}
Py_UNREACHABLE();
}
#endif

void
_Py_Specialize_BinaryOp(_PyStackRef lhs_st, _PyStackRef rhs_st, _Py_CODEUNIT *instr,
Expand Down Expand Up @@ -2373,7 +2374,8 @@ _Py_Specialize_BinaryOp(_PyStackRef lhs_st, _PyStackRef rhs_st, _Py_CODEUNIT *in
}
break;
}
unspecialize(instr, binary_op_fail_kind(oparg, lhs, rhs));
SPECIALIZATION_FAIL(BINARY_OP, binary_op_fail_kind(oparg, lhs, rhs));
unspecialize(instr);
}


Expand Down Expand Up @@ -2760,6 +2762,7 @@ _Py_Specialize_ToBool(_PyStackRef value_o, _Py_CODEUNIT *instr)
cache->counter = adaptive_counter_cooldown();
}

#ifdef Py_STATS
static int
containsop_fail_kind(PyObject *value) {
if (PyUnicode_CheckExact(value)) {
Expand All @@ -2776,6 +2779,7 @@ containsop_fail_kind(PyObject *value) {
}
return SPEC_FAIL_OTHER;
}
#endif

void
_Py_Specialize_ContainsOp(_PyStackRef value_st, _Py_CODEUNIT *instr)
Expand All @@ -2793,7 +2797,8 @@ _Py_Specialize_ContainsOp(_PyStackRef value_st, _Py_CODEUNIT *instr)
return;
}

unspecialize(instr, containsop_fail_kind(value));
SPECIALIZATION_FAIL(CONTAINS_OP, containsop_fail_kind(value));
unspecialize(instr);
return;
}

Expand Down
Loading