[wasm] Load allocation space top and limit via root register [v8/v8 : main]

0 views
Skip to first unread message

Clemens Backes (Gerrit)

unread,
Sep 4, 2025, 4:23:29 AM (3 days ago) Sep 4
to Dominik Inführ, V8 LUCI CQ, Matthias Liedtke, Hannes Payer, dmercadi...@chromium.org, mlippau...@chromium.org, v8-re...@googlegroups.com, was...@google.com
Attention needed from Dominik Inführ and Matthias Liedtke

Clemens Backes added 1 comment

Patchset-level comments
File-level comment, Patchset 1 (Latest):
Clemens Backes . resolved

Matthias and Dominik, PTAL.
Matthias for wasm and compiler, Dominik for heap.

I think we can also do some follow-up cleanup to completely remove the external references for new/old top and limit. I'm working on that.

Open in Gerrit

Related details

Attention is currently required from:
  • Dominik Inführ
  • Matthias Liedtke
Submit Requirements:
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
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: Idf3940ddc3f8538f65ae9d1add2cc0c0ad672fa2
Gerrit-Change-Number: 6909719
Gerrit-PatchSet: 1
Gerrit-Owner: Clemens Backes <clem...@chromium.org>
Gerrit-Reviewer: Clemens Backes <clem...@chromium.org>
Gerrit-Reviewer: Dominik Inführ <dinf...@chromium.org>
Gerrit-Reviewer: Matthias Liedtke <mlie...@chromium.org>
Gerrit-CC: Hannes Payer <hpa...@chromium.org>
Gerrit-Attention: Dominik Inführ <dinf...@chromium.org>
Gerrit-Attention: Matthias Liedtke <mlie...@chromium.org>
Gerrit-Comment-Date: Thu, 04 Sep 2025 08:23:23 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
unsatisfied_requirement
open
diffy

Darius Mercadier (Gerrit)

unread,
Sep 4, 2025, 4:33:10 AM (3 days ago) Sep 4
to Clemens Backes, Dominik Inführ, V8 LUCI CQ, Matthias Liedtke, Hannes Payer, dmercadi...@chromium.org, mlippau...@chromium.org, v8-re...@googlegroups.com, was...@google.com
Attention needed from Clemens Backes, Dominik Inführ and Matthias Liedtke

Darius Mercadier added 2 comments

File src/compiler/turboshaft/memory-optimization-reducer.h
Line 538, Patchset 1 (Parent): limit_address = __ ExternalConstant(
type == AllocationType::kYoung
? ExternalReference::new_space_allocation_limit_address(isolate_)
: ExternalReference::old_space_allocation_limit_address(
isolate_));
Darius Mercadier . unresolved

same

Line 256, Patchset 1 (Parent): top_address = __ ExternalConstant(
type == AllocationType::kYoung
? ExternalReference::new_space_allocation_top_address(isolate_)
: ExternalReference::old_space_allocation_top_address(isolate_));
Darius Mercadier . unresolved

I would keep this for JS since it requires one less addition than the Wasm version.

Open in Gerrit

Related details

Attention is currently required from:
  • Clemens Backes
  • Dominik Inführ
  • Matthias Liedtke
Submit Requirements:
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    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: Idf3940ddc3f8538f65ae9d1add2cc0c0ad672fa2
    Gerrit-Change-Number: 6909719
    Gerrit-PatchSet: 1
    Gerrit-Owner: Clemens Backes <clem...@chromium.org>
    Gerrit-Reviewer: Clemens Backes <clem...@chromium.org>
    Gerrit-Reviewer: Dominik Inführ <dinf...@chromium.org>
    Gerrit-Reviewer: Matthias Liedtke <mlie...@chromium.org>
    Gerrit-CC: Darius Mercadier <dmerc...@chromium.org>
    Gerrit-CC: Hannes Payer <hpa...@chromium.org>
    Gerrit-Attention: Clemens Backes <clem...@chromium.org>
    Gerrit-Attention: Dominik Inführ <dinf...@chromium.org>
    Gerrit-Attention: Matthias Liedtke <mlie...@chromium.org>
    Gerrit-Comment-Date: Thu, 04 Sep 2025 08:33:06 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    unsatisfied_requirement
    open
    diffy

    Clemens Backes (Gerrit)

    unread,
    Sep 4, 2025, 4:57:45 AM (3 days ago) Sep 4
    to Darius Mercadier, Dominik Inführ, V8 LUCI CQ, Matthias Liedtke, Hannes Payer, dmercadi...@chromium.org, mlippau...@chromium.org, v8-re...@googlegroups.com, was...@google.com
    Attention needed from Darius Mercadier, Dominik Inführ and Matthias Liedtke

    Clemens Backes added 1 comment

    File src/compiler/turboshaft/memory-optimization-reducer.h
    Line 256, Patchset 1 (Parent): top_address = __ ExternalConstant(
    type == AllocationType::kYoung
    ? ExternalReference::new_space_allocation_top_address(isolate_)
    : ExternalReference::old_space_allocation_top_address(isolate_));
    Darius Mercadier . unresolved

    I would keep this for JS since it requires one less addition than the Wasm version.

    Clemens Backes

    I was assuming that that would be folded away by a following step. In the end, it's "(kRootRegister + offset1) + offset2".
    If not, we can also split the existing isolate fields in three, for the three pointers they contain. Then we can address each one directly.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Darius Mercadier
    • Dominik Inführ
    • Matthias Liedtke
    Submit Requirements:
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    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: Idf3940ddc3f8538f65ae9d1add2cc0c0ad672fa2
    Gerrit-Change-Number: 6909719
    Gerrit-PatchSet: 1
    Gerrit-Owner: Clemens Backes <clem...@chromium.org>
    Gerrit-Reviewer: Clemens Backes <clem...@chromium.org>
    Gerrit-Reviewer: Dominik Inführ <dinf...@chromium.org>
    Gerrit-Reviewer: Matthias Liedtke <mlie...@chromium.org>
    Gerrit-CC: Darius Mercadier <dmerc...@chromium.org>
    Gerrit-CC: Hannes Payer <hpa...@chromium.org>
    Gerrit-Attention: Dominik Inführ <dinf...@chromium.org>
    Gerrit-Attention: Matthias Liedtke <mlie...@chromium.org>
    Gerrit-Attention: Darius Mercadier <dmerc...@chromium.org>
    Gerrit-Comment-Date: Thu, 04 Sep 2025 08:57:40 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Darius Mercadier <dmerc...@chromium.org>
    unsatisfied_requirement
    open
    diffy

    Matthias Liedtke (Gerrit)

    unread,
    Sep 4, 2025, 5:05:01 AM (3 days ago) Sep 4
    to Clemens Backes, Darius Mercadier, Dominik Inführ, V8 LUCI CQ, Hannes Payer, dmercadi...@chromium.org, mlippau...@chromium.org, v8-re...@googlegroups.com, was...@google.com
    Attention needed from Darius Mercadier and Dominik Inführ

    Matthias Liedtke added 1 comment

    File src/heap/linear-allocation-area.h
    Line 98, Patchset 1 (Latest): static constexpr int kLimitOffset = 2 * kSystemPointerSize;
    Matthias Liedtke . unresolved

    Wouldn't it be much nicer to make them `static const` and define them out of line using `offsetof` removing the need for the `CheckOffsets` and the manual offset calculation?
    We shouldn't need the `constexpr`-ness of these values.
    https://godbolt.org/z/ofsf55T49

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Darius Mercadier
    • Dominik Inführ
    Submit Requirements:
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    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: Idf3940ddc3f8538f65ae9d1add2cc0c0ad672fa2
    Gerrit-Change-Number: 6909719
    Gerrit-PatchSet: 1
    Gerrit-Owner: Clemens Backes <clem...@chromium.org>
    Gerrit-Reviewer: Clemens Backes <clem...@chromium.org>
    Gerrit-Reviewer: Dominik Inführ <dinf...@chromium.org>
    Gerrit-Reviewer: Matthias Liedtke <mlie...@chromium.org>
    Gerrit-CC: Darius Mercadier <dmerc...@chromium.org>
    Gerrit-CC: Hannes Payer <hpa...@chromium.org>
    Gerrit-Attention: Dominik Inführ <dinf...@chromium.org>
    Gerrit-Attention: Darius Mercadier <dmerc...@chromium.org>
    Gerrit-Comment-Date: Thu, 04 Sep 2025 09:04:56 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    unsatisfied_requirement
    open
    diffy

    Darius Mercadier (Gerrit)

    unread,
    Sep 4, 2025, 5:11:35 AM (3 days ago) Sep 4
    to Clemens Backes, Dominik Inführ, V8 LUCI CQ, Matthias Liedtke, Hannes Payer, dmercadi...@chromium.org, mlippau...@chromium.org, v8-re...@googlegroups.com, was...@google.com
    Attention needed from Clemens Backes and Dominik Inführ

    Darius Mercadier added 2 comments

    File src/compiler/turboshaft/memory-optimization-reducer.h
    Line 538, Patchset 1 (Parent): limit_address = __ ExternalConstant(
    type == AllocationType::kYoung

    ? ExternalReference::new_space_allocation_limit_address(isolate_)
    : ExternalReference::old_space_allocation_limit_address(
    isolate_));
    Darius Mercadier . resolved

    same

    Darius Mercadier

    As discussed above: all good.

    Line 256, Patchset 1 (Parent): top_address = __ ExternalConstant(
    type == AllocationType::kYoung
    ? ExternalReference::new_space_allocation_top_address(isolate_)
    : ExternalReference::old_space_allocation_top_address(isolate_));
    Darius Mercadier . resolved

    I would keep this for JS since it requires one less addition than the Wasm version.

    Clemens Backes

    I was assuming that that would be folded away by a following step. In the end, it's "(kRootRegister + offset1) + offset2".
    If not, we can also split the existing isolate fields in three, for the three pointers they contain. Then we can address each one directly.

    Darius Mercadier

    Mmmh, indeed, the instruction selector will fold this if everything goes well. I'm wondering if we have instruction selector unit tests for this folding; if we don't, then we should (but no need to do it in this CL).

    Ignore my initial comment then :)

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Clemens Backes
    • Dominik Inführ
    Submit Requirements:
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    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: Idf3940ddc3f8538f65ae9d1add2cc0c0ad672fa2
    Gerrit-Change-Number: 6909719
    Gerrit-PatchSet: 1
    Gerrit-Owner: Clemens Backes <clem...@chromium.org>
    Gerrit-Reviewer: Clemens Backes <clem...@chromium.org>
    Gerrit-Reviewer: Dominik Inführ <dinf...@chromium.org>
    Gerrit-Reviewer: Matthias Liedtke <mlie...@chromium.org>
    Gerrit-CC: Darius Mercadier <dmerc...@chromium.org>
    Gerrit-CC: Hannes Payer <hpa...@chromium.org>
    Gerrit-Attention: Clemens Backes <clem...@chromium.org>
    Gerrit-Attention: Dominik Inführ <dinf...@chromium.org>
    Gerrit-Comment-Date: Thu, 04 Sep 2025 09:11:30 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Clemens Backes <clem...@chromium.org>
    Comment-In-Reply-To: Darius Mercadier <dmerc...@chromium.org>
    unsatisfied_requirement
    open
    diffy

    Dominik Inführ (Gerrit)

    unread,
    Sep 4, 2025, 5:33:35 AM (3 days ago) Sep 4
    to Clemens Backes, Darius Mercadier, V8 LUCI CQ, Matthias Liedtke, Hannes Payer, dmercadi...@chromium.org, mlippau...@chromium.org, v8-re...@googlegroups.com, was...@google.com
    Attention needed from Clemens Backes

    Dominik Inführ voted and added 2 comments

    Votes added by Dominik Inführ

    Code-Review+1

    2 comments

    Patchset-level comments
    Dominik Inführ . resolved

    Cool, thanks a lot! LGTM

    File src/heap/linear-allocation-area.h
    Line 111, Patchset 1 (Latest): // Defined as a (static) class method, but outside the class, so we an verify
    Dominik Inführ . unresolved

    Nit: Can

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Clemens Backes
    Submit Requirements:
      • requirement is not satisfiedCode-Owners
      • requirement satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      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: Idf3940ddc3f8538f65ae9d1add2cc0c0ad672fa2
      Gerrit-Change-Number: 6909719
      Gerrit-PatchSet: 1
      Gerrit-Owner: Clemens Backes <clem...@chromium.org>
      Gerrit-Reviewer: Clemens Backes <clem...@chromium.org>
      Gerrit-Reviewer: Dominik Inführ <dinf...@chromium.org>
      Gerrit-Reviewer: Matthias Liedtke <mlie...@chromium.org>
      Gerrit-CC: Darius Mercadier <dmerc...@chromium.org>
      Gerrit-CC: Hannes Payer <hpa...@chromium.org>
      Gerrit-Attention: Clemens Backes <clem...@chromium.org>
      Gerrit-Comment-Date: Thu, 04 Sep 2025 09:33:31 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: Yes
      unsatisfied_requirement
      satisfied_requirement
      open
      diffy

      Clemens Backes (Gerrit)

      unread,
      Sep 4, 2025, 7:30:52 AM (3 days ago) Sep 4
      to Dominik Inführ, Darius Mercadier, V8 LUCI CQ, Matthias Liedtke, Hannes Payer, dmercadi...@chromium.org, mlippau...@chromium.org, v8-re...@googlegroups.com, was...@google.com
      Attention needed from Matthias Liedtke

      Clemens Backes added 2 comments

      File src/heap/linear-allocation-area.h
      Line 111, Patchset 1: // Defined as a (static) class method, but outside the class, so we an verify
      Dominik Inführ . resolved

      Nit: Can

      Clemens Backes

      Obsolete (code is removed now).

      Line 98, Patchset 1: static constexpr int kLimitOffset = 2 * kSystemPointerSize;
      Matthias Liedtke . unresolved

      Wouldn't it be much nicer to make them `static const` and define them out of line using `offsetof` removing the need for the `CheckOffsets` and the manual offset calculation?
      We shouldn't need the `constexpr`-ness of these values.
      https://godbolt.org/z/ofsf55T49

      Clemens Backes

      If we can make them `constexpr`, I would prefer that. It's also nice to write out the value explicitly, so it's easier to match that against generated code.

      I moved the validation to the existing `Verify` method; turns out that you can call `offsetof` inside the class definition, just not outside of method bodies...

      Is that acceptable to you?

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Matthias Liedtke
      Submit Requirements:
      • requirement is not satisfiedCode-Owners
      • requirement satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      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: Idf3940ddc3f8538f65ae9d1add2cc0c0ad672fa2
      Gerrit-Change-Number: 6909719
      Gerrit-PatchSet: 1
      Gerrit-Owner: Clemens Backes <clem...@chromium.org>
      Gerrit-Reviewer: Clemens Backes <clem...@chromium.org>
      Gerrit-Reviewer: Matthias Liedtke <mlie...@chromium.org>
      Gerrit-CC: Darius Mercadier <dmerc...@chromium.org>
      Gerrit-CC: Dominik Inführ <dinf...@chromium.org>
      Gerrit-CC: Hannes Payer <hpa...@chromium.org>
      Gerrit-Attention: Matthias Liedtke <mlie...@chromium.org>
      Gerrit-Comment-Date: Thu, 04 Sep 2025 11:28:51 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: Dominik Inführ <dinf...@chromium.org>
      Comment-In-Reply-To: Matthias Liedtke <mlie...@chromium.org>
      unsatisfied_requirement
      satisfied_requirement
      open
      diffy

      Matthias Liedtke (Gerrit)

      unread,
      Sep 4, 2025, 7:59:36 AM (3 days ago) Sep 4
      to Clemens Backes, Dominik Inführ, Darius Mercadier, V8 LUCI CQ, Hannes Payer, dmercadi...@chromium.org, mlippau...@chromium.org, v8-re...@googlegroups.com, was...@google.com
      Attention needed from Clemens Backes

      Matthias Liedtke voted and added 2 comments

      Votes added by Matthias Liedtke

      Code-Review+1

      2 comments

      Patchset-level comments
      File-level comment, Patchset 2 (Latest):
      Matthias Liedtke . resolved

      +1, I don't want to block this on a disagreement on an implementation detail vs. the clear and major benefit that the refactoring provides. 😊

      File src/heap/linear-allocation-area.h
      Line 98, Patchset 1: static constexpr int kLimitOffset = 2 * kSystemPointerSize;
      Matthias Liedtke . unresolved

      Wouldn't it be much nicer to make them `static const` and define them out of line using `offsetof` removing the need for the `CheckOffsets` and the manual offset calculation?
      We shouldn't need the `constexpr`-ness of these values.
      https://godbolt.org/z/ofsf55T49

      Clemens Backes

      If we can make them `constexpr`, I would prefer that. It's also nice to write out the value explicitly, so it's easier to match that against generated code.

      I moved the validation to the existing `Verify` method; turns out that you can call `offsetof` inside the class definition, just not outside of method bodies...

      Is that acceptable to you?

      Matthias Liedtke

      Acceptable yes but I don't like it at all.

      We shouldn't manually calculate offsets and make assumptions on C++ object layout which (afaik) is mostly defined by the ABI and not even defined on a C++ language level.
      It also makes it annoying if we ever add members, reorder members etc. which would "just work" using `offsetof`.

      The differences between `static const` and `static constexpr` are negligible in most cases (you can still use it as template arguments, size of a c-array, ...), so there isn't much benefit of `constexpr` here.)

      In either case we should also add a `static_assert(std::is_standard_layout_v<LinearAllocationArea>);` to ensure that `offsetof` is well-defined.

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Clemens Backes
      Submit Requirements:
      • requirement satisfiedCode-Owners
      • requirement satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      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: Idf3940ddc3f8538f65ae9d1add2cc0c0ad672fa2
      Gerrit-Change-Number: 6909719
      Gerrit-PatchSet: 2
      Gerrit-Owner: Clemens Backes <clem...@chromium.org>
      Gerrit-Reviewer: Clemens Backes <clem...@chromium.org>
      Gerrit-Reviewer: Matthias Liedtke <mlie...@chromium.org>
      Gerrit-CC: Darius Mercadier <dmerc...@chromium.org>
      Gerrit-CC: Dominik Inführ <dinf...@chromium.org>
      Gerrit-CC: Hannes Payer <hpa...@chromium.org>
      Gerrit-Attention: Clemens Backes <clem...@chromium.org>
      Gerrit-Comment-Date: Thu, 04 Sep 2025 11:59:31 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: Yes
      Comment-In-Reply-To: Clemens Backes <clem...@chromium.org>
      Comment-In-Reply-To: Matthias Liedtke <mlie...@chromium.org>
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Clemens Backes (Gerrit)

      unread,
      Sep 4, 2025, 8:47:15 AM (3 days ago) Sep 4
      to Matthias Liedtke, Dominik Inführ, Darius Mercadier, V8 LUCI CQ, Hannes Payer, dmercadi...@chromium.org, mlippau...@chromium.org, v8-re...@googlegroups.com, was...@google.com

      Clemens Backes added 1 comment

      File src/heap/linear-allocation-area.h
      Line 98, Patchset 1: static constexpr int kLimitOffset = 2 * kSystemPointerSize;
      Matthias Liedtke . resolved

      Wouldn't it be much nicer to make them `static const` and define them out of line using `offsetof` removing the need for the `CheckOffsets` and the manual offset calculation?
      We shouldn't need the `constexpr`-ness of these values.
      https://godbolt.org/z/ofsf55T49

      Clemens Backes

      If we can make them `constexpr`, I would prefer that. It's also nice to write out the value explicitly, so it's easier to match that against generated code.

      I moved the validation to the existing `Verify` method; turns out that you can call `offsetof` inside the class definition, just not outside of method bodies...

      Is that acceptable to you?

      Matthias Liedtke

      Acceptable yes but I don't like it at all.

      We shouldn't manually calculate offsets and make assumptions on C++ object layout which (afaik) is mostly defined by the ABI and not even defined on a C++ language level.
      It also makes it annoying if we ever add members, reorder members etc. which would "just work" using `offsetof`.

      The differences between `static const` and `static constexpr` are negligible in most cases (you can still use it as template arguments, size of a c-array, ...), so there isn't much benefit of `constexpr` here.)

      In either case we should also add a `static_assert(std::is_standard_layout_v<LinearAllocationArea>);` to ensure that `offsetof` is well-defined.

      Clemens Backes

      I guess it's fine to disagree on this for now.

      IMO the code in this CL is in line with existing V8 code. In particular, we already have the `kSize` constant and rely on statically knowing the layout of this class. The `IsolateData` class has two fields of type `LinearAllocationArea`, and then uses custom calculations (using `LinearAllocationArea::kSize`) to compute the offsets used in generated code for accessing fields inside these classes. So all of this only works if we fully control the memory layout. We explicitly do *not* want to automatically adapt to any changes which might be allowed by the C++ spec. Explicitly specifying offsets is easier to maintain and to debug in this case than deriving values automatically.
      Happy to have more in-person discussion on this.

      I added the static_assert out standard layout, which totally makes sense.

      Open in Gerrit

      Related details

      Attention set is empty
      Submit Requirements:
      • requirement satisfiedCode-Owners
      • requirement satisfiedCode-Review
      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: Idf3940ddc3f8538f65ae9d1add2cc0c0ad672fa2
      Gerrit-Change-Number: 6909719
      Gerrit-PatchSet: 2
      Gerrit-Owner: Clemens Backes <clem...@chromium.org>
      Gerrit-Reviewer: Clemens Backes <clem...@chromium.org>
      Gerrit-Reviewer: Matthias Liedtke <mlie...@chromium.org>
      Gerrit-CC: Darius Mercadier <dmerc...@chromium.org>
      Gerrit-CC: Dominik Inführ <dinf...@chromium.org>
      Gerrit-CC: Hannes Payer <hpa...@chromium.org>
      Gerrit-Comment-Date: Thu, 04 Sep 2025 12:47:07 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      satisfied_requirement
      open
      diffy

      Michael Lippautz (Gerrit)

      unread,
      Sep 4, 2025, 9:00:44 AM (3 days ago) Sep 4
      to Clemens Backes, Matthias Liedtke, Dominik Inführ, Darius Mercadier, V8 LUCI CQ, Hannes Payer, dmercadi...@chromium.org, mlippau...@chromium.org, v8-re...@googlegroups.com, was...@google.com
      Attention needed from Clemens Backes

      Michael Lippautz added 1 comment

      File src/heap/linear-allocation-area.h
      Line 102, Patchset 3 (Latest): static constexpr int kStartOffset = 0;
      Michael Lippautz . unresolved

      Drive-by: For the HeapObjectLayout stuff, I think we have established a convention where we

      • Add static constexpr accessors that use offsetoff().
      • Make those accessors private
      • friend class the specific compiler parts that need the internals to make this explicit.
      Open in Gerrit

      Related details

      Attention is currently required from:
      • Clemens Backes
      Submit Requirements:
        • requirement satisfiedCode-Owners
        • requirement satisfiedCode-Review
        • requirement is not satisfiedNo-Unresolved-Comments
        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: Idf3940ddc3f8538f65ae9d1add2cc0c0ad672fa2
        Gerrit-Change-Number: 6909719
        Gerrit-PatchSet: 3
        Gerrit-Owner: Clemens Backes <clem...@chromium.org>
        Gerrit-Reviewer: Clemens Backes <clem...@chromium.org>
        Gerrit-Reviewer: Matthias Liedtke <mlie...@chromium.org>
        Gerrit-CC: Darius Mercadier <dmerc...@chromium.org>
        Gerrit-CC: Dominik Inführ <dinf...@chromium.org>
        Gerrit-CC: Hannes Payer <hpa...@chromium.org>
        Gerrit-CC: Michael Lippautz <mlip...@chromium.org>
        Gerrit-Attention: Clemens Backes <clem...@chromium.org>
        Gerrit-Comment-Date: Thu, 04 Sep 2025 13:00:38 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Dominik Inführ (Gerrit)

        unread,
        Sep 4, 2025, 9:05:19 AM (3 days ago) Sep 4
        to Clemens Backes, Michael Lippautz, Matthias Liedtke, Darius Mercadier, V8 LUCI CQ, Hannes Payer, dmercadi...@chromium.org, mlippau...@chromium.org, v8-re...@googlegroups.com, was...@google.com
        Attention needed from Clemens Backes

        Dominik Inführ voted and added 1 comment

        Votes added by Dominik Inführ

        Code-Review+1

        1 comment

        File src/heap/linear-allocation-area.h
        Line 98, Patchset 1: static constexpr int kLimitOffset = 2 * kSystemPointerSize;
        Matthias Liedtke . resolved

        Wouldn't it be much nicer to make them `static const` and define them out of line using `offsetof` removing the need for the `CheckOffsets` and the manual offset calculation?
        We shouldn't need the `constexpr`-ness of these values.
        https://godbolt.org/z/ofsf55T49

        Clemens Backes

        If we can make them `constexpr`, I would prefer that. It's also nice to write out the value explicitly, so it's easier to match that against generated code.

        I moved the validation to the existing `Verify` method; turns out that you can call `offsetof` inside the class definition, just not outside of method bodies...

        Is that acceptable to you?

        Matthias Liedtke

        Acceptable yes but I don't like it at all.

        We shouldn't manually calculate offsets and make assumptions on C++ object layout which (afaik) is mostly defined by the ABI and not even defined on a C++ language level.
        It also makes it annoying if we ever add members, reorder members etc. which would "just work" using `offsetof`.

        The differences between `static const` and `static constexpr` are negligible in most cases (you can still use it as template arguments, size of a c-array, ...), so there isn't much benefit of `constexpr` here.)

        In either case we should also add a `static_assert(std::is_standard_layout_v<LinearAllocationArea>);` to ensure that `offsetof` is well-defined.

        Clemens Backes

        I guess it's fine to disagree on this for now.

        IMO the code in this CL is in line with existing V8 code. In particular, we already have the `kSize` constant and rely on statically knowing the layout of this class. The `IsolateData` class has two fields of type `LinearAllocationArea`, and then uses custom calculations (using `LinearAllocationArea::kSize`) to compute the offsets used in generated code for accessing fields inside these classes. So all of this only works if we fully control the memory layout. We explicitly do *not* want to automatically adapt to any changes which might be allowed by the C++ spec. Explicitly specifying offsets is easier to maintain and to debug in this case than deriving values automatically.
        Happy to have more in-person discussion on this.

        I added the static_assert out standard layout, which totally makes sense.

        Gerrit-Comment-Date: Thu, 04 Sep 2025 13:05:14 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: Yes
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Clemens Backes (Gerrit)

        unread,
        Sep 4, 2025, 9:55:56 AM (3 days ago) Sep 4
        to Michael Lippautz, Matthias Liedtke, Dominik Inführ, Darius Mercadier, V8 LUCI CQ, Hannes Payer, dmercadi...@chromium.org, mlippau...@chromium.org, v8-re...@googlegroups.com, was...@google.com
        Attention needed from Dominik Inführ, Matthias Liedtke and Michael Lippautz

        Clemens Backes added 3 comments

        Patchset-level comments
        File-level comment, Patchset 4 (Latest):
        Clemens Backes . resolved

        Michael, can you sign off src/execution and check if you like the latest changes?

        File src/heap/linear-allocation-area.h
        Line 102, Patchset 3: static constexpr int kStartOffset = 0;
        Michael Lippautz . resolved

        Drive-by: For the HeapObjectLayout stuff, I think we have established a convention where we

        • Add static constexpr accessors that use offsetoff().
        • Make those accessors private
        • friend class the specific compiler parts that need the internals to make this explicit.
        Clemens Backes

        Ah, right!
        I like the solution with constexpr accessors. I don't really see the benefit of making the offsets private, by did that as well.

        Line 98, Patchset 1: static constexpr int kLimitOffset = 2 * kSystemPointerSize;
        Matthias Liedtke . resolved

        Wouldn't it be much nicer to make them `static const` and define them out of line using `offsetof` removing the need for the `CheckOffsets` and the manual offset calculation?
        We shouldn't need the `constexpr`-ness of these values.
        https://godbolt.org/z/ofsf55T49

        Clemens Backes

        If we can make them `constexpr`, I would prefer that. It's also nice to write out the value explicitly, so it's easier to match that against generated code.

        I moved the validation to the existing `Verify` method; turns out that you can call `offsetof` inside the class definition, just not outside of method bodies...

        Is that acceptable to you?

        Matthias Liedtke

        Acceptable yes but I don't like it at all.

        We shouldn't manually calculate offsets and make assumptions on C++ object layout which (afaik) is mostly defined by the ABI and not even defined on a C++ language level.
        It also makes it annoying if we ever add members, reorder members etc. which would "just work" using `offsetof`.

        The differences between `static const` and `static constexpr` are negligible in most cases (you can still use it as template arguments, size of a c-array, ...), so there isn't much benefit of `constexpr` here.)

        In either case we should also add a `static_assert(std::is_standard_layout_v<LinearAllocationArea>);` to ensure that `offsetof` is well-defined.

        Clemens Backes

        I guess it's fine to disagree on this for now.

        IMO the code in this CL is in line with existing V8 code. In particular, we already have the `kSize` constant and rely on statically knowing the layout of this class. The `IsolateData` class has two fields of type `LinearAllocationArea`, and then uses custom calculations (using `LinearAllocationArea::kSize`) to compute the offsets used in generated code for accessing fields inside these classes. So all of this only works if we fully control the memory layout. We explicitly do *not* want to automatically adapt to any changes which might be allowed by the C++ spec. Explicitly specifying offsets is easier to maintain and to debug in this case than deriving values automatically.
        Happy to have more in-person discussion on this.

        I added the static_assert out standard layout, which totally makes sense.

        Dominik Inführ

        fwiw we already have this static_assert in IsolateData [0].

        0: https://source.chromium.org/chromium/chromium/src/+/main:v8/src/execution/isolate-data.h;l=614?q=IsolateData::AssertPredictableLayout&ss=chromium

        Clemens Backes

        Right. Still doesn't hurt to have it a second time where we use `offsetof` and again rely on this.

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Dominik Inführ
        • Matthias Liedtke
        • Michael Lippautz
        Submit Requirements:
        • requirement is not satisfiedCode-Owners
        • requirement is not satisfiedCode-Review
        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: Idf3940ddc3f8538f65ae9d1add2cc0c0ad672fa2
        Gerrit-Change-Number: 6909719
        Gerrit-PatchSet: 4
        Gerrit-Owner: Clemens Backes <clem...@chromium.org>
        Gerrit-Reviewer: Clemens Backes <clem...@chromium.org>
        Gerrit-Reviewer: Matthias Liedtke <mlie...@chromium.org>
        Gerrit-Reviewer: Michael Lippautz <mlip...@chromium.org>
        Gerrit-CC: Darius Mercadier <dmerc...@chromium.org>
        Gerrit-CC: Dominik Inführ <dinf...@chromium.org>
        Gerrit-CC: Hannes Payer <hpa...@chromium.org>
        Gerrit-Attention: Dominik Inführ <dinf...@chromium.org>
        Gerrit-Attention: Matthias Liedtke <mlie...@chromium.org>
        Gerrit-Attention: Michael Lippautz <mlip...@chromium.org>
        Gerrit-Comment-Date: Thu, 04 Sep 2025 13:55:51 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        Comment-In-Reply-To: Clemens Backes <clem...@chromium.org>
        Comment-In-Reply-To: Dominik Inführ <dinf...@chromium.org>
        Comment-In-Reply-To: Matthias Liedtke <mlie...@chromium.org>
        Comment-In-Reply-To: Michael Lippautz <mlip...@chromium.org>
        unsatisfied_requirement
        open
        diffy

        Clemens Backes (Gerrit)

        unread,
        Sep 4, 2025, 12:05:33 PM (3 days ago) Sep 4
        to Michael Lippautz, Matthias Liedtke, Dominik Inführ, Darius Mercadier, V8 LUCI CQ, Hannes Payer, dmercadi...@chromium.org, mlippau...@chromium.org, v8-re...@googlegroups.com, was...@google.com
        Attention needed from Dominik Inführ, Matthias Liedtke and Michael Lippautz

        Clemens Backes added 1 comment

        File src/heap/linear-allocation-area.h
        Line 102, Patchset 3: static constexpr int kStartOffset = 0;
        Michael Lippautz . resolved

        Drive-by: For the HeapObjectLayout stuff, I think we have established a convention where we

        • Add static constexpr accessors that use offsetoff().
        • Make those accessors private
        • friend class the specific compiler parts that need the internals to make this explicit.
        Clemens Backes

        Ah, right!
        I like the solution with constexpr accessors. I don't really see the benefit of making the offsets private, by did that as well.

        Clemens Backes

        Actually, we can avoid most of the friendships (and more that would need to be added in https://crrev.com/c/6915236) by introducing new `IsolateFieldId`s for the top/limit of old and new space.
        I did that in a separate CL, I think that makes things even nicer: https://crrev.com/c/6916875

        Gerrit-Comment-Date: Thu, 04 Sep 2025 16:05:28 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        Comment-In-Reply-To: Clemens Backes <clem...@chromium.org>
        Comment-In-Reply-To: Michael Lippautz <mlip...@chromium.org>
        unsatisfied_requirement
        open
        diffy

        Michael Lippautz (Gerrit)

        unread,
        Sep 5, 2025, 6:58:03 AM (2 days ago) Sep 5
        to Clemens Backes, Matthias Liedtke, Dominik Inführ, Darius Mercadier, V8 LUCI CQ, Hannes Payer, dmercadi...@chromium.org, mlippau...@chromium.org, v8-re...@googlegroups.com, was...@google.com
        Attention needed from Clemens Backes, Dominik Inführ and Matthias Liedtke

        Michael Lippautz voted Code-Review+1

        Code-Review+1
        Open in Gerrit

        Related details

        Attention is currently required from:
        • Clemens Backes
        • Dominik Inführ
        • Matthias Liedtke
        Submit Requirements:
        • requirement satisfiedCode-Owners
        • requirement satisfiedCode-Review
        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: Idf3940ddc3f8538f65ae9d1add2cc0c0ad672fa2
        Gerrit-Change-Number: 6909719
        Gerrit-PatchSet: 4
        Gerrit-Owner: Clemens Backes <clem...@chromium.org>
        Gerrit-Reviewer: Clemens Backes <clem...@chromium.org>
        Gerrit-Reviewer: Matthias Liedtke <mlie...@chromium.org>
        Gerrit-Reviewer: Michael Lippautz <mlip...@chromium.org>
        Gerrit-CC: Darius Mercadier <dmerc...@chromium.org>
        Gerrit-CC: Dominik Inführ <dinf...@chromium.org>
        Gerrit-CC: Hannes Payer <hpa...@chromium.org>
        Gerrit-Attention: Clemens Backes <clem...@chromium.org>
        Gerrit-Attention: Dominik Inführ <dinf...@chromium.org>
        Gerrit-Attention: Matthias Liedtke <mlie...@chromium.org>
        Gerrit-Comment-Date: Fri, 05 Sep 2025 10:57:59 +0000
        Gerrit-HasComments: No
        Gerrit-Has-Labels: Yes
        satisfied_requirement
        open
        diffy

        Clemens Backes (Gerrit)

        unread,
        Sep 5, 2025, 6:59:07 AM (2 days ago) Sep 5
        to Michael Lippautz, Matthias Liedtke, Dominik Inführ, Darius Mercadier, V8 LUCI CQ, Hannes Payer, dmercadi...@chromium.org, mlippau...@chromium.org, v8-re...@googlegroups.com, was...@google.com
        Attention needed from Dominik Inführ and Matthias Liedtke

        Clemens Backes voted Commit-Queue+2

        Commit-Queue+2
        Open in Gerrit

        Related details

        Attention is currently required from:
        • Dominik Inführ
        • Matthias Liedtke
        Submit Requirements:
        • requirement satisfiedCode-Owners
        • requirement satisfiedCode-Review
        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: Idf3940ddc3f8538f65ae9d1add2cc0c0ad672fa2
        Gerrit-Change-Number: 6909719
        Gerrit-PatchSet: 4
        Gerrit-Owner: Clemens Backes <clem...@chromium.org>
        Gerrit-Reviewer: Clemens Backes <clem...@chromium.org>
        Gerrit-Reviewer: Matthias Liedtke <mlie...@chromium.org>
        Gerrit-Reviewer: Michael Lippautz <mlip...@chromium.org>
        Gerrit-CC: Darius Mercadier <dmerc...@chromium.org>
        Gerrit-CC: Dominik Inführ <dinf...@chromium.org>
        Gerrit-CC: Hannes Payer <hpa...@chromium.org>
        Gerrit-Attention: Dominik Inführ <dinf...@chromium.org>
        Gerrit-Attention: Matthias Liedtke <mlie...@chromium.org>
        Gerrit-Comment-Date: Fri, 05 Sep 2025 10:59:02 +0000
        Gerrit-HasComments: No
        Gerrit-Has-Labels: Yes
        satisfied_requirement
        open
        diffy

        V8 LUCI CQ (Gerrit)

        unread,
        Sep 5, 2025, 7:00:36 AM (2 days ago) Sep 5
        to Clemens Backes, Michael Lippautz, Matthias Liedtke, Dominik Inführ, Darius Mercadier, Hannes Payer, dmercadi...@chromium.org, mlippau...@chromium.org, v8-re...@googlegroups.com, was...@google.com

        V8 LUCI CQ submitted the change

        Change information

        Commit message:
        [wasm] Load allocation space top and limit via root register

        We were currently storing pointers to the isolate fields on the
        `WasmTrustedInstanceData`. This adds one unnecessary indirection, making
        code larger and slower than needed.

        All four fields are accessible via the roots register instead.

        R=mlie...@chromium.org
        CC=dinf...@chromium.org
        Bug: 442745065
        Change-Id: Idf3940ddc3f8538f65ae9d1add2cc0c0ad672fa2
        Reviewed-by: Michael Lippautz <mlip...@chromium.org>
        Commit-Queue: Clemens Backes <clem...@chromium.org>
        Cr-Commit-Position: refs/heads/main@{#102271}
        Files:
        • M src/compiler/memory-lowering.cc
        • M src/compiler/turboshaft/memory-optimization-reducer.h
        • M src/diagnostics/objects-printer.cc
        • M src/execution/isolate-data.h
        • M src/heap/linear-allocation-area.h
        • M src/wasm/wasm-objects-inl.h
        • M src/wasm/wasm-objects.cc
        • M src/wasm/wasm-objects.h
        Change size: M
        Delta: 8 files changed, 57 insertions(+), 118 deletions(-)
        Branch: refs/heads/main
        Submit Requirements:
        • requirement satisfiedCode-Review: +1 by Michael Lippautz
        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: Idf3940ddc3f8538f65ae9d1add2cc0c0ad672fa2
        Gerrit-Change-Number: 6909719
        Gerrit-PatchSet: 5
        Gerrit-Owner: Clemens Backes <clem...@chromium.org>
        Gerrit-Reviewer: Clemens Backes <clem...@chromium.org>
        Gerrit-Reviewer: Matthias Liedtke <mlie...@chromium.org>
        Gerrit-Reviewer: Michael Lippautz <mlip...@chromium.org>
        open
        diffy
        satisfied_requirement
        Reply all
        Reply to author
        Forward
        0 new messages