From 082fdca1c9dc4e0b64939114534d1996674dd195 Mon Sep 17 00:00:00 2001 From: Liam Appelbe Date: Tue, 5 Mar 2024 21:48:00 +0000 Subject: [PATCH] [vm] Remove special casing for late error throws Since https://dart-review.googlesource.com/c/sdk/+/355000 landed, we don't need to special case the coverage collector to ignore throws of late initialization errors. TEST=No behavior changes, so using CI Change-Id: I3bce5409f32f48c53035181dbd4c27e3570fbf2b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/355600 Reviewed-by: Ryan Macnak Commit-Queue: Liam Appelbe --- runtime/vm/source_report.cc | 27 ++------------------------- runtime/vm/source_report.h | 1 - 2 files changed, 2 insertions(+), 26 deletions(-) diff --git a/runtime/vm/source_report.cc b/runtime/vm/source_report.cc index b5500515203..e039309eeb2 100644 --- a/runtime/vm/source_report.cc +++ b/runtime/vm/source_report.cc @@ -330,29 +330,6 @@ intptr_t SourceReport::GetTokenPosOrLine(const Script& script, return line; } -bool SourceReport::ShouldCoverageSkipCallSite(const ICData* ic_data) { - if (ic_data == nullptr) return true; - if (!ic_data->is_static_call()) return false; - Function& func = Function::Handle(ic_data->GetTargetAt(0)); - - // Ignore calls to the LateError functions. These are used to throw errors to - // do with late variables. These errors shouldn't be hit in working code, so - // shouldn't count against the coverage total. - // See https://github.com/dart-lang/coverage/issues/341 - if (late_error_class_id_ == ClassId::kIllegalCid) { - const auto& dart_internal = Library::Handle(Library::InternalLibrary()); - const auto& late_error_class = - Class::Handle(dart_internal.LookupClass(Symbols::LateError())); - ASSERT(!late_error_class.IsNull()); - late_error_class_id_ = late_error_class.id(); - } - Class& cls = Class::Handle(func.Owner()); - if (late_error_class_id_ == cls.id()) { - return true; - } - return false; -} - void SourceReport::PrintCoverageData(JSONObject* jsobj, const Function& function, const Code& code, @@ -386,7 +363,7 @@ void SourceReport::PrintCoverageData(JSONObject* jsobj, } auto update_coverage = [&](TokenPosition token_pos, bool was_executed) { - if (!token_pos.IsWithin(begin_pos, end_pos)) { + if (!(token_pos.IsReal() && token_pos.IsWithin(begin_pos, end_pos))) { return; } @@ -408,7 +385,7 @@ void SourceReport::PrintCoverageData(JSONObject* jsobj, HANDLESCOPE(thread()); ASSERT(iter.DeoptId() < ic_data_array->length()); const ICData* ic_data = (*ic_data_array)[iter.DeoptId()]; - if (!ShouldCoverageSkipCallSite(ic_data)) { + if (ic_data != nullptr) { const TokenPosition& token_pos = iter.TokenPos(); update_coverage(token_pos, ic_data->AggregateCount() > 0); } diff --git a/runtime/vm/source_report.h b/runtime/vm/source_report.h index a4f7c11fb8a..5a1cecb7f30 100644 --- a/runtime/vm/source_report.h +++ b/runtime/vm/source_report.h @@ -76,7 +76,6 @@ class SourceReport { bool IsReportRequested(ReportKind report_kind); bool ShouldSkipFunction(const Function& func); bool ShouldSkipField(const Field& field); - bool ShouldCoverageSkipCallSite(const ICData* ic_data); intptr_t GetScriptIndex(const Script& script); bool ScriptIsLoadedByLibrary(const Script& script, const Library& lib); intptr_t GetTokenPosOrLine(const Script& script,