OLD | NEW |
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_H_ | 5 #ifndef V8_AST_H_ |
6 #define V8_AST_H_ | 6 #define V8_AST_H_ |
7 | 7 |
8 #include "src/assembler.h" | 8 #include "src/assembler.h" |
9 #include "src/ast-value-factory.h" | 9 #include "src/ast-value-factory.h" |
10 #include "src/bailout-reason.h" | 10 #include "src/bailout-reason.h" |
(...skipping 3143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3154 void Visit(AstNode* node) final { \ | 3154 void Visit(AstNode* node) final { \ |
3155 if (!CheckStackOverflow()) node->Accept(this); \ | 3155 if (!CheckStackOverflow()) node->Accept(this); \ |
3156 } \ | 3156 } \ |
3157 \ | 3157 \ |
3158 void SetStackOverflow() { stack_overflow_ = true; } \ | 3158 void SetStackOverflow() { stack_overflow_ = true; } \ |
3159 void ClearStackOverflow() { stack_overflow_ = false; } \ | 3159 void ClearStackOverflow() { stack_overflow_ = false; } \ |
3160 bool HasStackOverflow() const { return stack_overflow_; } \ | 3160 bool HasStackOverflow() const { return stack_overflow_; } \ |
3161 \ | 3161 \ |
3162 bool CheckStackOverflow() { \ | 3162 bool CheckStackOverflow() { \ |
3163 if (stack_overflow_) return true; \ | 3163 if (stack_overflow_) return true; \ |
3164 StackLimitCheck check(isolate_); \ | 3164 if (GetCurrentStackPosition() < stack_limit_) { \ |
3165 if (!check.HasOverflowed()) return false; \ | 3165 stack_overflow_ = true; \ |
3166 stack_overflow_ = true; \ | 3166 return true; \ |
3167 return true; \ | 3167 } \ |
| 3168 return false; \ |
3168 } \ | 3169 } \ |
3169 \ | 3170 \ |
3170 private: \ | 3171 private: \ |
3171 void InitializeAstVisitor(Isolate* isolate, Zone* zone) { \ | 3172 void InitializeAstVisitor(Isolate* isolate, Zone* zone) { \ |
3172 isolate_ = isolate; \ | |
3173 zone_ = zone; \ | 3173 zone_ = zone; \ |
| 3174 stack_limit_ = isolate->stack_guard()->real_climit(); \ |
3174 stack_overflow_ = false; \ | 3175 stack_overflow_ = false; \ |
3175 } \ | 3176 } \ |
3176 Zone* zone() { return zone_; } \ | 3177 Zone* zone() { return zone_; } \ |
3177 Isolate* isolate() { return isolate_; } \ | |
3178 \ | 3178 \ |
3179 Isolate* isolate_; \ | |
3180 Zone* zone_; \ | 3179 Zone* zone_; \ |
| 3180 uintptr_t stack_limit_; \ |
3181 bool stack_overflow_ | 3181 bool stack_overflow_ |
3182 | 3182 |
3183 | 3183 |
3184 // ---------------------------------------------------------------------------- | 3184 // ---------------------------------------------------------------------------- |
3185 // AstNode factory | 3185 // AstNode factory |
3186 | 3186 |
3187 class AstNodeFactory final BASE_EMBEDDED { | 3187 class AstNodeFactory final BASE_EMBEDDED { |
3188 public: | 3188 public: |
3189 explicit AstNodeFactory(AstValueFactory* ast_value_factory) | 3189 explicit AstNodeFactory(AstValueFactory* ast_value_factory) |
3190 : local_zone_(ast_value_factory->zone()), | 3190 : local_zone_(ast_value_factory->zone()), |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3615 // the parser-level zone. | 3615 // the parser-level zone. |
3616 Zone* parser_zone_; | 3616 Zone* parser_zone_; |
3617 AstValueFactory* ast_value_factory_; | 3617 AstValueFactory* ast_value_factory_; |
3618 }; | 3618 }; |
3619 | 3619 |
3620 | 3620 |
3621 } // namespace internal | 3621 } // namespace internal |
3622 } // namespace v8 | 3622 } // namespace v8 |
3623 | 3623 |
3624 #endif // V8_AST_H_ | 3624 #endif // V8_AST_H_ |
OLD | NEW |