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/assembler.h" | 8 #include "src/assembler.h" |
9 #include "src/ast/ast-types.h" | 9 #include "src/ast/ast-types.h" |
10 #include "src/ast/ast-value-factory.h" | 10 #include "src/ast/ast-value-factory.h" |
(...skipping 1436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1447 | 1447 |
1448 // Unlike other AST nodes, this number of bailout IDs allocated for an | 1448 // Unlike other AST nodes, this number of bailout IDs allocated for an |
1449 // ObjectLiteral can vary, so num_ids() is not a static method. | 1449 // ObjectLiteral can vary, so num_ids() is not a static method. |
1450 int num_ids() const { return parent_num_ids() + 1 + properties()->length(); } | 1450 int num_ids() const { return parent_num_ids() + 1 + properties()->length(); } |
1451 | 1451 |
1452 // Object literals need one feedback slot for each non-trivial value, as well | 1452 // Object literals need one feedback slot for each non-trivial value, as well |
1453 // as some slots for home objects. | 1453 // as some slots for home objects. |
1454 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, | 1454 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, |
1455 FeedbackVectorSlotCache* cache); | 1455 FeedbackVectorSlotCache* cache); |
1456 | 1456 |
1457 bool has_rest_property() const { return has_rest_property_; } | |
1458 | |
1457 private: | 1459 private: |
1458 friend class AstNodeFactory; | 1460 friend class AstNodeFactory; |
1459 | 1461 |
1460 ObjectLiteral(ZoneList<Property*>* properties, int literal_index, | 1462 ObjectLiteral(ZoneList<Property*>* properties, int literal_index, |
1461 uint32_t boilerplate_properties, int pos) | 1463 uint32_t boilerplate_properties, int pos, |
1464 bool has_rest_property) | |
1462 : MaterializedLiteral(literal_index, pos, kObjectLiteral), | 1465 : MaterializedLiteral(literal_index, pos, kObjectLiteral), |
1463 boilerplate_properties_(boilerplate_properties), | 1466 boilerplate_properties_(boilerplate_properties), |
1464 properties_(properties) { | 1467 properties_(properties), |
1468 has_rest_property_(has_rest_property) { | |
1465 bit_field_ |= FastElementsField::encode(false) | | 1469 bit_field_ |= FastElementsField::encode(false) | |
1466 HasElementsField::encode(false) | | 1470 HasElementsField::encode(false) | |
1467 MayStoreDoublesField::encode(false); | 1471 MayStoreDoublesField::encode(false); |
1468 } | 1472 } |
1469 | 1473 |
1470 static int parent_num_ids() { return MaterializedLiteral::num_ids(); } | 1474 static int parent_num_ids() { return MaterializedLiteral::num_ids(); } |
1471 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 1475 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
1472 | 1476 |
1473 uint32_t boilerplate_properties_; | 1477 uint32_t boilerplate_properties_; |
1474 Handle<FixedArray> constant_properties_; | 1478 Handle<FixedArray> constant_properties_; |
1475 ZoneList<Property*>* properties_; | 1479 ZoneList<Property*>* properties_; |
1480 bool has_rest_property_; | |
adamk
2017/01/10 23:22:55
This should be stored in the bit_field_, like the
gsathya
2017/01/12 21:27:41
Done.
| |
1476 | 1481 |
1477 class FastElementsField | 1482 class FastElementsField |
1478 : public BitField<bool, MaterializedLiteral::kNextBitFieldIndex, 1> {}; | 1483 : public BitField<bool, MaterializedLiteral::kNextBitFieldIndex, 1> {}; |
1479 class HasElementsField : public BitField<bool, FastElementsField::kNext, 1> { | 1484 class HasElementsField : public BitField<bool, FastElementsField::kNext, 1> { |
1480 }; | 1485 }; |
1481 class MayStoreDoublesField | 1486 class MayStoreDoublesField |
1482 : public BitField<bool, HasElementsField::kNext, 1> {}; | 1487 : public BitField<bool, HasElementsField::kNext, 1> {}; |
1483 }; | 1488 }; |
1484 | 1489 |
1485 | 1490 |
(...skipping 1818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3304 Literal* NewUndefinedLiteral(int pos) { | 3309 Literal* NewUndefinedLiteral(int pos) { |
3305 return new (zone_) Literal(ast_value_factory_->NewUndefined(), pos); | 3310 return new (zone_) Literal(ast_value_factory_->NewUndefined(), pos); |
3306 } | 3311 } |
3307 | 3312 |
3308 Literal* NewTheHoleLiteral(int pos) { | 3313 Literal* NewTheHoleLiteral(int pos) { |
3309 return new (zone_) Literal(ast_value_factory_->NewTheHole(), pos); | 3314 return new (zone_) Literal(ast_value_factory_->NewTheHole(), pos); |
3310 } | 3315 } |
3311 | 3316 |
3312 ObjectLiteral* NewObjectLiteral( | 3317 ObjectLiteral* NewObjectLiteral( |
3313 ZoneList<ObjectLiteral::Property*>* properties, int literal_index, | 3318 ZoneList<ObjectLiteral::Property*>* properties, int literal_index, |
3314 uint32_t boilerplate_properties, int pos) { | 3319 uint32_t boilerplate_properties, int pos, bool has_rest_property) { |
3315 return new (zone_) | 3320 return new (zone_) |
3316 ObjectLiteral(properties, literal_index, boilerplate_properties, pos); | 3321 ObjectLiteral(properties, literal_index, boilerplate_properties, pos, |
3322 has_rest_property); | |
3317 } | 3323 } |
3318 | 3324 |
3319 ObjectLiteral::Property* NewObjectLiteralProperty( | 3325 ObjectLiteral::Property* NewObjectLiteralProperty( |
3320 Expression* key, Expression* value, ObjectLiteralProperty::Kind kind, | 3326 Expression* key, Expression* value, ObjectLiteralProperty::Kind kind, |
3321 bool is_computed_name) { | 3327 bool is_computed_name) { |
3322 return new (zone_) | 3328 return new (zone_) |
3323 ObjectLiteral::Property(key, value, kind, is_computed_name); | 3329 ObjectLiteral::Property(key, value, kind, is_computed_name); |
3324 } | 3330 } |
3325 | 3331 |
3326 ObjectLiteral::Property* NewObjectLiteralProperty(Expression* key, | 3332 ObjectLiteral::Property* NewObjectLiteralProperty(Expression* key, |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3621 : NULL; \ | 3627 : NULL; \ |
3622 } | 3628 } |
3623 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) | 3629 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) |
3624 #undef DECLARE_NODE_FUNCTIONS | 3630 #undef DECLARE_NODE_FUNCTIONS |
3625 | 3631 |
3626 | 3632 |
3627 } // namespace internal | 3633 } // namespace internal |
3628 } // namespace v8 | 3634 } // namespace v8 |
3629 | 3635 |
3630 #endif // V8_AST_AST_H_ | 3636 #endif // V8_AST_AST_H_ |
OLD | NEW |