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" |
(...skipping 2687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2698 BailoutId ExitId() { return BailoutId(local_id(2)); } | 2698 BailoutId ExitId() { return BailoutId(local_id(2)); } |
2699 BailoutId CreateLiteralId() const { return BailoutId(local_id(3)); } | 2699 BailoutId CreateLiteralId() const { return BailoutId(local_id(3)); } |
2700 | 2700 |
2701 // Return an AST id for a property that is used in simulate instructions. | 2701 // Return an AST id for a property that is used in simulate instructions. |
2702 BailoutId GetIdForProperty(int i) { return BailoutId(local_id(i + 4)); } | 2702 BailoutId GetIdForProperty(int i) { return BailoutId(local_id(i + 4)); } |
2703 | 2703 |
2704 // Unlike other AST nodes, this number of bailout IDs allocated for an | 2704 // Unlike other AST nodes, this number of bailout IDs allocated for an |
2705 // ClassLiteral can vary, so num_ids() is not a static method. | 2705 // ClassLiteral can vary, so num_ids() is not a static method. |
2706 int num_ids() const { return parent_num_ids() + 4 + properties()->length(); } | 2706 int num_ids() const { return parent_num_ids() + 4 + properties()->length(); } |
2707 | 2707 |
| 2708 // Object literals need one feedback slot for each non-trivial value, as well |
| 2709 // as some slots for home objects. |
| 2710 FeedbackVectorRequirements ComputeFeedbackRequirements( |
| 2711 Isolate* isolate, const ICSlotCache* cache) override; |
| 2712 void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot, |
| 2713 ICSlotCache* cache) override { |
| 2714 slot_ = slot; |
| 2715 } |
| 2716 Code::Kind FeedbackICSlotKind(int index) override { return Code::STORE_IC; } |
| 2717 FeedbackVectorICSlot GetNthSlot(int n) const { |
| 2718 return FeedbackVectorICSlot(slot_.ToInt() + n); |
| 2719 } |
| 2720 |
| 2721 // If value needs a home object, returns a valid feedback vector ic slot |
| 2722 // given by slot_index, and increments slot_index. |
| 2723 FeedbackVectorICSlot SlotForHomeObject(Expression* value, |
| 2724 int* slot_index) const; |
| 2725 |
| 2726 #ifdef DEBUG |
| 2727 int slot_count() const { return slot_count_; } |
| 2728 #endif |
| 2729 |
2708 protected: | 2730 protected: |
2709 ClassLiteral(Zone* zone, const AstRawString* name, Scope* scope, | 2731 ClassLiteral(Zone* zone, const AstRawString* name, Scope* scope, |
2710 VariableProxy* class_variable_proxy, Expression* extends, | 2732 VariableProxy* class_variable_proxy, Expression* extends, |
2711 FunctionLiteral* constructor, ZoneList<Property*>* properties, | 2733 FunctionLiteral* constructor, ZoneList<Property*>* properties, |
2712 int start_position, int end_position) | 2734 int start_position, int end_position) |
2713 : Expression(zone, start_position), | 2735 : Expression(zone, start_position), |
2714 raw_name_(name), | 2736 raw_name_(name), |
2715 scope_(scope), | 2737 scope_(scope), |
2716 class_variable_proxy_(class_variable_proxy), | 2738 class_variable_proxy_(class_variable_proxy), |
2717 extends_(extends), | 2739 extends_(extends), |
2718 constructor_(constructor), | 2740 constructor_(constructor), |
2719 properties_(properties), | 2741 properties_(properties), |
2720 end_position_(end_position) {} | 2742 end_position_(end_position), |
| 2743 #ifdef DEBUG |
| 2744 slot_count_(0), |
| 2745 #endif |
| 2746 slot_(FeedbackVectorICSlot::Invalid()) { |
| 2747 } |
| 2748 |
2721 static int parent_num_ids() { return Expression::num_ids(); } | 2749 static int parent_num_ids() { return Expression::num_ids(); } |
2722 | 2750 |
2723 private: | 2751 private: |
2724 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 2752 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
2725 | 2753 |
2726 const AstRawString* raw_name_; | 2754 const AstRawString* raw_name_; |
2727 Scope* scope_; | 2755 Scope* scope_; |
2728 VariableProxy* class_variable_proxy_; | 2756 VariableProxy* class_variable_proxy_; |
2729 Expression* extends_; | 2757 Expression* extends_; |
2730 FunctionLiteral* constructor_; | 2758 FunctionLiteral* constructor_; |
2731 ZoneList<Property*>* properties_; | 2759 ZoneList<Property*>* properties_; |
2732 int end_position_; | 2760 int end_position_; |
| 2761 #ifdef DEBUG |
| 2762 // slot_count_ helps validate that the logic to allocate ic slots and the |
| 2763 // logic to use them are in sync. |
| 2764 int slot_count_; |
| 2765 #endif |
| 2766 FeedbackVectorICSlot slot_; |
2733 }; | 2767 }; |
2734 | 2768 |
2735 | 2769 |
2736 class NativeFunctionLiteral final : public Expression { | 2770 class NativeFunctionLiteral final : public Expression { |
2737 public: | 2771 public: |
2738 DECLARE_NODE_TYPE(NativeFunctionLiteral) | 2772 DECLARE_NODE_TYPE(NativeFunctionLiteral) |
2739 | 2773 |
2740 Handle<String> name() const { return name_->string(); } | 2774 Handle<String> name() const { return name_->string(); } |
2741 v8::Extension* extension() const { return extension_; } | 2775 v8::Extension* extension() const { return extension_; } |
2742 | 2776 |
(...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3593 | 3627 |
3594 private: | 3628 private: |
3595 Zone* zone_; | 3629 Zone* zone_; |
3596 AstValueFactory* ast_value_factory_; | 3630 AstValueFactory* ast_value_factory_; |
3597 }; | 3631 }; |
3598 | 3632 |
3599 | 3633 |
3600 } } // namespace v8::internal | 3634 } } // namespace v8::internal |
3601 | 3635 |
3602 #endif // V8_AST_H_ | 3636 #endif // V8_AST_H_ |
OLD | NEW |