Skip to content

Commit d62d06b

Browse files
bcoeMylesBorins
authored andcommitted
deps: V8: cherry-pick b9d33036e9a8
Original commit message: [coverage] Improve whitespace precision of coverage reporting This CL improves whitespace precision of coverage around try blocks; previously a small portion of whitespace could be reported as uncovered between try blocks and catch and/or finally blocks. Change-Id: I763ae3d15106c88f2278cf8893c12b0869a62528 Fixed: v8:10030 Bug: v8:10030 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1962265 Reviewed-by: Toon Verwaest <verwaest@chromium.org> Reviewed-by: Jakob Gruber <jgruber@chromium.org> Commit-Queue: Sigurd Schneider <sigurds@chromium.org> Cr-Commit-Position: refs/heads/master@{#65593} Refs: v8/v8@b9d3303 PR-URL: #31335 Refs: #25937 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent 51e4a56 commit d62d06b

File tree

4 files changed

+88
-15
lines changed

4 files changed

+88
-15
lines changed

common.gypi

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939

4040
# Reset this number to 0 on major V8 upgrades.
4141
# Increment by one for each non-official patch applied to deps/v8.
42-
'v8_embedder_string': '-node.26',
42+
'v8_embedder_string': '-node.27',
4343

4444
##### V8 defaults for Node.js #####
4545

deps/v8/src/ast/source-range-ast-visitor.cc

+7
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,16 @@ void SourceRangeAstVisitor::VisitFunctionLiteral(FunctionLiteral* expr) {
4141

4242
void SourceRangeAstVisitor::VisitTryCatchStatement(TryCatchStatement* stmt) {
4343
AstTraversalVisitor::VisitTryCatchStatement(stmt);
44+
MaybeRemoveContinuationRange(stmt->try_block());
4445
MaybeRemoveContinuationRangeOfAsyncReturn(stmt);
4546
}
4647

48+
void SourceRangeAstVisitor::VisitTryFinallyStatement(
49+
TryFinallyStatement* stmt) {
50+
AstTraversalVisitor::VisitTryFinallyStatement(stmt);
51+
MaybeRemoveContinuationRange(stmt->try_block());
52+
}
53+
4754
bool SourceRangeAstVisitor::VisitNode(AstNode* node) {
4855
AstNodeSourceRanges* range = source_range_map_->Find(node);
4956

deps/v8/src/ast/source-range-ast-visitor.h

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class SourceRangeAstVisitor final
3838
void VisitFunctionLiteral(FunctionLiteral* expr);
3939
bool VisitNode(AstNode* node);
4040
void VisitTryCatchStatement(TryCatchStatement* stmt);
41+
void VisitTryFinallyStatement(TryFinallyStatement* stmt);
4142

4243
void MaybeRemoveContinuationRange(Statement* last_statement);
4344
void MaybeRemoveLastContinuationRange(ZonePtrList<Statement>* stmts);

deps/v8/test/mjsunit/code-coverage-block.js

+79-14
Original file line numberDiff line numberDiff line change
@@ -337,11 +337,7 @@ TestCoverage(
337337
[{"start":0,"end":849,"count":1},
338338
{"start":1,"end":801,"count":1},
339339
{"start":67,"end":87,"count":0},
340-
{"start":221,"end":222,"count":0},
341-
{"start":254,"end":274,"count":0},
342-
{"start":371,"end":372,"count":0},
343-
{"start":403,"end":404,"count":0},
344-
{"start":553,"end":554,"count":0}]
340+
{"start":254,"end":274,"count":0}]
345341
);
346342

347343
TestCoverage("try/catch/finally statements with early return",
@@ -358,10 +354,8 @@ TestCoverage("try/catch/finally statements with early return",
358354
`,
359355
[{"start":0,"end":449,"count":1},
360356
{"start":1,"end":151,"count":1},
361-
{"start":69,"end":70,"count":0},
362357
{"start":91,"end":150,"count":0},
363358
{"start":201,"end":401,"count":1},
364-
{"start":269,"end":270,"count":0},
365359
{"start":321,"end":400,"count":0}]
366360
);
367361

@@ -393,15 +387,13 @@ TestCoverage(
393387
`,
394388
[{"start":0,"end":1099,"count":1},
395389
{"start":1,"end":151,"count":1},
396-
{"start":69,"end":70,"count":0},
397390
{"start":91,"end":150,"count":0},
398391
{"start":201,"end":351,"count":1},
399392
{"start":286,"end":350,"count":0},
400393
{"start":401,"end":701,"count":1},
401394
{"start":603,"end":700,"count":0},
402395
{"start":561,"end":568,"count":0},
403396
{"start":751,"end":1051,"count":1},
404-
{"start":819,"end":820,"count":0},
405397
{"start":861,"end":1050,"count":0}]
406398
);
407399

@@ -561,7 +553,6 @@ try { // 0200
561553
} catch (e) {} // 0450
562554
`,
563555
[{"start":0,"end":499,"count":1},
564-
{"start":451,"end":452,"count":0},
565556
{"start":12,"end":101,"count":1},
566557
{"start":60,"end":100,"count":0},
567558
{"start":264,"end":353,"count":1},
@@ -636,7 +627,6 @@ try { // 0200
636627
} catch (e) {} // 0450
637628
`,
638629
[{"start":0,"end":499,"count":1},
639-
{"start":451,"end":452,"count":0},
640630
{"start":12,"end":101,"count":1},
641631
{"start":65,"end":100,"count":0},
642632
{"start":264,"end":353,"count":1},
@@ -1017,7 +1007,6 @@ try { // 0500
10171007
} catch (err) {} // 0600
10181008
`,
10191009
[{"start":0,"end":649,"count":1},
1020-
{"start":351,"end":352,"count":0},
10211010
{"start":602,"end":616,"count":0},
10221011
{"start":0,"end":201,"count":2},
10231012
{"start":69,"end":153,"count":1}]
@@ -1093,7 +1082,8 @@ function test(foo = "foodef") { // 0000
10931082
console.log("test"); // 0200
10941083
} // 0250
10951084
} // 0300
1096-
test().bar(); // 0350`,
1085+
test().bar(); // 0350
1086+
`,
10971087
[{"start":0,"end":399,"count":1},
10981088
{"start":0,"end":301,"count":1},
10991089
{"start":152,"end":253,"count":1}]);
@@ -1105,11 +1095,86 @@ function test(foo = (()=>{})) { // 0000
11051095
return {foo}; // 0050
11061096
} // 0100
11071097
// 0150
1108-
test(()=>{}).foo(); // 0200`,
1098+
test(()=>{}).foo(); // 0200
1099+
`,
11091100
[{"start":0,"end":249,"count":1},
11101101
{"start":0,"end":101,"count":1},
11111102
{"start":21,"end":27,"count":0},
11121103
{"start":205,"end":211,"count":1}]
11131104
);
11141105

1106+
TestCoverage(
1107+
"https://crbug.com/v8/10030 - original",
1108+
`
1109+
function a (shouldThrow) { // 0000
1110+
try { // 0050
1111+
if (shouldThrow) // 0100
1112+
throw Error('I threw!'); // 0150
1113+
return 'I ran'; // 0200
1114+
} catch(e) { // 0250
1115+
console.info('caught'); // 0300
1116+
} // 0350
1117+
} // 0400
1118+
a(false); // 0450
1119+
a(true); // 0500
1120+
`,
1121+
[{"start":0,"end":549,"count":1},
1122+
{"start":0,"end":401,"count":2},
1123+
{"start":156,"end":353,"count":1}]
1124+
);
1125+
1126+
TestCoverage(
1127+
"https://crbug.com/v8/10030 - only throw",
1128+
`
1129+
function a (shouldThrow) { // 0000
1130+
try { // 0050
1131+
if (shouldThrow) // 0100
1132+
throw Error('I threw!'); // 0150
1133+
return 'I ran'; // 0200
1134+
} catch(e) { // 0250
1135+
console.info('caught'); // 0300
1136+
} // 0350
1137+
} // 0400
1138+
a(true); // 0450
1139+
`,
1140+
[{"start":0,"end":499,"count":1},
1141+
{"start":0,"end":401,"count":1},
1142+
{"start":180,"end":254,"count":0}]
1143+
);
1144+
1145+
TestCoverage(
1146+
"https://crbug.com/v8/10030 - finally",
1147+
`
1148+
function a (shouldThrow) { // 0000
1149+
try { // 0050
1150+
return 'I ran'; // 0100
1151+
} finally { // 0150
1152+
console.info('finally'); // 0200
1153+
} // 0250
1154+
} // 0300
1155+
a(false); // 0350
1156+
a(true); // 0400
1157+
`,
1158+
[{"start":0,"end":449,"count":1},
1159+
{"start":0,"end":301,"count":2}]);
1160+
1161+
TestCoverage(
1162+
"https://crbug.com/v8/10030 - catch & finally",
1163+
`
1164+
function a (shouldThrow) { // 0000
1165+
try { // 0050
1166+
return 'I ran'; // 0100
1167+
} catch (e) { // 0150
1168+
console.info('caught'); // 0200
1169+
} finally { // 0250
1170+
console.info('finally'); // 0300
1171+
} // 0350
1172+
} // 0400
1173+
a(false); // 0450
1174+
a(true); // 0500
1175+
`,
1176+
[{"start":0,"end":549,"count":1},
1177+
{"start":0,"end":401,"count":2},
1178+
{"start":154,"end":254,"count":0}]);
1179+
11151180
%DebugToggleBlockCoverage(false);

0 commit comments

Comments
 (0)