Skip to content

[v24.x] deps: V8: backport d259a9e2ead7#63865

Open
GuillaumeLagrange wants to merge 1 commit into
nodejs:v24.x-stagingfrom
GuillaumeLagrange:maglev-srcpos-backport
Open

[v24.x] deps: V8: backport d259a9e2ead7#63865
GuillaumeLagrange wants to merge 1 commit into
nodejs:v24.x-stagingfrom
GuillaumeLagrange:maglev-srcpos-backport

Conversation

@GuillaumeLagrange

@GuillaumeLagrange GuillaumeLagrange commented Jun 12, 2026

Copy link
Copy Markdown

Backports v8/v8@d259a9e to the V8 13.6 tree.

Changes only impact when running with profiling enabled.

Fixes: #63816

Adaptation

One deviation from a straight cherry-pick: upstream adds collect_source_positions() to a single graph-labeller condition in MaglevCompiler::Compile. The 13.6 tree builds the labeller in a differently shaped block, so the condition is added separately. Noted inline.

Profiling with samply

samply record -- ./node \
  --perf-prof --interpreted-frames-native-stack \
  --detailed-line-info --no-enable-lazy-source-positions \
  your-script.js

Before this change, Maglev (+) frames resolve to a function name with no line detail. After, samples inside Maglev code map to their source lines and the inlined functions they came from.

Example

loop.js

When running this script, here's the before and after flamegraphs recorded with samply for convenience, but similar results can be achieved with perf + folding scripts.

Before

image

After

image

Original commit message:

    [maglev] Add source position collection

    This change adds support for collecting source positions in Maglev for
    profiling. It wires a SourcePositionTableBuilder through the code
    generator and uses the existing source positions from the graph
    labeller.

    Fixed: 436575053
    Change-Id: I64fa1e8829b036e498fa1d756c996716d16fb2a8
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/6897146
    Reviewed-by: Victor Gomes <victorgomes@chromium.org>
    Auto-Submit: Leszek Swirski <leszeks@chromium.org>
    Commit-Queue: Leszek Swirski <leszeks@chromium.org>
    Cr-Commit-Position: refs/heads/main@{#102119}

Before this change Maglev attached an empty source position table to its
generated Code objects (set_empty_source_position_table()). As a result,
when profiling with `--perf-prof --interpreted-frames-native-stack`
(linux perf / samply), Maglev-optimized frames carried no line/inlining
information in the jitdump, so inlined call chains were lost in the
resulting flamegraphs (baseline and TurboFan code were unaffected). This
backport restores per-pc source positions for Maglev code, matching V8
>= 15.x and newer Node.js.

The change is gated on collect_source_positions() (enabled by
--detailed-line-info / profiling); the steady-state generated machine
code is unchanged and there is no extra cost when not profiling.

Adaptations for V8 13.6 (node): the graph-labeller creation in
MaglevCompiler::Compile is added as a separate condition because node's
13.6 tree creates the labeller in a differently-shaped block than
upstream; the rest is a direct cherry-pick.

Refs: v8/v8@d259a9e
Fixes: nodejs#63816
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/gyp
  • @nodejs/security-wg
  • @nodejs/v8-update

@nodejs-github-bot nodejs-github-bot added build Issues and PRs related to build files or the CI. needs-ci PRs that need a full CI run. v24.x Issues that can be reproduced on v24.x or PRs targeting the v24.x-staging branch. v8 engine Issues and PRs related to the V8 dependency. labels Jun 12, 2026
@aduh95 aduh95 changed the base branch from v24.x to v24.x-staging June 12, 2026 08:21
@aduh95 aduh95 changed the title deps: V8: backport d259a9e2ead7 [v24.x] deps: V8: backport d259a9e2ead7 Jun 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build Issues and PRs related to build files or the CI. needs-ci PRs that need a full CI run. v8 engine Issues and PRs related to the V8 dependency. v24.x Issues that can be reproduced on v24.x or PRs targeting the v24.x-staging branch.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants