Skip to content

Commit ac7bca3

Browse files
liamappelbeCommit Bot
authored andcommitted
[vm] Add an isolate group flag for branch coverage.
Branch coverage can't be enabled by a simple global flag, because this causes problems when functions in an app-jit snapshot that didn't have the flag enabled are compiled by a VM that has the flag enabled. In particular, the coverage array will see a different set of token positions, causing some important asserts to fail. Change-Id: I35227252b5d271f20b01de99466c06708ec83ed8 TEST=CI Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/223360 Reviewed-by: Ryan Macnak <[email protected]> Commit-Queue: Liam Appelbe <[email protected]>
1 parent 296167d commit ac7bca3

File tree

5 files changed

+11
-3
lines changed

5 files changed

+11
-3
lines changed

runtime/bin/dartdev_isolate.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ void DartDevIsolate::DartDevRunner::RunCallback(uword args) {
210210
flags.use_field_guards = true;
211211
flags.use_osr = true;
212212
flags.is_system_isolate = true;
213+
flags.branch_coverage = false;
213214

214215
char* error;
215216
Dart_Isolate dartdev_isolate = runner->create_isolate_(

runtime/include/dart_api.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,7 @@ typedef struct {
606606
bool null_safety;
607607
bool is_system_isolate;
608608
bool snapshot_is_dontneed_safe;
609+
bool branch_coverage;
609610
} Dart_IsolateFlags;
610611

611612
/**

runtime/vm/dart.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,6 +1173,8 @@ char* Dart::FeaturesString(IsolateGroup* isolate_group,
11731173
ADD_ISOLATE_GROUP_FLAG(use_field_guards, use_field_guards,
11741174
FLAG_use_field_guards);
11751175
ADD_ISOLATE_GROUP_FLAG(use_osr, use_osr, FLAG_use_osr);
1176+
ADD_ISOLATE_GROUP_FLAG(branch_coverage, branch_coverage,
1177+
FLAG_branch_coverage);
11761178
}
11771179

11781180
// Generated code must match the host architecture and ABI.

runtime/vm/flag_list.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ constexpr bool FLAG_support_il_printer = false;
246246
D(support_rr, bool, false, "Support running within RR.") \
247247
P(verify_entry_points, bool, false, \
248248
"Throw API error on invalid member access throuh native API. See " \
249-
"entry_point_pragma.md")
249+
"entry_point_pragma.md") \
250+
C(branch_coverage, false, false, bool, false, "Enable branch coverage")
250251

251252
#endif // RUNTIME_VM_FLAG_LIST_H_

runtime/vm/isolate.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,9 @@ typedef FixedCache<intptr_t, CatchEntryMovesRefPtr, 16> CatchEntryMovesCache;
163163
load_vmservice_library, false) \
164164
V(NONPRODUCT, use_osr, UseOsr, use_osr, FLAG_use_osr) \
165165
V(NONPRODUCT, snapshot_is_dontneed_safe, SnapshotIsDontNeedSafe, \
166-
snapshot_is_dontneed_safe, false)
166+
snapshot_is_dontneed_safe, false) \
167+
V(NONPRODUCT, branch_coverage, BranchCoverage, branch_coverage, \
168+
FLAG_branch_coverage)
167169

168170
#define BOOL_ISOLATE_FLAG_LIST_DEFAULT_GETTER(V) \
169171
V(PRODUCT, copy_parent_code, CopyParentCode, copy_parent_code, false) \
@@ -796,7 +798,8 @@ class IsolateGroup : public IntrusiveDListEntry<IsolateGroup> {
796798
V(Obfuscate) \
797799
V(UseFieldGuards) \
798800
V(UseOsr) \
799-
V(SnapshotIsDontNeedSafe)
801+
V(SnapshotIsDontNeedSafe) \
802+
V(BranchCoverage)
800803

801804
// Isolate group specific flags.
802805
enum FlagBits {

0 commit comments

Comments
 (0)