Commit Graph

21 Commits

Author SHA1 Message Date
Mark Shannon 25c4956488
GH-109369: Exit tier 2 if executor is invalid (GH-111657) 2023-11-09 11:19:51 +00:00
Mark Shannon d27acd4461
GH-111485: Increment `next_instr` consistently at the start of the instruction. (GH-111486) 2023-10-31 10:09:54 +00:00
Hugo van Kemenade ea530f2f9a
gh-106193: Rename and fix duplicated tests in `test_monitoring` (GH-109139) 2023-10-12 08:43:58 +01:00
Tian Gao 412f5e85d6
gh-109371: Fix monitoring with instruction events set (gh-109385) 2023-09-18 23:30:08 +09:00
Tian Gao d69805b38a
gh-109156: Add tests for de-instrumenting instructions with instrumented lines (GH-109157) 2023-09-13 09:47:35 +01:00
Victor Stinner 388d91cd47
gh-109357: Fix test_monitoring.test_gh108976() (#109358)
The test now calls free_tool_id() so it can be run multiple times in
the same process. For example, the following command no longer fails:

    python -m test test_monitoring -R 3:3
2023-09-13 01:54:28 +00:00
Guido van Rossum 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
Mark Shannon 4a69301ea4
GH-108976. Keep monitoring data structures valid during de-optimization during callback. (GH-109131) 2023-09-11 14:37:09 +01:00
Dong-hee Na 3bfa24e29f
gh-107265: Remove all ENTER_EXECUTOR when execute _Py_Instrument (gh-108539) 2023-09-07 09:53:54 +09:00
Mark Shannon 5a2a046151
GH-108390: Prevent non-local events being set with `sys.monitoring.set_local_events()` (GH-108420) 2023-09-05 08:03:53 +01:00
Mark Shannon 52fbcf61b5
GH-107724: Fix the signature of `PY_THROW` callback functions. (GH-107725) 2023-08-09 09:30:50 +01:00
Mark Shannon ac7a0f858a
GH-106898: Add the exception as an argument to the `PY_UNWIND` event callback function. (GH-107347) 2023-07-27 15:47:33 +01:00
Mark Shannon c6539b36c1
GH-106895: Raise a `ValueError` when attempting to disable events that cannot be disabled. (GH-107337) 2023-07-27 15:27:11 +01:00
Mark Shannon 766d2518ae
GH-106897: Add `RERAISE` event to `sys.monitoring`. (GH-107291)
* Ensures that exception handling events are balanced. Each [re]raise event has a matching unwind/handled event.
2023-07-27 13:32:30 +01:00
Mark Shannon 0689340366
GH-105229: Replace some superinstructions with single instruction equivalent. (GH-105230) 2023-06-05 11:07:04 +01:00
Mark Shannon 601ae09f0c
GH-105162: Account for `INSTRUMENTED_RESUME` in gen.close/throw. (GH-105187) 2023-06-02 10:39:38 +01:00
Carl Meyer f40890b124
gh-103865: add monitoring support to LOAD_SUPER_ATTR (#103866) 2023-05-16 10:29:00 -06:00
Mark Shannon 45f5aa8fc7
GH-103082: Filter LINE events in VM, to simplify tool implementation. (GH-104387)
When monitoring LINE events, instrument all instructions that can have a predecessor on a different line.
Then check that the a new line has been hit in the instrumentation code.
This brings the behavior closer to that of 3.11, simplifying implementation and porting of tools.
2023-05-12 12:21:20 +01:00
Tian Gao bcea36f8db
gh-103845: Remove line & instruction instrumentations before adding them back (GH-103851) 2023-05-03 10:51:47 +01:00
Mark Shannon 70e0a28bed
GH-103082: Turn on branch events for FOR_ITER instructions. (#103507)
Turn on branch events for FOR_ITER instructions.
2023-04-13 13:56:09 +01:00
Mark Shannon 411b169281
GH-103082: Implementation of PEP 669: Low Impact Monitoring for CPython (GH-103083)
* The majority of the monitoring code is in instrumentation.c

* The new instrumentation bytecodes are in bytecodes.c

* legacy_tracing.c adapts the new API to the old sys.setrace and sys.setprofile APIs
2023-04-12 12:04:55 +01:00