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_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-types.h" | 8 #include "src/ast/ast-types.h" |
9 #include "src/ast/ast-value-factory.h" | 9 #include "src/ast/ast-value-factory.h" |
10 #include "src/ast/modules.h" | 10 #include "src/ast/modules.h" |
11 #include "src/ast/variables.h" | 11 #include "src/ast/variables.h" |
12 #include "src/bailout-reason.h" | 12 #include "src/bailout-reason.h" |
13 #include "src/base/flags.h" | 13 #include "src/base/flags.h" |
14 #include "src/factory.h" | |
15 #include "src/globals.h" | 14 #include "src/globals.h" |
16 #include "src/isolate.h" | |
17 #include "src/list.h" | 15 #include "src/list.h" |
18 #include "src/parsing/token.h" | 16 #include "src/parsing/token.h" |
19 #include "src/runtime/runtime.h" | 17 #include "src/runtime/runtime.h" |
20 #include "src/small-pointer-list.h" | 18 #include "src/small-pointer-list.h" |
21 #include "src/utils.h" | 19 #include "src/utils.h" |
22 | 20 |
23 namespace v8 { | 21 namespace v8 { |
24 namespace internal { | 22 namespace internal { |
25 | 23 |
26 // The abstract syntax tree is an intermediate, light-weight | 24 // The abstract syntax tree is an intermediate, light-weight |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 STATEMENT_NODE_LIST(V) \ | 108 STATEMENT_NODE_LIST(V) \ |
111 EXPRESSION_NODE_LIST(V) | 109 EXPRESSION_NODE_LIST(V) |
112 | 110 |
113 // Forward declarations | 111 // Forward declarations |
114 class AstNodeFactory; | 112 class AstNodeFactory; |
115 class Declaration; | 113 class Declaration; |
116 class Module; | 114 class Module; |
117 class BreakableStatement; | 115 class BreakableStatement; |
118 class Expression; | 116 class Expression; |
119 class IterationStatement; | 117 class IterationStatement; |
| 118 class Isolate; |
120 class MaterializedLiteral; | 119 class MaterializedLiteral; |
121 class Statement; | 120 class Statement; |
122 class TypeFeedbackOracle; | 121 class TypeFeedbackOracle; |
123 | 122 |
124 #define DEF_FORWARD_DECLARATION(type) class type; | 123 #define DEF_FORWARD_DECLARATION(type) class type; |
125 AST_NODE_LIST(DEF_FORWARD_DECLARATION) | 124 AST_NODE_LIST(DEF_FORWARD_DECLARATION) |
126 #undef DEF_FORWARD_DECLARATION | 125 #undef DEF_FORWARD_DECLARATION |
127 | 126 |
128 | 127 |
129 // Typedef only introduced to avoid unreadable code. | 128 // Typedef only introduced to avoid unreadable code. |
(...skipping 2767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2897 bool CheckStackOverflow() { \ | 2896 bool CheckStackOverflow() { \ |
2898 if (stack_overflow_) return true; \ | 2897 if (stack_overflow_) return true; \ |
2899 if (GetCurrentStackPosition() < stack_limit_) { \ | 2898 if (GetCurrentStackPosition() < stack_limit_) { \ |
2900 stack_overflow_ = true; \ | 2899 stack_overflow_ = true; \ |
2901 return true; \ | 2900 return true; \ |
2902 } \ | 2901 } \ |
2903 return false; \ | 2902 return false; \ |
2904 } \ | 2903 } \ |
2905 \ | 2904 \ |
2906 private: \ | 2905 private: \ |
2907 void InitializeAstVisitor(Isolate* isolate) { \ | |
2908 stack_limit_ = isolate->stack_guard()->real_climit(); \ | |
2909 stack_overflow_ = false; \ | |
2910 } \ | |
2911 \ | |
2912 void InitializeAstVisitor(uintptr_t stack_limit) { \ | 2906 void InitializeAstVisitor(uintptr_t stack_limit) { \ |
2913 stack_limit_ = stack_limit; \ | 2907 stack_limit_ = stack_limit; \ |
2914 stack_overflow_ = false; \ | 2908 stack_overflow_ = false; \ |
2915 } \ | 2909 } \ |
2916 \ | 2910 \ |
2917 uintptr_t stack_limit_; \ | 2911 uintptr_t stack_limit_; \ |
2918 bool stack_overflow_ | 2912 bool stack_overflow_ |
2919 | 2913 |
2920 #define DEFINE_AST_VISITOR_MEMBERS_WITHOUT_STACKOVERFLOW() \ | 2914 #define DEFINE_AST_VISITOR_MEMBERS_WITHOUT_STACKOVERFLOW() \ |
2921 public: \ | 2915 public: \ |
2922 void Visit(AstNode* node) { GENERATE_AST_VISITOR_SWITCH() } \ | 2916 void Visit(AstNode* node) { GENERATE_AST_VISITOR_SWITCH() } \ |
2923 \ | 2917 \ |
2924 private: | 2918 private: |
2925 | 2919 |
2926 #define DEFINE_AST_REWRITER_SUBCLASS_MEMBERS() \ | 2920 #define DEFINE_AST_REWRITER_SUBCLASS_MEMBERS() \ |
2927 public: \ | 2921 public: \ |
2928 AstNode* Rewrite(AstNode* node) { \ | 2922 AstNode* Rewrite(AstNode* node) { \ |
2929 DCHECK_NULL(replacement_); \ | 2923 DCHECK_NULL(replacement_); \ |
2930 DCHECK_NOT_NULL(node); \ | 2924 DCHECK_NOT_NULL(node); \ |
2931 Visit(node); \ | 2925 Visit(node); \ |
2932 if (HasStackOverflow()) return node; \ | 2926 if (HasStackOverflow()) return node; \ |
2933 if (replacement_ == nullptr) return node; \ | 2927 if (replacement_ == nullptr) return node; \ |
2934 AstNode* result = replacement_; \ | 2928 AstNode* result = replacement_; \ |
2935 replacement_ = nullptr; \ | 2929 replacement_ = nullptr; \ |
2936 return result; \ | 2930 return result; \ |
2937 } \ | 2931 } \ |
2938 \ | 2932 \ |
2939 private: \ | 2933 private: \ |
2940 void InitializeAstRewriter(Isolate* isolate) { \ | |
2941 InitializeAstVisitor(isolate); \ | |
2942 replacement_ = nullptr; \ | |
2943 } \ | |
2944 \ | |
2945 void InitializeAstRewriter(uintptr_t stack_limit) { \ | 2934 void InitializeAstRewriter(uintptr_t stack_limit) { \ |
2946 InitializeAstVisitor(stack_limit); \ | 2935 InitializeAstVisitor(stack_limit); \ |
2947 replacement_ = nullptr; \ | 2936 replacement_ = nullptr; \ |
2948 } \ | 2937 } \ |
2949 \ | 2938 \ |
2950 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); \ | 2939 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); \ |
2951 \ | 2940 \ |
2952 protected: \ | 2941 protected: \ |
2953 AstNode* replacement_ | 2942 AstNode* replacement_ |
2954 // Generic macro for rewriting things; `GET` is the expression to be | 2943 // Generic macro for rewriting things; `GET` is the expression to be |
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3464 : NULL; \ | 3453 : NULL; \ |
3465 } | 3454 } |
3466 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) | 3455 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) |
3467 #undef DECLARE_NODE_FUNCTIONS | 3456 #undef DECLARE_NODE_FUNCTIONS |
3468 | 3457 |
3469 | 3458 |
3470 } // namespace internal | 3459 } // namespace internal |
3471 } // namespace v8 | 3460 } // namespace v8 |
3472 | 3461 |
3473 #endif // V8_AST_AST_H_ | 3462 #endif // V8_AST_AST_H_ |
OLD | NEW |