diff options
author | Guido van Rossum <guido@python.org> | 2023-11-20 19:25:32 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-20 19:25:32 (GMT) |
commit | 8deb8bc2e5af0e229df87002ee8e0b0c1383f572 (patch) | |
tree | 42e2f8422a5891036ed689f35bf376b4d34eb468 /Tools/cases_generator | |
parent | c4c63211e83aa50927f3f1e57eacfaf4952ed228 (diff) | |
download | cpython-8deb8bc2e5af0e229df87002ee8e0b0c1383f572.zip cpython-8deb8bc2e5af0e229df87002ee8e0b0c1383f572.tar.gz cpython-8deb8bc2e5af0e229df87002ee8e0b0c1383f572.tar.bz2 |
gh-112287: Speed up Tier 2 (uop) interpreter a little (#112286)
This makes the Tier 2 interpreter a little faster.
I calculated by about 3%,
though I hesitate to claim an exact number.
This starts by doubling the trace size limit (to 512),
making it more likely that loops fit in a trace.
The rest of the approach is to only load
`oparg` and `operand` in cases that use them.
The code generator know when these are used.
For `oparg`, it will conditionally emit
```
oparg = CURRENT_OPARG();
```
at the top of the case block.
(The `oparg` variable may be referenced multiple times
by the instructions code block, so it must be in a variable.)
For `operand`, it will use `CURRENT_OPERAND()` directly
instead of referencing the `operand` variable,
which no longer exists.
(There is only one place where this will be used.)
Diffstat (limited to 'Tools/cases_generator')
-rw-r--r-- | Tools/cases_generator/generate_cases.py | 2 | ||||
-rw-r--r-- | Tools/cases_generator/instructions.py | 2 |
2 files changed, 3 insertions, 1 deletions
diff --git a/Tools/cases_generator/generate_cases.py b/Tools/cases_generator/generate_cases.py index 149558e..851bd2f 100644 --- a/Tools/cases_generator/generate_cases.py +++ b/Tools/cases_generator/generate_cases.py @@ -810,6 +810,8 @@ class Generator(Analyzer): n_uops += 1 self.out.emit("") with self.out.block(f"case {instr.name}:"): + if instr.instr_flags.HAS_ARG_FLAG: + self.out.emit("oparg = CURRENT_OPARG();") stacking.write_single_instr(instr, self.out, tier=TIER_TWO) if instr.check_eval_breaker: self.out.emit("CHECK_EVAL_BREAKER();") diff --git a/Tools/cases_generator/instructions.py b/Tools/cases_generator/instructions.py index 9039ac5..149a088 100644 --- a/Tools/cases_generator/instructions.py +++ b/Tools/cases_generator/instructions.py @@ -166,7 +166,7 @@ class Instruction: f"{func}(&this_instr[{active.offset + 1}].cache);" ) else: - out.emit(f"{typ}{ceffect.name} = ({typ.strip()})operand;") + out.emit(f"{typ}{ceffect.name} = ({typ.strip()})CURRENT_OPERAND();") # Write the body, substituting a goto for ERROR_IF() and other stuff assert dedent <= 0 |