diff --git a/src/hydrogen.cc b/src/hydrogen.cc index 3ce76c1ef1..91f3842d5d 100644 --- a/src/hydrogen.cc +++ b/src/hydrogen.cc @@ -4792,7 +4792,10 @@ void HGraphBuilder::VisitObjectLiteral(ObjectLiteral* expr) { CHECK_ALIVE(VisitForValue(value)); HValue* value = Pop(); HInstruction* store; - CHECK_ALIVE(store = BuildStoreNamed(literal, value, property)); + CHECK_ALIVE(store = BuildStoreNamed(literal, + value, + property->GetReceiverType(), + property->key())); AddInstruction(store); if (store->HasObservableSideEffects()) AddSimulate(key->id()); } else { @@ -5030,14 +5033,13 @@ HInstruction* HGraphBuilder::BuildStoreNamedGeneric(HValue* object, HInstruction* HGraphBuilder::BuildStoreNamed(HValue* object, HValue* value, - ObjectLiteral::Property* prop) { - Literal* key = prop->key()->AsLiteral(); - Handle name = Handle::cast(key->handle()); + Handle type, + Expression* key) { + Handle name = Handle::cast(key->AsLiteral()->handle()); ASSERT(!name.is_null()); LookupResult lookup(isolate()); - Handle type = prop->GetReceiverType(); - bool is_monomorphic = prop->IsMonomorphic() && + bool is_monomorphic = !type.is_null() && ComputeLoadStoreField(type, name, &lookup, true); return is_monomorphic @@ -5047,28 +5049,6 @@ HInstruction* HGraphBuilder::BuildStoreNamed(HValue* object, } -HInstruction* HGraphBuilder::BuildStoreNamed(HValue* object, - HValue* value, - Expression* expr) { - Property* prop = (expr->AsProperty() != NULL) - ? expr->AsProperty() - : expr->AsAssignment()->target()->AsProperty(); - Literal* key = prop->key()->AsLiteral(); - Handle name = Handle::cast(key->handle()); - ASSERT(!name.is_null()); - - LookupResult lookup(isolate()); - SmallMapList* types = expr->GetReceiverTypes(); - bool is_monomorphic = expr->IsMonomorphic() && - ComputeLoadStoreField(types->first(), name, &lookup, true); - - return is_monomorphic - ? BuildStoreNamedField(object, name, value, types->first(), &lookup, - true) // Needs smi and map check. - : BuildStoreNamedGeneric(object, name, value); -} - - void HGraphBuilder::HandlePolymorphicLoadNamedField(Property* expr, HValue* object, SmallMapList* types, @@ -5220,7 +5200,10 @@ void HGraphBuilder::HandlePropertyAssignment(Assignment* expr) { SmallMapList* types = expr->GetReceiverTypes(); if (expr->IsMonomorphic()) { - CHECK_ALIVE(instr = BuildStoreNamed(object, value, expr)); + CHECK_ALIVE(instr = BuildStoreNamed(object, + value, + types->first(), + prop->key())); } else if (types != NULL && types->length() > 1) { HandlePolymorphicStoreNamedField(expr, object, value, types, name); @@ -5380,10 +5363,11 @@ void HGraphBuilder::HandleCompoundAssignment(Assignment* expr) { CHECK_ALIVE(VisitForValue(prop->obj())); HValue* obj = Top(); - HInstruction* load = NULL; + Handle map; + HInstruction* load; if (prop->IsMonomorphic()) { Handle name = prop->key()->AsLiteral()->AsPropertyName(); - Handle map = prop->GetReceiverTypes()->first(); + map = prop->GetReceiverTypes()->first(); load = BuildLoadNamed(obj, prop, map, name); } else { load = BuildLoadNamedGeneric(obj, prop); @@ -5400,7 +5384,7 @@ void HGraphBuilder::HandleCompoundAssignment(Assignment* expr) { if (instr->HasObservableSideEffects()) AddSimulate(operation->id()); HInstruction* store; - CHECK_ALIVE(store = BuildStoreNamed(obj, instr, prop)); + CHECK_ALIVE(store = BuildStoreNamed(obj, instr, map, prop->key())); AddInstruction(store); // Drop the simulated receiver and value. Return the value. Drop(2); @@ -7786,10 +7770,11 @@ void HGraphBuilder::VisitCountOperation(CountOperation* expr) { CHECK_ALIVE(VisitForValue(prop->obj())); HValue* obj = Top(); - HInstruction* load = NULL; + Handle map; + HInstruction* load; if (prop->IsMonomorphic()) { Handle name = prop->key()->AsLiteral()->AsPropertyName(); - Handle map = prop->GetReceiverTypes()->first(); + map = prop->GetReceiverTypes()->first(); load = BuildLoadNamed(obj, prop, map, name); } else { load = BuildLoadNamedGeneric(obj, prop); @@ -7801,7 +7786,7 @@ void HGraphBuilder::VisitCountOperation(CountOperation* expr) { input = Pop(); HInstruction* store; - CHECK_ALIVE(store = BuildStoreNamed(obj, after, prop)); + CHECK_ALIVE(store = BuildStoreNamed(obj, after, map, prop->key())); AddInstruction(store); // Overwrite the receiver in the bailout environment with the result diff --git a/src/hydrogen.h b/src/hydrogen.h index ac19db71fb..539cfe3bea 100644 --- a/src/hydrogen.h +++ b/src/hydrogen.h @@ -1149,10 +1149,8 @@ class HGraphBuilder: public AstVisitor { Handle name); HInstruction* BuildStoreNamed(HValue* object, HValue* value, - Expression* expr); - HInstruction* BuildStoreNamed(HValue* object, - HValue* value, - ObjectLiteral::Property* prop); + Handle type, + Expression* key); HInstruction* BuildStoreNamedField(HValue* object, Handle name, HValue* value,