Repository navigation
Fix JITted context tagging - #8862
Conversation
There was a problem hiding this comment.
Superseded by the review of
d3533f2b.
This review, of 09ebc2d1
💬 Approved with comments — No blocking or warning-level defects. There is one question about the new root's placement for debug builds and one informational note about the cost of invalidating the PromiseHook protector.
Findings: 1 question · 1 info (1 is an inline comment on the diff)
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
📋 Code Quality: ❓ 1 question
The patches are internally consistent. One question about how the new mutable root is set.
Recommendation: 💬 Optional Nits
- [QUESTION] Please confirm that the new
PromiseContextTagroot sits in a movable mutable root list, soHeap::set_promise_context_tagcan be called after deserialization (on everyPromiseContextScopeentry) and can hold a young-generation object without tripping a debug-build DCHECK. (patches/v8/2023-06-22-Implement-Promise-Context-Tagging.patch:479)
View full review
- The
indexline chain across the six patches is consistent. - Moving the tag into
PromiseInit,InnerNewJSPromiseandFactory::NewJSPromiseWithoutHookcovers the promise creation paths in the patch. NeedsPromiseContextSwitchmatches the runtime andJSPromise::Fulfill/Rejectsemantics.- One question:
PromiseContextTagis a mutable root, andPromiseContextScopewrites it on every scope entry after deserialization has finished. Please confirm it sits in a root list whose setter allows that, so debug builds do not hit a DCHECK.
⚡ Performance: 💬 1 info
Invalidating the protector turns off inline promise allocation in optimized code for every isolate that sets the callback. The builtin changes are a net improvement.
Recommendation: 💬 Optional Nits
- [INFO] Setting the cross-context callback invalidates the PromiseHook protector, which turns off inline promise allocation (and other fast paths that depend on the protector) in Maglev and TurboFan for every Worker isolate. (
patches/v8/2023-06-22-Implement-Promise-Context-Tagging.patch:258)
View full review
- Builtins now copy and compare the tag inline and call the runtime only when the tags differ. That removes the per-promise
PromiseContextInitandPromiseResolveContextCheckruntime calls from the hot path. - The trade-off:
set_promise_cross_context_callbackinvalidates the PromiseHook protector. workerd installs that callback in every Worker isolate, so Maglev and TurboFan never allocate promises inline there. This cost is required for correctness.
✅ All other checks passed
🔒 Security: ✅ LGTM
No security concerns in the reworked promise context tagging patches.
📖 AGENTS.md: ✅ LGTM
No AGENTS.md updates are needed.
📝 Documentation: ✅ LGTM
The patch commit message describes the new behaviour accurately.
Reviewed commit: 09ebc2d1
Make promise context tagging work in JITted code. Every promise now records the PromiseContextTag root, which is the hole outside any PromiseContextScope; builtins copy and compare the tag inline and call the runtime only when the tags differ. Optimized code allocates promises inline while the PromiseHook protector holds, so setting the cross-context callback invalidates the protector. The root-based tag moves from the cross-request resolve patch into the context tagging patch, and the resolve patch drops its PromiseResolveContextCheck runtime call in favor of the inline check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
09ebc2d to
d3533f2
Compare
There was a problem hiding this comment.
💬 Approved with comments — No blocking or warning-level defects. There is one question about the new root's placement for debug builds and one informational note about the cost of invalidating the PromiseHook protector.
Findings: 1 question · 1 info
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
📋 Code Quality: ❓ 1 question
The patches are internally consistent. One question about how the new mutable root is set.
Recommendation: 💬 Optional Nits
- [QUESTION] Please confirm that the new
PromiseContextTagroot sits in a movable mutable root list, soHeap::set_promise_context_tagcan be called after deserialization (on everyPromiseContextScopeentry) and can hold a young-generation object without tripping a debug-build DCHECK. (patches/v8/2023-06-22-Implement-Promise-Context-Tagging.patch:479)
View full review
- The
indexline chain across the six patches is consistent. - Moving the tag into
PromiseInit,InnerNewJSPromiseandFactory::NewJSPromiseWithoutHookcovers the promise creation paths in the patch. NeedsPromiseContextSwitchmatches the runtime andJSPromise::Fulfill/Rejectsemantics.- One question:
PromiseContextTagis a mutable root, andPromiseContextScopewrites it on every scope entry after deserialization has finished. Please confirm it sits in a root list whose setter allows that, so debug builds do not hit a DCHECK.
⚡ Performance: 💬 1 info
Invalidating the protector turns off inline promise allocation in optimized code for every isolate that sets the callback. The builtin changes are a net improvement.
Recommendation: 💬 Optional Nits
- [INFO] Setting the cross-context callback invalidates the PromiseHook protector, which turns off inline promise allocation (and other fast paths that depend on the protector) in Maglev and TurboFan for every Worker isolate. (
patches/v8/2023-06-22-Implement-Promise-Context-Tagging.patch:258)
View full review
- Builtins now copy and compare the tag inline and call the runtime only when the tags differ. That removes the per-promise
PromiseContextInitandPromiseResolveContextCheckruntime calls from the hot path. - The trade-off:
set_promise_cross_context_callbackinvalidates the PromiseHook protector. workerd installs that callback in every Worker isolate, so Maglev and TurboFan never allocate promises inline there. This cost is required for correctness.
✅ All other checks passed
🔒 Security: ✅ LGTM
No security concerns in the reworked promise context tagging patches.
📖 AGENTS.md: ✅ LGTM
No AGENTS.md updates are needed.
📝 Documentation: ✅ LGTM
The patch commit message describes the new behaviour accurately.
Reviewed commit: d3533f2b — same changes as 09ebc2d1, so this is that commit's review (no new review was run; line numbers are as of 09ebc2d1)
Make promise context tagging work in JITted code.
Every promise now records the
PromiseContextTagroot, which is the hole outside anyPromiseContextScope. Builtins copy and compare the tag inline and call the runtime only when the tags differ. Optimized code (Maglev and TurboFan) allocates promises inline while the PromiseHook protector holds, without tagging them, so setting the cross-context callback now invalidates the protector.Patch changes:
Implement-Promise-Context-Tagging: the tag moves into a root, the default tag is the hole instead of Smi 0, tag checks happen inline in builtins, and aPromiseContextTagTestunittest is added.Implement-cross-request-context-promise-resolve-handling: the root move now lives in the patch above, and thePromiseResolveContextCheckruntime call is replaced by the inlineNeedsPromiseContextSwitchcheck.indexlines.This mirrors the same fix in internal V8 patches.
🤖 Generated with Claude Code