Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(62)

Side by Side Diff: src/ast/ast.h

Issue 2632503003: [runtime] Allocate space for computed property names (Closed)
Patch Set: Comments and reorder. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/ast/ast.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 1818 matching lines...) Expand 10 before | Expand all | Expand 10 after
3330 Literal* NewUndefinedLiteral(int pos) { 3336 Literal* NewUndefinedLiteral(int pos) {
3331 return new (zone_) Literal(ast_value_factory_->NewUndefined(), pos); 3337 return new (zone_) Literal(ast_value_factory_->NewUndefined(), pos);
3332 } 3338 }
3333 3339
3334 Literal* NewTheHoleLiteral(int pos) { 3340 Literal* NewTheHoleLiteral(int pos) {
3335 return new (zone_) Literal(ast_value_factory_->NewTheHole(), pos); 3341 return new (zone_) Literal(ast_value_factory_->NewTheHole(), pos);
3336 } 3342 }
3337 3343
3338 ObjectLiteral* NewObjectLiteral( 3344 ObjectLiteral* NewObjectLiteral(
3339 ZoneList<ObjectLiteral::Property*>* properties, int literal_index, 3345 ZoneList<ObjectLiteral::Property*>* properties, int literal_index,
3340 uint32_t boilerplate_properties, int pos, bool has_rest_property) { 3346 uint32_t boilerplate_properties, bool has_seen_proto, int pos,
3347 bool has_rest_property) {
3341 return new (zone_) 3348 return new (zone_)
3342 ObjectLiteral(properties, literal_index, boilerplate_properties, pos, 3349 ObjectLiteral(properties, literal_index, boilerplate_properties,
3343 has_rest_property); 3350 has_seen_proto, pos, has_rest_property);
3344 } 3351 }
3345 3352
3346 ObjectLiteral::Property* NewObjectLiteralProperty( 3353 ObjectLiteral::Property* NewObjectLiteralProperty(
3347 Expression* key, Expression* value, ObjectLiteralProperty::Kind kind, 3354 Expression* key, Expression* value, ObjectLiteralProperty::Kind kind,
3348 bool is_computed_name) { 3355 bool is_computed_name) {
3349 return new (zone_) 3356 return new (zone_)
3350 ObjectLiteral::Property(key, value, kind, is_computed_name); 3357 ObjectLiteral::Property(key, value, kind, is_computed_name);
3351 } 3358 }
3352 3359
3353 ObjectLiteral::Property* NewObjectLiteralProperty(Expression* key, 3360 ObjectLiteral::Property* NewObjectLiteralProperty(Expression* key,
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
3648 : NULL; \ 3655 : NULL; \
3649 } 3656 }
3650 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) 3657 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS)
3651 #undef DECLARE_NODE_FUNCTIONS 3658 #undef DECLARE_NODE_FUNCTIONS
3652 3659
3653 3660
3654 } // namespace internal 3661 } // namespace internal
3655 } // namespace v8 3662 } // namespace v8
3656 3663
3657 #endif // V8_AST_AST_H_ 3664 #endif // V8_AST_AST_H_
OLDNEW
« no previous file with comments | « no previous file | src/ast/ast.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698