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-value-factory.h" | 8 #include "src/ast/ast-value-factory.h" |
9 #include "src/ast/modules.h" | 9 #include "src/ast/modules.h" |
10 #include "src/ast/variables.h" | 10 #include "src/ast/variables.h" |
(...skipping 2105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2116 default: | 2116 default: |
2117 break; | 2117 break; |
2118 } | 2118 } |
2119 } | 2119 } |
2120 | 2120 |
2121 // The short-circuit logical operations need an AST ID for their | 2121 // The short-circuit logical operations need an AST ID for their |
2122 // right-hand subexpression. | 2122 // right-hand subexpression. |
2123 static int num_ids() { return parent_num_ids() + 2; } | 2123 static int num_ids() { return parent_num_ids() + 2; } |
2124 BailoutId RightId() const { return BailoutId(local_id(0)); } | 2124 BailoutId RightId() const { return BailoutId(local_id(0)); } |
2125 | 2125 |
| 2126 // BinaryOperation will have both a slot in the feedback vector and the |
| 2127 // TypeFeedbackId to record the type information. TypeFeedbackId is used |
| 2128 // by full codegen and the feedback vector slot is used by interpreter. |
| 2129 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, |
| 2130 FeedbackVectorSlotCache* cache); |
| 2131 |
| 2132 FeedbackVectorSlot BinaryOperationFeedbackSlot() const { |
| 2133 return type_feedback_slot_; |
| 2134 } |
| 2135 |
2126 TypeFeedbackId BinaryOperationFeedbackId() const { | 2136 TypeFeedbackId BinaryOperationFeedbackId() const { |
2127 return TypeFeedbackId(local_id(1)); | 2137 return TypeFeedbackId(local_id(1)); |
2128 } | 2138 } |
2129 Maybe<int> fixed_right_arg() const { | 2139 Maybe<int> fixed_right_arg() const { |
2130 return has_fixed_right_arg_ ? Just(fixed_right_arg_value_) : Nothing<int>(); | 2140 return has_fixed_right_arg_ ? Just(fixed_right_arg_value_) : Nothing<int>(); |
2131 } | 2141 } |
2132 void set_fixed_right_arg(Maybe<int> arg) { | 2142 void set_fixed_right_arg(Maybe<int> arg) { |
2133 has_fixed_right_arg_ = arg.IsJust(); | 2143 has_fixed_right_arg_ = arg.IsJust(); |
2134 if (arg.IsJust()) fixed_right_arg_value_ = arg.FromJust(); | 2144 if (arg.IsJust()) fixed_right_arg_value_ = arg.FromJust(); |
2135 } | 2145 } |
(...skipping 17 matching lines...) Expand all Loading... |
2153 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 2163 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
2154 | 2164 |
2155 const byte op_; // actually Token::Value | 2165 const byte op_; // actually Token::Value |
2156 // TODO(rossberg): the fixed arg should probably be represented as a Constant | 2166 // TODO(rossberg): the fixed arg should probably be represented as a Constant |
2157 // type for the RHS. Currenty it's actually a Maybe<int> | 2167 // type for the RHS. Currenty it's actually a Maybe<int> |
2158 bool has_fixed_right_arg_; | 2168 bool has_fixed_right_arg_; |
2159 int fixed_right_arg_value_; | 2169 int fixed_right_arg_value_; |
2160 Expression* left_; | 2170 Expression* left_; |
2161 Expression* right_; | 2171 Expression* right_; |
2162 Handle<AllocationSite> allocation_site_; | 2172 Handle<AllocationSite> allocation_site_; |
| 2173 FeedbackVectorSlot type_feedback_slot_; |
2163 }; | 2174 }; |
2164 | 2175 |
2165 | 2176 |
2166 class CountOperation final : public Expression { | 2177 class CountOperation final : public Expression { |
2167 public: | 2178 public: |
2168 DECLARE_NODE_TYPE(CountOperation) | 2179 DECLARE_NODE_TYPE(CountOperation) |
2169 | 2180 |
2170 bool is_prefix() const { return IsPrefixField::decode(bit_field_); } | 2181 bool is_prefix() const { return IsPrefixField::decode(bit_field_); } |
2171 bool is_postfix() const { return !is_prefix(); } | 2182 bool is_postfix() const { return !is_prefix(); } |
2172 | 2183 |
(...skipping 23 matching lines...) Expand all Loading... |
2196 static int num_ids() { return parent_num_ids() + 4; } | 2207 static int num_ids() { return parent_num_ids() + 4; } |
2197 BailoutId AssignmentId() const { return BailoutId(local_id(0)); } | 2208 BailoutId AssignmentId() const { return BailoutId(local_id(0)); } |
2198 BailoutId ToNumberId() const { return BailoutId(local_id(1)); } | 2209 BailoutId ToNumberId() const { return BailoutId(local_id(1)); } |
2199 TypeFeedbackId CountBinOpFeedbackId() const { | 2210 TypeFeedbackId CountBinOpFeedbackId() const { |
2200 return TypeFeedbackId(local_id(2)); | 2211 return TypeFeedbackId(local_id(2)); |
2201 } | 2212 } |
2202 TypeFeedbackId CountStoreFeedbackId() const { | 2213 TypeFeedbackId CountStoreFeedbackId() const { |
2203 return TypeFeedbackId(local_id(3)); | 2214 return TypeFeedbackId(local_id(3)); |
2204 } | 2215 } |
2205 | 2216 |
| 2217 // Feedback slot for binary operation is only used by ignition. |
| 2218 FeedbackVectorSlot CountBinaryOpFeedbackSlot() const { |
| 2219 return binary_operation_slot_; |
| 2220 } |
| 2221 |
2206 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, | 2222 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, |
2207 FeedbackVectorSlotCache* cache); | 2223 FeedbackVectorSlotCache* cache); |
2208 FeedbackVectorSlot CountSlot() const { return slot_; } | 2224 FeedbackVectorSlot CountSlot() const { return slot_; } |
2209 | 2225 |
2210 protected: | 2226 protected: |
2211 CountOperation(Zone* zone, Token::Value op, bool is_prefix, Expression* expr, | 2227 CountOperation(Zone* zone, Token::Value op, bool is_prefix, Expression* expr, |
2212 int pos) | 2228 int pos) |
2213 : Expression(zone, pos, kCountOperation), | 2229 : Expression(zone, pos, kCountOperation), |
2214 bit_field_( | 2230 bit_field_( |
2215 IsPrefixField::encode(is_prefix) | KeyTypeField::encode(ELEMENT) | | 2231 IsPrefixField::encode(is_prefix) | KeyTypeField::encode(ELEMENT) | |
2216 StoreModeField::encode(STANDARD_STORE) | TokenField::encode(op)), | 2232 StoreModeField::encode(STANDARD_STORE) | TokenField::encode(op)), |
2217 type_(NULL), | 2233 type_(NULL), |
2218 expression_(expr) {} | 2234 expression_(expr) {} |
2219 static int parent_num_ids() { return Expression::num_ids(); } | 2235 static int parent_num_ids() { return Expression::num_ids(); } |
2220 | 2236 |
2221 private: | 2237 private: |
2222 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 2238 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
2223 | 2239 |
2224 class IsPrefixField : public BitField16<bool, 0, 1> {}; | 2240 class IsPrefixField : public BitField16<bool, 0, 1> {}; |
2225 class KeyTypeField : public BitField16<IcCheckType, 1, 1> {}; | 2241 class KeyTypeField : public BitField16<IcCheckType, 1, 1> {}; |
2226 class StoreModeField : public BitField16<KeyedAccessStoreMode, 2, 3> {}; | 2242 class StoreModeField : public BitField16<KeyedAccessStoreMode, 2, 3> {}; |
2227 class TokenField : public BitField16<Token::Value, 5, 8> {}; | 2243 class TokenField : public BitField16<Token::Value, 5, 8> {}; |
2228 | 2244 |
2229 // Starts with 16-bit field, which should get packed together with | 2245 // Starts with 16-bit field, which should get packed together with |
2230 // Expression's trailing 16-bit field. | 2246 // Expression's trailing 16-bit field. |
2231 uint16_t bit_field_; | 2247 uint16_t bit_field_; |
2232 FeedbackVectorSlot slot_; | 2248 FeedbackVectorSlot slot_; |
| 2249 FeedbackVectorSlot binary_operation_slot_; |
2233 Type* type_; | 2250 Type* type_; |
2234 Expression* expression_; | 2251 Expression* expression_; |
2235 SmallMapList receiver_types_; | 2252 SmallMapList receiver_types_; |
2236 }; | 2253 }; |
2237 | 2254 |
2238 | 2255 |
2239 class CompareOperation final : public Expression { | 2256 class CompareOperation final : public Expression { |
2240 public: | 2257 public: |
2241 DECLARE_NODE_TYPE(CompareOperation) | 2258 DECLARE_NODE_TYPE(CompareOperation) |
2242 | 2259 |
(...skipping 1285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3528 : NULL; \ | 3545 : NULL; \ |
3529 } | 3546 } |
3530 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) | 3547 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) |
3531 #undef DECLARE_NODE_FUNCTIONS | 3548 #undef DECLARE_NODE_FUNCTIONS |
3532 | 3549 |
3533 | 3550 |
3534 } // namespace internal | 3551 } // namespace internal |
3535 } // namespace v8 | 3552 } // namespace v8 |
3536 | 3553 |
3537 #endif // V8_AST_AST_H_ | 3554 #endif // V8_AST_AST_H_ |
OLD | NEW |