FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-135379: Move PyLong_CheckCompact to private header by Fidget-Spinner · Pull Request #135707 · python/cpython · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .c  (2) .h  (4) .py  (1) All 3 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
6 changes: 0 additions & 6 deletions Include/cpython/longintrepr.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,6 @@ _PyLong_IsCompact(const PyLongObject* op) {
return op->long_value.lv_tag < (2 << _PyLong_NON_SIZE_BITS);
}

static inline int
PyLong_CheckCompact(PyObject *op)
{
return PyLong_CheckExact(op) && _PyLong_IsCompact((const PyLongObject *)op);
}

#define PyUnstable_Long_IsCompact _PyLong_IsCompact

static inline Py_ssize_t
Expand Down
6 changes: 6 additions & 0 deletions Include/internal/pycore_long.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,12 @@ _PyLong_FlipSign(PyLongObject *op) {
#define _PyLong_FALSE_TAG TAG_FROM_SIGN_AND_SIZE(0, 0)
#define _PyLong_TRUE_TAG TAG_FROM_SIGN_AND_SIZE(1, 1)

static inline int
_PyLong_CheckExactAndCompact(PyObject *op)
{
return PyLong_CheckExact(op) && _PyLong_IsCompact((const PyLongObject *)op);
}

#ifdef __cplusplus
}
#endif
Expand Down
4 changes: 2 additions & 2 deletions Python/bytecodes.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -569,12 +569,12 @@ dummy_func(

op(_GUARD_NOS_INT, (left, unused -- left, unused)) {
PyObject *left_o = PyStackRef_AsPyObjectBorrow(left);
EXIT_IF(!PyLong_CheckCompact(left_o));
EXIT_IF(!_PyLong_CheckExactAndCompact(left_o));
}

op(_GUARD_TOS_INT, (value -- value)) {
PyObject *value_o = PyStackRef_AsPyObjectBorrow(value);
EXIT_IF(!PyLong_CheckCompact(value_o));
EXIT_IF(!_PyLong_CheckExactAndCompact(value_o));
}

op(_GUARD_NOS_OVERFLOWED, (left, unused -- left, unused)) {
Expand Down
4 changes: 2 additions & 2 deletions Python/executor_cases.c.h

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

24 changes: 12 additions & 12 deletions Python/generated_cases.c.h

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

6 changes: 3 additions & 3 deletions Python/optimizer_symbols.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ _Py_uop_sym_set_const(JitOptContext *ctx, JitOptRef ref, PyObject *const_val)
make_const(sym, const_val);
return;
case JIT_SYM_COMPACT_INT:
if (PyLong_CheckCompact(const_val)) {
if (_PyLong_CheckExactAndCompact(const_val)) {
make_const(sym, const_val);
}
else {
Expand Down Expand Up @@ -679,7 +679,7 @@ _Py_uop_sym_is_compact_int(JitOptRef ref)
{
JitOptSymbol *sym = PyJitRef_Unwrap(ref);
if (sym->tag == JIT_SYM_KNOWN_VALUE_TAG) {
return (bool)PyLong_CheckCompact(sym->value.value);
return (bool)_PyLong_CheckExactAndCompact(sym->value.value);
}
return sym->tag == JIT_SYM_COMPACT_INT;
}
Expand Down Expand Up @@ -716,7 +716,7 @@ _Py_uop_sym_set_compact_int(JitOptContext *ctx, JitOptRef ref)
}
return;
case JIT_SYM_KNOWN_VALUE_TAG:
if (!PyLong_CheckCompact(sym->value.value)) {
if (!_PyLong_CheckExactAndCompact(sym->value.value)) {
Py_CLEAR(sym->value.value);
sym_set_bottom(ctx, sym);
}
Expand Down
2 changes: 1 addition & 1 deletion Tools/cases_generator/analyzer.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ def has_error_without_pop(op: parser.CodeDef) -> bool:
"PyStackRef_IsValid",
"PyStackRef_Wrap",
"PyStackRef_Unwrap",
"PyLong_CheckCompact",
"_PyLong_CheckExactAndCompact",
)


Expand Down

Back | FazBrowse Home | New Git URL