Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(630)

Side by Side Diff: src/ast/ast-numbering.cc

Issue 2161263003: [debug] use catch prediction flag for promise rejections. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/ast/ast-numbering.h" 5 #include "src/ast/ast-numbering.h"
6 6
7 #include "src/ast/ast.h" 7 #include "src/ast/ast.h"
8 #include "src/ast/scopes.h" 8 #include "src/ast/scopes.h"
9 9
10 namespace v8 { 10 namespace v8 {
11 namespace internal { 11 namespace internal {
12 12
13 class AstNumberingVisitor final : public AstVisitor<AstNumberingVisitor> { 13 class AstNumberingVisitor final : public AstVisitor<AstNumberingVisitor> {
14 public: 14 public:
15 AstNumberingVisitor(Isolate* isolate, Zone* zone) 15 AstNumberingVisitor(Isolate* isolate, Zone* zone)
16 : isolate_(isolate), 16 : isolate_(isolate),
17 zone_(zone), 17 zone_(zone),
18 next_id_(BailoutId::FirstUsable().ToInt()), 18 next_id_(BailoutId::FirstUsable().ToInt()),
19 yield_count_(0), 19 yield_count_(0),
20 properties_(zone), 20 properties_(zone),
21 slot_cache_(zone), 21 slot_cache_(zone),
22 dont_optimize_reason_(kNoReason), 22 dont_optimize_reason_(kNoReason),
23 catch_predicted_(false) { 23 catch_prediction_(HandlerTable::UNCAUGHT) {
24 InitializeAstVisitor(isolate); 24 InitializeAstVisitor(isolate);
25 } 25 }
26 26
27 bool Renumber(FunctionLiteral* node); 27 bool Renumber(FunctionLiteral* node);
28 28
29 private: 29 private:
30 // AST node visitor interface. 30 // AST node visitor interface.
31 #define DEFINE_VISIT(type) void Visit##type(type* node); 31 #define DEFINE_VISIT(type) void Visit##type(type* node);
32 AST_NODE_LIST(DEFINE_VISIT) 32 AST_NODE_LIST(DEFINE_VISIT)
33 #undef DEFINE_VISIT 33 #undef DEFINE_VISIT
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 BailoutReason dont_optimize_reason() const { return dont_optimize_reason_; } 73 BailoutReason dont_optimize_reason() const { return dont_optimize_reason_; }
74 74
75 Isolate* isolate_; 75 Isolate* isolate_;
76 Zone* zone_; 76 Zone* zone_;
77 int next_id_; 77 int next_id_;
78 int yield_count_; 78 int yield_count_;
79 AstProperties properties_; 79 AstProperties properties_;
80 // The slot cache allows us to reuse certain feedback vector slots. 80 // The slot cache allows us to reuse certain feedback vector slots.
81 FeedbackVectorSlotCache slot_cache_; 81 FeedbackVectorSlotCache slot_cache_;
82 BailoutReason dont_optimize_reason_; 82 BailoutReason dont_optimize_reason_;
83 bool catch_predicted_; 83 HandlerTable::CatchPrediction catch_prediction_;
84 84
85 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); 85 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS();
86 DISALLOW_COPY_AND_ASSIGN(AstNumberingVisitor); 86 DISALLOW_COPY_AND_ASSIGN(AstNumberingVisitor);
87 }; 87 };
88 88
89 89
90 void AstNumberingVisitor::VisitVariableDeclaration(VariableDeclaration* node) { 90 void AstNumberingVisitor::VisitVariableDeclaration(VariableDeclaration* node) {
91 IncrementNodeCount(); 91 IncrementNodeCount();
92 VisitVariableProxy(node->proxy()); 92 VisitVariableProxy(node->proxy());
93 } 93 }
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 Visit(node->cond()); 285 Visit(node->cond());
286 Visit(node->body()); 286 Visit(node->body());
287 node->set_yield_count(yield_count_ - node->first_yield_id()); 287 node->set_yield_count(yield_count_ - node->first_yield_id());
288 } 288 }
289 289
290 290
291 void AstNumberingVisitor::VisitTryCatchStatement(TryCatchStatement* node) { 291 void AstNumberingVisitor::VisitTryCatchStatement(TryCatchStatement* node) {
292 IncrementNodeCount(); 292 IncrementNodeCount();
293 DisableCrankshaft(kTryCatchStatement); 293 DisableCrankshaft(kTryCatchStatement);
294 { 294 {
295 const bool old_catch_predicted = catch_predicted_; 295 const HandlerTable::CatchPrediction old_prediction = catch_prediction_;
296 // If the node's clear_pending_message flag is unset, we assume that the 296 // This node uses its own prediction, unless it's "uncaught", in which case
297 // catch block is a ReThrow and hence predict uncaught (unless caught by 297 // we adopt the prediction of the outer try-block.
Michael Starzinger 2016/07/20 09:20:18 nit: s/outer/surrounding/
298 // outer handlers). Otherwise, we predict caught. 298 HandlerTable::CatchPrediction catch_prediction = node->catch_prediction();
299 const bool not_rethrow = node->clear_pending_message(); 299 if (catch_prediction != HandlerTable::UNCAUGHT) {
300 catch_predicted_ = catch_predicted_ || not_rethrow; 300 catch_prediction_ = catch_prediction;
301 node->set_catch_predicted(catch_predicted_); 301 }
302 node->set_catch_prediction(catch_prediction_);
302 Visit(node->try_block()); 303 Visit(node->try_block());
303 catch_predicted_ = old_catch_predicted; 304 catch_prediction_ = old_prediction;
304 } 305 }
305 Visit(node->catch_block()); 306 Visit(node->catch_block());
306 } 307 }
307 308
308 309
309 void AstNumberingVisitor::VisitTryFinallyStatement(TryFinallyStatement* node) { 310 void AstNumberingVisitor::VisitTryFinallyStatement(TryFinallyStatement* node) {
310 IncrementNodeCount(); 311 IncrementNodeCount();
311 DisableCrankshaft(kTryFinallyStatement); 312 DisableCrankshaft(kTryFinallyStatement);
312 // We can't know whether the finally block will override ("catch") an 313 // We can't know whether the finally block will override ("catch") an
313 // exception thrown in the try block, so we just adopt the outer prediction. 314 // exception thrown in the try block, so we just adopt the outer prediction.
314 node->set_catch_predicted(catch_predicted_); 315 node->set_catch_prediction(catch_prediction_);
315 Visit(node->try_block()); 316 Visit(node->try_block());
316 Visit(node->finally_block()); 317 Visit(node->finally_block());
317 } 318 }
318 319
319 320
320 void AstNumberingVisitor::VisitPropertyReference(Property* node) { 321 void AstNumberingVisitor::VisitPropertyReference(Property* node) {
321 IncrementNodeCount(); 322 IncrementNodeCount();
322 node->set_base_id(ReserveIdRange(Property::num_ids())); 323 node->set_base_id(ReserveIdRange(Property::num_ids()));
323 Visit(node->key()); 324 Visit(node->key());
324 Visit(node->obj()); 325 Visit(node->obj());
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 } 593 }
593 594
594 595
595 bool AstNumbering::Renumber(Isolate* isolate, Zone* zone, 596 bool AstNumbering::Renumber(Isolate* isolate, Zone* zone,
596 FunctionLiteral* function) { 597 FunctionLiteral* function) {
597 AstNumberingVisitor visitor(isolate, zone); 598 AstNumberingVisitor visitor(isolate, zone);
598 return visitor.Renumber(function); 599 return visitor.Renumber(function);
599 } 600 }
600 } // namespace internal 601 } // namespace internal
601 } // namespace v8 602 } // namespace v8
OLDNEW
« no previous file with comments | « src/ast/ast.h ('k') | src/ast/prettyprinter.cc » ('j') | src/isolate.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698