From 1fb0c0c231cd8a1e3429daa56d1b2f716fa1fb42 Mon Sep 17 00:00:00 2001 From: Tess Strickland Date: Tue, 12 May 2026 07:46:06 -0700 Subject: [PATCH] [vm,dynamic_modules] Add record-coverage bytecode option. This CL only adds the option and appropriate uses of it. Followup CLs will use it to actually generate appropriate instructions and metadata for collecting coverage information. TEST=ci (just adding flag) Cq-Include-Trybots: luci.dart.try:vm-dyn-linux-debug-x64-try,vm-aot-dyn-linux-debug-x64-try,vm-aot-dyn-linux-product-x64-try Change-Id: I194154ef926abe7dae8bb93f397fb68029e2db3c Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/501500 Reviewed-by: Alexander Markov Commit-Queue: Tess Strickland Reviewed-by: Alexander Thomas --- pkg/dart2bytecode/bin/kernel_service.dart | 1 + pkg/dart2bytecode/lib/options.dart | 6 ++++++ pkg/test_runner/lib/src/compiler_configuration.dart | 3 ++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/pkg/dart2bytecode/bin/kernel_service.dart b/pkg/dart2bytecode/bin/kernel_service.dart index 2742b782be4..277db07ac3b 100644 --- a/pkg/dart2bytecode/bin/kernel_service.dart +++ b/pkg/dart2bytecode/bin/kernel_service.dart @@ -38,6 +38,7 @@ Uint8List _generateBytecode( emitLocalVarInfo: true, emitInstanceFieldInitializers: true, embedSourceText: true, + recordCoverage: true, ), ); return byteSink.builder.takeBytes(); diff --git a/pkg/dart2bytecode/lib/options.dart b/pkg/dart2bytecode/lib/options.dart index 929364f05f1..82d7481b63f 100644 --- a/pkg/dart2bytecode/lib/options.dart +++ b/pkg/dart2bytecode/lib/options.dart @@ -15,6 +15,7 @@ class BytecodeOptions { 'closure-context-lowering': 'Use the closure context lowering in Kernel AST instead of computing it', 'embed-source-text': 'Embed the source text of scripts', + 'record-coverage': 'Emit instructions and metadata for recording coverage', }; bool enableAsserts; @@ -27,6 +28,7 @@ class BytecodeOptions { bool showBytecodeSizeStatistics; bool isClosureContextLoweringEnabled; bool embedSourceText; + bool recordCoverage; BytecodeOptions({ this.enableAsserts = false, @@ -39,6 +41,7 @@ class BytecodeOptions { this.showBytecodeSizeStatistics = false, this.isClosureContextLoweringEnabled = false, this.embedSourceText = false, + this.recordCoverage = false, }) {} void parseCommandLineFlags(List? flags) { @@ -71,6 +74,9 @@ class BytecodeOptions { case 'embed-source-text': embedSourceText = true; break; + case 'record-coverage': + recordCoverage = true; + break; default: throw 'Unexpected bytecode flag $flag'; } diff --git a/pkg/test_runner/lib/src/compiler_configuration.dart b/pkg/test_runner/lib/src/compiler_configuration.dart index 7cedafc93b4..c0481c32b4d 100644 --- a/pkg/test_runner/lib/src/compiler_configuration.dart +++ b/pkg/test_runner/lib/src/compiler_configuration.dart @@ -1893,7 +1893,8 @@ class BytecodeCompilerConfiguration extends CompilerConfiguration { arguments.contains('--enable_asserts')) '--enable-asserts', if (!isProductMode) - '--bytecode-options=source-positions,embed-source-text', + '--bytecode-options=source-positions,embed-source-text' + '${_isAot ? '' : ',record-coverage'}', ]; return CompilationCommand(