[M] Change in dart/sdk[main]: [vm,dyn_modules] Update some coverage information for bytecode.

0 views
Skip to first unread message

Tess Strickland (Gerrit)

unread,
Sep 18, 2025, 7:19:15 AM (11 days ago) Sep 18
to Alexander Markov, rev...@dartlang.org, vm-...@dartlang.org
Attention needed from Alexander Markov

Tess Strickland voted Commit-Queue+1

Commit-Queue+1
Open in Gerrit

Related details

Attention is currently required from:
  • Alexander Markov
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement satisfiedCommit-Message-Has-TEST
  • 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: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I14b6ffba1e175993e992c0fe939473557303bfeb
Gerrit-Change-Number: 449900
Gerrit-PatchSet: 8
Gerrit-Owner: Tess Strickland <sstr...@google.com>
Gerrit-Reviewer: Alexander Markov <alexm...@google.com>
Gerrit-Reviewer: Tess Strickland <sstr...@google.com>
Gerrit-Attention: Alexander Markov <alexm...@google.com>
Gerrit-Comment-Date: Thu, 18 Sep 2025 11:19:10 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Alexander Markov (Gerrit)

unread,
Sep 18, 2025, 10:04:55 AM (11 days ago) Sep 18
to Tess Strickland, Commit Queue, Alexander Markov, rev...@dartlang.org, vm-...@dartlang.org
Attention needed from Tess Strickland

Alexander Markov added 4 comments

File pkg/dart2bytecode/lib/declarations.dart
Line 246, Patchset 8 (Latest): writer.writePackedUInt30(flags);
Alexander Markov . unresolved

Should we also set `hasConstConstructorCoverageFlag` flag here?

File runtime/vm/bytecode_reader.cc
Line 1666, Patchset 8 (Latest): if ((flags & kHasConstConstructorCoverageFlag) != 0) {
Alexander Markov . unresolved

We might need to read constructors lazily, only when requested. Otherwise we risk trying to read constructor references even before reading members of classes (as we may read source file info earlier, in order to create Script object for a Library or a Class).

File runtime/vm/object.h
Line 5062, Patchset 8 (Latest): TypedDataViewPtr kernel_constant_coverage() const;
Alexander Markov . unresolved

Can we have shared public API to query covered constant constructors with private kernel- and bytecode- specific implementation?

File runtime/vm/source_report.cc
Line 450, Patchset 8 (Latest):#endif
Alexander Markov . unresolved
Nit:
```
#else
UNREACHABLE();
```
Open in Gerrit

Related details

Attention is currently required from:
  • Tess Strickland
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement satisfiedCommit-Message-Has-TEST
  • 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: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I14b6ffba1e175993e992c0fe939473557303bfeb
Gerrit-Change-Number: 449900
Gerrit-PatchSet: 8
Gerrit-Owner: Tess Strickland <sstr...@google.com>
Gerrit-Reviewer: Alexander Markov <alexm...@google.com>
Gerrit-Reviewer: Tess Strickland <sstr...@google.com>
Gerrit-Attention: Tess Strickland <sstr...@google.com>
Gerrit-Comment-Date: Thu, 18 Sep 2025 14:04:52 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Tess Strickland (Gerrit)

unread,
Sep 24, 2025, 7:05:55 AM (5 days ago) Sep 24
to Commit Queue, Alexander Markov, rev...@dartlang.org, vm-...@dartlang.org

Tess Strickland added 5 comments

Patchset-level comments
File-level comment, Patchset 9:
Tess Strickland . resolved

Thanks, Alex! I'll ping again once I've reworked things to support lazy reading of the const constructor coverage info from bytecode and resolved the rest of the comments.

File pkg/dart2bytecode/lib/declarations.dart
Line 246, Patchset 8: writer.writePackedUInt30(flags);
Alexander Markov . resolved

Should we also set `hasConstConstructorCoverageFlag` flag here?

Tess Strickland

Done

Line 246, Patchset 8: writer.writePackedUInt30(flags);
Alexander Markov . resolved

Should we also set `hasConstConstructorCoverageFlag` flag here?

Tess Strickland

Done

File runtime/vm/bytecode_reader.cc
Line 1666, Patchset 8: if ((flags & kHasConstConstructorCoverageFlag) != 0) {
Alexander Markov . unresolved

We might need to read constructors lazily, only when requested. Otherwise we risk trying to read constructor references even before reading members of classes (as we may read source file info earlier, in order to create Script object for a Library or a Class).

Tess Strickland

This makes sense, and explains why the kernel is read lazily. We can do the same for the bytecode, but we'll need some way to be able to get back to the bytecode from the script. Perhaps an alternate version of `KernelProgramInfo`, `BytecodeProgramInfo`, where the two have a common superclass that can be used for types of fields containing either? Hmm, will have to think about this.

File runtime/vm/source_report.cc
Line 450, Patchset 8:#endif
Alexander Markov . resolved
Nit:
```
#else
UNREACHABLE();
```
Tess Strickland

Done

Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement satisfiedCommit-Message-Has-TEST
  • 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: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I14b6ffba1e175993e992c0fe939473557303bfeb
Gerrit-Change-Number: 449900
Gerrit-PatchSet: 10
Gerrit-Owner: Tess Strickland <sstr...@google.com>
Gerrit-Reviewer: Alexander Markov <alexm...@google.com>
Gerrit-Reviewer: Tess Strickland <sstr...@google.com>
Gerrit-Comment-Date: Wed, 24 Sep 2025 11:05:50 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Alexander Markov <alexm...@google.com>
satisfied_requirement
unsatisfied_requirement
open
diffy

Alexander Markov (Gerrit)

unread,
Sep 24, 2025, 11:28:54 AM (5 days ago) Sep 24
to Tess Strickland, Commit Queue, Alexander Markov, rev...@dartlang.org, vm-...@dartlang.org
Attention needed from Tess Strickland

Alexander Markov added 1 comment

File runtime/vm/bytecode_reader.cc
Line 1666, Patchset 8: if ((flags & kHasConstConstructorCoverageFlag) != 0) {
Alexander Markov . unresolved

We might need to read constructors lazily, only when requested. Otherwise we risk trying to read constructor references even before reading members of classes (as we may read source file info earlier, in order to create Script object for a Library or a Class).

Tess Strickland

This makes sense, and explains why the kernel is read lazily. We can do the same for the bytecode, but we'll need some way to be able to get back to the bytecode from the script. Perhaps an alternate version of `KernelProgramInfo`, `BytecodeProgramInfo`, where the two have a common superclass that can be used for types of fields containing either? Hmm, will have to think about this.

Alexander Markov

Yeah, I agree that reading the list of constructors lazily is also problematic and requires retaining at least object table indefinitely.

I have been thinking about this problem, and I'm wondering if we could replace this whole list of references to constructors with just a `CoveredConstConstructor` flag on a constructor. When reading functions, we could look at this flag and add constructor's `Function` object to a growable list of covered constructors in its script. WDYT? Could you try that?

Re: `BytecodeProgramInfo`: we can potentially keep BytecodeComponentData (`Array`) for incremental reading, but I think this should be a last resort. If the idea with `CoveredConstConstructor` won't work, then we can also try reading those constructor lists right after reading all classes in a library to avoid keeping any extra info after bytecode is loaded.

Open in Gerrit

Related details

Attention is currently required from:
  • Tess Strickland
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement satisfiedCommit-Message-Has-TEST
  • 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: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I14b6ffba1e175993e992c0fe939473557303bfeb
Gerrit-Change-Number: 449900
Gerrit-PatchSet: 10
Gerrit-Owner: Tess Strickland <sstr...@google.com>
Gerrit-Reviewer: Alexander Markov <alexm...@google.com>
Gerrit-Reviewer: Tess Strickland <sstr...@google.com>
Gerrit-Attention: Tess Strickland <sstr...@google.com>
Gerrit-Comment-Date: Wed, 24 Sep 2025 15:28:49 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Tess Strickland <sstr...@google.com>
Comment-In-Reply-To: Alexander Markov <alexm...@google.com>
satisfied_requirement
unsatisfied_requirement
open
diffy

Tess Strickland (Gerrit)

unread,
Sep 26, 2025, 11:23:14 AM (3 days ago) Sep 26
to Commit Queue, Alexander Markov, rev...@dartlang.org, vm-...@dartlang.org
Attention needed from Alexander Markov

Tess Strickland added 3 comments

Patchset-level comments
File-level comment, Patchset 11 (Latest):
Tess Strickland . resolved

Okay, have done the suggested refactoring, PTAL.

File runtime/vm/bytecode_reader.cc
Line 1666, Patchset 8: if ((flags & kHasConstConstructorCoverageFlag) != 0) {
Alexander Markov . resolved

We might need to read constructors lazily, only when requested. Otherwise we risk trying to read constructor references even before reading members of classes (as we may read source file info earlier, in order to create Script object for a Library or a Class).

Tess Strickland

This makes sense, and explains why the kernel is read lazily. We can do the same for the bytecode, but we'll need some way to be able to get back to the bytecode from the script. Perhaps an alternate version of `KernelProgramInfo`, `BytecodeProgramInfo`, where the two have a common superclass that can be used for types of fields containing either? Hmm, will have to think about this.

Alexander Markov

Yeah, I agree that reading the list of constructors lazily is also problematic and requires retaining at least object table indefinitely.

I have been thinking about this problem, and I'm wondering if we could replace this whole list of references to constructors with just a `CoveredConstConstructor` flag on a constructor. When reading functions, we could look at this flag and add constructor's `Function` object to a growable list of covered constructors in its script. WDYT? Could you try that?

Re: `BytecodeProgramInfo`: we can potentially keep BytecodeComponentData (`Array`) for incremental reading, but I think this should be a last resort. If the idea with `CoveredConstConstructor` won't work, then we can also try reading those constructor lists right after reading all classes in a library to avoid keeping any extra info after bytecode is loaded.

Tess Strickland

Done in PS11.

File runtime/vm/object.h
Line 5062, Patchset 8: TypedDataViewPtr kernel_constant_coverage() const;
Alexander Markov . resolved

Can we have shared public API to query covered constant constructors with private kernel- and bytecode- specific implementation?

Tess Strickland

`CollectConstConstructorCoverageFrom` is the already existing shared public API. I've marked the other functions as private, with an appropriate friend declaration for `bytecode::BytecodeReaderHelper`.

Open in Gerrit

Related details

Attention is currently required from:
  • Alexander Markov
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement satisfiedCommit-Message-Has-TEST
  • 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: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I14b6ffba1e175993e992c0fe939473557303bfeb
Gerrit-Change-Number: 449900
Gerrit-PatchSet: 11
Gerrit-Owner: Tess Strickland <sstr...@google.com>
Gerrit-Reviewer: Alexander Markov <alexm...@google.com>
Gerrit-Reviewer: Tess Strickland <sstr...@google.com>
Gerrit-Attention: Alexander Markov <alexm...@google.com>
Gerrit-Comment-Date: Fri, 26 Sep 2025 15:23:08 +0000
satisfied_requirement
unsatisfied_requirement
open
diffy

Alexander Markov (Gerrit)

unread,
Sep 26, 2025, 2:42:58 PM (3 days ago) Sep 26
to Tess Strickland, Commit Queue, Alexander Markov, rev...@dartlang.org, vm-...@dartlang.org
Attention needed from Tess Strickland

Alexander Markov added 4 comments

File pkg/dart2bytecode/lib/bytecode_generator.dart
Line 233, Patchset 14 (Latest): if (options.emitSourcePositions && includeSourceInfo) {
if (source.lineStarts == null) {
LineStarts lineStarts = new LineStarts(astSource.lineStarts!);
bytecodeComponent.lineStarts.add(lineStarts);
source.lineStarts = lineStarts;
}
Alexander Markov . unresolved

Nit: seems like an unnecessary change, can it be reverted?

File pkg/dart2bytecode/lib/declarations.dart
Line 510, Patchset 14 (Latest): static const isCoveredConstConstructorFlag = 1 << 24;
Alexander Markov . unresolved

Please add the new flag to bytecode.md.

File runtime/vm/bytecode_reader.cc
Line 2193, Patchset 14 (Latest): constant_coverage = Array::Grow(constant_coverage, new_index + 1);
Alexander Markov . unresolved

Growing this array every time would result in O(N^2) reading time, where N is a number of covered const constructors. Can we use `GrowableObjectArray` instead?

Line 2195, Patchset 14 (Latest): script.set_collected_constant_coverage(constant_coverage);
Alexander Markov . unresolved

I'm wondering if we could make a yet another step in this direction and add a flag to the VM's `Function`, maybe to `STATE_BITS_LIST`? This way we won't need to store the list of covered constructors at all and can collect them from `Class::functions()` at any time.

Open in Gerrit

Related details

Attention is currently required from:
  • Tess Strickland
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement satisfiedCommit-Message-Has-TEST
  • 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: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I14b6ffba1e175993e992c0fe939473557303bfeb
Gerrit-Change-Number: 449900
Gerrit-PatchSet: 14
Gerrit-Owner: Tess Strickland <sstr...@google.com>
Gerrit-Reviewer: Alexander Markov <alexm...@google.com>
Gerrit-Reviewer: Tess Strickland <sstr...@google.com>
Gerrit-Attention: Tess Strickland <sstr...@google.com>
Gerrit-Comment-Date: Fri, 26 Sep 2025 18:42:54 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Tess Strickland (Gerrit)

unread,
6:20 AM (3 hours ago) 6:20 AM
to Commit Queue, Alexander Markov, rev...@dartlang.org, vm-...@dartlang.org

Tess Strickland added 2 comments

File pkg/dart2bytecode/lib/bytecode_generator.dart
Line 233, Patchset 14: if (options.emitSourcePositions && includeSourceInfo) {

if (source.lineStarts == null) {
LineStarts lineStarts = new LineStarts(astSource.lineStarts!);
bytecodeComponent.lineStarts.add(lineStarts);
source.lineStarts = lineStarts;
}
Alexander Markov . resolved

Nit: seems like an unnecessary change, can it be reverted?

Tess Strickland

Done

File pkg/dart2bytecode/lib/declarations.dart
Line 510, Patchset 14: static const isCoveredConstConstructorFlag = 1 << 24;
Alexander Markov . resolved

Please add the new flag to bytecode.md.

Tess Strickland

Done

Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement satisfiedCommit-Message-Has-TEST
  • 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: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I14b6ffba1e175993e992c0fe939473557303bfeb
Gerrit-Change-Number: 449900
Gerrit-PatchSet: 16
Gerrit-Owner: Tess Strickland <sstr...@google.com>
Gerrit-Reviewer: Alexander Markov <alexm...@google.com>
Gerrit-Reviewer: Tess Strickland <sstr...@google.com>
Gerrit-Comment-Date: Mon, 29 Sep 2025 10:20:04 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Alexander Markov <alexm...@google.com>
satisfied_requirement
unsatisfied_requirement
open
diffy

Tess Strickland (Gerrit)

unread,
7:25 AM (2 hours ago) 7:25 AM
to Commit Queue, Alexander Markov, rev...@dartlang.org, vm-...@dartlang.org

Tess Strickland added 2 comments

File runtime/vm/bytecode_reader.cc
Line 2193, Patchset 14: constant_coverage = Array::Grow(constant_coverage, new_index + 1);
Alexander Markov . resolved

Growing this array every time would result in O(N^2) reading time, where N is a number of covered const constructors. Can we use `GrowableObjectArray` instead?

Tess Strickland

Mooted due to other changes described below.

Line 2195, Patchset 14: script.set_collected_constant_coverage(constant_coverage);
Alexander Markov . unresolved

I'm wondering if we could make a yet another step in this direction and add a flag to the VM's `Function`, maybe to `STATE_BITS_LIST`? This way we won't need to store the list of covered constructors at all and can collect them from `Class::functions()` at any time.

Tess Strickland

I did this change, but while doing it and looking at the kernel version, I realized that we _can't_ mark the constructor as being constant evaluated at bytecode generation time, or at least we need to be able to update whether it's constant evaluated due to _other_ scripts. This is why the kernel version is lazy--because you have to check the constant evaluation information for all loaded scripts, not just the ones containing const constructors, to determine if any const constructors were constant evaluated in the front end.

That also means making it a state bit on the function is probably not a good idea, because whether or not the constructor was evaluated at const evaluation time depends on which scripts are loaded: for example, let's say a const constructor `C` is defined (but unused) in `script1` and the code in `script2` uses it while creating a constant. Then we can have the following sequence of events:

  • `script1` is loaded
  • coverage info is requested, `C` is reported as unexecuted
  • `script2` is loaded
  • coverage info is re-requested, now `C` is reported as executed
  • `script2` is reloaded with a version that removes the use of `C`
  • coverage info is re-requested, now `C` should be reported as unexecuted again.
  • If we make it a state bit on the function, then unless this bit is appropriately recalculated on all functions whenever any script is unloaded/reloaded, then we could have bad coverage information.

This also means we almost certainly need the last resort you mentioned in https://dart-review.googlesource.com/c/sdk/+/449900/comment/b971d1d4_d1be06f3/, so we can appropriately compute this information as needed.

I'll ping you to take a look after I've done that.

Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement satisfiedCommit-Message-Has-TEST
  • 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: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I14b6ffba1e175993e992c0fe939473557303bfeb
Gerrit-Change-Number: 449900
Gerrit-PatchSet: 16
Gerrit-Owner: Tess Strickland <sstr...@google.com>
Gerrit-Reviewer: Alexander Markov <alexm...@google.com>
Gerrit-Reviewer: Tess Strickland <sstr...@google.com>
Gerrit-Comment-Date: Mon, 29 Sep 2025 11:25:50 +0000
satisfied_requirement
unsatisfied_requirement
open
diffy
Reply all
Reply to author
Forward
0 new messages