[vm,dyn_modules] Ensure coverage arrays during source reporting.

The original iteration of adding coverage arrays originally eagerly
allocated coverage arrays for bytecode methods with recorded coverage.

Now that these coverage arrays are lazily allocated,
Function::GetCoverageArray() needs to ensure that the appropriate
coverage array has been allocated.  Otherwise, no misses within the
function are recorded in cases where no RecordCoverage instruction in
the method has yet been executed.

TEST=vm/cc/SourceReport_Coverage_UnusedClass_ForceCompile
     pkg/vm_service/test/branch_coverage_test
     pkg/vm_service/test/coverage_async_test
     pkg/vm_service/test/coverage_closure_call_after_optimization_test
     pkg/vm_service/test/coverage_closure_call_test
     pkg/vm_service/test/coverage_instance_call_after_optimization_test
     pkg/vm_service/test/coverage_static_call_after_optimization_test

Cq-Include-Trybots: luci.dart.try:vm-dyn-linux-debug-x64-try
Change-Id: Iff4ddaf583d0f9583bc415142bdee52c046a6712
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/507440
Reviewed-by: Alexander Markov <alexmarkov@google.com>
This commit is contained in:
Tess Strickland
2026-06-01 10:35:58 -07:00
committed by dart-scoped@luci-project-accounts.iam.gserviceaccount.com
parent ca78143775
commit 34c4e4799d
+4 -3
View File
@@ -11555,10 +11555,11 @@ TypedDataPtr Function::GetCoverageArray() const {
if (HasBytecode()) {
#if !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME)
const auto& bytecode = Bytecode::Handle(GetBytecode());
return bytecode.coverage_array();
#else
return TypedData::null();
if (bytecode.HasRecordedCoverage()) {
return bytecode.EnsureCoverageArray(Thread::Current());
}
#endif
return TypedData::null();
}
#endif
const Array& arr = Array::Handle(ic_data_array());