-
Notifications
You must be signed in to change notification settings - Fork 19
builtins, code objects, gc, and typing: CPython 3.14 surface completions #1332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
67ed7cb
8bb3291
36a78bf
91f073d
c822a4b
214d5bf
34dcef6
4c08e5b
4aa2b10
82aadbd
4ebc60b
8dcd670
83b5d58
59df56a
69b7688
e070bae
f202792
04a27d6
75f4f7b
c065b2e
039d32a
4eb8dcb
1843a14
2a07341
40226e6
1f2df22
1b7a881
f1047bd
5fd756d
5373475
fba6052
e88f1f7
e9c95a1
a949a73
4b55739
3fbea5c
b88887c
707db63
12a6d56
9a5f87b
9f6d5ab
dd4ebcd
2e06a84
0ddb6a9
0b4511f
4b6429a
d1c06c6
118390c
84cb8bd
b3a337a
16a8ca4
1a797b7
dc257e1
ae2c645
14a114a
b77dd00
7d6ba21
8b99f8f
c821b27
28a863a
f93b8c4
4f75905
6492d5e
13c7830
0d9b376
8a00051
29ebc25
8c33305
353ab16
bee98fe
3a9283a
1f39f8a
bfdb263
2fdbb92
ae327ed
7720413
3003b9d
406f892
45383b9
b1a34e4
3c5c768
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -55,8 +55,8 @@ function jitCallTrampoline(framePtr, callAreaOfs = CALL_RESULT_OFS) { | |
| } | ||
|
|
||
| export function jit_compile_wasm(bytesPtr, bytesLen) { | ||
| const trace = instantiateTrace(bytesPtr, bytesLen); | ||
| return registerTrace(trace); | ||
| const entries = instantiateTrace(bytesPtr, bytesLen); | ||
| return registerTrace(entries); | ||
| } | ||
|
|
||
| function instantiateTrace(bytesPtr, bytesLen) { | ||
|
|
@@ -74,16 +74,24 @@ function instantiateTrace(bytesPtr, bytesLen) { | |
| const instance = new WebAssembly.Instance(module, { | ||
| env: { memory: mainMemory, jit_call: jitCallTrampoline, jit_call_compact: jitCallTrampoline, __indirect_function_table: mainTable } | ||
| }); | ||
| return instance.exports.trace; | ||
| return traceEntries(instance); | ||
| } catch (e) { | ||
| // Retry without jit_call (for traces without CALL ops) | ||
| const instance = new WebAssembly.Instance(module, { | ||
| env: { memory: mainMemory } | ||
| }); | ||
| return instance.exports.trace; | ||
| return traceEntries(instance); | ||
| } | ||
| } | ||
|
|
||
| // A resumable peeled loop exports a fixed-arity `trace_wide` beside the narrow | ||
| // `trace` shim, and the backend publishes its table slot as `handle + 1`. Both | ||
| // hosts must therefore install the pair adjacently or that published slot names | ||
| // an unrelated trace. | ||
| function traceEntries(instance) { | ||
| return { trace: instance.exports.trace, wide: instance.exports.trace_wide }; | ||
| } | ||
|
|
||
| // Compile and instantiate a trace, then overwrite an existing shared-table | ||
| // slot. A caller already running the old function retains that invocation; | ||
| // later indirect calls use the replacement. | ||
|
|
@@ -92,11 +100,29 @@ export function jit_replace_wasm(funcId, bytesPtr, bytesLen) { | |
| if (!funcTable[funcId]) { | ||
| return 0; | ||
| } | ||
| const trace = instantiateTrace(bytesPtr, bytesLen); | ||
| const { trace, wide } = instantiateTrace(bytesPtr, bytesLen); | ||
| // Modules emitted while this slot was wide carry `call_indirect funcId + 1` | ||
| // baked in. A narrow replacement cannot retract those, so accepting one | ||
| // would leave the pair straddling two compiles: `funcId` on the new trace | ||
| // and `funcId + 1` still on the old. `funcTable` records the wide entry | ||
| // only when one existed, so it is the discriminator the shared table | ||
| // cannot be — its spare slot holds the narrow function either way. Reject | ||
| // the shape change before touching either table; narrow-to-wide stays | ||
| // allowed, mirroring the wasmtime host. | ||
| if (!wide && funcTable[funcId + 1] !== undefined) { | ||
| console.error('[jit_replace_wasm] refused: id', funcId, 'has a published wide entry the replacement does not'); | ||
| return 0; | ||
| } | ||
| if (mainTable) { | ||
| mainTable.set(funcId, trace); | ||
| if (wide) { | ||
| mainTable.set(funcId + 1, wide); | ||
| } | ||
| } | ||
| funcTable[funcId] = trace; | ||
| if (wide) { | ||
| funcTable[funcId + 1] = wide; | ||
| } | ||
| return funcId; | ||
| } catch (e) { | ||
| console.error('[jit_replace_wasm] failed:', e); | ||
|
|
@@ -108,15 +134,27 @@ export function jit_replace_wasm(funcId, bytesPtr, bytesLen) { | |
| // table slot as the id, mirroring the wasmtime host. The slot is both the | ||
| // jit_execute_wasm handle and the index an in-module call_indirect targets. | ||
| // Falls back to a private counter when no table is available. | ||
| function registerTrace(traceFn) { | ||
| function registerTrace(entries) { | ||
| const { trace, wide } = entries; | ||
| let id; | ||
| // The pair is appended even for a narrow module, mirroring the wasmtime | ||
| // host. An emitted module names its wide entry `id + 1`, and a later | ||
| // `jit_replace_wasm` may install one where this compile had none; without | ||
| // the reservation that write would land on the next trace's own entry. | ||
| if (mainTable) { | ||
| id = mainTable.grow(1); | ||
| mainTable.set(id, traceFn); | ||
| id = mainTable.grow(2, trace); | ||
| mainTable.set(id, trace); | ||
| if (wide) { | ||
| mainTable.set(id + 1, wide); | ||
| } | ||
| } else { | ||
| id = nextFuncId++; | ||
| id = nextFuncId; | ||
| nextFuncId += 2; | ||
| } | ||
| funcTable[id] = trace; | ||
| if (wide) { | ||
| funcTable[id + 1] = wide; | ||
|
Comment on lines
+154
to
+156
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When a browser/WebAssembly trace exports AGENTS.md reference: AGENTS.md:L66-L77 Useful? React with 👍 / 👎. |
||
| } | ||
| funcTable[id] = traceFn; | ||
| return id; | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.