| 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/v8.h" | 8 #include "src/v8.h" |
| 9 | 9 |
| 10 #include "src/assembler.h" | 10 #include "src/assembler.h" |
| 11 #include "src/ast-value-factory.h" | 11 #include "src/ast-value-factory.h" |
| 12 #include "src/bailout-reason.h" | 12 #include "src/bailout-reason.h" |
| 13 #include "src/base/flags.h" |
| 13 #include "src/factory.h" | 14 #include "src/factory.h" |
| 14 #include "src/isolate.h" | 15 #include "src/isolate.h" |
| 15 #include "src/jsregexp.h" | 16 #include "src/jsregexp.h" |
| 16 #include "src/list-inl.h" | 17 #include "src/list-inl.h" |
| 17 #include "src/modules.h" | 18 #include "src/modules.h" |
| 18 #include "src/runtime/runtime.h" | 19 #include "src/runtime/runtime.h" |
| 19 #include "src/small-pointer-list.h" | 20 #include "src/small-pointer-list.h" |
| 20 #include "src/smart-pointers.h" | 21 #include "src/smart-pointers.h" |
| 21 #include "src/token.h" | 22 #include "src/token.h" |
| 22 #include "src/types.h" | 23 #include "src/types.h" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 typedef ZoneList<Handle<String>> ZoneStringList; | 131 typedef ZoneList<Handle<String>> ZoneStringList; |
| 131 typedef ZoneList<Handle<Object>> ZoneObjectList; | 132 typedef ZoneList<Handle<Object>> ZoneObjectList; |
| 132 | 133 |
| 133 | 134 |
| 134 #define DECLARE_NODE_TYPE(type) \ | 135 #define DECLARE_NODE_TYPE(type) \ |
| 135 void Accept(AstVisitor* v) override; \ | 136 void Accept(AstVisitor* v) override; \ |
| 136 AstNode::NodeType node_type() const final { return AstNode::k##type; } \ | 137 AstNode::NodeType node_type() const final { return AstNode::k##type; } \ |
| 137 friend class AstNodeFactory; | 138 friend class AstNodeFactory; |
| 138 | 139 |
| 139 | 140 |
| 140 enum AstPropertiesFlag { kDontSelfOptimize, kDontCrankshaft }; | |
| 141 | |
| 142 | |
| 143 class FeedbackVectorRequirements { | 141 class FeedbackVectorRequirements { |
| 144 public: | 142 public: |
| 145 FeedbackVectorRequirements(int slots, int ic_slots) | 143 FeedbackVectorRequirements(int slots, int ic_slots) |
| 146 : slots_(slots), ic_slots_(ic_slots) {} | 144 : slots_(slots), ic_slots_(ic_slots) {} |
| 147 | 145 |
| 148 int slots() const { return slots_; } | 146 int slots() const { return slots_; } |
| 149 int ic_slots() const { return ic_slots_; } | 147 int ic_slots() const { return ic_slots_; } |
| 150 | 148 |
| 151 private: | 149 private: |
| 152 int slots_; | 150 int slots_; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 168 Variable* variable_; | 166 Variable* variable_; |
| 169 FeedbackVectorICSlot slot_; | 167 FeedbackVectorICSlot slot_; |
| 170 }; | 168 }; |
| 171 | 169 |
| 172 | 170 |
| 173 typedef List<VariableICSlotPair> ICSlotCache; | 171 typedef List<VariableICSlotPair> ICSlotCache; |
| 174 | 172 |
| 175 | 173 |
| 176 class AstProperties final BASE_EMBEDDED { | 174 class AstProperties final BASE_EMBEDDED { |
| 177 public: | 175 public: |
| 178 class Flags : public EnumSet<AstPropertiesFlag, int> {}; | 176 enum Flag { |
| 177 kNoFlags = 0, |
| 178 kDontSelfOptimize = 1 << 0, |
| 179 kDontCrankshaft = 1 << 1 |
| 180 }; |
| 181 |
| 182 typedef base::Flags<Flag> Flags; |
| 179 | 183 |
| 180 explicit AstProperties(Zone* zone) : node_count_(0), spec_(zone) {} | 184 explicit AstProperties(Zone* zone) : node_count_(0), spec_(zone) {} |
| 181 | 185 |
| 182 Flags* flags() { return &flags_; } | 186 Flags& flags() { return flags_; } |
| 187 Flags flags() const { return flags_; } |
| 183 int node_count() { return node_count_; } | 188 int node_count() { return node_count_; } |
| 184 void add_node_count(int count) { node_count_ += count; } | 189 void add_node_count(int count) { node_count_ += count; } |
| 185 | 190 |
| 186 int slots() const { return spec_.slots(); } | 191 int slots() const { return spec_.slots(); } |
| 187 void increase_slots(int count) { spec_.increase_slots(count); } | 192 void increase_slots(int count) { spec_.increase_slots(count); } |
| 188 | 193 |
| 189 int ic_slots() const { return spec_.ic_slots(); } | 194 int ic_slots() const { return spec_.ic_slots(); } |
| 190 void increase_ic_slots(int count) { spec_.increase_ic_slots(count); } | 195 void increase_ic_slots(int count) { spec_.increase_ic_slots(count); } |
| 191 void SetKind(int ic_slot, Code::Kind kind) { spec_.SetKind(ic_slot, kind); } | 196 void SetKind(int ic_slot, Code::Kind kind) { spec_.SetKind(ic_slot, kind); } |
| 192 const ZoneFeedbackVectorSpec* get_spec() const { return &spec_; } | 197 const ZoneFeedbackVectorSpec* get_spec() const { return &spec_; } |
| 193 | 198 |
| 194 private: | 199 private: |
| 195 Flags flags_; | 200 Flags flags_; |
| 196 int node_count_; | 201 int node_count_; |
| 197 ZoneFeedbackVectorSpec spec_; | 202 ZoneFeedbackVectorSpec spec_; |
| 198 }; | 203 }; |
| 199 | 204 |
| 205 DEFINE_OPERATORS_FOR_FLAGS(AstProperties::Flags) |
| 206 |
| 200 | 207 |
| 201 class AstNode: public ZoneObject { | 208 class AstNode: public ZoneObject { |
| 202 public: | 209 public: |
| 203 #define DECLARE_TYPE_ENUM(type) k##type, | 210 #define DECLARE_TYPE_ENUM(type) k##type, |
| 204 enum NodeType { | 211 enum NodeType { |
| 205 AST_NODE_LIST(DECLARE_TYPE_ENUM) | 212 AST_NODE_LIST(DECLARE_TYPE_ENUM) |
| 206 kInvalid = -1 | 213 kInvalid = -1 |
| 207 }; | 214 }; |
| 208 #undef DECLARE_TYPE_ENUM | 215 #undef DECLARE_TYPE_ENUM |
| 209 | 216 |
| (...skipping 2370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2580 bool should_be_used_once_hint() const { | 2587 bool should_be_used_once_hint() const { |
| 2581 return ShouldBeUsedOnceHintBit::decode(bitfield_) == kShouldBeUsedOnce; | 2588 return ShouldBeUsedOnceHintBit::decode(bitfield_) == kShouldBeUsedOnce; |
| 2582 } | 2589 } |
| 2583 void set_should_be_used_once_hint() { | 2590 void set_should_be_used_once_hint() { |
| 2584 bitfield_ = ShouldBeUsedOnceHintBit::update(bitfield_, kShouldBeUsedOnce); | 2591 bitfield_ = ShouldBeUsedOnceHintBit::update(bitfield_, kShouldBeUsedOnce); |
| 2585 } | 2592 } |
| 2586 | 2593 |
| 2587 FunctionKind kind() const { return FunctionKindBits::decode(bitfield_); } | 2594 FunctionKind kind() const { return FunctionKindBits::decode(bitfield_); } |
| 2588 | 2595 |
| 2589 int ast_node_count() { return ast_properties_.node_count(); } | 2596 int ast_node_count() { return ast_properties_.node_count(); } |
| 2590 AstProperties::Flags* flags() { return ast_properties_.flags(); } | 2597 AstProperties::Flags flags() const { return ast_properties_.flags(); } |
| 2591 void set_ast_properties(AstProperties* ast_properties) { | 2598 void set_ast_properties(AstProperties* ast_properties) { |
| 2592 ast_properties_ = *ast_properties; | 2599 ast_properties_ = *ast_properties; |
| 2593 } | 2600 } |
| 2594 const ZoneFeedbackVectorSpec* feedback_vector_spec() const { | 2601 const ZoneFeedbackVectorSpec* feedback_vector_spec() const { |
| 2595 return ast_properties_.get_spec(); | 2602 return ast_properties_.get_spec(); |
| 2596 } | 2603 } |
| 2597 bool dont_optimize() { return dont_optimize_reason_ != kNoReason; } | 2604 bool dont_optimize() { return dont_optimize_reason_ != kNoReason; } |
| 2598 BailoutReason dont_optimize_reason() { return dont_optimize_reason_; } | 2605 BailoutReason dont_optimize_reason() { return dont_optimize_reason_; } |
| 2599 void set_dont_optimize_reason(BailoutReason reason) { | 2606 void set_dont_optimize_reason(BailoutReason reason) { |
| 2600 dont_optimize_reason_ = reason; | 2607 dont_optimize_reason_ = reason; |
| (...skipping 1005 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3606 | 3613 |
| 3607 private: | 3614 private: |
| 3608 Zone* zone_; | 3615 Zone* zone_; |
| 3609 AstValueFactory* ast_value_factory_; | 3616 AstValueFactory* ast_value_factory_; |
| 3610 }; | 3617 }; |
| 3611 | 3618 |
| 3612 | 3619 |
| 3613 } } // namespace v8::internal | 3620 } } // namespace v8::internal |
| 3614 | 3621 |
| 3615 #endif // V8_AST_H_ | 3622 #endif // V8_AST_H_ |
| OLD | NEW |