| 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 2104 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2115       default: | 2115       default: | 
| 2116         break; | 2116         break; | 
| 2117     } | 2117     } | 
| 2118   } | 2118   } | 
| 2119 | 2119 | 
| 2120   // The short-circuit logical operations need an AST ID for their | 2120   // The short-circuit logical operations need an AST ID for their | 
| 2121   // right-hand subexpression. | 2121   // right-hand subexpression. | 
| 2122   static int num_ids() { return parent_num_ids() + 2; } | 2122   static int num_ids() { return parent_num_ids() + 2; } | 
| 2123   BailoutId RightId() const { return BailoutId(local_id(0)); } | 2123   BailoutId RightId() const { return BailoutId(local_id(0)); } | 
| 2124 | 2124 | 
|  | 2125   // BinaryOperation will have both a slot in the feedback vector and the | 
|  | 2126   // TypeFeedbackId to record the type information. TypeFeedbackId is used | 
|  | 2127   // by full codegen and the feedback vector slot is used by interpreter. | 
|  | 2128   void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, | 
|  | 2129                                  FeedbackVectorSlotCache* cache); | 
|  | 2130 | 
|  | 2131   FeedbackVectorSlot BinaryOperationFeedbackSlot() const { | 
|  | 2132     return type_feedback_slot_; | 
|  | 2133   } | 
|  | 2134 | 
| 2125   TypeFeedbackId BinaryOperationFeedbackId() const { | 2135   TypeFeedbackId BinaryOperationFeedbackId() const { | 
| 2126     return TypeFeedbackId(local_id(1)); | 2136     return TypeFeedbackId(local_id(1)); | 
| 2127   } | 2137   } | 
| 2128   Maybe<int> fixed_right_arg() const { | 2138   Maybe<int> fixed_right_arg() const { | 
| 2129     return has_fixed_right_arg_ ? Just(fixed_right_arg_value_) : Nothing<int>(); | 2139     return has_fixed_right_arg_ ? Just(fixed_right_arg_value_) : Nothing<int>(); | 
| 2130   } | 2140   } | 
| 2131   void set_fixed_right_arg(Maybe<int> arg) { | 2141   void set_fixed_right_arg(Maybe<int> arg) { | 
| 2132     has_fixed_right_arg_ = arg.IsJust(); | 2142     has_fixed_right_arg_ = arg.IsJust(); | 
| 2133     if (arg.IsJust()) fixed_right_arg_value_ = arg.FromJust(); | 2143     if (arg.IsJust()) fixed_right_arg_value_ = arg.FromJust(); | 
| 2134   } | 2144   } | 
| (...skipping 17 matching lines...) Expand all  Loading... | 
| 2152   int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 2162   int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 
| 2153 | 2163 | 
| 2154   const byte op_;  // actually Token::Value | 2164   const byte op_;  // actually Token::Value | 
| 2155   // TODO(rossberg): the fixed arg should probably be represented as a Constant | 2165   // TODO(rossberg): the fixed arg should probably be represented as a Constant | 
| 2156   // type for the RHS. Currenty it's actually a Maybe<int> | 2166   // type for the RHS. Currenty it's actually a Maybe<int> | 
| 2157   bool has_fixed_right_arg_; | 2167   bool has_fixed_right_arg_; | 
| 2158   int fixed_right_arg_value_; | 2168   int fixed_right_arg_value_; | 
| 2159   Expression* left_; | 2169   Expression* left_; | 
| 2160   Expression* right_; | 2170   Expression* right_; | 
| 2161   Handle<AllocationSite> allocation_site_; | 2171   Handle<AllocationSite> allocation_site_; | 
|  | 2172   FeedbackVectorSlot type_feedback_slot_; | 
| 2162 }; | 2173 }; | 
| 2163 | 2174 | 
| 2164 | 2175 | 
| 2165 class CountOperation final : public Expression { | 2176 class CountOperation final : public Expression { | 
| 2166  public: | 2177  public: | 
| 2167   DECLARE_NODE_TYPE(CountOperation) | 2178   DECLARE_NODE_TYPE(CountOperation) | 
| 2168 | 2179 | 
| 2169   bool is_prefix() const { return IsPrefixField::decode(bit_field_); } | 2180   bool is_prefix() const { return IsPrefixField::decode(bit_field_); } | 
| 2170   bool is_postfix() const { return !is_prefix(); } | 2181   bool is_postfix() const { return !is_prefix(); } | 
| 2171 | 2182 | 
| (...skipping 23 matching lines...) Expand all  Loading... | 
| 2195   static int num_ids() { return parent_num_ids() + 4; } | 2206   static int num_ids() { return parent_num_ids() + 4; } | 
| 2196   BailoutId AssignmentId() const { return BailoutId(local_id(0)); } | 2207   BailoutId AssignmentId() const { return BailoutId(local_id(0)); } | 
| 2197   BailoutId ToNumberId() const { return BailoutId(local_id(1)); } | 2208   BailoutId ToNumberId() const { return BailoutId(local_id(1)); } | 
| 2198   TypeFeedbackId CountBinOpFeedbackId() const { | 2209   TypeFeedbackId CountBinOpFeedbackId() const { | 
| 2199     return TypeFeedbackId(local_id(2)); | 2210     return TypeFeedbackId(local_id(2)); | 
| 2200   } | 2211   } | 
| 2201   TypeFeedbackId CountStoreFeedbackId() const { | 2212   TypeFeedbackId CountStoreFeedbackId() const { | 
| 2202     return TypeFeedbackId(local_id(3)); | 2213     return TypeFeedbackId(local_id(3)); | 
| 2203   } | 2214   } | 
| 2204 | 2215 | 
|  | 2216   // Feedback slot for binary operation is only used by ignition. | 
|  | 2217   FeedbackVectorSlot CountBinaryOpFeedbackSlot() const { | 
|  | 2218     return binary_operation_slot_; | 
|  | 2219   } | 
|  | 2220 | 
| 2205   void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, | 2221   void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, | 
| 2206                                  FeedbackVectorSlotCache* cache); | 2222                                  FeedbackVectorSlotCache* cache); | 
| 2207   FeedbackVectorSlot CountSlot() const { return slot_; } | 2223   FeedbackVectorSlot CountSlot() const { return slot_; } | 
| 2208 | 2224 | 
| 2209  protected: | 2225  protected: | 
| 2210   CountOperation(Zone* zone, Token::Value op, bool is_prefix, Expression* expr, | 2226   CountOperation(Zone* zone, Token::Value op, bool is_prefix, Expression* expr, | 
| 2211                  int pos) | 2227                  int pos) | 
| 2212       : Expression(zone, pos, kCountOperation), | 2228       : Expression(zone, pos, kCountOperation), | 
| 2213         bit_field_( | 2229         bit_field_( | 
| 2214             IsPrefixField::encode(is_prefix) | KeyTypeField::encode(ELEMENT) | | 2230             IsPrefixField::encode(is_prefix) | KeyTypeField::encode(ELEMENT) | | 
| 2215             StoreModeField::encode(STANDARD_STORE) | TokenField::encode(op)), | 2231             StoreModeField::encode(STANDARD_STORE) | TokenField::encode(op)), | 
| 2216         type_(NULL), | 2232         type_(NULL), | 
| 2217         expression_(expr) {} | 2233         expression_(expr) {} | 
| 2218   static int parent_num_ids() { return Expression::num_ids(); } | 2234   static int parent_num_ids() { return Expression::num_ids(); } | 
| 2219 | 2235 | 
| 2220  private: | 2236  private: | 
| 2221   int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 2237   int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 
| 2222 | 2238 | 
| 2223   class IsPrefixField : public BitField16<bool, 0, 1> {}; | 2239   class IsPrefixField : public BitField16<bool, 0, 1> {}; | 
| 2224   class KeyTypeField : public BitField16<IcCheckType, 1, 1> {}; | 2240   class KeyTypeField : public BitField16<IcCheckType, 1, 1> {}; | 
| 2225   class StoreModeField : public BitField16<KeyedAccessStoreMode, 2, 3> {}; | 2241   class StoreModeField : public BitField16<KeyedAccessStoreMode, 2, 3> {}; | 
| 2226   class TokenField : public BitField16<Token::Value, 5, 8> {}; | 2242   class TokenField : public BitField16<Token::Value, 5, 8> {}; | 
| 2227 | 2243 | 
| 2228   // Starts with 16-bit field, which should get packed together with | 2244   // Starts with 16-bit field, which should get packed together with | 
| 2229   // Expression's trailing 16-bit field. | 2245   // Expression's trailing 16-bit field. | 
| 2230   uint16_t bit_field_; | 2246   uint16_t bit_field_; | 
| 2231   FeedbackVectorSlot slot_; | 2247   FeedbackVectorSlot slot_; | 
|  | 2248   FeedbackVectorSlot binary_operation_slot_; | 
| 2232   Type* type_; | 2249   Type* type_; | 
| 2233   Expression* expression_; | 2250   Expression* expression_; | 
| 2234   SmallMapList receiver_types_; | 2251   SmallMapList receiver_types_; | 
| 2235 }; | 2252 }; | 
| 2236 | 2253 | 
| 2237 | 2254 | 
| 2238 class CompareOperation final : public Expression { | 2255 class CompareOperation final : public Expression { | 
| 2239  public: | 2256  public: | 
| 2240   DECLARE_NODE_TYPE(CompareOperation) | 2257   DECLARE_NODE_TYPE(CompareOperation) | 
| 2241 | 2258 | 
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2363   void set_value(Expression* e) { value_ = e; } | 2380   void set_value(Expression* e) { value_ = e; } | 
| 2364 | 2381 | 
| 2365   BinaryOperation* binary_operation() const { return binary_operation_; } | 2382   BinaryOperation* binary_operation() const { return binary_operation_; } | 
| 2366 | 2383 | 
| 2367   // This check relies on the definition order of token in token.h. | 2384   // This check relies on the definition order of token in token.h. | 
| 2368   bool is_compound() const { return op() > Token::ASSIGN; } | 2385   bool is_compound() const { return op() > Token::ASSIGN; } | 
| 2369 | 2386 | 
| 2370   static int num_ids() { return parent_num_ids() + 2; } | 2387   static int num_ids() { return parent_num_ids() + 2; } | 
| 2371   BailoutId AssignmentId() const { return BailoutId(local_id(0)); } | 2388   BailoutId AssignmentId() const { return BailoutId(local_id(0)); } | 
| 2372 | 2389 | 
|  | 2390   // Type feedback vector slot. Used only by ignition. | 
|  | 2391   FeedbackVectorSlot BinaryOperationFeedbackSlot() const { | 
|  | 2392     return binary_operation_slot_; | 
|  | 2393   } | 
|  | 2394 | 
| 2373   // Type feedback information. | 2395   // Type feedback information. | 
| 2374   TypeFeedbackId AssignmentFeedbackId() { return TypeFeedbackId(local_id(1)); } | 2396   TypeFeedbackId AssignmentFeedbackId() { return TypeFeedbackId(local_id(1)); } | 
| 2375   bool IsUninitialized() const { | 2397   bool IsUninitialized() const { | 
| 2376     return IsUninitializedField::decode(bit_field_); | 2398     return IsUninitializedField::decode(bit_field_); | 
| 2377   } | 2399   } | 
| 2378   bool HasNoTypeInformation() { | 2400   bool HasNoTypeInformation() { | 
| 2379     return IsUninitializedField::decode(bit_field_); | 2401     return IsUninitializedField::decode(bit_field_); | 
| 2380   } | 2402   } | 
| 2381   bool IsMonomorphic() const { return receiver_types_.length() == 1; } | 2403   bool IsMonomorphic() const { return receiver_types_.length() == 1; } | 
| 2382   SmallMapList* GetReceiverTypes() { return &receiver_types_; } | 2404   SmallMapList* GetReceiverTypes() { return &receiver_types_; } | 
| (...skipping 28 matching lines...) Expand all  Loading... | 
| 2411       : public BitField16<IcCheckType, IsUninitializedField::kNext, 1> {}; | 2433       : public BitField16<IcCheckType, IsUninitializedField::kNext, 1> {}; | 
| 2412   class StoreModeField | 2434   class StoreModeField | 
| 2413       : public BitField16<KeyedAccessStoreMode, KeyTypeField::kNext, 3> {}; | 2435       : public BitField16<KeyedAccessStoreMode, KeyTypeField::kNext, 3> {}; | 
| 2414   class TokenField : public BitField16<Token::Value, StoreModeField::kNext, 8> { | 2436   class TokenField : public BitField16<Token::Value, StoreModeField::kNext, 8> { | 
| 2415   }; | 2437   }; | 
| 2416 | 2438 | 
| 2417   // Starts with 16-bit field, which should get packed together with | 2439   // Starts with 16-bit field, which should get packed together with | 
| 2418   // Expression's trailing 16-bit field. | 2440   // Expression's trailing 16-bit field. | 
| 2419   uint16_t bit_field_; | 2441   uint16_t bit_field_; | 
| 2420   FeedbackVectorSlot slot_; | 2442   FeedbackVectorSlot slot_; | 
|  | 2443   FeedbackVectorSlot binary_operation_slot_; | 
| 2421   Expression* target_; | 2444   Expression* target_; | 
| 2422   Expression* value_; | 2445   Expression* value_; | 
| 2423   BinaryOperation* binary_operation_; | 2446   BinaryOperation* binary_operation_; | 
| 2424   SmallMapList receiver_types_; | 2447   SmallMapList receiver_types_; | 
| 2425 }; | 2448 }; | 
| 2426 | 2449 | 
| 2427 | 2450 | 
| 2428 // The RewritableExpression class is a wrapper for AST nodes that wait | 2451 // The RewritableExpression class is a wrapper for AST nodes that wait | 
| 2429 // for some potential rewriting.  However, even if such nodes are indeed | 2452 // for some potential rewriting.  However, even if such nodes are indeed | 
| 2430 // rewritten, the RewritableExpression wrapper nodes will survive in the | 2453 // rewritten, the RewritableExpression wrapper nodes will survive in the | 
| (...skipping 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 3519                                     : NULL;                                   \ | 3542                                     : NULL;                                   \ | 
| 3520   } | 3543   } | 
| 3521 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) | 3544 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) | 
| 3522 #undef DECLARE_NODE_FUNCTIONS | 3545 #undef DECLARE_NODE_FUNCTIONS | 
| 3523 | 3546 | 
| 3524 | 3547 | 
| 3525 }  // namespace internal | 3548 }  // namespace internal | 
| 3526 }  // namespace v8 | 3549 }  // namespace v8 | 
| 3527 | 3550 | 
| 3528 #endif  // V8_AST_AST_H_ | 3551 #endif  // V8_AST_AST_H_ | 
| OLD | NEW | 
|---|