Skip to content
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

bpo-30860: Consolidate stateful runtime globals. #3397

Merged
merged 94 commits into from
Sep 8, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
d4799a7
Add the check-c-globals script.
ericsnowcurrently May 31, 2017
9abaa7b
Clean up the check-c-globals script.
ericsnowcurrently Jun 1, 2017
aa3a7db
Update the list of "runtime" globals.
ericsnowcurrently Jun 1, 2017
c7c86c7
Handle builtin modules via a pattern check.
ericsnowcurrently Jun 1, 2017
6b991d9
Rely on a pattern check for static type-related vars.
ericsnowcurrently Jun 1, 2017
8a8763d
Handle most exceptions and warnings via pattern checks.
ericsnowcurrently Jun 1, 2017
c8b5b43
Clean up _is_type_var().
ericsnowcurrently Jun 1, 2017
72e1d9b
Add runtime vars for builtin modules.
ericsnowcurrently Jun 1, 2017
f51e788
Ignore trailing comments in globals-runtime.txt.
ericsnowcurrently Jun 1, 2017
9836224
Add runtime vars for builtin types.
ericsnowcurrently Jun 1, 2017
9dab7a7
Add runtime vars for compiler.
ericsnowcurrently Jun 1, 2017
7e1cad8
Add runtime vars for interpreter.
ericsnowcurrently Jun 1, 2017
7b8279a
Add runtime vars for import.
ericsnowcurrently Jun 1, 2017
c067341
Add runtime vars for startup.
ericsnowcurrently Jun 1, 2017
794fb24
Add other runtime vars.
ericsnowcurrently Jun 1, 2017
942dbfa
Separate the 3 runtime global "scopes".
ericsnowcurrently Jun 1, 2017
7a2c42a
Do not worry about a possible race.
ericsnowcurrently Jun 1, 2017
2e6526b
Narrow down the globals lists.
ericsnowcurrently Jun 3, 2017
39296ea
runtime -> core.
ericsnowcurrently Jun 3, 2017
103205d
Hold up more globals.
ericsnowcurrently Jun 7, 2017
ea3a2cf
Add _PyRuntimeState and _PyRuntime.
ericsnowcurrently Jun 19, 2017
a112d71
Pull pylifecycle globals into _PyRuntimeState.
ericsnowcurrently Jun 19, 2017
99a8aa6
Pull mem globals into _PyRuntimeState.
ericsnowcurrently Jun 20, 2017
4e6d1d9
Pull warnings globals into _PyRuntimeState.
ericsnowcurrently Jun 21, 2017
10f7601
Move nb_threads into PyInterpreterState.
ericsnowcurrently Jun 21, 2017
d82561c
Pull ceval globals into _PyRuntimeState.
ericsnowcurrently Jun 21, 2017
06b8fc8
Pull gil into _PyRuntimeState.
ericsnowcurrently Jun 21, 2017
960e1b0
Move check_interval, warnoptions, and xoptions into PyInterpreterState.
ericsnowcurrently Jun 21, 2017
8fb060f
Move pythread_stacksize into PyInterpreterState.
ericsnowcurrently Jun 21, 2017
fc8d4fd
Pull the rest of the GIL globals into _PyRuntime.
ericsnowcurrently Jun 28, 2017
1189e2e
Factor out _gil_globals and _gilstate_globals structs.
ericsnowcurrently Jun 28, 2017
edbaad5
Factor out globals structs.
ericsnowcurrently Jun 28, 2017
cec09bf
Factor out a _pending_calls struct.
ericsnowcurrently Jun 29, 2017
4dc9692
Update globals list.
ericsnowcurrently Jun 29, 2017
c438b8f
Ignore a few more globals.
ericsnowcurrently Jun 30, 2017
d0dd810
Only track one list of globals.
ericsnowcurrently Jul 3, 2017
d8e5c21
Mark _Py_HashSecret* as global.
ericsnowcurrently Jul 3, 2017
1e48db2
_Py_TracingPossible -> _PyRuntime.ceval.tracing_possible.
ericsnowcurrently Jul 3, 2017
6a1f65f
Re-structure globals.txt.
ericsnowcurrently Jul 3, 2017
f41754f
Ignore the symtable globals.
ericsnowcurrently Jul 3, 2017
cb29c94
_Py_CoreInitialized -> _PyRuntime.core_initialized.
ericsnowcurrently Jul 3, 2017
e1f1c4c
Pull in the list of interpreters.
ericsnowcurrently Jul 3, 2017
4befb69
Clean up globals.txt.
ericsnowcurrently Jul 3, 2017
ed94b6a
Ignore the import lock.
ericsnowcurrently Jul 3, 2017
cbccbf2
Fix func header formatting.
ericsnowcurrently Jul 4, 2017
41ce494
Move "globals" structs to the appropriate header files.
ericsnowcurrently Jul 5, 2017
6ef10c9
Factor out pymalloc.h.
ericsnowcurrently Jul 4, 2017
a8263c3
Pull usedpools into _PyRuntime.
ericsnowcurrently Jul 5, 2017
b4482c7
Drop a dead comment.
ericsnowcurrently Jul 5, 2017
ed25669
Pull in gcmodule.c.
ericsnowcurrently Jul 5, 2017
f6e4b9c
Clean up globals.txt.
ericsnowcurrently Jul 5, 2017
0817b0e
Pass pointers to the *_Initialize() funcs.
ericsnowcurrently Jul 5, 2017
4eea51e
Clean up line length.
ericsnowcurrently Jul 6, 2017
40292bd
Add a filename CLI arg.
ericsnowcurrently Jul 6, 2017
16b0b73
Move check-c-globals into Tools/c-globals.
ericsnowcurrently Jul 6, 2017
1b137d1
Add a README.
ericsnowcurrently Jul 6, 2017
5cbb8ed
Fix typo in header guard.
ericsnowcurrently Jul 6, 2017
46e4063
Ignore _TARGET_LOCALES.
ericsnowcurrently Jul 6, 2017
1074895
Factor out _PyRuntimeState_Initialize().
ericsnowcurrently Jul 7, 2017
9dbb1d1
Only initialize _PyRuntime once.
ericsnowcurrently Jul 7, 2017
c1d73b4
Do not assume that there is an active threadstate.
ericsnowcurrently Jul 8, 2017
18b5b18
Always use the global allocators.
ericsnowcurrently Jul 8, 2017
29d21bd
Factor out _allocators_globals.
ericsnowcurrently Jul 8, 2017
3eb1fa9
Touch up the c-globals README.
ericsnowcurrently Jul 9, 2017
3063db1
globals.txt -> ignored-globals.txt.
ericsnowcurrently Jul 9, 2017
bc3b84b
Move runtime state into "internal" header files.
ericsnowcurrently Jul 10, 2017
e411f86
globals -> state
ericsnowcurrently Jul 11, 2017
330552f
Define _PyRuntime for pgen.
ericsnowcurrently Jul 11, 2017
a18d6f5
Drop a superfluous include.
ericsnowcurrently Jul 11, 2017
2434213
Add the new header files to the Windows config.
ericsnowcurrently Jul 11, 2017
8e9deb7
Move _PyInterpreterState_Init() to the internal header file.
ericsnowcurrently Jul 12, 2017
671eeef
Add _PyRuntimeState_Fini().
ericsnowcurrently Jul 12, 2017
aed8c9a
Manage the interpreters mutex globally.
ericsnowcurrently Jul 12, 2017
bdb5ced
Fix Windows build.
ericsnowcurrently Jul 14, 2017
aaab3a9
"uint" -> unsigned int.
ericsnowcurrently Jul 17, 2017
1903528
Set up allocators in _Py_InitializeCore().
ericsnowcurrently Jul 17, 2017
be04984
Add a NEWS entry.
ericsnowcurrently Sep 5, 2017
5d3b366
Fix the news entry.
ericsnowcurrently Sep 5, 2017
8e6fcc0
Drop the underscore prefix from include file names.
ericsnowcurrently Sep 6, 2017
91d239c
Move _PyRuntime into its own header file.
ericsnowcurrently Sep 6, 2017
b223e85
Move _PyRuntime back to internal/pystate.h.
ericsnowcurrently Sep 6, 2017
3d0b18b
Include internal/pystate.h directly in source files.
ericsnowcurrently Sep 6, 2017
66c0114
Fix pgen.
ericsnowcurrently Sep 6, 2017
bb27081
Fix empty initializer lists.
ericsnowcurrently Sep 6, 2017
4797ce5
Fix includes.
ericsnowcurrently Sep 6, 2017
6592065
Drop an insignificant comment.
ericsnowcurrently Sep 7, 2017
69fe645
Restore _Py_CheckRecursionLimit under the stable ABI.
ericsnowcurrently Sep 7, 2017
6628e85
_Py_IS_FINALIZING() -> _Py_IsFinalizing().
ericsnowcurrently Sep 7, 2017
0f97249
Fix modules on Windows.
ericsnowcurrently Sep 7, 2017
1c85e28
Drop WITH_THREAD.
ericsnowcurrently Sep 7, 2017
2b28324
Undef Py_BUILD_CORE in core extension modules.
ericsnowcurrently Sep 7, 2017
b1ca420
Fix a syntax error in a Windows-only file.
ericsnowcurrently Sep 7, 2017
72d7251
Be careful about Yield on Windows.
ericsnowcurrently Sep 7, 2017
f1f10ff
Fix includes in builtin extensions on Windows.
ericsnowcurrently Sep 8, 2017
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
Prev Previous commit
Next Next commit
Add runtime vars for compiler.
  • Loading branch information
ericsnowcurrently committed Sep 7, 2017
commit 9dab7a7d061ae2087aece0b47c7453301fcb2a7f
11 changes: 11 additions & 0 deletions check-c-globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ def _is_runtime_var(name):
return True
if _is_exception(name):
return True
if _is_compiler(name):
return True
return name in RUNTIME_VARS


Expand Down Expand Up @@ -127,6 +129,15 @@ def _is_exception(name):
return name.endswith(('Error', 'Warning'))


def _is_compiler(name):
return (
# Python/Pythyon-ast.c
name.endswith('_type') or
name.endswith('_singleton') or
name.endswith('_attributes')
)


class Var(namedtuple('Var', 'name kind runtime capi filename')):

@classmethod
Expand Down
283 changes: 63 additions & 220 deletions globals-runtime.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,50 +5,6 @@
# See check-c-globals.py.


#######################################
# static types

# Handled via _is_type_var() in check-c-globals.py.


#######################################
# static errors (Objects/exceptions.c)

# Handled via _is_exception() in check-c-globals.py, with some special
# cases here.

PyExc_BaseException
PyExc_Exception
PyExc_GeneratorExit
PyExc_KeyboardInterrupt
PyExc_StopAsyncIteration
PyExc_StopIteration
PyExc_SystemExit

_PyExc_BaseException
_PyExc_Exception
_PyExc_GeneratorExit
_PyExc_KeyboardInterrupt
_PyExc_StopAsyncIteration
_PyExc_StopIteration
_PyExc_SystemExit


#######################################
# singletons

# Include/boolobject.h
_Py_FalseStruct
_Py_TrueStruct

# Include/object.h
_Py_NoneStruct
_Py_NotImplementedStruct

# Include/sliceobject.h
_Py_EllipsisObject


#######################################
# builtin modules

Expand Down Expand Up @@ -181,6 +137,9 @@ zip_searchorder
#######################################
# builtin types

# Generic names for static types handled via _is_type_var()
# in check-c-globals.py.

# Objects/boolobject.c
false_str
true_str
Expand Down Expand Up @@ -307,164 +266,68 @@ bloom_linebreak


#######################################
# ast
# singletons

# Include/boolobject.h
_Py_FalseStruct
_Py_TrueStruct

# Include/object.h
_Py_NoneStruct
_Py_NotImplementedStruct

# Include/sliceobject.h
_Py_EllipsisObject


#######################################
# exceptions/warnings

# Handled via _is_exception() in check-c-globals.py, with some special
# cases here.

# Objects/exceptions.c
PyExc_BaseException
PyExc_Exception
PyExc_GeneratorExit
PyExc_KeyboardInterrupt
PyExc_StopAsyncIteration
PyExc_StopIteration
PyExc_SystemExit
_PyExc_BaseException
_PyExc_Exception
_PyExc_GeneratorExit
_PyExc_KeyboardInterrupt
_PyExc_StopAsyncIteration
_PyExc_StopIteration
_PyExc_SystemExit


#######################################
# compiler

# AST vars are handled in _is_compiler().

# Parser/tokenizer.c
_PyParser_TokenNames

# Python/graminit.c
_PyParser_Grammar
dfas
labels

# Python/Python-ast.c
AST_type
Add_singleton
Add_type
And_singleton
And_type
AnnAssign_type
Assert_type
Assign_type
AsyncFor_type
AsyncFunctionDef_type
AsyncWith_type
Attribute_type
AugAssign_type
AugLoad_singleton
AugLoad_type
AugStore_singleton
AugStore_type
Await_type
BinOp_type
BitAnd_singleton
BitAnd_type
BitOr_singleton
BitOr_type
BitXor_singleton
BitXor_type
BoolOp_type
Break_type
Bytes_type
Call_type
ClassDef_type
Compare_type
Constant_type
Continue_type
Del_singleton
Del_type
Delete_type
DictComp_type
Dict_type
Div_singleton
Div_type
Ellipsis_type
Eq_singleton
Eq_type
ExceptHandler_type
Expr_type
Expression_type
ExtSlice_type
FloorDiv_singleton
FloorDiv_type
For_type
FormattedValue_type
FunctionDef_type
GeneratorExp_type
Global_type
GtE_singleton
GtE_type
Gt_singleton
Gt_type
IfExp_type
If_type
ImportFrom_type
Import_type
In_singleton
In_type
Index_type
Interactive_type
Invert_singleton
Invert_type
IsNot_singleton
IsNot_type
Is_singleton
Is_type
JoinedStr_type
LShift_singleton
LShift_type
Lambda_type
ListComp_type
List_type
Load_singleton
Load_type
LtE_singleton
LtE_type
Lt_singleton
Lt_type
MatMult_singleton
MatMult_type
Mod_singleton
Mod_type
Module_type
Mult_singleton
Mult_type
NameConstant_type
Name_type
Nonlocal_type
NotEq_singleton
NotEq_type
NotIn_singleton
NotIn_type
Not_singleton
Not_type
Num_type
Or_singleton
Or_type
Param_singleton
Param_type
Pass_type
Pow_singleton
Pow_type
RShift_singleton
RShift_type
Raise_type
Return_type
SetComp_type
Set_type
Slice_type
Starred_type
Store_singleton
Store_type
Str_type
Sub_singleton
Sub_type
Subscript_type
Suite_type
Try_type
Tuple_type
UAdd_singleton
UAdd_type
USub_singleton
USub_type
UnaryOp_type
While_type
With_type
YieldFrom_type
Yield_type
alias_type
arg_attributes
arg_type
arguments_type
ast_type_getsets
boolop_type
cmpop_type
comprehension_type
excepthandler_attributes
excepthandler_type
expr_attributes
expr_context_type
expr_type
keyword_type
mod_type
operator_type
slice_type
stmt_attributes
stmt_type
unaryop_type
withitem_type
alias_fields

# Python/symtable.c
# XXX All okay?
#__class__
#dictcomp
#genexpr
#lambda
#listcomp
#setcomp
#top


#######################################
Expand All @@ -476,9 +339,6 @@ withitem_type
#_PyOS_ReadlineLock
#_PyOS_ReadlineTState

# Parser/tokenizer.c
#_PyParser_TokenNames

# Python/_warnings.c
#_default_action
#_filters
Expand Down Expand Up @@ -549,11 +409,6 @@ _PyOS_optarg
_PyOS_opterr
_PyOS_optind

# Python/graminit.c
_PyParser_Grammar
dfas
labels

# Python/import.c
PyImport_Inittab
#extensions
Expand All @@ -566,9 +421,6 @@ PyHash_Func
_Py_HashSecret
_Py_HashSecret_Initialized

# Python/Python-ast.c
alias_fields

# Python/modsupport.c
#_Py_PackageContext

Expand Down Expand Up @@ -613,15 +465,6 @@ _Py_CoreInitialized
#interp_main
#_next_interp_id

# Python/symtable.c
#__class__
#dictcomp
#genexpr
#lambda
#listcomp
#setcomp
#top

# Python/sysmodule.c
AsyncGenHooksType
#_check_interval
Expand Down