8000 gh-111520: Integrate the Tier 2 interpreter in the Tier 1 interpreter… · python/cpython@7e135a4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7e135a4

Browse files
authored
gh-111520: Integrate the Tier 2 interpreter in the Tier 1 interpreter (#111428)
- There is no longer a separate Python/executor.c file. - Conventions in Python/bytecodes.c are slightly different -- don't use `goto error`, you must use `GOTO_ERROR(error)` (same for others like `unused_local_error`). - The `TIER_ONE` and `TIER_TWO` symbols are only valid in the generated (.c.h) files. - In Lib/test/support/__init__.py, `Py_C_RECURSION_LIMIT` is imported from `_testcapi`. - On Windows, in debug mode, stack allocation grows from 8MiB to 12MiB. - **Beware!** This changes the env vars to enable uops and their debugging to `PYTHON_UOPS` and `PYTHON_LLTRACE`.
1 parent 5d6db16 commit 7e135a4

19 files changed

+509
-487
lines changed

Lib/test/support/__init__.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2355,8 +2355,15 @@ def adjust_int_max_str_digits(max_digits):
23552355
#For recursion tests, easily exceeds default recursion limit
23562356
EXCEEDS_RECURSION_LIMIT = 5000
23572357

2358-
# The default C recursion limit (from Include/cpython/pystate.h).
2359-
Py_C_RECURSION_LIMIT = 1500
2358+
def _get_c_recursion_limit():
2359+
try:
2360+
import _testcapi
2361+
return _testcapi.Py_C_RECURSION_LIMIT
2362+
except (ImportError, AttributeError):
2363+
return 1500 # (from Include/cpython/pystate.h)
2364+
2365+
# The default C recursion limit.
2366+
Py_C_RECURSION_LIMIT = _get_c_recursion_limit()
23602367

23612368
#Windows doesn't have os.uname() but it doesn't support s390x.
23622369
skip_on_s390x = unittest.skipIf(hasattr(os, 'uname') and os.uname().machine == 's390x',

Lib/test/test_generated_cases.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,17 +118,19 @@ def run_cases_test(self, input: str, expected: str):
118118

119119
with open(self.temp_output_filename) as temp_output:
120120
lines = temp_output.readlines()
121-
while lines and lines[0].startswith("// "):
121+
while lines and lines[0].startswith(("// ", "#", " #", "\n")):
122122
lines.pop(0)
123+
while lines and lines[-1].startswith(("#", "\n")):
124+
lines.pop(-1)
123125
actual = "".join(lines)
124-
# if actual.rstrip() != expected.rstrip():
126+
# if actual.strip() != expected.strip():
125127
# print("Actual:")
126128
# print(actual)
127129
# print("Expected:")
128130
# print(expected)
129131
# print("End")
130132

131-
self.assertEqual(actual.rstrip(), expected.rstrip())
133+
self.assertEqual(actual.strip(), expected.strip())
132134

133135
def test_inst_no_args(self):
134136
input = """

Makefile.pre.in

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,6 @@ PYTHON_OBJS= \
412412
Python/crossinterp.o \
413413
Python/dynamic_annotations.o \
414414
Python/errors.o \
415-
Python/executor.o \
416415
Python/flowgraph.o \
417416
Python/frame.o \
418417
Python/frozenmain.o \
@@ -1603,12 +1602,6 @@ Python/ceval.o: \
16031602
$(srcdir)/Python/generated_cases.c.h \
16041603
$(srcdir)/Python/opcode_targets.h
16051604

1606-
Python/executor.o: \
1607-
$(srcdir)/Include/internal/pycore_opcode_metadata.h \
1608-
$(srcdir)/Include/internal/pycore_optimizer.h \
1609-
$(srcdir)/Python/ceval_macros.h \
1610-
$(srcdir)/Python/executor_cases.c.h
1611-
16121605
Python/flowgraph.o: \
16131606
$(srcdir)/Include/internal/pycore_opcode_metadata.h
16141607

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Merge the Tier 1 (bytecode) and Tier 2 (micro-ops) interpreters together,
2+
moving the Tier 2 interpreter loop and switch into
3+
``_PyEval_EvalFrameDefault()`` in ``Python/ceval.c``.
4+
The ``Python/executor.c`` file is gone.
5+
Also the ``TIER_ONE`` and ``TIER_TWO`` macros are now handled
6+
by the code generator.
7+
8+
**Beware!** This changes the environment variables to enable micro-ops and
9+
their debugging to ``PYTHON_UOPS`` and ``PYTHON_LLTRACE``.

PCbuild/_freeze_module.vcxproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,6 @@
200200
<ClCompile Include="..\Python\dynamic_annotations.c" />
201201
<ClCompile Include="..\Python\dynload_win.c" />
202202
<ClCompile Include="..\Python\errors.c" />
203-
<ClCompile Include="..\Python\executor.c" />
204203
<ClCompile Include="..\Python\fileutils.c" />
205204
<ClCompile Include="..\Python\flowgraph.c" />
206205
<ClCompile Include="..\Python\formatter_unicode.c" />

PCbuild/_freeze_module.vcxproj.filters

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,6 @@
127127
<ClCompile Include="..\Python\errors.c">
128128
<Filter>Source Files</Filter>
129129
</ClCompile>
130-
<ClCompile Include="..\Python\executor.c">
131-
<Filter>Source Files</Filter>
132-
</ClCompile>
133130
<ClCompile Include="..\Objects\exceptions.c">
134131
<Filter>Source Files</Filter>
135132
</ClCompile>

PCbuild/python.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
<Link>
9696
<SubSystem>Console</SubSystem>
9797
<StackReserveSize Condition="$(Configuration) != 'Debug'">2000000</StackReserveSize>
98-
<StackReserveSize Condition="$(Configuration) == 'Debug'">8000000</StackReserveSize>
98+
<StackReserveSize Condition="$(Configuration) == 'Debug'">12000000</StackReserveSize>
9999
</Link>
100100
</ItemDefinitionGroup>
101101
<ItemGroup>

PCbuild/pythoncore.vcxproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,6 @@
552552
<ClCompile Include="..\Python\dynamic_annotations.c" />
553553
<ClCompile Include="..\Python\dynload_win.c" />
554554
<ClCompile Include="..\Python\errors.c" />
555-
<ClCompile Include="..\Python\executor.c" />
556555
<ClCompile Include="..\Python\fileutils.c" />
557556
<ClCompile Include="..\Python\flowgraph.c" />
558557
<ClCompile Include="..\Python\formatter_unicode.c" />

PCbuild/pythoncore.vcxproj.filters

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,9 +1253,6 @@
12531253
<ClCompile Include="..\Python\errors.c">
12541254
<Filter>Python</Filter>
12551255
</ClCompile>
1256-
<ClCompile Include="..\Python\executor.c">
1257-
<Filter>Python</Filter>
1258-
</ClCompile>
12591256
<ClCompile Include="..\Python\fileutils.c">
12601257
<Filter>Python</Filter>
12611258
</ClCompile>

0 commit comments

Comments
 (0)
0