Skip to content

Commit 23ea7ee

Browse files
bcoeBethGriggs
authored andcommittedApr 8, 2019
deps: v8, backport coverage fixes
Pulls in patches from V8 (52e2b5, 512175, aac2f8, 9365d09, 2d08967) which address a variety of coverage bugs, bringing Node v10 coverage to parity with Node v11. Original commit message: [coverage] Extend SourceRangeAstVisitor for throw statements The SourceRangeAstVisitor has custom logic for blocks ending with a statement that has a continuation range. In these cases, the trailing continuation is removed which makes the reported coverage ranges a bit nicer. throw Error('foo') consists of an ExpressionStatement, with a Throw expression stored within the statement. The source range itself is stored with the Throw, not the statement. We now properly extract the correct AST node for trailing throw statements. R=jgruber@chromium.org, neis@chromium.org, yangguo@chromium.org Bug: v8:8691 Change-Id: Ibcbab79fbe54719a8993045040349c863b139011 Reviewed-on: https://chromium-review.googlesource.com/c/1480632 Commit-Queue: Georg Neis <neis@chromium.org> Reviewed-by: Georg Neis <neis@chromium.org> Reviewed-by: Jakob Gruber <jgruber@chromium.org> Cr-Commit-Position: refs/heads/master@{#59936} Refs: v8/v8@2d08967 Original commit message: [coverage] Rework continuation counter handling This changes a few bits about how continuation counters are handled. It introduces a new mechanism that allows removal of a continuation range after it has been created. If coverage is enabled, we run a first post-processing pass on the AST immediately after parsing, which removes problematic continuation ranges in two situations: 1. nested continuation counters - only the outermost stays alive. 2. trailing continuation counters within a block-like structure are removed if the containing structure itself has a continuation. R=bmeurer@chromium.org, jgruber@chromium.org, yangguo@chromium.org Bug: v8:8381, v8:8539 Change-Id: I6bcaea5060d8c481d7bae099f6db9f993cc30ee3 Reviewed-on: https://chromium-review.googlesource.com/c/1339119 Reviewed-by: Yang Guo <yangguo@chromium.org> Reviewed-by: Leszek Swirski <leszeks@chromium.org> Reviewed-by: Georg Neis <neis@chromium.org> Commit-Queue: Jakob Gruber <jgruber@chromium.org> Cr-Commit-Position: refs/heads/master@{#58443} Refs: v8/v8@9365d09 Original commit message: [coverage] Filter out singleton ranges that alias full ranges Block coverage is based on a system of ranges that can either have both a start and end position, or only a start position (so-called singleton ranges). When formatting coverage information, singletons are expanded until the end of the immediate full parent range. E.g. in: {0, 10} // Full range. {5, -1} // Singleton range. the singleton range is expanded to {5, 10}. Singletons are produced mostly for continuation counters that track whether we execute past a specific language construct. Unfortunately, continuation counters can turn up in spots that confuse our post-processing. For example: if (true) { ... block1 ... } else { ... block2 ... } If block1 produces a continuation counter, it could end up with the same start position as the else-branch counter. Since we merge identical blocks, the else-branch could incorrectly end up with an execution count of one. We need to avoid merging such cases. A full range should always take precedence over a singleton range; a singleton range should never expand to completely fill a full range. An additional post-processing pass ensures this. Bug: v8:8237 Change-Id: Idb3ec7b2feddc0585313810b9c8be1e9f4ec64bf Reviewed-on: https://chromium-review.googlesource.com/c/1273095 Reviewed-by: Georg Neis <neis@chromium.org> Reviewed-by: Yang Guo <yangguo@chromium.org> Commit-Queue: Jakob Gruber <jgruber@chromium.org> Cr-Commit-Position: refs/heads/master@{#56531} Refs: v8/v8@aac2f8c Original commit message: [ast] Introduce ZonePtrList<T> typedef for ZoneList<T*>. This is a preliminary step before changing the way we store zone pointers in the zones. Bug: v8:7903, v8:7754 Change-Id: I1e1af1823766c888ee0f8fe190f205f5b7e21973 Reviewed-on: https://chromium-review.googlesource.com/1118887 Reviewed-by: Ross McIlroy <rmcilroy@chromium.org> Reviewed-by: Marja Hölttä <marja@chromium.org> Reviewed-by: Camillo Bruni <cbruni@chromium.org> Commit-Queue: Igor Sheludko <ishell@chromium.org> Cr-Commit-Position: refs/heads/master@{#54193} Refs: v8/v8@512175a Original commit message: [explicit isolates] Replace every Handle(T*) in parsing/ Replace all but one Handle<T*>(T*) calls with ones that explicitly pass in an Isolate. Requires plumbing Isolate* through several Parser functions which previously avoided it because of worries about accessing the heap off the main thread. In all off-main-thread cases, isolate will be nullptr and every such function asserts with: DCHECK_EQ(parsing_on_main_thread_, isolate != nullptr); Also deletes unused function ParseInfo::ReopenHandlesInNewHandleScope. Bug: v8:7786 Change-Id: I3dd9c49dcde49fdbcb684ba73f47a30d00fc495e Reviewed-on: https://chromium-review.googlesource.com/1087272 Commit-Queue: Dan Elphick <delphick@chromium.org> Reviewed-by: Toon Verwaest <verwaest@chromium.org> Cr-Commit-Position: refs/heads/master@{#53820} Refs: v8/v8@52e2b5a PR-URL: #26579 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com> Reviewed-By: Shelley Vohr <codebytere@gmail.com> Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Beth Griggs <Bethany.Griggs@uk.ibm.com>
1 parent 2643801 commit 23ea7ee

35 files changed

+964
-605
lines changed
 

‎common.gypi

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
# Reset this number to 0 on major V8 upgrades.
3535
# Increment by one for each non-official patch applied to deps/v8.
36-
'v8_embedder_string': '-node.51',
36+
'v8_embedder_string': '-node.52',
3737

3838
# Enable disassembler for `--print-code` v8 options
3939
'v8_enable_disassembler': 1,

‎deps/v8/AUTHORS

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Andrew Paprocki <andrew@ishiboo.com>
4949
Andrei Kashcha <anvaka@gmail.com>
5050
Anna Henningsen <anna@addaleax.net>
5151
Bangfu Tao <bangfu.tao@samsung.com>
52-
Ben Coe <ben@npmjs.com>
52+
Ben Coe <bencoe@gmail.com>
5353
Ben Newman <ben@meteor.com>
5454
Ben Noordhuis <info@bnoordhuis.nl>
5555
Benjamin Tan <demoneaux@gmail.com>

‎deps/v8/BUILD.gn

+2
Original file line numberDiff line numberDiff line change
@@ -1496,6 +1496,8 @@ v8_source_set("v8_base") {
14961496
"src/ast/prettyprinter.h",
14971497
"src/ast/scopes.cc",
14981498
"src/ast/scopes.h",
1499+
"src/ast/source-range-ast-visitor.cc",
1500+
"src/ast/source-range-ast-visitor.h",
14991501
"src/ast/variables.cc",
15001502
"src/ast/variables.h",
15011503
"src/bailout-reason.cc",

‎deps/v8/gypfiles/v8.gyp

+2
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,8 @@
516516
'../src/ast/prettyprinter.h',
517517
'../src/ast/scopes.cc',
518518
'../src/ast/scopes.h',
519+
"../src/ast/source-range-ast-visitor.cc",
520+
"../src/ast/source-range-ast-visitor.h",
519521
'../src/ast/variables.cc',
520522
'../src/ast/variables.h',
521523
'../src/bailout-reason.cc',

‎deps/v8/src/ast/ast-source-ranges.h

+89-12
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,24 @@ class AstNodeSourceRanges : public ZoneObject {
5858
public:
5959
virtual ~AstNodeSourceRanges() {}
6060
virtual SourceRange GetRange(SourceRangeKind kind) = 0;
61+
virtual bool HasRange(SourceRangeKind kind) = 0;
62+
virtual void RemoveContinuationRange() { UNREACHABLE(); }
6163
};
6264

6365
class BinaryOperationSourceRanges final : public AstNodeSourceRanges {
6466
public:
6567
explicit BinaryOperationSourceRanges(const SourceRange& right_range)
6668
: right_range_(right_range) {}
6769

68-
SourceRange GetRange(SourceRangeKind kind) {
69-
DCHECK_EQ(kind, SourceRangeKind::kRight);
70+
SourceRange GetRange(SourceRangeKind kind) override {
71+
DCHECK(HasRange(kind));
7072
return right_range_;
7173
}
7274

75+
bool HasRange(SourceRangeKind kind) override {
76+
return kind == SourceRangeKind::kRight;
77+
}
78+
7379
private:
7480
SourceRange right_range_;
7581
};
@@ -79,11 +85,20 @@ class ContinuationSourceRanges : public AstNodeSourceRanges {
7985
explicit ContinuationSourceRanges(int32_t continuation_position)
8086
: continuation_position_(continuation_position) {}
8187

82-
SourceRange GetRange(SourceRangeKind kind) {
83-
DCHECK_EQ(kind, SourceRangeKind::kContinuation);
88+
SourceRange GetRange(SourceRangeKind kind) override {
89+
DCHECK(HasRange(kind));
8490
return SourceRange::OpenEnded(continuation_position_);
8591
}
8692

93+
bool HasRange(SourceRangeKind kind) override {
94+
return kind == SourceRangeKind::kContinuation;
95+
}
96+
97+
void RemoveContinuationRange() override {
98+
DCHECK(HasRange(SourceRangeKind::kContinuation));
99+
continuation_position_ = kNoSourcePosition;
100+
}
101+
87102
private:
88103
int32_t continuation_position_;
89104
};
@@ -99,11 +114,15 @@ class CaseClauseSourceRanges final : public AstNodeSourceRanges {
99114
explicit CaseClauseSourceRanges(const SourceRange& body_range)
100115
: body_range_(body_range) {}
101116

102-
SourceRange GetRange(SourceRangeKind kind) {
103-
DCHECK_EQ(kind, SourceRangeKind::kBody);
117+
SourceRange GetRange(SourceRangeKind kind) override {
118+
DCHECK(HasRange(kind));
104119
return body_range_;
105120
}
106121

122+
bool HasRange(SourceRangeKind kind) override {
123+
return kind == SourceRangeKind::kBody;
124+
}
125+
107126
private:
108127
SourceRange body_range_;
109128
};
@@ -114,7 +133,8 @@ class ConditionalSourceRanges final : public AstNodeSourceRanges {
114133
const SourceRange& else_range)
115134
: then_range_(then_range), else_range_(else_range) {}
116135

117-
SourceRange GetRange(SourceRangeKind kind) {
136+
SourceRange GetRange(SourceRangeKind kind) override {
137+
DCHECK(HasRange(kind));
118138
switch (kind) {
119139
case SourceRangeKind::kThen:
120140
return then_range_;
@@ -125,6 +145,10 @@ class ConditionalSourceRanges final : public AstNodeSourceRanges {
125145
}
126146
}
127147

148+
bool HasRange(SourceRangeKind kind) override {
149+
return kind == SourceRangeKind::kThen || kind == SourceRangeKind::kElse;
150+
}
151+
128152
private:
129153
SourceRange then_range_;
130154
SourceRange else_range_;
@@ -136,13 +160,15 @@ class IfStatementSourceRanges final : public AstNodeSourceRanges {
136160
const SourceRange& else_range)
137161
: then_range_(then_range), else_range_(else_range) {}
138162

139-
SourceRange GetRange(SourceRangeKind kind) {
163+
SourceRange GetRange(SourceRangeKind kind) override {
164+
DCHECK(HasRange(kind));
140165
switch (kind) {
141166
case SourceRangeKind::kElse:
142167
return else_range_;
143168
case SourceRangeKind::kThen:
144169
return then_range_;
145170
case SourceRangeKind::kContinuation: {
171+
if (!has_continuation_) return SourceRange::Empty();
146172
const SourceRange& trailing_range =
147173
else_range_.IsEmpty() ? then_range_ : else_range_;
148174
return SourceRange::ContinuationOf(trailing_range);
@@ -152,29 +178,53 @@ class IfStatementSourceRanges final : public AstNodeSourceRanges {
152178
}
153179
}
154180

181+
bool HasRange(SourceRangeKind kind) override {
182+
return kind == SourceRangeKind::kThen || kind == SourceRangeKind::kElse ||
183+
kind == SourceRangeKind::kContinuation;
184+
}
185+
186+
void RemoveContinuationRange() override {
187+
DCHECK(HasRange(SourceRangeKind::kContinuation));
188+
has_continuation_ = false;
189+
}
190+
155191
private:
156192
SourceRange then_range_;
157193
SourceRange else_range_;
194+
bool has_continuation_ = true;
158195
};
159196

160197
class IterationStatementSourceRanges final : public AstNodeSourceRanges {
161198
public:
162199
explicit IterationStatementSourceRanges(const SourceRange& body_range)
163200
: body_range_(body_range) {}
164201

165-
SourceRange GetRange(SourceRangeKind kind) {
202+
SourceRange GetRange(SourceRangeKind kind) override {
203+
DCHECK(HasRange(kind));
166204
switch (kind) {
167205
case SourceRangeKind::kBody:
168206
return body_range_;
169207
case SourceRangeKind::kContinuation:
208+
if (!has_continuation_) return SourceRange::Empty();
170209
return SourceRange::ContinuationOf(body_range_);
171210
default:
172211
UNREACHABLE();
173212
}
174213
}
175214

215+
bool HasRange(SourceRangeKind kind) override {
216+
return kind == SourceRangeKind::kBody ||
217+
kind == SourceRangeKind::kContinuation;
218+
}
219+
220+
void RemoveContinuationRange() override {
221+
DCHECK(HasRange(SourceRangeKind::kContinuation));
222+
has_continuation_ = false;
223+
}
224+
176225
private:
177226
SourceRange body_range_;
227+
bool has_continuation_ = true;
178228
};
179229

180230
class JumpStatementSourceRanges final : public ContinuationSourceRanges {
@@ -198,7 +248,8 @@ class NaryOperationSourceRanges final : public AstNodeSourceRanges {
198248
void AddRange(const SourceRange& range) { ranges_.push_back(range); }
199249
size_t RangeCount() const { return ranges_.size(); }
200250

201-
SourceRange GetRange(SourceRangeKind kind) { UNREACHABLE(); }
251+
SourceRange GetRange(SourceRangeKind kind) override { UNREACHABLE(); }
252+
bool HasRange(SourceRangeKind kind) override { return false; }
202253

203254
private:
204255
ZoneVector<SourceRange> ranges_;
@@ -227,39 +278,65 @@ class TryCatchStatementSourceRanges final : public AstNodeSourceRanges {
227278
explicit TryCatchStatementSourceRanges(const SourceRange& catch_range)
228279
: catch_range_(catch_range) {}
229280

230-
SourceRange GetRange(SourceRangeKind kind) {
281+
SourceRange GetRange(SourceRangeKind kind) override {
282+
DCHECK(HasRange(kind));
231283
switch (kind) {
232284
case SourceRangeKind::kCatch:
233285
return catch_range_;
234286
case SourceRangeKind::kContinuation:
287+
if (!has_continuation_) return SourceRange::Empty();
235288
return SourceRange::ContinuationOf(catch_range_);
236289
default:
237290
UNREACHABLE();
238291
}
239292
}
240293

294+
bool HasRange(SourceRangeKind kind) override {
295+
return kind == SourceRangeKind::kCatch ||
296+
kind == SourceRangeKind::kContinuation;
297+
}
298+
299+
void RemoveContinuationRange() override {
300+
DCHECK(HasRange(SourceRangeKind::kContinuation));
301+
has_continuation_ = false;
302+
}
303+
241304
private:
242305
SourceRange catch_range_;
306+
bool has_continuation_ = true;
243307
};
244308

245309
class TryFinallyStatementSourceRanges final : public AstNodeSourceRanges {
246310
public:
247311
explicit TryFinallyStatementSourceRanges(const SourceRange& finally_range)
248312
: finally_range_(finally_range) {}
249313

250-
SourceRange GetRange(SourceRangeKind kind) {
314+
SourceRange GetRange(SourceRangeKind kind) override {
315+
DCHECK(HasRange(kind));
251316
switch (kind) {
252317
case SourceRangeKind::kFinally:
253318
return finally_range_;
254319
case SourceRangeKind::kContinuation:
320+
if (!has_continuation_) return SourceRange::Empty();
255321
return SourceRange::ContinuationOf(finally_range_);
256322
default:
257323
UNREACHABLE();
258324
}
259325
}
260326

327+
bool HasRange(SourceRangeKind kind) override {
328+
return kind == SourceRangeKind::kFinally ||
329+
kind == SourceRangeKind::kContinuation;
330+
}
331+
332+
void RemoveContinuationRange() override {
333+
DCHECK(HasRange(SourceRangeKind::kContinuation));
334+
has_continuation_ = false;
335+
}
336+
261337
private:
262338
SourceRange finally_range_;
339+
bool has_continuation_ = true;
263340
};
264341

265342
// Maps ast node pointers to associated source ranges. The parser creates these

‎deps/v8/src/ast/ast-traversal-visitor.h

+11-11
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class AstTraversalVisitor : public AstVisitor<Subclass> {
4141

4242
// Iteration left-to-right.
4343
void VisitDeclarations(Declaration::List* declarations);
44-
void VisitStatements(ZoneList<Statement*>* statements);
44+
void VisitStatements(ZonePtrList<Statement>* statements);
4545

4646
// Individual nodes
4747
#define DECLARE_VISIT(type) void Visit##type(type* node);
@@ -112,7 +112,7 @@ void AstTraversalVisitor<Subclass>::VisitDeclarations(
112112

113113
template <class Subclass>
114114
void AstTraversalVisitor<Subclass>::VisitStatements(
115-
ZoneList<Statement*>* stmts) {
115+
ZonePtrList<Statement>* stmts) {
116116
for (int i = 0; i < stmts->length(); ++i) {
117117
Statement* stmt = stmts->at(i);
118118
RECURSE(Visit(stmt));
@@ -198,14 +198,14 @@ void AstTraversalVisitor<Subclass>::VisitSwitchStatement(
198198
PROCESS_NODE(stmt);
199199
RECURSE(Visit(stmt->tag()));
200200

201-
ZoneList<CaseClause*>* clauses = stmt->cases();
201+
ZonePtrList<CaseClause>* clauses = stmt->cases();
202202
for (int i = 0; i < clauses->length(); ++i) {
203203
CaseClause* clause = clauses->at(i);
204204
if (!clause->is_default()) {
205205
Expression* label = clause->label();
206206
RECURSE(Visit(label));
207207
}
208-
ZoneList<Statement*>* stmts = clause->statements();
208+
ZonePtrList<Statement>* stmts = clause->statements();
209209
RECURSE(VisitStatements(stmts));
210210
}
211211
}
@@ -330,7 +330,7 @@ void AstTraversalVisitor<Subclass>::VisitRegExpLiteral(RegExpLiteral* expr) {
330330
template <class Subclass>
331331
void AstTraversalVisitor<Subclass>::VisitObjectLiteral(ObjectLiteral* expr) {
332332
PROCESS_EXPRESSION(expr);
333-
ZoneList<ObjectLiteralProperty*>* props = expr->properties();
333+
ZonePtrList<ObjectLiteralProperty>* props = expr->properties();
334334
for (int i = 0; i < props->length(); ++i) {
335335
ObjectLiteralProperty* prop = props->at(i);
336336
RECURSE_EXPRESSION(Visit(prop->key()));
@@ -341,7 +341,7 @@ void AstTraversalVisitor<Subclass>::VisitObjectLiteral(ObjectLiteral* expr) {
341341
template <class Subclass>
342342
void AstTraversalVisitor<Subclass>::VisitArrayLiteral(ArrayLiteral* expr) {
343343
PROCESS_EXPRESSION(expr);
344-
ZoneList<Expression*>* values = expr->values();
344+
ZonePtrList<Expression>* values = expr->values();
345345
for (int i = 0; i < values->length(); ++i) {
346346
Expression* value = values->at(i);
347347
RECURSE_EXPRESSION(Visit(value));
@@ -404,7 +404,7 @@ template <class Subclass>
404404
void AstTraversalVisitor<Subclass>::VisitCall(Call* expr) {
405405
PROCESS_EXPRESSION(expr);
406406
RECURSE_EXPRESSION(Visit(expr->expression()));
407-
ZoneList<Expression*>* args = expr->arguments();
407+
ZonePtrList<Expression>* args = expr->arguments();
408408
for (int i = 0; i < args->length(); ++i) {
409409
Expression* arg = args->at(i);
410410
RECURSE_EXPRESSION(Visit(arg));
@@ -415,7 +415,7 @@ template <class Subclass>
415415
void AstTraversalVisitor<Subclass>::VisitCallNew(CallNew* expr) {
416416
PROCESS_EXPRESSION(expr);
417417
RECURSE_EXPRESSION(Visit(expr->expression()));
418-
ZoneList<Expression*>* args = expr->arguments();
418+
ZonePtrList<Expression>* args = expr->arguments();
419419
for (int i = 0; i < args->length(); ++i) {
420420
Expression* arg = args->at(i);
421421
RECURSE_EXPRESSION(Visit(arg));
@@ -425,7 +425,7 @@ void AstTraversalVisitor<Subclass>::VisitCallNew(CallNew* expr) {
425425
template <class Subclass>
426426
void AstTraversalVisitor<Subclass>::VisitCallRuntime(CallRuntime* expr) {
427427
PROCESS_EXPRESSION(expr);
428-
ZoneList<Expression*>* args = expr->arguments();
428+
ZonePtrList<Expression>* args = expr->arguments();
429429
for (int i = 0; i < args->length(); ++i) {
430430
Expression* arg = args->at(i);
431431
RECURSE_EXPRESSION(Visit(arg));
@@ -487,7 +487,7 @@ void AstTraversalVisitor<Subclass>::VisitClassLiteral(ClassLiteral* expr) {
487487
if (expr->instance_fields_initializer_function() != nullptr) {
488488
RECURSE_EXPRESSION(Visit(expr->instance_fields_initializer_function()));
489489
}
490-
ZoneList<ClassLiteralProperty*>* props = expr->properties();
490+
ZonePtrList<ClassLiteral::Property>* props = expr->properties();
491491
for (int i = 0; i < props->length(); ++i) {
492492
ClassLiteralProperty* prop = props->at(i);
493493
if (!prop->key()->IsLiteral()) {
@@ -501,7 +501,7 @@ template <class Subclass>
501501
void AstTraversalVisitor<Subclass>::VisitInitializeClassFieldsStatement(
502502
InitializeClassFieldsStatement* stmt) {
503503
PROCESS_NODE(stmt);
504-
ZoneList<ClassLiteralProperty*>* props = stmt->fields();
504+
ZonePtrList<ClassLiteral::Property>* props = stmt->fields();
505505
for (int i = 0; i < props->length(); ++i) {
506506
ClassLiteralProperty* prop = props->at(i);
507507
if (!prop->key()->IsLiteral()) {

‎deps/v8/src/ast/ast.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,7 @@ Call::CallType Call::GetCallType() const {
831831
return OTHER_CALL;
832832
}
833833

834-
CaseClause::CaseClause(Expression* label, ZoneList<Statement*>* statements)
834+
CaseClause::CaseClause(Expression* label, ZonePtrList<Statement>* statements)
835835
: label_(label), statements_(statements) {}
836836

837837
bool Literal::IsPropertyName() const {
@@ -954,7 +954,7 @@ const char* CallRuntime::debug_name() {
954954
case k##NodeType: \
955955
return static_cast<const NodeType*>(this)->labels();
956956

957-
ZoneList<const AstRawString*>* BreakableStatement::labels() const {
957+
ZonePtrList<const AstRawString>* BreakableStatement::labels() const {
958958
switch (node_type()) {
959959
BREAKABLE_NODE_LIST(RETURN_LABELS)
960960
ITERATION_NODE_LIST(RETURN_LABELS)

0 commit comments

Comments
 (0)