Skip to content

Commit 6bc4c90

Browse files
committed
Address code review
1 parent c08f8b7 commit 6bc4c90

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

Python/specialize.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2665,6 +2665,7 @@ _Py_Specialize_Send(_PyStackRef receiver_st, _Py_CODEUNIT *instr)
26652665
cache->counter = adaptive_counter_cooldown();
26662666
}
26672667

2668+
#ifdef Py_STATS
26682669
static int
26692670
to_bool_fail_kind(PyObject *value)
26702671
{
@@ -2691,6 +2692,7 @@ to_bool_fail_kind(PyObject *value)
26912692
}
26922693
return SPEC_FAIL_OTHER;
26932694
}
2695+
#endif // Py_STATS
26942696

26952697
static int
26962698
check_type_always_true(PyTypeObject *ty)
@@ -2710,15 +2712,13 @@ check_type_always_true(PyTypeObject *ty)
27102712
return 0;
27112713
}
27122714

2713-
27142715
void
27152716
_Py_Specialize_ToBool(_PyStackRef value_o, _Py_CODEUNIT *instr)
27162717
{
27172718
assert(ENABLE_SPECIALIZATION_FT);
27182719
assert(_PyOpcode_Caches[TO_BOOL] == INLINE_CACHE_ENTRIES_TO_BOOL);
27192720
_PyToBoolCache *cache = (_PyToBoolCache *)(instr + 1);
27202721
PyObject *value = PyStackRef_AsPyObjectBorrow(value_o);
2721-
int reason;
27222722
uint8_t specialized_op;
27232723
if (PyBool_Check(value)) {
27242724
specialized_op = TO_BOOL_BOOL;
@@ -2744,11 +2744,11 @@ _Py_Specialize_ToBool(_PyStackRef value_o, _Py_CODEUNIT *instr)
27442744
unsigned int version = 0;
27452745
int err = _PyType_Validate(Py_TYPE(value), check_type_always_true, &version);
27462746
if (err < 0) {
2747-
reason = SPEC_FAIL_OUT_OF_VERSIONS;
2747+
SPECIALIZATION_FAIL(instr, SPEC_FAIL_OUT_OF_VERSIONS);
27482748
goto failure;
27492749
}
27502750
else if (err > 0) {
2751-
reason = err;
2751+
SPECIALIZATION_FAIL(instr, err);
27522752
goto failure;
27532753
}
27542754

@@ -2758,9 +2758,10 @@ _Py_Specialize_ToBool(_PyStackRef value_o, _Py_CODEUNIT *instr)
27582758
specialized_op = TO_BOOL_ALWAYS_TRUE;
27592759
goto success;
27602760
}
2761-
reason = to_bool_fail_kind(value);
2761+
2762+
SPECIALIZATION_FAIL(instr, to_bool_fail_kind(value));
27622763
failure:
2763-
unspecialize(instr, reason);
2764+
unspecialize(instr);
27642765
return;
27652766
success:
27662767
specialize(instr, specialized_op);

0 commit comments

Comments
 (0)