Files
youknowdotandJeong YunWon 97bd4af533 Add interpreter-bound operation critical sections (#9215)
* Factor shared interpreter stop-the-world guard

Move the existing collector barrier into the VM without changing its stop, restart or ownership behavior, preparing reuse by fork.

Assisted-by: dot:GPT-6.1

* Add interpreter-bound operation section primitive

Prepare attached-only ownership acquisition and detached observer parking with private per-interpreter scope stacks. Lifecycle wiring follows separately; no profiler consumer is enabled by this commit.

Assisted-by: dot:GPT-6.1

* Suspend operation sections at VM lifecycle boundaries

Integrate detach, stop-the-world, shutdown and interpreter-switch boundaries. Reuse the all-interpreter barrier for fork repair and add focused native ownership invariants.

Assisted-by: dot:GPT-6.1

* Replace operation sections with PyMutex critical sections

Add PyMutex with the lock.c protocol: LOCKED/HAS_PARKED bits, a bounded
spin, direct handoff to waiters parked longer than 1 ms, and detaching
while parked.

Rebuild critical sections on PyMutex with the stack kept as a tagged
pointer in ThreadSlot: single and two-mutex sections, recursive
top-most skipping, locking skipped while the world is stopped,
SuspendAll on detach/suspend/shutdown and Resume of the top-most
section on attach. Fork carries the stacks into the replacement slots.

Assisted-by: Claude Code:claude-opus-5-5

* Check attachment around critical-section suspension

Assert that a thread entering a critical section is attached, and
suspend sections in do_suspend only while the slot is still ATTACHED.

Assisted-by: Claude Code:claude-opus-5-5

---------

Co-authored-by: Jeong YunWon <jeong@youknowone.org>
2026-10-21 19:57:21 +09:00

102 lines
3.2 KiB
TOML

[package]
name = "rustpython-vm"
description = "RustPython virtual machine."
include = ["src/**/*.rs", "Cargo.toml", "build.rs", "Lib/**/*.py"]
version.workspace = true
authors.workspace = true
edition.workspace = true
rust-version.workspace = true
repository.workspace = true
license.workspace = true
[features]
default = ["compiler", "wasmbind", "gc", "host_env", "stdio", "doc"]
doc = ["dep:rustpython-doc", "dep:xz"]
host_env = ["rustpython-host_env/ctypes"]
stdio = []
importlib = []
encodings = ["importlib"]
vm-tracing-logging = []
opcode-histogram = []
flame-it = ["flame", "flamer"]
freeze-stdlib = ["encodings"]
jit = ["rustpython-jit"]
threading = ["rustpython-common/threading", "dep:parking_lot_core"]
gc = []
compiler = ["parser", "codegen", "rustpython-compiler"]
ast = ["ruff_python_ast", "ruff_text_size"]
codegen = ["rustpython-codegen", "ast"]
parser = ["ast"]
serde = ["dep:serde"]
wasmbind = ["rustpython-common/wasm_js", "jiff/js", "wasm-bindgen"]
[dependencies]
rustpython-compiler = { workspace = true, optional = true }
rustpython-codegen = { workspace = true, optional = true }
rustpython-common = { workspace = true }
rustpython-doc = { workspace = true, optional = true }
rustpython-derive = { workspace = true }
rustpython-host_env = { workspace = true }
rustpython-jit = { workspace = true, optional = true }
ruff_python_ast = { workspace = true, optional = true }
ruff_python_parser = { workspace = true }
ruff_text_size = { workspace = true, optional = true }
rustpython-compiler-core = { workspace = true }
rustpython-literal = { workspace = true }
rustpython-sre_engine = { workspace = true }
rustpython-unicode = { workspace = true }
ascii = { workspace = true }
bitflags = { workspace = true }
bitflagset = { workspace = true }
bstr = { workspace = true }
crossbeam-utils = { workspace = true }
constant_time_eq = { workspace = true }
flame = { workspace = true, optional = true }
hex = { workspace = true }
indexmap = { workspace = true }
itertools = { workspace = true }
itoa = { workspace = true }
is-macro = { workspace = true }
jiff = { workspace = true }
libc = { workspace = true }
log = { workspace = true }
malachite-bigint = { workspace = true }
num-complex = { workspace = true }
num-integer = { workspace = true }
num-traits = { workspace = true }
num_enum = { workspace = true }
parking_lot = { workspace = true }
parking_lot_core = { workspace = true, optional = true }
paste = { workspace = true }
rapidhash = { workspace = true }
scopeguard = { workspace = true }
serde = { workspace = true, optional = true }
static_assertions = { workspace = true }
xz = { workspace = true, optional = true }
strum = { workspace = true }
strum_macros = { workspace = true }
thiserror = { workspace = true }
thin-vec = { workspace = true }
memchr = { workspace = true }
flamer = { workspace = true, optional = true }
half = { workspace = true }
psm = { workspace = true }
optional = { workspace = true }
result-like = { workspace = true }
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
widestring = { workspace = true }
[target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dependencies]
wasm-bindgen = { workspace = true, optional = true }
[build-dependencies]
glob = { workspace = true }
jiff = { workspace = true }
[lints]
workspace = true