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

Side by Side Diff: src/ast/ast.h

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
« no previous file with comments | « no previous file | src/ast/ast-numbering.cc » ('j') | src/ast/ast-numbering.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef V8_AST_AST_H_ 5 #ifndef V8_AST_AST_H_
6 #define V8_AST_AST_H_ 6 #define V8_AST_AST_H_
7 7
8 #include "src/ast/ast-value-factory.h" 8 #include "src/ast/ast-value-factory.h"
9 #include "src/ast/modules.h" 9 #include "src/ast/modules.h"
10 #include "src/ast/variables.h" 10 #include "src/ast/variables.h"
(...skipping 1074 matching lines...) Expand 10 before | Expand all | Expand 10 after
1085 // Prediction of whether exceptions thrown into the handler for this try block 1085 // Prediction of whether exceptions thrown into the handler for this try block
1086 // will be caught. 1086 // will be caught.
1087 // 1087 //
1088 // This is set in ast-numbering and later compiled into the code's handler 1088 // This is set in ast-numbering and later compiled into the code's handler
1089 // table. The runtime uses this information to implement a feature that 1089 // table. The runtime uses this information to implement a feature that
1090 // notifies the debugger when an uncaught exception is thrown, _before_ the 1090 // notifies the debugger when an uncaught exception is thrown, _before_ the
1091 // exception propagates to the top. 1091 // exception propagates to the top.
1092 // 1092 //
1093 // Since it's generally undecidable whether an exception will be caught, our 1093 // Since it's generally undecidable whether an exception will be caught, our
1094 // prediction is only an approximation. 1094 // prediction is only an approximation.
1095 bool catch_predicted() const { return catch_predicted_; } 1095 HandlerTable::CatchPrediction catch_prediction() const {
1096 void set_catch_predicted(bool b) { catch_predicted_ = b; } 1096 return catch_prediction_;
1097 }
1098 void set_catch_prediction(HandlerTable::CatchPrediction prediction) {
1099 catch_prediction_ = prediction;
1100 }
1097 1101
1098 protected: 1102 protected:
1099 TryStatement(Zone* zone, Block* try_block, int pos, NodeType type) 1103 TryStatement(Zone* zone, Block* try_block, int pos, NodeType type)
1100 : Statement(zone, pos, type), 1104 : Statement(zone, pos, type),
1101 catch_predicted_(false), 1105 catch_prediction_(HandlerTable::UNCAUGHT),
1102 try_block_(try_block) {} 1106 try_block_(try_block) {}
1103 1107
1108 HandlerTable::CatchPrediction catch_prediction_;
1109
1104 private: 1110 private:
1105 bool catch_predicted_;
1106 Block* try_block_; 1111 Block* try_block_;
1107 }; 1112 };
1108 1113
1109 1114
1110 class TryCatchStatement final : public TryStatement { 1115 class TryCatchStatement final : public TryStatement {
1111 public: 1116 public:
1112 DECLARE_NODE_TYPE(TryCatchStatement) 1117 DECLARE_NODE_TYPE(TryCatchStatement)
1113 1118
1114 Scope* scope() { return scope_; } 1119 Scope* scope() { return scope_; }
1115 Variable* variable() { return variable_; } 1120 Variable* variable() { return variable_; }
1116 Block* catch_block() const { return catch_block_; } 1121 Block* catch_block() const { return catch_block_; }
1117 void set_catch_block(Block* b) { catch_block_ = b; } 1122 void set_catch_block(Block* b) { catch_block_ = b; }
1118 1123
1119 // The clear_pending_message flag indicates whether or not to clear the 1124 // The clear_pending_message flag indicates whether or not to clear the
1120 // isolate's pending exception message before executing the catch_block. In 1125 // isolate's pending exception message before executing the catch_block. In
1121 // the normal use case, this flag is always on because the message object 1126 // the normal use case, this flag is always on because the message object
1122 // is not needed anymore when entering the catch block and should not be kept 1127 // is not needed anymore when entering the catch block and should not be kept
1123 // alive. 1128 // alive.
1124 // The use case where the flag is off is when the catch block is guaranteed to 1129 // The use case where the flag is off is when the catch block is guaranteed to
1125 // rethrow the caught exception (using %ReThrow), which reuses the pending 1130 // rethrow the caught exception (using %ReThrow), which reuses the pending
1126 // message instead of generating a new one. 1131 // message instead of generating a new one.
1127 // (When the catch block doesn't rethrow but is guaranteed to perform an 1132 // (When the catch block doesn't rethrow but is guaranteed to perform an
1128 // ordinary throw, not clearing the old message is safe but not very useful.) 1133 // ordinary throw, not clearing the old message is safe but not very useful.)
1129 bool clear_pending_message() { return clear_pending_message_; } 1134 bool clear_pending_message() const {
1135 return catch_prediction_ != HandlerTable::UNCAUGHT;
1136 }
1130 1137
1131 protected: 1138 protected:
1132 TryCatchStatement(Zone* zone, Block* try_block, Scope* scope, 1139 TryCatchStatement(Zone* zone, Block* try_block, Scope* scope,
1133 Variable* variable, Block* catch_block, 1140 Variable* variable, Block* catch_block,
1134 bool clear_pending_message, int pos) 1141 HandlerTable::CatchPrediction catch_prediction, int pos)
1135 : TryStatement(zone, try_block, pos, kTryCatchStatement), 1142 : TryStatement(zone, try_block, pos, kTryCatchStatement),
1136 clear_pending_message_(clear_pending_message),
1137 scope_(scope), 1143 scope_(scope),
1138 variable_(variable), 1144 variable_(variable),
1139 catch_block_(catch_block) {} 1145 catch_block_(catch_block) {
1146 catch_prediction_ = catch_prediction;
1147 }
1140 1148
1141 private: 1149 private:
1142 bool clear_pending_message_;
1143 Scope* scope_; 1150 Scope* scope_;
1144 Variable* variable_; 1151 Variable* variable_;
1145 Block* catch_block_; 1152 Block* catch_block_;
1146 }; 1153 };
1147 1154
1148 1155
1149 class TryFinallyStatement final : public TryStatement { 1156 class TryFinallyStatement final : public TryStatement {
1150 public: 1157 public:
1151 DECLARE_NODE_TYPE(TryFinallyStatement) 1158 DECLARE_NODE_TYPE(TryFinallyStatement)
1152 1159
(...skipping 1997 matching lines...) Expand 10 before | Expand all | Expand 10 after
3150 Statement* then_statement, 3157 Statement* then_statement,
3151 Statement* else_statement, 3158 Statement* else_statement,
3152 int pos) { 3159 int pos) {
3153 return new (local_zone_) IfStatement(local_zone_, condition, then_statement, 3160 return new (local_zone_) IfStatement(local_zone_, condition, then_statement,
3154 else_statement, pos); 3161 else_statement, pos);
3155 } 3162 }
3156 3163
3157 TryCatchStatement* NewTryCatchStatement(Block* try_block, Scope* scope, 3164 TryCatchStatement* NewTryCatchStatement(Block* try_block, Scope* scope,
3158 Variable* variable, 3165 Variable* variable,
3159 Block* catch_block, int pos) { 3166 Block* catch_block, int pos) {
3160 return new (local_zone_) TryCatchStatement( 3167 return new (local_zone_)
3161 local_zone_, try_block, scope, variable, catch_block, true, pos); 3168 TryCatchStatement(local_zone_, try_block, scope, variable, catch_block,
3169 HandlerTable::CAUGHT, pos);
3162 } 3170 }
3163 3171
3164 TryCatchStatement* NewTryCatchStatementForReThrow(Block* try_block, 3172 TryCatchStatement* NewTryCatchStatementForReThrow(Block* try_block,
3165 Scope* scope, 3173 Scope* scope,
3166 Variable* variable, 3174 Variable* variable,
3167 Block* catch_block, 3175 Block* catch_block,
3168 int pos) { 3176 int pos) {
3169 return new (local_zone_) TryCatchStatement( 3177 return new (local_zone_)
3170 local_zone_, try_block, scope, variable, catch_block, false, pos); 3178 TryCatchStatement(local_zone_, try_block, scope, variable, catch_block,
3179 HandlerTable::UNCAUGHT, pos);
3180 }
3181
3182 TryCatchStatement* NewTryCatchStatementForPromiseReject(Block* try_block,
3183 Scope* scope,
3184 Variable* variable,
3185 Block* catch_block,
3186 int pos) {
3187 return new (local_zone_)
3188 TryCatchStatement(local_zone_, try_block, scope, variable, catch_block,
3189 HandlerTable::PROMISE, pos);
3171 } 3190 }
3172 3191
3173 TryFinallyStatement* NewTryFinallyStatement(Block* try_block, 3192 TryFinallyStatement* NewTryFinallyStatement(Block* try_block,
3174 Block* finally_block, int pos) { 3193 Block* finally_block, int pos) {
3175 return new (local_zone_) 3194 return new (local_zone_)
3176 TryFinallyStatement(local_zone_, try_block, finally_block, pos); 3195 TryFinallyStatement(local_zone_, try_block, finally_block, pos);
3177 } 3196 }
3178 3197
3179 DebuggerStatement* NewDebuggerStatement(int pos) { 3198 DebuggerStatement* NewDebuggerStatement(int pos) {
3180 return new (local_zone_) DebuggerStatement(local_zone_, pos); 3199 return new (local_zone_) DebuggerStatement(local_zone_, pos);
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
3543 : NULL; \ 3562 : NULL; \
3544 } 3563 }
3545 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) 3564 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS)
3546 #undef DECLARE_NODE_FUNCTIONS 3565 #undef DECLARE_NODE_FUNCTIONS
3547 3566
3548 3567
3549 } // namespace internal 3568 } // namespace internal
3550 } // namespace v8 3569 } // namespace v8
3551 3570
3552 #endif // V8_AST_AST_H_ 3571 #endif // V8_AST_AST_H_
OLDNEW
« no previous file with comments | « no previous file | src/ast/ast-numbering.cc » ('j') | src/ast/ast-numbering.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698