Index: src/ast.cc |
diff --git a/src/ast.cc b/src/ast.cc |
index 8b1d94176fb7c3b20068a0e8d530bf00c2922a48..c625f979eec0ddd14c55c189156cd142e56de806 100644 |
--- a/src/ast.cc |
+++ b/src/ast.cc |
@@ -181,21 +181,25 @@ void FunctionLiteral::InitializeSharedInfo( |
ObjectLiteralProperty::ObjectLiteralProperty( |
- Zone* zone, Literal* key, Expression* value) { |
+ Zone* zone, Expression* key, Expression* value, bool is_computed_name) { |
emit_store_ = true; |
key_ = key; |
value_ = value; |
- Handle<Object> k = key->value(); |
- if (k->IsInternalizedString() && |
- String::Equals(Handle<String>::cast(k), |
- zone->isolate()->factory()->proto_string())) { |
- kind_ = PROTOTYPE; |
- } else if (value_->AsMaterializedLiteral() != NULL) { |
- kind_ = MATERIALIZED_LITERAL; |
- } else if (value_->IsLiteral()) { |
- kind_ = CONSTANT; |
+ if (is_computed_name) { |
+ kind_ = COMPUTED_NAME; |
} else { |
- kind_ = COMPUTED; |
+ Handle<Object> k = key->AsLiteral()->value(); |
+ if (k->IsInternalizedString() && |
+ String::Equals(Handle<String>::cast(k), |
+ zone->isolate()->factory()->proto_string())) { |
+ kind_ = PROTOTYPE; |
+ } else if (value_->AsMaterializedLiteral() != NULL) { |
+ kind_ = MATERIALIZED_LITERAL; |
+ } else if (value_->IsLiteral()) { |
+ kind_ = CONSTANT; |
+ } else { |
+ kind_ = COMPUTED; |
+ } |
} |
} |
@@ -232,7 +236,8 @@ void ObjectLiteral::CalculateEmitStore(Zone* zone) { |
allocator); |
for (int i = properties()->length() - 1; i >= 0; i--) { |
ObjectLiteral::Property* property = properties()->at(i); |
- Literal* literal = property->key(); |
+ if (property->kind() == ObjectLiteral::Property::COMPUTED_NAME) continue; |
+ Literal* literal = property->key()->AsLiteral(); |
if (literal->value()->IsNull()) continue; |
uint32_t hash = literal->Hash(); |
// If the key of a computed property is in the table, do not emit |
@@ -274,6 +279,14 @@ void ObjectLiteral::BuildConstantProperties(Isolate* isolate) { |
is_simple = false; |
continue; |
} |
+ |
+ if (position == boilerplate_properties_ * 2) { |
+ // Constant properties stop at the first computed name. |
+ ASSERT(property->kind() == ObjectLiteral::Property::COMPUTED_NAME); |
+ break; |
+ } |
+ ASSERT(property->kind() != ObjectLiteral::Property::COMPUTED_NAME); |
+ |
MaterializedLiteral* m_literal = property->value()->AsMaterializedLiteral(); |
if (m_literal != NULL) { |
m_literal->BuildConstants(isolate); |
@@ -283,7 +296,7 @@ void ObjectLiteral::BuildConstantProperties(Isolate* isolate) { |
// Add CONSTANT and COMPUTED properties to boilerplate. Use undefined |
// value for COMPUTED properties, the real value is filled in at |
// runtime. The enumeration order is maintained. |
- Handle<Object> key = property->key()->value(); |
+ Handle<Object> key = property->key()->AsLiteral()->value(); |
Handle<Object> value = GetBoilerplateValue(property->value(), isolate); |
// Ensure objects that may, at any point in time, contain fields with double |
@@ -632,7 +645,8 @@ void CallNew::RecordTypeFeedback(TypeFeedbackOracle* oracle) { |
void ObjectLiteral::Property::RecordTypeFeedback(TypeFeedbackOracle* oracle) { |
- TypeFeedbackId id = key()->LiteralFeedbackId(); |
+ ASSERT(key()->IsLiteral()); |
+ TypeFeedbackId id = key()->AsLiteral()->LiteralFeedbackId(); |
SmallMapList maps; |
oracle->CollectReceiverTypes(id, &maps); |
receiver_type_ = maps.length() == 1 ? maps.at(0) |