[parser] Force func decl allocation for non-block code coverage
In addition to the previous change enabling forced FunctionDeclaration allocation when block code coverage is enabled, enable it now for all (non-best-effort) code coverage by reading off the coverage mode from the isolate (rather than relying on the presence of a source range map). Bug: chromium:927464 Change-Id: I26f86c9fbebc0df52d5cdeff3ca1095215a6d912 Reviewed-on: https://chromium-review.googlesource.com/c/1456041 Commit-Queue: Leszek Swirski <leszeks@chromium.org> Reviewed-by: Jakob Gruber <jgruber@chromium.org> Cr-Commit-Position: refs/heads/master@{#59626}
This commit is contained in:
parent
93c1371425
commit
54e515220d
@ -51,6 +51,7 @@ ParseInfo::ParseInfo(Isolate* isolate, AccountingAllocator* zone_allocator)
|
||||
set_ast_string_constants(isolate->ast_string_constants());
|
||||
set_collect_source_positions(!FLAG_enable_lazy_source_positions ||
|
||||
isolate->NeedsDetailedOptimizedCodeLineInfo());
|
||||
if (!isolate->is_best_effort_code_coverage()) set_coverage_enabled();
|
||||
if (isolate->is_block_code_coverage()) set_block_coverage_enabled();
|
||||
if (isolate->is_collecting_type_profile()) set_collect_type_profile();
|
||||
if (isolate->compiler_dispatcher()->IsEnabled()) {
|
||||
|
@ -84,6 +84,7 @@ class V8_EXPORT_PRIVATE ParseInfo {
|
||||
FLAG_ACCESSOR(kIsAsmWasmBroken, is_asm_wasm_broken, set_asm_wasm_broken)
|
||||
FLAG_ACCESSOR(kContainsAsmModule, contains_asm_module,
|
||||
set_contains_asm_module)
|
||||
FLAG_ACCESSOR(kCoverageEnabled, coverage_enabled, set_coverage_enabled)
|
||||
FLAG_ACCESSOR(kBlockCoverageEnabled, block_coverage_enabled,
|
||||
set_block_coverage_enabled)
|
||||
FLAG_ACCESSOR(kOnBackgroundThread, on_background_thread,
|
||||
@ -296,26 +297,27 @@ class V8_EXPORT_PRIVATE ParseInfo {
|
||||
kIsNamedExpression = 1 << 8,
|
||||
kLazyCompile = 1 << 9,
|
||||
kCollectTypeProfile = 1 << 10,
|
||||
kBlockCoverageEnabled = 1 << 11,
|
||||
kIsAsmWasmBroken = 1 << 12,
|
||||
kOnBackgroundThread = 1 << 13,
|
||||
kWrappedAsFunction = 1 << 14, // Implicitly wrapped as function.
|
||||
kAllowEvalCache = 1 << 15,
|
||||
kIsDeclaration = 1 << 16,
|
||||
kRequiresInstanceMembersInitializer = 1 << 17,
|
||||
kContainsAsmModule = 1 << 18,
|
||||
kMightAlwaysOpt = 1 << 19,
|
||||
kAllowLazyCompile = 1 << 20,
|
||||
kAllowNativeSyntax = 1 << 21,
|
||||
kAllowHarmonyPublicFields = 1 << 22,
|
||||
kAllowHarmonyStaticFields = 1 << 23,
|
||||
kAllowHarmonyDynamicImport = 1 << 24,
|
||||
kAllowHarmonyImportMeta = 1 << 25,
|
||||
kAllowHarmonyNumericSeparator = 1 << 26,
|
||||
kAllowHarmonyPrivateFields = 1 << 27,
|
||||
kAllowHarmonyPrivateMethods = 1 << 28,
|
||||
kIsOneshotIIFE = 1 << 29,
|
||||
kCollectSourcePositions = 1 << 30,
|
||||
kCoverageEnabled = 1 << 11,
|
||||
kBlockCoverageEnabled = 1 << 12,
|
||||
kIsAsmWasmBroken = 1 << 13,
|
||||
kOnBackgroundThread = 1 << 14,
|
||||
kWrappedAsFunction = 1 << 15, // Implicitly wrapped as function.
|
||||
kAllowEvalCache = 1 << 16,
|
||||
kIsDeclaration = 1 << 17,
|
||||
kRequiresInstanceMembersInitializer = 1 << 18,
|
||||
kContainsAsmModule = 1 << 19,
|
||||
kMightAlwaysOpt = 1 << 20,
|
||||
kAllowLazyCompile = 1 << 21,
|
||||
kAllowNativeSyntax = 1 << 22,
|
||||
kAllowHarmonyPublicFields = 1 << 23,
|
||||
kAllowHarmonyStaticFields = 1 << 24,
|
||||
kAllowHarmonyDynamicImport = 1 << 25,
|
||||
kAllowHarmonyImportMeta = 1 << 26,
|
||||
kAllowHarmonyNumericSeparator = 1 << 27,
|
||||
kAllowHarmonyPrivateFields = 1 << 28,
|
||||
kAllowHarmonyPrivateMethods = 1 << 29,
|
||||
kIsOneshotIIFE = 1 << 30,
|
||||
kCollectSourcePositions = 1 << 31,
|
||||
};
|
||||
|
||||
//------------- Inputs to parsing and scope analysis -----------------------
|
||||
|
@ -1447,7 +1447,7 @@ Statement* Parser::DeclareFunction(const AstRawString* variable_name,
|
||||
bool was_added;
|
||||
Declare(declaration, variable_name, kind, mode, kCreatedInitialized, scope(),
|
||||
&was_added, beg_pos);
|
||||
if (source_range_map_ != nullptr) {
|
||||
if (info()->coverage_enabled()) {
|
||||
// Force the function to be allocated when collecting source coverage, so
|
||||
// that even dead functions get source coverage data.
|
||||
declaration->var()->set_is_used();
|
||||
|
@ -753,6 +753,17 @@ Running test: testPreciseCountCoveragePartial
|
||||
}
|
||||
]
|
||||
}
|
||||
[6] : {
|
||||
functionName : nested_4
|
||||
isBlockCoverage : false
|
||||
ranges : [
|
||||
[0] : {
|
||||
count : 0
|
||||
endOffset : 201
|
||||
startOffset : 179
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
scriptId : <scriptId>
|
||||
url : testPreciseCountCoveragePartial
|
||||
|
@ -57,3 +57,19 @@ fib(5);
|
||||
[{"start":0,"end":80,"count":1},
|
||||
{"start":0,"end":72,"count":1}]
|
||||
);
|
||||
|
||||
TestCoverageNoGC(
|
||||
"https://crbug.com/927464",
|
||||
`
|
||||
!function f() { // 0000
|
||||
function unused() { nop(); } // 0100
|
||||
nop(); // 0150
|
||||
}(); // 0200
|
||||
`,
|
||||
[{"start":0,"end":199,"count":1},
|
||||
{"start":1,"end":151,"count":1}
|
||||
// The unused function is unfortunately not marked as unused in best-effort
|
||||
// code coverage, as the information about its source range is discarded
|
||||
// entirely.
|
||||
]
|
||||
);
|
||||
|
@ -50,4 +50,17 @@ for (var i = 0; i < 10; i++) {
|
||||
[{"start":0,"end":63,"count":1},{"start":41,"end":48,"count":5}]
|
||||
);
|
||||
|
||||
TestCoverage(
|
||||
"https://crbug.com/927464",
|
||||
`
|
||||
!function f() { // 0000
|
||||
function unused() { nop(); } // 0100
|
||||
nop(); // 0150
|
||||
}(); // 0200
|
||||
`,
|
||||
[{"start":0,"end":199,"count":1},
|
||||
{"start":1,"end":151,"count":1},
|
||||
{"start":52,"end":80,"count":0}]
|
||||
);
|
||||
|
||||
%DebugTogglePreciseCoverage(false);
|
||||
|
Loading…
Reference in New Issue
Block a user