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