8000 Remove the use of _PyStaticObject_CheckRefcnt · python/cpython@bcdfa80 · GitHub
[go: up one dir, main page]

Skip to content

Commit bcdfa80

Browse files
Remove the use of _PyStaticObject_CheckRefcnt
1 parent 3a314f7 commit bcdfa80

File tree

6 files changed

+1
-1588
lines changed

6 files changed

+1
-1588
lines changed

Include/internal/pycore_global_objects_fini_generated.h

Lines changed: 0 additions & 1535 deletions
This file was deleted.

Makefile.pre.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1752,7 +1752,6 @@ PYTHON_HEADERS= \
17521752
$(srcdir)/Include/internal/pycore_getopt.h \
17531753
$(srcdir)/Include/internal/pycore_gil.h \
17541754
$(srcdir)/Include/internal/pycore_global_objects.h \
1755-
$(srcdir)/Include/internal/pycore_global_objects_fini_generated.h \
17561755
$(srcdir)/Include/internal/pycore_hamt.h \
17571756
$(srcdir)/Include/internal/pycore_hashtable.h \
17581757
$(srcdir)/Include/internal/pycore_import.h \

PCbuild/pythoncore.vcxproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,6 @@
229229
<ClInclude Include="..\Include\internal\pycore_getopt.h" />
230230
<ClInclude Include="..\Include\internal\pycore_gil.h" />
231231
<ClInclude Include="..\Include\internal\pycore_global_objects.h" />
232-
<ClInclude Include="..\Include\internal\pycore_global_objects_fini_generated.h" />
233232
<ClInclude Include="..\Include\internal\pycore_hamt.h" />
234233
<ClInclude Include="..\Include\internal\pycore_hashtable.h" />
235234
<ClInclude Include="..\Include\internal\pycore_import.h" />

PCbuild/pythoncore.vcxproj.filters

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -591,9 +591,6 @@
591591
<ClInclude Include="..\Include\internal\pycore_global_objects.h">
592592
<Filter>Include\internal</Filter>
593593
</ClInclude>
594-
<ClInclude Include="..\Include\internal\pycore_global_objects_fini_generated.h">
595-
<Filter>Include\internal</Filter>
596-
</ClInclude>
597594
<ClInclude Include="..\Include\internal\pycore_hamt.h">
598595
<Filter>Include\internal</Filter>
599596
</ClInclude>

Python/pylifecycle.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include "pycore_fileutils.h" // _Py_ResetForceASCII()
1010
#include "pycore_floatobject.h" // _PyFloat_InitTypes()
1111
#include "pycore_genobject.h" // _PyAsyncGen_Fini()
12-
#include "pycore_global_objects_fini_generated.h" // "_PyStaticObjects_CheckRefcnt()
1312
#include "pycore_import.h" // _PyImport_BootstrapImp()
1413
#include "pycore_initconfig.h" // _PyStatus_OK()
1514
#include "pycore_list.h" // _PyList_Fini()
@@ -1688,9 +1687,6 @@ finalize_interp_types(PyInterpreterState *interp)
16881687

16891688
_PyUnicode_Fini(interp);
16901689
_PyFloat_Fini(interp);
1691-
#ifdef Py_DEBUG
1692-
_PyStaticObjects_CheckRefcnt(interp);
1693-
#endif
16941690
}
16951691

16961692

Tools/build/generate_global_objects.py

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -294,35 +294,29 @@ def generate_runtime_init(identifiers, strings):
294294

295295
# Generate the file.
296296
with open_for_changes(filename, orig) as outfile:
297-
immortal_objects = []
298297
printer = Printer(outfile)
299298
printer.write(before)
300299
printer.write(START)
301300
with printer.block('#define _Py_small_ints_INIT', continuation=True):
302301
for i in range(-nsmallnegints, nsmallposints):
303302
printer.write(f'_PyLong_DIGIT_INIT({i}),')
304-
immortal_objects.append(f'(PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + {i}]')
305303
printer.write('')
306304
with printer.block('#define _Py_bytes_characters_INIT', continuation=True):
307305
for i in range(256):
308306
printer.write(f'_PyBytes_CHAR_INIT({i}),')
309-
immortal_objects.append(f'(PyObject *)&_Py_SINGLETON(bytes_characters)[{i}]')
310307
printer.write('')
311308
with printer.block('#define _Py_str_literals_INIT', continuation=True):
312309
for literal, name in sorted(strings.items(), key=lambda x: x[1]):
313310
printer.write(f'INIT_STR({name}, "{literal}"),')
314-
immortal_objects.append(f'(PyObject *)&_Py_STR({name})')
315311
printer.write('')
316312
with printer.block('#define _Py_str_identifiers_INIT', continuation=True):
317313
for name in sorted(identifiers):
318314
assert name.isidentifier(), name
319315
printer.write(f'INIT_ID({name}),')
320-
immortal_objects.append(f'(PyObject *)&_Py_ID({name})')
321316
printer.write('')
322317
with printer.block('#define _Py_str_ascii_INIT', continuation=True):
323318
for i in range(128):
324319
printer.write(f'_PyASCIIObject_INIT("\\x{i:02x}"),')
325-
immortal_objects.append(f'(PyObject *)&_Py_SINGLETON(strings).ascii[{i}]')
326320
printer.write('')
327321
with printer.block('#define _Py_str_latin1_INIT', continuation=True):
328322
for i in range(128, 256):
@@ -331,10 +325,8 @@ def generate_runtime_init(identifiers, strings):
331325
utf8.append(f"\\x{c:02x}")
332326
utf8.append('"')
333327
printer.write(f'_PyUnicode_LATIN1_INIT("\\x{i:02x}", {"".join(utf8)}),')
334-
immortal_objects.append(f'(PyObject *)&_Py_SINGLETON(strings).latin1[{i} - 128]')
335328
printer.write(END)
336329
printer.write(after)
337-
return immortal_objects
338330

339331

340332
def generate_static_strings_initializer(identifiers, strings):
@@ -369,40 +361,6 @@ def generate_static_strings_initializer(identifiers, strings):
369361
printer.write(after)
370362

371363

372-
def generate_global_object_finalizers(generated_immortal_objects):
373-
# Target the runtime initializer.
374-
filename = os.path.join(INTERNAL, 'pycore_global_objects_fini_generated.h')
375-
376-
# Read the non-generated part of the file.
377-
with open(filename) as infile:
378-
orig = infile.read()
379-
lines = iter(orig.rstrip().splitlines())
380-
before = '\n'.join(iter_to_marker(lines, START))
381-
for _ in iter_to_marker(lines, END):
382-
pass
383-
after = '\n'.join(lines)
384-
385-
# Generate the file.
386-
with open_for_changes(filename, orig) as outfile:
387-
printer = Printer(outfile)
388-
printer.write(before)
389-
printer.write(START)
390-
printer.write('#ifdef Py_DEBUG')
391-
printer.write("static inline void")
392-
with printer.block(
393-
"_PyStaticObjects_CheckRefcnt(PyInterpreterState *interp)"):
394-
printer.write('/* generated runtime-global */')
395-
printer.write('// (see pycore_runtime_init_generated.h)')
396-
for ref in generated_immortal_objects:
397-
printer.write(f'_PyStaticObject_CheckRefcnt({ref});')
398-
printer.write('/* non-generated */')
399-
for ref in NON_GENERATED_IMMORTAL_OBJECTS:
400-
printer.write(f'_PyStaticObject_CheckRefcnt({ref});')
401-
printer.write('#endif // Py_DEBUG')
402-
printer.write(END)
403-
printer.write(after)
404-
405-
406364
def get_identifiers_and_strings() -> 'tuple[set[str], dict[str, str]]':
407365
identifiers = set(IDENTIFIERS)
408366
strings = {}
@@ -425,9 +383,8 @@ def main() -> None:
425383
identifiers, strings = get_identifiers_and_strings()
426384

427385
generate_global_strings(identifiers, strings)
428-
generated_immortal_objects = generate_runtime_init(identifiers, strings)
386+
generate_runtime_init(identifiers, strings)
429387
generate_static_strings_initializer(identifiers, strings)
430-
generate_global_object_finalizers(generated_immortal_objects)
431388

432389

433390
if __name__ == '__main__':

0 commit comments

Comments
 (0)
0