mirror of
https://github.com/dart-lang/sdk
synced 2024-09-30 04:48:37 +00:00
Add 'coverage' flag, defaulting to true, but let the gn application_snapshot default it to false
Automatic set coverage when loading snapshot TEST=Existing tests, manual inspection of reduction in sdk snapshot sizes (see data in comments in https://dart-review.googlesource.com/c/sdk/+/370501) Change-Id: I044616144c2defeed252a6715eba1abcabffc86d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/371700 Reviewed-by: Slava Egorov <vegorov@google.com> Commit-Queue: Jens Johansen <jensj@google.com>
This commit is contained in:
parent
08ca631673
commit
9b67562b4d
|
@ -288,7 +288,8 @@ trace to find the place to insert the appropriate support.
|
|||
self.depfiles = [self.rebase(self.optarg)]
|
||||
elif self.get_option([
|
||||
'--packages', '-D', '--snapshot-kind',
|
||||
'--depfile_output_filename'
|
||||
'--depfile_output_filename', '--coverage',
|
||||
'--ignore-unrecognized-flags'
|
||||
]):
|
||||
pass
|
||||
elif arg in ['--deterministic', '--sound-null-safety']:
|
||||
|
@ -387,7 +388,8 @@ trace to find the place to insert the appropriate support.
|
|||
os.path.join(self.optarg, 'dart2js_platform.dill')))
|
||||
elif self.get_option([
|
||||
'--invoker', '--packages', '--libraries-spec',
|
||||
'--snapshot-kind', '--depfile_output_filename'
|
||||
'--snapshot-kind', '--depfile_output_filename',
|
||||
'--coverage', '--ignore-unrecognized-flags'
|
||||
]):
|
||||
pass
|
||||
elif arg in [
|
||||
|
@ -661,7 +663,10 @@ trace to find the place to insert the appropriate support.
|
|||
'--elf',
|
||||
]):
|
||||
self.outputs.append(self.rebase(self.optarg))
|
||||
elif self.get_option(['--snapshot_kind', '--snapshot-kind']):
|
||||
elif self.get_option([
|
||||
'--snapshot_kind', '--snapshot-kind', '--coverage',
|
||||
'--ignore-unrecognized-flags'
|
||||
]):
|
||||
pass
|
||||
elif arg in [
|
||||
'--sound-null-safety',
|
||||
|
|
|
@ -246,6 +246,7 @@ void DartDevIsolate::DartDevRunner::RunCallback(uword args) {
|
|||
flags.use_osr = true;
|
||||
flags.is_system_isolate = true;
|
||||
flags.branch_coverage = false;
|
||||
flags.coverage = false;
|
||||
|
||||
char* error = nullptr;
|
||||
Dart_Isolate dartdev_isolate = runner->create_isolate_(
|
||||
|
|
|
@ -594,6 +594,7 @@ typedef struct {
|
|||
bool is_kernel_isolate;
|
||||
bool snapshot_is_dontneed_safe;
|
||||
bool branch_coverage;
|
||||
bool coverage;
|
||||
} Dart_IsolateFlags;
|
||||
|
||||
/**
|
||||
|
|
|
@ -9276,6 +9276,26 @@ ApiErrorPtr Deserializer::VerifyImageAlignment() {
|
|||
return ApiError::null();
|
||||
}
|
||||
|
||||
void SnapshotHeaderReader::SetCoverageFromSnapshotFeatures(
|
||||
IsolateGroup* isolate_group) {
|
||||
auto prev_position = stream_.Position();
|
||||
char* error = VerifyVersion();
|
||||
if (error == nullptr) {
|
||||
const char* features = nullptr;
|
||||
intptr_t features_length = 0;
|
||||
char* error = ReadFeatures(&features, &features_length);
|
||||
if (error == nullptr) {
|
||||
if (strstr(features, " no-coverage") != nullptr) {
|
||||
isolate_group->set_coverage(false);
|
||||
} else if (strstr(features, " coverage") != nullptr) {
|
||||
isolate_group->set_coverage(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stream_.SetPosition(prev_position);
|
||||
}
|
||||
|
||||
char* SnapshotHeaderReader::VerifyVersionAndFeatures(
|
||||
IsolateGroup* isolate_group,
|
||||
intptr_t* offset) {
|
||||
|
@ -9960,6 +9980,7 @@ ApiErrorPtr FullSnapshotReader::ReadVMSnapshot() {
|
|||
|
||||
ApiErrorPtr FullSnapshotReader::ReadProgramSnapshot() {
|
||||
SnapshotHeaderReader header_reader(kind_, buffer_, size_);
|
||||
header_reader.SetCoverageFromSnapshotFeatures(thread_->isolate_group());
|
||||
intptr_t offset = 0;
|
||||
char* error =
|
||||
header_reader.VerifyVersionAndFeatures(thread_->isolate_group(), &offset);
|
||||
|
|
|
@ -85,6 +85,8 @@ class SnapshotHeaderReader {
|
|||
stream_.SetPosition(Snapshot::kHeaderSize);
|
||||
}
|
||||
|
||||
void SetCoverageFromSnapshotFeatures(IsolateGroup* isolate_group);
|
||||
|
||||
// Verifies the version and features in the snapshot are compatible with the
|
||||
// current VM. If isolate is non-null it validates isolate-specific features.
|
||||
//
|
||||
|
|
|
@ -1271,6 +1271,7 @@ Fragment BaseFlowGraphBuilder::RecordCoverageImpl(TokenPosition position,
|
|||
bool is_branch_coverage) {
|
||||
Fragment instructions;
|
||||
if (!SupportsCoverage()) return instructions;
|
||||
if (!IG->coverage()) return instructions;
|
||||
if (!position.IsReal()) return instructions;
|
||||
if (is_branch_coverage && !IG->branch_coverage()) return instructions;
|
||||
|
||||
|
|
|
@ -1044,6 +1044,7 @@ char* Dart::FeaturesString(IsolateGroup* isolate_group,
|
|||
ADD_ISOLATE_GROUP_FLAG(use_osr, use_osr, FLAG_use_osr);
|
||||
ADD_ISOLATE_GROUP_FLAG(branch_coverage, branch_coverage,
|
||||
FLAG_branch_coverage);
|
||||
ADD_ISOLATE_GROUP_FLAG(coverage, coverage, FLAG_coverage);
|
||||
}
|
||||
|
||||
// Generated code must match the host architecture and ABI. We check the
|
||||
|
|
|
@ -245,6 +245,7 @@ constexpr bool FLAG_support_il_printer = false;
|
|||
P(verify_entry_points, bool, false, \
|
||||
"Throw API error on invalid member access through native API. See " \
|
||||
"entry_point_pragma.md") \
|
||||
C(branch_coverage, false, false, bool, false, "Enable branch coverage")
|
||||
C(branch_coverage, false, false, bool, false, "Enable branch coverage") \
|
||||
C(coverage, false, false, bool, true, "Enable coverage")
|
||||
|
||||
#endif // RUNTIME_VM_FLAG_LIST_H_
|
||||
|
|
|
@ -144,7 +144,8 @@ typedef FixedCache<intptr_t, CatchEntryMovesRefPtr, 16> CatchEntryMovesCache;
|
|||
V(NONPRODUCT, snapshot_is_dontneed_safe, SnapshotIsDontNeedSafe, \
|
||||
snapshot_is_dontneed_safe, false) \
|
||||
V(NONPRODUCT, branch_coverage, BranchCoverage, branch_coverage, \
|
||||
FLAG_branch_coverage)
|
||||
FLAG_branch_coverage) \
|
||||
V(NONPRODUCT, coverage, Coverage, coverage, FLAG_coverage)
|
||||
|
||||
// List of Isolate flags with corresponding members of Dart_IsolateFlags and
|
||||
// corresponding global command line flags.
|
||||
|
@ -459,6 +460,10 @@ class IsolateGroup : public IntrusiveDListEntry<IsolateGroup> {
|
|||
BranchCoverageBit::update(value, isolate_group_flags_);
|
||||
}
|
||||
|
||||
void set_coverage(bool value) {
|
||||
isolate_group_flags_ = CoverageBit::update(value, isolate_group_flags_);
|
||||
}
|
||||
|
||||
#if !defined(PRODUCT)
|
||||
#if !defined(DART_PRECOMPILED_RUNTIME)
|
||||
bool HasAttemptedReload() const {
|
||||
|
@ -774,7 +779,8 @@ class IsolateGroup : public IntrusiveDListEntry<IsolateGroup> {
|
|||
V(UseFieldGuards) \
|
||||
V(UseOsr) \
|
||||
V(SnapshotIsDontNeedSafe) \
|
||||
V(BranchCoverage)
|
||||
V(BranchCoverage) \
|
||||
V(Coverage)
|
||||
|
||||
// Isolate group specific flags.
|
||||
enum FlagBits {
|
||||
|
|
|
@ -61,6 +61,24 @@ template("application_snapshot") {
|
|||
if (defined(invoker.vm_args)) {
|
||||
snapshot_vm_args = invoker.vm_args
|
||||
}
|
||||
|
||||
# If --coverage=true/false hasn't been explicitly specified,
|
||||
# add --coverage=false.
|
||||
has_coverage_setting = false
|
||||
foreach(vm_arg, snapshot_vm_args) {
|
||||
vm_arg_split = string_split(vm_arg, "=")
|
||||
if (vm_arg_split[0] == "--coverage") {
|
||||
has_coverage_setting = true
|
||||
}
|
||||
}
|
||||
if (!has_coverage_setting) {
|
||||
# Also add --ignore-unrecognized-flags because --coverage is unrecognized
|
||||
# in product mode.
|
||||
snapshot_vm_args += [
|
||||
"--coverage=false",
|
||||
"--ignore-unrecognized-flags",
|
||||
]
|
||||
}
|
||||
main_dart = invoker.main_dart
|
||||
training_args = invoker.training_args
|
||||
training_deps = []
|
||||
|
|
Loading…
Reference in a new issue