[turbolev] Add pre-pass to escape analysis [v8/v8 : main]

0 views
Skip to first unread message

Darius Mercadier (Gerrit)

unread,
Jul 23, 2026, 8:32:08 AM (2 days ago) Jul 23
to Victor Gomes, chrom...@appspot.gserviceaccount.com, android-bu...@system.gserviceaccount.com, v8-s...@luci-project-accounts.iam.gserviceaccount.com, dmercadi...@chromium.org, leszek...@chromium.org, v8-re...@googlegroups.com, verwaes...@chromium.org, victorgo...@chromium.org
Attention needed from Victor Gomes

Darius Mercadier voted and added 1 comment

Votes added by Darius Mercadier

Auto-Submit+1

1 comment

Patchset-level comments
File-level comment, Patchset 10:
Darius Mercadier . resolved

PTAL! :)

Open in Gerrit

Related details

Attention is currently required from:
  • Victor Gomes
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: v8/v8
Gerrit-Branch: main
Gerrit-Change-Id: I7080ce0a6c3a9ed2d3b24bfa4b3ee420374eb5d0
Gerrit-Change-Number: 8137540
Gerrit-PatchSet: 11
Gerrit-Owner: Darius Mercadier <dmerc...@chromium.org>
Gerrit-Reviewer: Darius Mercadier <dmerc...@chromium.org>
Gerrit-Reviewer: Victor Gomes <victo...@chromium.org>
Gerrit-Attention: Victor Gomes <victo...@chromium.org>
Gerrit-Comment-Date: Thu, 23 Jul 2026 12:32:02 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Victor Gomes (Gerrit)

unread,
Jul 23, 2026, 8:48:34 AM (2 days ago) Jul 23
to Darius Mercadier, chrom...@appspot.gserviceaccount.com, android-bu...@system.gserviceaccount.com, v8-s...@luci-project-accounts.iam.gserviceaccount.com, dmercadi...@chromium.org, leszek...@chromium.org, v8-re...@googlegroups.com, verwaes...@chromium.org, victorgo...@chromium.org
Attention needed from Darius Mercadier

Victor Gomes added 4 comments

File src/maglev/turbolev-escape-analysis.h
Line 129, Patchset 11 (Latest): bool has_exception_handler = false;
Victor Gomes . unresolved

This could be computed during graph building. As soon as we create an excetion block, we could mark this (if we move it to MaglevGraph)

Line 37, Patchset 11 (Latest):// # Implementation
//
// Escape Analysis happens in 2 phases:
//
// * `CandidateAnalyzer` looks at the graph, computes which objects are
// escaping, and decides which objects to elide. It also computes the value
// of every field of elided objects at a given point of the program.
//
// * `Elider` actually removes the objects from the graph and update the nodes
// that reference them (in particular Stores and Loads, since those objects
// are guaranteed to not escape the current function).
//
//
// More implementation details & choices can be found in the design doc (linked
// at the top of the file).
Victor Gomes . unresolved

I guess you need to update that?

File src/maglev/turbolev-escape-analysis.cc
Line 561, Patchset 11 (Latest): data_.candidates[alloc] = CandidateStatus::kCannotElide;
if (!alloc->HasBeenAnalysed()) {
alloc->SetEscaped();
} else {
DCHECK(alloc->HasEscaped());
}
Victor Gomes . unresolved

Idea for follow up: You could re-use HasEscaped bit in alloc if you want, instead of data_.candidates. Or add a new field in InlinedAllocations. This removes the data_.candidates completely, right?

This would make this processor completely detach from the rest of the escape analysis and we can put it in any place we want in the pipeline.

Line 1376, Patchset 11 (Latest): GraphProcessor<AnalyzerPrePass> prepass(data_);
prepass.ProcessGraph(data_.graph);
Victor Gomes . unresolved

Add a TODO, we could run the processor together with the previous pass (like together with an optimizer pass), since it is quite simple. It depends where we put the escape analysis in the end.

Open in Gerrit

Related details

Attention is currently required from:
  • Darius Mercadier
Submit Requirements:
    • requirement satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: v8/v8
    Gerrit-Branch: main
    Gerrit-Change-Id: I7080ce0a6c3a9ed2d3b24bfa4b3ee420374eb5d0
    Gerrit-Change-Number: 8137540
    Gerrit-PatchSet: 11
    Gerrit-Owner: Darius Mercadier <dmerc...@chromium.org>
    Gerrit-Reviewer: Darius Mercadier <dmerc...@chromium.org>
    Gerrit-Reviewer: Victor Gomes <victo...@chromium.org>
    Gerrit-Attention: Darius Mercadier <dmerc...@chromium.org>
    Gerrit-Comment-Date: Thu, 23 Jul 2026 12:48:29 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Darius Mercadier (Gerrit)

    unread,
    Jul 23, 2026, 10:47:02 AM (2 days ago) Jul 23
    to Victor Gomes, chrom...@appspot.gserviceaccount.com, android-bu...@system.gserviceaccount.com, v8-s...@luci-project-accounts.iam.gserviceaccount.com, dmercadi...@chromium.org, leszek...@chromium.org, v8-re...@googlegroups.com, verwaes...@chromium.org, victorgo...@chromium.org
    Attention needed from Victor Gomes

    Darius Mercadier added 4 comments

    File src/maglev/turbolev-escape-analysis.h
    Line 129, Patchset 11 (Latest): bool has_exception_handler = false;
    Victor Gomes . resolved

    This could be computed during graph building. As soon as we create an excetion block, we could mark this (if we move it to MaglevGraph)

    Darius Mercadier

    Exception handlers can become unreachable in which case they shouldn't block escape analysis. I guess that once we move the prepass to the previous phase it won't matter anyways that we recompute this since it's very cheap.

    (also, exception handlers blocking escape analysis should really be a very temporary state that I'm planning on fixing some times soon... although I'm not sure that "soon" is "this year" 😄)

    Line 37, Patchset 11 (Latest):// # Implementation
    //
    // Escape Analysis happens in 2 phases:
    //
    // * `CandidateAnalyzer` looks at the graph, computes which objects are
    // escaping, and decides which objects to elide. It also computes the value
    // of every field of elided objects at a given point of the program.
    //
    // * `Elider` actually removes the objects from the graph and update the nodes
    // that reference them (in particular Stores and Loads, since those objects
    // are guaranteed to not escape the current function).
    //
    //
    // More implementation details & choices can be found in the design doc (linked
    // at the top of the file).
    Victor Gomes . resolved

    I guess you need to update that?

    Darius Mercadier

    Done

    (and updated the doc and added the performance numbers to the doc)

    File src/maglev/turbolev-escape-analysis.cc
    Line 561, Patchset 11 (Latest): data_.candidates[alloc] = CandidateStatus::kCannotElide;
    if (!alloc->HasBeenAnalysed()) {
    alloc->SetEscaped();
    } else {
    DCHECK(alloc->HasEscaped());
    }
    Victor Gomes . resolved

    Idea for follow up: You could re-use HasEscaped bit in alloc if you want, instead of data_.candidates. Or add a new field in InlinedAllocations. This removes the data_.candidates completely, right?

    This would make this processor completely detach from the rest of the escape analysis and we can put it in any place we want in the pipeline.

    Darius Mercadier

    Yes good idea. For the prepass this could remove candidates indeed. For the main analysis, eventually I'm considering making candidates a SnapshotTable so that I can do allocation sinking, so I'd still need it. But that's far away.

    I've incorporated this in the new TODO that you recommended below.

    Line 1376, Patchset 11 (Latest): GraphProcessor<AnalyzerPrePass> prepass(data_);
    prepass.ProcessGraph(data_.graph);
    Victor Gomes . resolved

    Add a TODO, we could run the processor together with the previous pass (like together with an optimizer pass), since it is quite simple. It depends where we put the escape analysis in the end.

    Darius Mercadier

    Done

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Victor Gomes
    Submit Requirements:
      • requirement satisfiedCode-Owners
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: v8/v8
      Gerrit-Branch: main
      Gerrit-Change-Id: I7080ce0a6c3a9ed2d3b24bfa4b3ee420374eb5d0
      Gerrit-Change-Number: 8137540
      Gerrit-PatchSet: 11
      Gerrit-Owner: Darius Mercadier <dmerc...@chromium.org>
      Gerrit-Reviewer: Darius Mercadier <dmerc...@chromium.org>
      Gerrit-Reviewer: Victor Gomes <victo...@chromium.org>
      Gerrit-Attention: Victor Gomes <victo...@chromium.org>
      Gerrit-Comment-Date: Thu, 23 Jul 2026 14:46:56 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: Victor Gomes <victo...@chromium.org>
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Victor Gomes (Gerrit)

      unread,
      Jul 24, 2026, 3:51:57 AM (yesterday) Jul 24
      to Darius Mercadier, chrom...@appspot.gserviceaccount.com, android-bu...@system.gserviceaccount.com, v8-s...@luci-project-accounts.iam.gserviceaccount.com, dmercadi...@chromium.org, leszek...@chromium.org, v8-re...@googlegroups.com, verwaes...@chromium.org, victorgo...@chromium.org
      Attention needed from Darius Mercadier

      Victor Gomes voted and added 1 comment

      Votes added by Victor Gomes

      Code-Review+1
      Commit-Queue+2

      1 comment

      Patchset-level comments
      File-level comment, Patchset 12 (Latest):
      Victor Gomes . resolved

      LGTM!

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Darius Mercadier
      Submit Requirements:
      • requirement satisfiedCode-Owners
      • requirement satisfiedCode-Review
      • requirement satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: v8/v8
      Gerrit-Branch: main
      Gerrit-Change-Id: I7080ce0a6c3a9ed2d3b24bfa4b3ee420374eb5d0
      Gerrit-Change-Number: 8137540
      Gerrit-PatchSet: 12
      Gerrit-Attention: Darius Mercadier <dmerc...@chromium.org>
      Gerrit-Comment-Date: Fri, 24 Jul 2026 07:51:51 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: Yes
      satisfied_requirement
      open
      diffy

      v8-scoped@luci-project-accounts.iam.gserviceaccount.com (Gerrit)

      unread,
      Jul 24, 2026, 3:53:54 AM (yesterday) Jul 24
      to Darius Mercadier, Victor Gomes, chrom...@appspot.gserviceaccount.com, android-bu...@system.gserviceaccount.com, dmercadi...@chromium.org, leszek...@chromium.org, v8-re...@googlegroups.com, verwaes...@chromium.org, victorgo...@chromium.org

      v8-s...@luci-project-accounts.iam.gserviceaccount.com submitted the change

      Change information

      Commit message:
      [turbolev] Add pre-pass to escape analysis

      This CL adds a very quick pre-pass to escape analysis that allows to
      not run the expensive analysis for cases where all allocations
      eventually escape.

      This reduces the time that we spend in escape analysis by 1.34x on
      average on JetStream3, and the average improvement on JS3 line items
      is 2.03x and the median 1.46x (talking about time spent in escape
      analysis again, not about score!). In terms of raw data, on my
      workstation this saves about 60ms of compile time on JS3.
      Bug: 529841774
      Change-Id: I7080ce0a6c3a9ed2d3b24bfa4b3ee420374eb5d0
      Auto-Submit: Darius Mercadier <dmerc...@chromium.org>
      Commit-Queue: Victor Gomes <victo...@chromium.org>
      Reviewed-by: Victor Gomes <victo...@chromium.org>
      Cr-Commit-Position: refs/heads/main@{#108856}
      Files:
      • M src/maglev/turbolev-escape-analysis.cc
      • M src/maglev/turbolev-escape-analysis.h
      Change size: M
      Delta: 2 files changed, 163 insertions(+), 27 deletions(-)
      Branch: refs/heads/main
      Submit Requirements:
      • requirement satisfiedCode-Review: +1 by Victor Gomes
      Open in Gerrit
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: merged
      Gerrit-Project: v8/v8
      Gerrit-Branch: main
      Gerrit-Change-Id: I7080ce0a6c3a9ed2d3b24bfa4b3ee420374eb5d0
      Gerrit-Change-Number: 8137540
      Gerrit-PatchSet: 13
      Gerrit-Owner: Darius Mercadier <dmerc...@chromium.org>
      Gerrit-Reviewer: Darius Mercadier <dmerc...@chromium.org>
      Gerrit-Reviewer: Victor Gomes <victo...@chromium.org>
      open
      diffy
      satisfied_requirement
      Reply all
      Reply to author
      Forward
      0 new messages