Skip to content

Commit 0243260

Browse files
gh-135379: Move PyLong_CheckCompact to private header and rename it (GH-135707)
1 parent ff639af commit 0243260

File tree

7 files changed

+26
-26
lines changed

7 files changed

+26
-26
lines changed

Include/cpython/longintrepr.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,6 @@ _PyLong_IsCompact(const PyLongObject* op) {
124124
return op->long_value.lv_tag < (2 << _PyLong_NON_SIZE_BITS);
125125
}
126126

127-
static inline int
128-
PyLong_CheckCompact(PyObject *op)
129-
{
130-
return PyLong_CheckExact(op) && _PyLong_IsCompact((const PyLongObject *)op);
131-
}
132-
133127
#define PyUnstable_Long_IsCompact _PyLong_IsCompact
134128

135129
static inline Py_ssize_t

Include/internal/pycore_long.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,12 @@ _PyLong_FlipSign(PyLongObject *op) {
312312
#define _PyLong_FALSE_TAG TAG_FROM_SIGN_AND_SIZE(0, 0)
313313
#define _PyLong_TRUE_TAG TAG_FROM_SIGN_AND_SIZE(1, 1)
314314

315+
static inline int
316+
_PyLong_CheckExactAndCompact(PyObject *op)
317+
{
318+
return PyLong_CheckExact(op) && _PyLong_IsCompact((const PyLongObject *)op);
319+
}
320+
315321
#ifdef __cplusplus
316322
}
317323
#endif

Python/bytecodes.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -569,12 +569,12 @@ dummy_func(
569569

570570
op(_GUARD_NOS_INT, (left, unused -- left, unused)) {
571571
PyObject *left_o = PyStackRef_AsPyObjectBorrow(left);
572-
EXIT_IF(!PyLong_CheckCompact(left_o));
572+
EXIT_IF(!_PyLong_CheckExactAndCompact(left_o));
573573
}
574574

575575
op(_GUARD_TOS_INT, (value -- value)) {
576576
PyObject *value_o = PyStackRef_AsPyObjectBorrow(value);
577-
EXIT_IF(!PyLong_CheckCompact(value_o));
577+
EXIT_IF(!_PyLong_CheckExactAndCompact(value_o));
578578
}
579579

580580
op(_GUARD_NOS_OVERFLOWED, (left, unused -- left, unused)) {

Python/executor_cases.c.h

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

Python/generated_cases.c.h

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

Python/optimizer_symbols.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ _Py_uop_sym_set_const(JitOptContext *ctx, JitOptRef ref, PyObject *const_val)
386386
make_const(sym, const_val);
387387
return;
388388
case JIT_SYM_COMPACT_INT:
389-
if (PyLong_CheckCompact(const_val)) {
389+
if (_PyLong_CheckExactAndCompact(const_val)) {
390390
make_const(sym, const_val);
391391
}
392392
else {
@@ -679,7 +679,7 @@ _Py_uop_sym_is_compact_int(JitOptRef ref)
679679
{
680680
JitOptSymbol *sym = PyJitRef_Unwrap(ref);
681681
if (sym->tag == JIT_SYM_KNOWN_VALUE_TAG) {
682-
return (bool)PyLong_CheckCompact(sym->value.value);
682+
return (bool)_PyLong_CheckExactAndCompact(sym->value.value);
683683
}
684684
return sym->tag == JIT_SYM_COMPACT_INT;
685685
}
@@ -716,7 +716,7 @@ _Py_uop_sym_set_compact_int(JitOptContext *ctx, JitOptRef ref)
716716
}
717717
return;
718718
case JIT_SYM_KNOWN_VALUE_TAG:
719-
if (!PyLong_CheckCompact(sym->value.value)) {
719+
if (!_PyLong_CheckExactAndCompact(sym->value.value)) {
720720
Py_CLEAR(sym->value.value);
721721
sym_set_bottom(ctx, sym);
722722
}

Tools/cases_generator/analyzer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ def has_error_without_pop(op: parser.CodeDef) -> bool:
687687
"PyStackRef_IsValid",
688688
"PyStackRef_Wrap",
689689
"PyStackRef_Unwrap",
690-
"PyLong_CheckCompact",
690+
"_PyLong_CheckExactAndCompact",
691691
)
692692

693693

0 commit comments

Comments
 (0)