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-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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2364 void set_value(Expression* e) { value_ = e; } | 2381 void set_value(Expression* e) { value_ = e; } |
| 2365 | 2382 |
| 2366 BinaryOperation* binary_operation() const { return binary_operation_; } | 2383 BinaryOperation* binary_operation() const { return binary_operation_; } |
| 2367 | 2384 |
| 2368 // This check relies on the definition order of token in token.h. | 2385 // This check relies on the definition order of token in token.h. |
| 2369 bool is_compound() const { return op() > Token::ASSIGN; } | 2386 bool is_compound() const { return op() > Token::ASSIGN; } |
| 2370 | 2387 |
| 2371 static int num_ids() { return parent_num_ids() + 2; } | 2388 static int num_ids() { return parent_num_ids() + 2; } |
| 2372 BailoutId AssignmentId() const { return BailoutId(local_id(0)); } | 2389 BailoutId AssignmentId() const { return BailoutId(local_id(0)); } |
| 2373 | 2390 |
| 2391 // Type feedback vector slot. Used only by ignition. | |
| 2392 FeedbackVectorSlot BinaryOperationFeedbackSlot() const { | |
| 2393 return binary_operation_slot_; | |
| 2394 } | |
| 2395 | |
| 2374 // Type feedback information. | 2396 // Type feedback information. |
| 2375 TypeFeedbackId AssignmentFeedbackId() { return TypeFeedbackId(local_id(1)); } | 2397 TypeFeedbackId AssignmentFeedbackId() { return TypeFeedbackId(local_id(1)); } |
| 2376 bool IsUninitialized() const { | 2398 bool IsUninitialized() const { |
| 2377 return IsUninitializedField::decode(bit_field_); | 2399 return IsUninitializedField::decode(bit_field_); |
| 2378 } | 2400 } |
| 2379 bool HasNoTypeInformation() { | 2401 bool HasNoTypeInformation() { |
| 2380 return IsUninitializedField::decode(bit_field_); | 2402 return IsUninitializedField::decode(bit_field_); |
| 2381 } | 2403 } |
| 2382 bool IsMonomorphic() const { return receiver_types_.length() == 1; } | 2404 bool IsMonomorphic() const { return receiver_types_.length() == 1; } |
| 2383 SmallMapList* GetReceiverTypes() { return &receiver_types_; } | 2405 SmallMapList* GetReceiverTypes() { return &receiver_types_; } |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 2412 : public BitField16<IcCheckType, IsUninitializedField::kNext, 1> {}; | 2434 : public BitField16<IcCheckType, IsUninitializedField::kNext, 1> {}; |
| 2413 class StoreModeField | 2435 class StoreModeField |
| 2414 : public BitField16<KeyedAccessStoreMode, KeyTypeField::kNext, 3> {}; | 2436 : public BitField16<KeyedAccessStoreMode, KeyTypeField::kNext, 3> {}; |
| 2415 class TokenField : public BitField16<Token::Value, StoreModeField::kNext, 8> { | 2437 class TokenField : public BitField16<Token::Value, StoreModeField::kNext, 8> { |
| 2416 }; | 2438 }; |
| 2417 | 2439 |
| 2418 // Starts with 16-bit field, which should get packed together with | 2440 // Starts with 16-bit field, which should get packed together with |
| 2419 // Expression's trailing 16-bit field. | 2441 // Expression's trailing 16-bit field. |
| 2420 uint16_t bit_field_; | 2442 uint16_t bit_field_; |
| 2421 FeedbackVectorSlot slot_; | 2443 FeedbackVectorSlot slot_; |
| 2444 FeedbackVectorSlot binary_operation_slot_; | |
|
Michael Starzinger
2016/08/05 09:44:27
nit: This field seems to be unused, the BytecodeGe
mythria
2016/08/05 09:55:18
Thanks, I missed removing this one. Initially I ha
| |
| 2422 Expression* target_; | 2445 Expression* target_; |
| 2423 Expression* value_; | 2446 Expression* value_; |
| 2424 BinaryOperation* binary_operation_; | 2447 BinaryOperation* binary_operation_; |
| 2425 SmallMapList receiver_types_; | 2448 SmallMapList receiver_types_; |
| 2426 }; | 2449 }; |
| 2427 | 2450 |
| 2428 | 2451 |
| 2429 // The RewritableExpression class is a wrapper for AST nodes that wait | 2452 // The RewritableExpression class is a wrapper for AST nodes that wait |
| 2430 // for some potential rewriting. However, even if such nodes are indeed | 2453 // for some potential rewriting. However, even if such nodes are indeed |
| 2431 // rewritten, the RewritableExpression wrapper nodes will survive in the | 2454 // rewritten, the RewritableExpression wrapper nodes will survive in the |
| (...skipping 1098 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3530 : NULL; \ | 3553 : NULL; \ |
| 3531 } | 3554 } |
| 3532 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) | 3555 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) |
| 3533 #undef DECLARE_NODE_FUNCTIONS | 3556 #undef DECLARE_NODE_FUNCTIONS |
| 3534 | 3557 |
| 3535 | 3558 |
| 3536 } // namespace internal | 3559 } // namespace internal |
| 3537 } // namespace v8 | 3560 } // namespace v8 |
| 3538 | 3561 |
| 3539 #endif // V8_AST_AST_H_ | 3562 #endif // V8_AST_AST_H_ |
| OLD | NEW |