Rename tier 2 redundancy eliminator to optimizer (#115888)

The original name is just too much of a mouthful.
This commit is contained in:
Guido van Rossum 2024-02-26 08:42:53 -08:00 committed by GitHub
parent 7259480957
commit c0fdfba7ff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 30 additions and 30 deletions

2
.gitattributes vendored
View File

@ -95,7 +95,7 @@ Programs/test_frozenmain.h generated
Python/Python-ast.c generated Python/Python-ast.c generated
Python/executor_cases.c.h generated Python/executor_cases.c.h generated
Python/generated_cases.c.h generated Python/generated_cases.c.h generated
Python/tier2_redundancy_eliminator_cases.c.h generated Python/optimizer_cases.c.h generated
Python/opcode_targets.h generated Python/opcode_targets.h generated
Python/stdlib_module_names.h generated Python/stdlib_module_names.h generated
Tools/peg_generator/pegen/grammar_parser.py generated Tools/peg_generator/pegen/grammar_parser.py generated

2
.github/CODEOWNERS vendored
View File

@ -38,7 +38,7 @@ Python/ast_opt.c @isidentical
Python/bytecodes.c @markshannon @gvanrossum Python/bytecodes.c @markshannon @gvanrossum
Python/optimizer*.c @markshannon @gvanrossum Python/optimizer*.c @markshannon @gvanrossum
Python/optimizer_analysis.c @Fidget-Spinner Python/optimizer_analysis.c @Fidget-Spinner
Python/tier2_redundancy_eliminator_bytecodes.c @Fidget-Spinner Python/optimizer_bytecodes.c @Fidget-Spinner
Lib/test/test_patma.py @brandtbucher Lib/test/test_patma.py @brandtbucher
Lib/test/test_type_*.py @JelleZijlstra Lib/test/test_type_*.py @JelleZijlstra
Lib/test/test_capi/test_misc.py @markshannon @gvanrossum Lib/test/test_capi/test_misc.py @markshannon @gvanrossum

View File

@ -5,13 +5,13 @@ on:
- '**jit**' - '**jit**'
- 'Python/bytecodes.c' - 'Python/bytecodes.c'
- 'Python/optimizer*.c' - 'Python/optimizer*.c'
- 'Python/tier2_redundancy_eliminator_bytecodes.c' - 'Python/optimizer_bytecodes.c'
push: push:
paths: paths:
- '**jit**' - '**jit**'
- 'Python/bytecodes.c' - 'Python/bytecodes.c'
- 'Python/optimizer*.c' - 'Python/optimizer*.c'
- 'Python/tier2_redundancy_eliminator_bytecodes.c' - 'Python/optimizer_bytecodes.c'
workflow_dispatch: workflow_dispatch:
concurrency: concurrency:

View File

@ -33,7 +33,7 @@ with test_tools.imports_under_tool("cases_generator"):
import parser import parser
from stack import Stack from stack import Stack
import tier1_generator import tier1_generator
import tier2_abstract_generator import optimizer_generator
def handle_stderr(): def handle_stderr():
@ -841,7 +841,7 @@ class TestGeneratedAbstractCases(unittest.TestCase):
temp_input.flush() temp_input.flush()
with handle_stderr(): with handle_stderr():
tier2_abstract_generator.generate_tier2_abstract_from_files( optimizer_generator.generate_tier2_abstract_from_files(
[self.temp_input_filename, self.temp_input2_filename], [self.temp_input_filename, self.temp_input2_filename],
self.temp_output_filename self.temp_output_filename
) )

View File

@ -1889,9 +1889,9 @@ regen-cases:
-o $(srcdir)/Python/generated_cases.c.h.new $(srcdir)/Python/bytecodes.c -o $(srcdir)/Python/generated_cases.c.h.new $(srcdir)/Python/bytecodes.c
$(PYTHON_FOR_REGEN) $(srcdir)/Tools/cases_generator/tier2_generator.py \ $(PYTHON_FOR_REGEN) $(srcdir)/Tools/cases_generator/tier2_generator.py \
-o $(srcdir)/Python/executor_cases.c.h.new $(srcdir)/Python/bytecodes.c -o $(srcdir)/Python/executor_cases.c.h.new $(srcdir)/Python/bytecodes.c
$(PYTHON_FOR_REGEN) $(srcdir)/Tools/cases_generator/tier2_abstract_generator.py \ $(PYTHON_FOR_REGEN) $(srcdir)/Tools/cases_generator/optimizer_generator.py \
-o $(srcdir)/Python/tier2_redundancy_eliminator_cases.c.h.new \ -o $(srcdir)/Python/optimizer_cases.c.h.new \
$(srcdir)/Python/tier2_redundancy_eliminator_bytecodes.c \ $(srcdir)/Python/optimizer_bytecodes.c \
$(srcdir)/Python/bytecodes.c $(srcdir)/Python/bytecodes.c
$(PYTHON_FOR_REGEN) $(srcdir)/Tools/cases_generator/opcode_metadata_generator.py \ $(PYTHON_FOR_REGEN) $(srcdir)/Tools/cases_generator/opcode_metadata_generator.py \
-o $(srcdir)/Include/internal/pycore_opcode_metadata.h.new $(srcdir)/Python/bytecodes.c -o $(srcdir)/Include/internal/pycore_opcode_metadata.h.new $(srcdir)/Python/bytecodes.c
@ -1904,7 +1904,7 @@ regen-cases:
$(UPDATE_FILE) $(srcdir)/Include/internal/pycore_opcode_metadata.h $(srcdir)/Include/internal/pycore_opcode_metadata.h.new $(UPDATE_FILE) $(srcdir)/Include/internal/pycore_opcode_metadata.h $(srcdir)/Include/internal/pycore_opcode_metadata.h.new
$(UPDATE_FILE) $(srcdir)/Include/internal/pycore_uop_metadata.h $(srcdir)/Include/internal/pycore_uop_metadata.h.new $(UPDATE_FILE) $(srcdir)/Include/internal/pycore_uop_metadata.h $(srcdir)/Include/internal/pycore_uop_metadata.h.new
$(UPDATE_FILE) $(srcdir)/Python/executor_cases.c.h $(srcdir)/Python/executor_cases.c.h.new $(UPDATE_FILE) $(srcdir)/Python/executor_cases.c.h $(srcdir)/Python/executor_cases.c.h.new
$(UPDATE_FILE) $(srcdir)/Python/tier2_redundancy_eliminator_cases.c.h $(srcdir)/Python/tier2_redundancy_eliminator_cases.c.h.new $(UPDATE_FILE) $(srcdir)/Python/optimizer_cases.c.h $(srcdir)/Python/optimizer_cases.c.h.new
$(UPDATE_FILE) $(srcdir)/Lib/_opcode_metadata.py $(srcdir)/Lib/_opcode_metadata.py.new $(UPDATE_FILE) $(srcdir)/Lib/_opcode_metadata.py $(srcdir)/Lib/_opcode_metadata.py.new
Python/compile.o: $(srcdir)/Include/internal/pycore_opcode_metadata.h Python/compile.o: $(srcdir)/Include/internal/pycore_opcode_metadata.h
@ -1927,7 +1927,7 @@ Python/optimizer.o: \
Python/optimizer_analysis.o: \ Python/optimizer_analysis.o: \
$(srcdir)/Include/internal/pycore_opcode_metadata.h \ $(srcdir)/Include/internal/pycore_opcode_metadata.h \
$(srcdir)/Include/internal/pycore_optimizer.h \ $(srcdir)/Include/internal/pycore_optimizer.h \
$(srcdir)/Python/tier2_redundancy_eliminator_cases.c.h $(srcdir)/Python/optimizer_cases.c.h
Python/frozen.o: $(FROZEN_FILES_OUT) Python/frozen.o: $(FROZEN_FILES_OUT)

View File

@ -31,8 +31,8 @@
<!-- Taken from _Target._compute_digest in Tools\jit\_targets.py: --> <!-- Taken from _Target._compute_digest in Tools\jit\_targets.py: -->
<_JITSources Include="$(PySourcePath)Python\executor_cases.c.h;$(GeneratedPyConfigDir)pyconfig.h;$(PySourcePath)Tools\jit\**"/> <_JITSources Include="$(PySourcePath)Python\executor_cases.c.h;$(GeneratedPyConfigDir)pyconfig.h;$(PySourcePath)Tools\jit\**"/>
<_JITOutputs Include="$(GeneratedPyConfigDir)jit_stencils.h"/> <_JITOutputs Include="$(GeneratedPyConfigDir)jit_stencils.h"/>
<_CasesSources Include="$(PySourcePath)Python\bytecodes.c;$(PySourcePath)Python\tier2_redundancy_eliminator_bytecodes.c;"/> <_CasesSources Include="$(PySourcePath)Python\bytecodes.c;$(PySourcePath)Python\optimizer_bytecodes.c;"/>
<_CasesOutputs Include="$(PySourcePath)Python\generated_cases.c.h;$(PySourcePath)Include\opcode_ids.h;$(PySourcePath)Include\internal\pycore_uop_ids.h;$(PySourcePath)Python\opcode_targets.h;$(PySourcePath)Include\internal\pycore_opcode_metadata.h;$(PySourcePath)Include\internal\pycore_uop_metadata.h;$(PySourcePath)Python\tier2_redundancy_eliminator_cases.c.h;$(PySourcePath)Lib\_opcode_metadata.py"/> <_CasesOutputs Include="$(PySourcePath)Python\generated_cases.c.h;$(PySourcePath)Include\opcode_ids.h;$(PySourcePath)Include\internal\pycore_uop_ids.h;$(PySourcePath)Python\opcode_targets.h;$(PySourcePath)Include\internal\pycore_opcode_metadata.h;$(PySourcePath)Include\internal\pycore_uop_metadata.h;$(PySourcePath)Python\optimizer_cases.c.h;$(PySourcePath)Lib\_opcode_metadata.py"/>
</ItemGroup> </ItemGroup>
<Target Name="_TouchRegenSources" Condition="$(ForceRegen) == 'true'"> <Target Name="_TouchRegenSources" Condition="$(ForceRegen) == 'true'">
@ -98,7 +98,7 @@
WorkingDirectory="$(PySourcePath)" /> WorkingDirectory="$(PySourcePath)" />
<Exec Command="$(PythonForBuild) $(PySourcePath)Tools\cases_generator\tier2_generator.py $(PySourcePath)Python\bytecodes.c" <Exec Command="$(PythonForBuild) $(PySourcePath)Tools\cases_generator\tier2_generator.py $(PySourcePath)Python\bytecodes.c"
WorkingDirectory="$(PySourcePath)" /> WorkingDirectory="$(PySourcePath)" />
<Exec Command="$(PythonForBuild) $(PySourcePath)Tools\cases_generator\tier2_abstract_generator.py $(PySourcePath)Python\tier2_redundancy_eliminator_bytecodes.c $(PySourcePath)Python\bytecodes.c" <Exec Command="$(PythonForBuild) $(PySourcePath)Tools\cases_generator\optimizer_generator.py $(PySourcePath)Python\optimizer_bytecodes.c $(PySourcePath)Python\bytecodes.c"
WorkingDirectory="$(PySourcePath)" /> WorkingDirectory="$(PySourcePath)" />
<Exec Command="$(PythonForBuild) $(PySourcePath)Tools\cases_generator\opcode_metadata_generator.py $(PySourcePath)Python\bytecodes.c" <Exec Command="$(PythonForBuild) $(PySourcePath)Tools\cases_generator\opcode_metadata_generator.py $(PySourcePath)Python\bytecodes.c"
WorkingDirectory="$(PySourcePath)" /> WorkingDirectory="$(PySourcePath)" />

View File

@ -1,5 +1,5 @@
/* /*
* This file contains the support code for CPython's uops redundancy eliminator. * This file contains the support code for CPython's uops optimizer.
* It also performs some simple optimizations. * It also performs some simple optimizations.
* It performs a traditional data-flow analysis[1] over the trace of uops. * It performs a traditional data-flow analysis[1] over the trace of uops.
* Using the information gained, it chooses to emit, or skip certain instructions * Using the information gained, it chooses to emit, or skip certain instructions
@ -606,7 +606,7 @@ remove_globals(_PyInterpreterFrame *frame, _PyUOpInstruction *buffer,
/* 1 for success, 0 for not ready, cannot error at the moment. */ /* 1 for success, 0 for not ready, cannot error at the moment. */
static int static int
uop_redundancy_eliminator( optimize_uops(
PyCodeObject *co, PyCodeObject *co,
_PyUOpInstruction *trace, _PyUOpInstruction *trace,
int trace_len, int trace_len,
@ -638,7 +638,7 @@ uop_redundancy_eliminator(
_PyUOpName(opcode), _PyUOpName(opcode),
oparg); oparg);
switch (opcode) { switch (opcode) {
#include "tier2_redundancy_eliminator_cases.c.h" #include "optimizer_cases.c.h"
default: default:
DPRINTF(1, "Unknown opcode in abstract interpreter\n"); DPRINTF(1, "Unknown opcode in abstract interpreter\n");
@ -812,7 +812,7 @@ _Py_uop_analyze_and_optimize(
char *uop_optimize = Py_GETENV("PYTHONUOPSOPTIMIZE"); char *uop_optimize = Py_GETENV("PYTHONUOPSOPTIMIZE");
if (uop_optimize != NULL && *uop_optimize > '0') { if (uop_optimize != NULL && *uop_optimize > '0') {
err = uop_redundancy_eliminator( err = optimize_uops(
(PyCodeObject *)frame->f_executable, buffer, (PyCodeObject *)frame->f_executable, buffer,
buffer_size, curr_stacklen, dependencies); buffer_size, curr_stacklen, dependencies);
} }

View File

@ -1,6 +1,6 @@
// This file is generated by Tools/cases_generator/tier2_abstract_generator.py // This file is generated by Tools/cases_generator/optimizer_generator.py
// from: // from:
// Python/tier2_redundancy_eliminator_bytecodes.c // Python/optimizer_bytecodes.c
// Do not edit! // Do not edit!
case _NOP: { case _NOP: {

View File

@ -83,11 +83,11 @@ Python/deepfreeze/*.c
Python/frozen_modules/*.h Python/frozen_modules/*.h
Python/generated_cases.c.h Python/generated_cases.c.h
Python/executor_cases.c.h Python/executor_cases.c.h
Python/tier2_redundancy_eliminator_cases.c.h Python/optimizer_cases.c.h
# not actually source # not actually source
Python/bytecodes.c Python/bytecodes.c
Python/tier2_redundancy_eliminator_bytecodes.c Python/optimizer_bytecodes.c
# mimalloc # mimalloc
Objects/mimalloc/*.c Objects/mimalloc/*.c

View File

@ -13,9 +13,9 @@ What's currently here:
- `parser.py` helper for interactions with `parsing.py` - `parser.py` helper for interactions with `parsing.py`
- `tierN_generator.py`: a couple of driver scripts to read `Python/bytecodes.c` and - `tierN_generator.py`: a couple of driver scripts to read `Python/bytecodes.c` and
write `Python/generated_cases.c.h` (and several other files) write `Python/generated_cases.c.h` (and several other files)
- `tier2_abstract_generator.py`: reads `Python/bytecodes.c` and - `optimizer_generator.py`: reads `Python/bytecodes.c` and
`Python/tier2_redundancy_eliminator_bytecodes.c` and writes `Python/optimizer_bytecodes.c` and writes
`Python/tier2_redundancy_eliminator_cases.c.h` `Python/optimizer_cases.c.h`
- `stack.py`: code to handle generalized stack effects - `stack.py`: code to handle generalized stack effects
- `cwriter.py`: code which understands tokens and how to format C code; - `cwriter.py`: code which understands tokens and how to format C code;
main class: `CWriter` main class: `CWriter`

View File

@ -1,6 +1,6 @@
"""Generate the cases for the tier 2 redundancy eliminator/abstract interpreter. """Generate the cases for the tier 2 optimizer.
Reads the instruction definitions from bytecodes.c. and tier2_redundancy_eliminator.bytecodes.c Reads the instruction definitions from bytecodes.c and optimizer_bytecodes.c
Writes the cases to tier2_redundancy_eliminator_cases.c.h, which is #included in Python/optimizer_analysis.c. Writes the cases to optimizer_cases.c.h, which is #included in Python/optimizer_analysis.c.
""" """
import argparse import argparse
@ -30,8 +30,8 @@ from typing import TextIO, Iterator
from lexer import Token from lexer import Token
from stack import StackOffset, Stack, SizeMismatch, UNUSED from stack import StackOffset, Stack, SizeMismatch, UNUSED
DEFAULT_OUTPUT = ROOT / "Python/tier2_redundancy_eliminator_cases.c.h" DEFAULT_OUTPUT = ROOT / "Python/optimizer_cases.c.h"
DEFAULT_ABSTRACT_INPUT = ROOT / "Python/tier2_redundancy_eliminator_bytecodes.c" DEFAULT_ABSTRACT_INPUT = ROOT / "Python/optimizer_bytecodes.c"
def validate_uop(override: Uop, uop: Uop) -> None: def validate_uop(override: Uop, uop: Uop) -> None: