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-types.h" | 8 #include "src/ast/ast-types.h" |
9 #include "src/ast/ast-value-factory.h" | 9 #include "src/ast/ast-value-factory.h" |
10 #include "src/ast/modules.h" | 10 #include "src/ast/modules.h" |
(...skipping 1384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1395 bool may_store_doubles() const { | 1395 bool may_store_doubles() const { |
1396 return MayStoreDoublesField::decode(bit_field_); | 1396 return MayStoreDoublesField::decode(bit_field_); |
1397 } | 1397 } |
1398 bool has_elements() const { return HasElementsField::decode(bit_field_); } | 1398 bool has_elements() const { return HasElementsField::decode(bit_field_); } |
1399 bool has_shallow_properties() const { | 1399 bool has_shallow_properties() const { |
1400 return depth() == 1 && !has_elements() && !may_store_doubles(); | 1400 return depth() == 1 && !has_elements() && !may_store_doubles(); |
1401 } | 1401 } |
1402 bool has_rest_property() const { | 1402 bool has_rest_property() const { |
1403 return HasRestPropertyField::decode(bit_field_); | 1403 return HasRestPropertyField::decode(bit_field_); |
1404 } | 1404 } |
1405 bool has_seen_proto() const { | |
1406 return HasSeenProtoPropertyField::decode(bit_field_); | |
1407 } | |
1408 | 1405 |
1409 // Decide if a property should be in the object boilerplate. | 1406 // Decide if a property should be in the object boilerplate. |
1410 static bool IsBoilerplateProperty(Property* property); | 1407 static bool IsBoilerplateProperty(Property* property); |
1411 | 1408 |
1412 // Populate the depth field and flags. | 1409 // Populate the depth field and flags. |
1413 void InitDepthAndFlags(); | 1410 void InitDepthAndFlags(); |
1414 | 1411 |
1415 // Get the constant properties fixed array, populating it if necessary. | 1412 // Get the constant properties fixed array, populating it if necessary. |
1416 Handle<FixedArray> GetOrBuildConstantProperties(Isolate* isolate) { | 1413 Handle<FixedArray> GetOrBuildConstantProperties(Isolate* isolate) { |
1417 if (constant_properties_.is_null()) { | 1414 if (constant_properties_.is_null()) { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1469 | 1466 |
1470 // Object literals need one feedback slot for each non-trivial value, as well | 1467 // Object literals need one feedback slot for each non-trivial value, as well |
1471 // as some slots for home objects. | 1468 // as some slots for home objects. |
1472 void AssignFeedbackVectorSlots(FeedbackVectorSpec* spec, | 1469 void AssignFeedbackVectorSlots(FeedbackVectorSpec* spec, |
1473 FeedbackVectorSlotCache* cache); | 1470 FeedbackVectorSlotCache* cache); |
1474 | 1471 |
1475 private: | 1472 private: |
1476 friend class AstNodeFactory; | 1473 friend class AstNodeFactory; |
1477 | 1474 |
1478 ObjectLiteral(ZoneList<Property*>* properties, int literal_index, | 1475 ObjectLiteral(ZoneList<Property*>* properties, int literal_index, |
1479 uint32_t boilerplate_properties, bool has_seen_proto, int pos, | 1476 uint32_t boilerplate_properties, int pos, |
1480 bool has_rest_property) | 1477 bool has_rest_property) |
1481 : MaterializedLiteral(literal_index, pos, kObjectLiteral), | 1478 : MaterializedLiteral(literal_index, pos, kObjectLiteral), |
1482 boilerplate_properties_(boilerplate_properties), | 1479 boilerplate_properties_(boilerplate_properties), |
1483 properties_(properties) { | 1480 properties_(properties) { |
1484 bit_field_ |= FastElementsField::encode(false) | | 1481 bit_field_ |= FastElementsField::encode(false) | |
1485 HasElementsField::encode(false) | | 1482 HasElementsField::encode(false) | |
1486 MayStoreDoublesField::encode(false) | | 1483 MayStoreDoublesField::encode(false) | |
1487 HasRestPropertyField::encode(has_rest_property) | | 1484 HasRestPropertyField::encode(has_rest_property); |
1488 HasSeenProtoPropertyField::encode(has_seen_proto); | |
1489 } | 1485 } |
1490 | 1486 |
1491 static int parent_num_ids() { return MaterializedLiteral::num_ids(); } | 1487 static int parent_num_ids() { return MaterializedLiteral::num_ids(); } |
1492 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 1488 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
1493 | 1489 |
1494 uint32_t boilerplate_properties_; | 1490 uint32_t boilerplate_properties_; |
1495 Handle<FixedArray> constant_properties_; | 1491 Handle<FixedArray> constant_properties_; |
1496 ZoneList<Property*>* properties_; | 1492 ZoneList<Property*>* properties_; |
1497 | 1493 |
1498 class FastElementsField | 1494 class FastElementsField |
1499 : public BitField<bool, MaterializedLiteral::kNextBitFieldIndex, 1> {}; | 1495 : public BitField<bool, MaterializedLiteral::kNextBitFieldIndex, 1> {}; |
1500 class HasElementsField : public BitField<bool, FastElementsField::kNext, 1> { | 1496 class HasElementsField : public BitField<bool, FastElementsField::kNext, 1> { |
1501 }; | 1497 }; |
1502 class MayStoreDoublesField | 1498 class MayStoreDoublesField |
1503 : public BitField<bool, HasElementsField::kNext, 1> {}; | 1499 : public BitField<bool, HasElementsField::kNext, 1> {}; |
1504 class HasRestPropertyField | 1500 class HasRestPropertyField |
1505 : public BitField<bool, MayStoreDoublesField::kNext, 1> {}; | 1501 : public BitField<bool, MayStoreDoublesField::kNext, 1> {}; |
1506 class HasSeenProtoPropertyField | |
1507 : public BitField<bool, HasRestPropertyField::kNext, 1> {}; | |
1508 }; | 1502 }; |
1509 | 1503 |
1510 | 1504 |
1511 // A map from property names to getter/setter pairs allocated in the zone. | 1505 // A map from property names to getter/setter pairs allocated in the zone. |
1512 class AccessorTable | 1506 class AccessorTable |
1513 : public base::TemplateHashMap<Literal, ObjectLiteral::Accessors, | 1507 : public base::TemplateHashMap<Literal, ObjectLiteral::Accessors, |
1514 bool (*)(void*, void*), | 1508 bool (*)(void*, void*), |
1515 ZoneAllocationPolicy> { | 1509 ZoneAllocationPolicy> { |
1516 public: | 1510 public: |
1517 explicit AccessorTable(Zone* zone) | 1511 explicit AccessorTable(Zone* zone) |
(...skipping 1818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3336 Literal* NewUndefinedLiteral(int pos) { | 3330 Literal* NewUndefinedLiteral(int pos) { |
3337 return new (zone_) Literal(ast_value_factory_->NewUndefined(), pos); | 3331 return new (zone_) Literal(ast_value_factory_->NewUndefined(), pos); |
3338 } | 3332 } |
3339 | 3333 |
3340 Literal* NewTheHoleLiteral(int pos) { | 3334 Literal* NewTheHoleLiteral(int pos) { |
3341 return new (zone_) Literal(ast_value_factory_->NewTheHole(), pos); | 3335 return new (zone_) Literal(ast_value_factory_->NewTheHole(), pos); |
3342 } | 3336 } |
3343 | 3337 |
3344 ObjectLiteral* NewObjectLiteral( | 3338 ObjectLiteral* NewObjectLiteral( |
3345 ZoneList<ObjectLiteral::Property*>* properties, int literal_index, | 3339 ZoneList<ObjectLiteral::Property*>* properties, int literal_index, |
3346 uint32_t boilerplate_properties, bool has_seen_proto, int pos, | 3340 uint32_t boilerplate_properties, int pos, bool has_rest_property) { |
3347 bool has_rest_property) { | |
3348 return new (zone_) | 3341 return new (zone_) |
3349 ObjectLiteral(properties, literal_index, boilerplate_properties, | 3342 ObjectLiteral(properties, literal_index, boilerplate_properties, pos, |
3350 has_seen_proto, pos, has_rest_property); | 3343 has_rest_property); |
3351 } | 3344 } |
3352 | 3345 |
3353 ObjectLiteral::Property* NewObjectLiteralProperty( | 3346 ObjectLiteral::Property* NewObjectLiteralProperty( |
3354 Expression* key, Expression* value, ObjectLiteralProperty::Kind kind, | 3347 Expression* key, Expression* value, ObjectLiteralProperty::Kind kind, |
3355 bool is_computed_name) { | 3348 bool is_computed_name) { |
3356 return new (zone_) | 3349 return new (zone_) |
3357 ObjectLiteral::Property(key, value, kind, is_computed_name); | 3350 ObjectLiteral::Property(key, value, kind, is_computed_name); |
3358 } | 3351 } |
3359 | 3352 |
3360 ObjectLiteral::Property* NewObjectLiteralProperty(Expression* key, | 3353 ObjectLiteral::Property* NewObjectLiteralProperty(Expression* key, |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3655 : NULL; \ | 3648 : NULL; \ |
3656 } | 3649 } |
3657 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) | 3650 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) |
3658 #undef DECLARE_NODE_FUNCTIONS | 3651 #undef DECLARE_NODE_FUNCTIONS |
3659 | 3652 |
3660 | 3653 |
3661 } // namespace internal | 3654 } // namespace internal |
3662 } // namespace v8 | 3655 } // namespace v8 |
3663 | 3656 |
3664 #endif // V8_AST_AST_H_ | 3657 #endif // V8_AST_AST_H_ |
OLD | NEW |