Index: src/ast.cc |
diff --git a/src/ast.cc b/src/ast.cc |
index 6329371faa5f01736b49d7f8686ad7f4ceaa373b..fdff9ede05cbaaf3f114059bc1f9a159b9751054 100644 |
--- a/src/ast.cc |
+++ b/src/ast.cc |
@@ -185,13 +185,17 @@ void FunctionLiteral::InitializeSharedInfo( |
ObjectLiteralProperty::ObjectLiteralProperty(Zone* zone, |
AstValueFactory* ast_value_factory, |
- Literal* key, Expression* value, |
- bool is_static) { |
- emit_store_ = true; |
- key_ = key; |
- value_ = value; |
- is_static_ = is_static; |
- if (key->raw_value()->EqualsString(ast_value_factory->proto_string())) { |
+ Expression* key, Expression* value, |
+ bool is_static, |
+ bool is_computed_name) |
+ : key_(key), |
+ value_(value), |
+ emit_store_(true), |
+ is_static_(is_static), |
+ is_computed_name_(is_computed_name) { |
+ if (!is_computed_name && |
+ key->AsLiteral()->raw_value()->EqualsString( |
+ ast_value_factory->proto_string())) { |
kind_ = PROTOTYPE; |
} else if (value_->AsMaterializedLiteral() != NULL) { |
kind_ = MATERIALIZED_LITERAL; |
@@ -204,13 +208,16 @@ ObjectLiteralProperty::ObjectLiteralProperty(Zone* zone, |
ObjectLiteralProperty::ObjectLiteralProperty(Zone* zone, bool is_getter, |
+ Expression* key, |
FunctionLiteral* value, |
- bool is_static) { |
- emit_store_ = true; |
- value_ = value; |
- kind_ = is_getter ? GETTER : SETTER; |
- is_static_ = is_static; |
-} |
+ bool is_static, |
+ bool is_computed_name) |
+ : key_(key), |
+ value_(value), |
+ kind_(is_getter ? GETTER : SETTER), |
+ emit_store_(true), |
+ is_static_(is_static), |
+ is_computed_name_(is_computed_name) {} |
bool ObjectLiteral::Property::IsCompileTimeValue() { |
@@ -237,7 +244,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->is_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 |
@@ -279,6 +287,13 @@ void ObjectLiteral::BuildConstantProperties(Isolate* isolate) { |
is_simple = false; |
continue; |
} |
+ |
+ if (position == boilerplate_properties_ * 2) { |
+ DCHECK(property->is_computed_name()); |
+ break; |
+ } |
+ DCHECK(!property->is_computed_name()); |
+ |
MaterializedLiteral* m_literal = property->value()->AsMaterializedLiteral(); |
if (m_literal != NULL) { |
m_literal->BuildConstants(isolate); |
@@ -288,7 +303,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 |
@@ -640,7 +655,7 @@ void CallNew::RecordTypeFeedback(TypeFeedbackOracle* oracle) { |
void ObjectLiteral::Property::RecordTypeFeedback(TypeFeedbackOracle* oracle) { |
- TypeFeedbackId id = key()->LiteralFeedbackId(); |
+ TypeFeedbackId id = key()->AsLiteral()->LiteralFeedbackId(); |
Dmitry Lomov (no reviews)
2014/12/11 12:34:35
What if key() is not Literal?
arv (Not doing code reviews)
2014/12/11 23:10:33
The caller needs to test that the property is not
|
SmallMapList maps; |
oracle->CollectReceiverTypes(id, &maps); |
receiver_type_ = maps.length() == 1 ? maps.at(0) |