Commit Graph
201 Commits
Author SHA1 Message Date
Mark ShannonandGitHub a519b87958 GH-111848: Convert remaining jumps to deopts into tier 2 code. (GH-112045) 2023-11-14 15:30:33 +00:00
Serhiy StorchakaandGitHub b11c443bb2 gh-111789: Simplify bytecodes.c by using PyDict_GetItemRef() (GH-111978) 2023-11-14 15:38:49 +02:00
Mark ShannonandGitHub 34a03e951b GH-111843: Tier 2 exponential backoff (GH-111850) 2023-11-09 13:49:51 +00:00
Mark ShannonandGitHub 25c4956488 GH-109369: Exit tier 2 if executor is invalid (GH-111657) 2023-11-09 11:19:51 +00:00
Mark ShannonandGitHub 06efb60264 GH-111848: Tidy up tier 2 handling of FOR_ITER specialization by using DEOPT_IF instead of jumps. (GH-111849) 2023-11-08 13:31:55 +00:00
Mark ShannonandGitHub 931f4438c9 GH-111485: Allow arbitrary annotations on instructions and micro-ops. (GH-111697) 2023-11-07 09:42:39 +00:00
Brandt BucherandGitHub 3e99c9cbf6 GH-111485: Make BEFORE_WITH a uop (GH-111812) 2023-11-06 16:42:49 -08:00
Irit KatrielandGitHub d49aba5a7a gh-111354: Simplify _PyGen_yf by moving some of its work to the compiler and frame state (#111648) 2023-11-03 10:01:36 +00:00
AN LongandGitHub 3a1b09e6d0 gh-111654: remove redundant decref in LOAD_FROM_DICT_OR_DEREF (#111655) 2023-11-02 21:06:51 -07:00
Irit KatrielandGitHub 52cc4af6ae gh-111354: simplify detection of RESUME after YIELD_VALUE at except-depth 1 (#111459) 2023-11-02 10:18:43 +00:00
Guido van RossumandGitHub e4b37835ef GH-111485: Silence warnings in Python/executor_cases.c.h (#111619) 2023-11-01 14:24:52 -07:00
Guido van RossumandGitHub 7e135a48d6 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`.
2023-11-01 13:13:02 -07:00
Mark ShannonandGitHub 5697fc2d4b GH-111537: Avoid using this_instr in asserts. (GH-111600) 2023-11-01 12:59:08 +00:00
Mark ShannonandGitHub b14e882428 GH-111485: Use micro-ops to split specialization code from base action (GH-111561) 2023-11-01 10:53:27 +00:00
Mark ShannonandGitHub 2904d99839 GH-111485: Remove some special cases from the code generator and bytecodes.c (GH-111540) 2023-10-31 13:21:07 +00:00
Mark ShannonandGitHub d27acd4461 GH-111485: Increment next_instr consistently at the start of the instruction. (GH-111486) 2023-10-31 10:09:54 +00:00
Nikita SobolevandGitHub 524a701d07 gh-111386: Fix uint32_t cast in generated_cases.c.h (#111387) 2023-10-27 12:37:59 +01:00
Irit KatrielandGitHub a0c414c35d gh-111354: define names for RESUME oparg values (#111365) 2023-10-26 16:30:18 +01:00
Irit KatrielandGitHub 67a91f78e4 gh-109094: replace frame->prev_instr by frame->instr_ptr (#109095) 2023-10-26 13:43:10 +00:00
Brandt BucherandGitHub e5168ff3f8 GH-109214: _SET_IP before _PUSH_FRAME (but not _POP_FRAME) (GH-111001) 2023-10-24 13:27:42 -07:00
Irit KatrielandGitHub 7dd3c2b800 gh-109094: remove redundant arg to _PyFrame_PushTrampolineUnchecked (GH-110759) 2023-10-12 11:02:42 +01:00
Mark ShannonandGitHub 19b7ead5eb GH-109214: Convert _SAVE_CURRENT_IP to _SET_IP in tier 2 trace creation. (GH-110755) 2023-10-12 10:34:32 +01:00
Michael DroettboomandGitHub e561e98058 GH-109329: Add tier 2 stats (GH-109913) 2023-10-04 14:52:28 -07:00
Mark ShannonandGitHub bf4bc36069 GH-109369: Merge all eval-breaker flags and monitoring version into one word. (GH-109846) 2023-10-04 16:09:48 +01:00
Guido van RossumandGitHub 7c149a76b2 gh-104909: Split more LOAD_ATTR specializations (GH-110317)
* Split LOAD_ATTR_MODULE

* Split LOAD_ATTR_WITH_HINT

* Split _GUARD_TYPE_VERSION out of the latter

* Split LOAD_ATTR_CLASS

* Split LOAD_ATTR_NONDESCRIPTOR_WITH_VALUES

* Fix indent of DEOPT_IF in macros

* Split LOAD_ATTR_METHOD_LAZY_DICT

* Split LOAD_ATTR_NONDESCRIPTOR_NO_DICT

* Fix omission of _CHECK_ATTR_METHOD_LAZY_DICT
2023-10-04 16:08:02 +01:00
Guido van RossumandGitHub 625ecbe92e gh-109979: Unify _GUARD_TYPE_VERSION{,_STORE} (#110301)
Now the target for `DEOPT_IF()` is auto-filled,
we don't need a separate `_GUARD_TYPE_VERSION_STORE` uop.
2023-10-03 22:37:21 +00:00
Guido van RossumandGitHub d67edcf0b3 gh-109979: Auto-generate the target for DEOPT_IF() (#110193)
In Python/bytecodes.c, you now write
```
    DEOPT_IF(condition);
```
The code generator expands this to
```
    DEOPT_IF(condition, opcode);
```
where `opcode` is the name of the unspecialized instruction.
This works inside macro expansions too.

**CAVEAT:** The entire `DEOPT_IF(condition)` statement must be on a single line.
If it isn't, the substitution will fail; an error will be printed by the code generator
and the C compiler will report some errors.
2023-10-03 10:13:50 -07:00
Nikita SobolevandGitHub 3814bc1723 gh-110020: Fix unused variable warnings in bytecodes.c (GH-110023) 2023-09-28 15:31:32 +01:00
Guido van RossumandGitHub 5bb6f0fcba gh-104909: Split some more insts into ops (#109943)
These are the most popular specializations of `LOAD_ATTR` and `STORE_ATTR`
that weren't already viable uops:

* Split LOAD_ATTR_METHOD_WITH_VALUES
* Split LOAD_ATTR_METHOD_NO_DICT
* Split LOAD_ATTR_SLOT
* Split STORE_ATTR_SLOT
* Split STORE_ATTR_INSTANCE_VALUE

Also:

* Add `-v` flag to code generator which prints a list of non-viable uops
  (easter-egg: it can print execution counts -- see source)
* Double _Py_UOP_MAX_TRACE_LENGTH to 128



I had dropped one of the DEOPT_IF() calls! :-(
2023-09-27 15:27:44 -07:00
Brandt BucherandGitHub 6c13e13b13 GH-104584: Don't call executors from JUMP_BACKWARD (GH-109347) 2023-09-13 10:26:50 -07:00
Brandt BucherandGitHub 22e65eecaa GH-105848: Replace KW_NAMES + CALL with LOAD_CONST + CALL_KW (GH-109300) 2023-09-13 10:25:45 -07:00
Nikita SobolevandGitHub 247ee1bf84 gh-109216: Fix possible memory leak in BUILD_MAP (#109257) 2023-09-12 15:07:22 +05:30
Guido van RossumandGitHub fbaf77eb9b gh-109214: Rename SAVE_IP to _SET_IP, and similar (#109285)
* Rename SAVE_IP to _SET_IP
* Rename EXIT_TRACE to _EXIT_TRACE
* Rename SAVE_CURRENT_IP to _SAVE_CURRENT_IP
* Rename INSERT to _INSERT (This is for Ken Jin's abstract interpreter)
* Rename IS_NONE to _IS_NONE
* Rename JUMP_TO_TOP to _JUMP_TO_TOP
2023-09-11 15:39:19 -07:00
Guido van RossumandGitHub bcce5e2718 gh-109039: Branch prediction for Tier 2 interpreter (#109038)
This adds a 16-bit inline cache entry to the conditional branch instructions POP_JUMP_IF_{FALSE,TRUE,NONE,NOT_NONE} and their instrumented variants, which is used to keep track of the branch direction.

Each time we encounter these instructions we shift the cache entry left by one and set the bottom bit to whether we jumped.

Then when it's time to translate such a branch to Tier 2 uops, we use the bit count from the cache entry to decided whether to continue translating the "didn't jump" branch or the "jumped" branch.

The counter is initialized to a pattern of alternating ones and zeros to avoid bias.

The .pyc file magic number is updated. There's a new test, some fixes for existing tests, and a few miscellaneous cleanups.
2023-09-11 18:20:24 +00:00
Jelle ZijlstraandGitHub 17f994174d gh-109118: Fix runtime crash when NameError happens in PEP 695 function (#109123) 2023-09-09 02:49:20 +00:00
Mark ShannonandGitHub 501f2dc527 GH-108614: Unbreak emscripten build (GH-109132) 2023-09-08 17:54:45 +01:00
Mark ShannonandGitHub 0858328ca2 GH-108614: Add RESUME_CHECK instruction (GH-108630) 2023-09-07 14:39:03 +01:00
Mark ShannonandGitHub 5a3672cb39 GH-108614: Remove TIER_ONE and TIER_TWO from _PUSH_FRAME (GH-108725) 2023-09-04 11:36:57 +01:00
Mark ShannonandGitHub 059bd4d299 GH-108614: Remove non-debug uses of #if TIER_ONE and #if TIER_TWO from _POP_FRAME op. (GH-108685) 2023-08-31 11:34:52 +01:00
Guido van RossumandGitHub 47d7eba889 gh-108487: Move assert(self != NULL) down beyond DEOPT_IF() (#108510) 2023-08-28 10:17:00 -07:00
Brandt BucherandGitHub 4eae1e5342 GH-106581: Fix instrumentation in tier 2 (GH-108493) 2023-08-25 19:12:59 +00:00
Guido van RossumandGitHub ddf66b54ed gh-106581: Split CALL_BOUND_METHOD_EXACT_ARGS into uops (#108462)
Instead of using `GO_TO_INSTRUCTION(CALL_PY_EXACT_ARGS)` we just add the macro elements of the latter to the macro for the former. This requires lengthening the uops array in struct opcode_macro_expansion. (It also required changes to stacking.py that were merged already.)
2023-08-24 17:36:00 -07:00
Guido van RossumandGitHub 61c7249759 gh-106581: Project through calls (#108067)
This finishes the work begun in gh-107760. When, while projecting a superblock, we encounter a call to a short, simple function, the superblock will now enter the function using `_PUSH_FRAME`, continue through it, and leave it using `_POP_FRAME`, and then continue through the original code. Multiple frame pushes and pops are even possible. It is also possible to stop appending to the superblock in the middle of a called function, when running out of space or encountering an unsupported bytecode.
2023-08-17 11:29:58 -07:00
Mark ShannonandGitHub 006e44f950 GH-108035: Remove the _PyCFrame struct as it is no longer needed for performance. (GH-108036) 2023-08-17 11:16:03 +01:00
Guido van RossumandGitHub dc8fdf5fd5 gh-106581: Split CALL_PY_EXACT_ARGS into uops (#107760)
* Split `CALL_PY_EXACT_ARGS` into uops

This is only the first step for doing `CALL` in Tier 2.
The next step involves tracing into the called code object and back.
After that we'll have to do the remaining `CALL` specialization.
Finally we'll have to deal with `KW_NAMES`.

Note: this moves setting `frame->return_offset` directly in front of
`DISPATCH_INLINED()`, to make it easier to move it into `_PUSH_FRAME`.
2023-08-16 16:26:43 -07:00
Irit KatrielandGitHub 665a4391e1 gh-105481: generate op IDs from bytecode.c instead of hard coding them in opcode.py (#107971) 2023-08-16 22:25:18 +00:00
e28b0dc86d gh-107557: Setup abstract interpretation (#107847)
Co-authored-by: Guido van Rossum <[email protected]>
Co-authored-by: Jules <[email protected]>
2023-08-15 18:04:17 +00:00
Brandt BucherandGitHub 326f0ba1c5 GH-106485: Dematerialize instance dictionaries when possible (GH-106539) 2023-08-09 19:14:50 +00:00
Brandt BucherandGitHub a9caf9cf90 GH-105848: Simplify the arrangement of CALL's stack (GH-107788) 2023-08-09 18:19:39 +00:00
Brandt BucherandGitHub ea72c6fe3b GH-107596: Specialize str[int] (GH-107597) 2023-08-08 13:42:43 -07:00