Chromium Code Reviews| 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" | 14 #include "src/factory.h" |
| 15 #include "src/globals.h" | 15 #include "src/globals.h" |
| 16 #include "src/isolate.h" | 16 #include "src/isolate.h" |
| 17 #include "src/label.h" | 17 #include "src/label.h" |
| 18 #include "src/list.h" | 18 #include "src/list.h" |
| 19 #include "src/parsing/token.h" | 19 #include "src/parsing/token.h" |
| 20 #include "src/runtime/runtime.h" | 20 #include "src/runtime/runtime.h" |
| 21 #include "src/small-pointer-list.h" | 21 #include "src/small-pointer-list.h" |
| 22 #include "src/utils.h" | |
| 23 | 22 |
| 24 namespace v8 { | 23 namespace v8 { |
| 25 namespace internal { | 24 namespace internal { |
| 26 | 25 |
| 27 // The abstract syntax tree is an intermediate, light-weight | 26 // The abstract syntax tree is an intermediate, light-weight |
| 28 // representation of the parsed JavaScript code suitable for | 27 // representation of the parsed JavaScript code suitable for |
| 29 // compilation to native code. | 28 // compilation to native code. |
| 30 | 29 |
| 31 // Nodes are allocated in a separate zone, which allows faster | 30 // Nodes are allocated in a separate zone, which allows faster |
| 32 // allocation and constant-time deallocation of the entire syntax | 31 // allocation and constant-time deallocation of the entire syntax |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 105 V(EmptyParentheses) \ | 104 V(EmptyParentheses) \ |
| 106 V(GetIterator) \ | 105 V(GetIterator) \ |
| 107 V(DoExpression) \ | 106 V(DoExpression) \ |
| 108 V(RewritableExpression) | 107 V(RewritableExpression) |
| 109 | 108 |
| 110 #define AST_NODE_LIST(V) \ | 109 #define AST_NODE_LIST(V) \ |
| 111 DECLARATION_NODE_LIST(V) \ | 110 DECLARATION_NODE_LIST(V) \ |
| 112 STATEMENT_NODE_LIST(V) \ | 111 STATEMENT_NODE_LIST(V) \ |
| 113 EXPRESSION_NODE_LIST(V) | 112 EXPRESSION_NODE_LIST(V) |
| 114 | 113 |
| 114 #ifdef DEBUG | |
| 115 static const char* NameForNativeContextIntrinsicIndex(uint32_t idx) { | |
|
adamk
2017/01/25 20:26:43
Rather than copying this, what about exposing it i
gsathya
2017/01/25 21:05:19
Why is moving to contexts.h better?
adamk
2017/01/25 21:11:17
I'd rather not have two copies of this function. M
gsathya
2017/01/25 21:17:17
It's not exactly the same. As mentioned in my prev
adamk
2017/01/25 23:13:58
Sorry, missed the details of the macros. I'm ok wi
gsathya
2017/01/25 23:27:25
Done.
| |
| 116 switch (idx) { | |
| 117 #define NATIVE_CONTEXT_FIELDS_IDX(NAME, Type, name) \ | |
| 118 case Context::NAME: \ | |
| 119 return #name; | |
| 120 | |
| 121 NATIVE_CONTEXT_FIELDS(NATIVE_CONTEXT_FIELDS_IDX) | |
| 122 | |
| 123 default: | |
| 124 break; | |
| 125 } | |
| 126 | |
| 127 return "UnknownIntrinsicIndex"; | |
| 128 } | |
| 129 #endif // DEBUG | |
| 130 | |
| 115 // Forward declarations | 131 // Forward declarations |
| 116 class AstNodeFactory; | 132 class AstNodeFactory; |
| 117 class Declaration; | 133 class Declaration; |
| 118 class Module; | 134 class Module; |
| 119 class BreakableStatement; | 135 class BreakableStatement; |
| 120 class Expression; | 136 class Expression; |
| 121 class IterationStatement; | 137 class IterationStatement; |
| 122 class MaterializedLiteral; | 138 class MaterializedLiteral; |
| 123 class Statement; | 139 class Statement; |
| 124 class TypeFeedbackOracle; | 140 class TypeFeedbackOracle; |
| (...skipping 1925 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2050 } | 2066 } |
| 2051 const Runtime::Function* function() const { | 2067 const Runtime::Function* function() const { |
| 2052 DCHECK(!is_jsruntime()); | 2068 DCHECK(!is_jsruntime()); |
| 2053 return function_; | 2069 return function_; |
| 2054 } | 2070 } |
| 2055 | 2071 |
| 2056 static int num_ids() { return parent_num_ids() + 1; } | 2072 static int num_ids() { return parent_num_ids() + 1; } |
| 2057 BailoutId CallId() { return BailoutId(local_id(0)); } | 2073 BailoutId CallId() { return BailoutId(local_id(0)); } |
| 2058 | 2074 |
| 2059 const char* debug_name() { | 2075 const char* debug_name() { |
| 2076 #ifdef DEBUG | |
| 2077 return NameForNativeContextIntrinsicIndex(context_index_); | |
| 2078 #else | |
| 2060 return is_jsruntime() ? "(context function)" : function_->name; | 2079 return is_jsruntime() ? "(context function)" : function_->name; |
| 2080 #endif // DEBUG | |
| 2061 } | 2081 } |
| 2062 | 2082 |
| 2063 private: | 2083 private: |
| 2064 friend class AstNodeFactory; | 2084 friend class AstNodeFactory; |
| 2065 | 2085 |
| 2066 CallRuntime(const Runtime::Function* function, | 2086 CallRuntime(const Runtime::Function* function, |
| 2067 ZoneList<Expression*>* arguments, int pos) | 2087 ZoneList<Expression*>* arguments, int pos) |
| 2068 : Expression(pos, kCallRuntime), | 2088 : Expression(pos, kCallRuntime), |
| 2069 function_(function), | 2089 function_(function), |
| 2070 arguments_(arguments) {} | 2090 arguments_(arguments) {} |
| (...skipping 1585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3656 : NULL; \ | 3676 : NULL; \ |
| 3657 } | 3677 } |
| 3658 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) | 3678 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) |
| 3659 #undef DECLARE_NODE_FUNCTIONS | 3679 #undef DECLARE_NODE_FUNCTIONS |
| 3660 | 3680 |
| 3661 | 3681 |
| 3662 } // namespace internal | 3682 } // namespace internal |
| 3663 } // namespace v8 | 3683 } // namespace v8 |
| 3664 | 3684 |
| 3665 #endif // V8_AST_AST_H_ | 3685 #endif // V8_AST_AST_H_ |
| OLD | NEW |