8000 gh-81057: Move More Globals to _PyRuntimeState by ericsnowcurrently · Pull Request #100092 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-81057: Move More Globals to _PyRuntimeState #100092

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

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Move p5s to _PyRuntimeState.
  • Loading branch information
ericsnowcurrently committed Dec 7, 2022
commit f7a7bc32c5f8220c8a7f2ea73dd27f3d8dfe9234
11 changes: 7 additions & 4 deletions Include/internal/pycore_dtoa.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Bigint {
#ifdef Py_USING_MEMORY_DEBUGGER

struct _dtoa_runtime_state {
int _not_used;
int _not_used;
};
#define _dtoa_runtime_state_INIT {0}

Expand All @@ -41,9 +41,12 @@ struct _dtoa_runtime_state {
((PRIVATE_MEM+sizeof(double)-1)/sizeof(double))

struct _dtoa_runtime_state {
struct Bigint *freelist[Bigint_Kmax+1];
double preallocated[Bigint_PREALLOC_SIZE];
double *preallocated_next;
/* p5s is a linked list of powers of 5 of the form 5**(2**i), i >= 2 */
// XXX This should be freed during runtime fini.
struct Bigint *p5s;
struct Bigint *freelist[Bigint_Kmax+1];
double preallocated[Bigint_PREALLOC_SIZE];
double *preallocated_next;
};
#define _dtoa_runtime_state_INIT(runtime) \
{ \
Expand Down
8 changes: 2 additions & 6 deletions Python/dtoa.c
Original file line number Diff line number Diff line change
Expand Up @@ -673,10 +673,6 @@ mult(Bigint *a, Bigint *b)

#ifndef Py_USING_MEMORY_DEBUGGER

/* p5s is a linked list of powers of 5 of the form 5**(2**i), i >= 2 */

static Bigint *p5s;

/* multiply the Bigint b by 5**k. Returns a pointer to the result, or NULL on
failure; if the returned pointer is distinct from b then the original
Bigint b will have been Bfree'd. Ignores the sign of b. */
Expand All @@ -696,15 +692,15 @@ pow5mult(Bigint *b, int k)

if (!(k >>= 2))
return b;
p5 = p5s;
p5 = _PyRuntime.dtoa.p5s;
if (!p5) {
/* first time */
p5 = i2b(625);
if (p5 == NULL) {
Bfree(b);
return NULL;
}
p5s = p5;
_PyRuntime.dtoa.p5s = p5;
p5->next = 0;
}
for(;;) {
Expand Down
1 change: 0 additions & 1 deletion Tools/c-analyzer/cpython/globals-to-fix.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,6 @@ Objects/sliceobject.c - _Py_EllipsisObject -
## effectively-const but initialized lazily

## idempotent
Python/dtoa.c - p5s -
Objects/obmalloc.c new_arena debug_stats -

## others
Expand Down
0