Re-land "Removed one copy-n-paste clone of HGraphBuilder::BuildStoreNamed."

The previous CL used the wrong map in some cases, leading to a wrong decision
regarding monomorphic usage and therefore some performance regressions.

Review URL: https://chromiumcodereview.appspot.com/10694129

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@12037 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent b2f1c412
...@@ -4792,7 +4792,10 @@ void HGraphBuilder::VisitObjectLiteral(ObjectLiteral* expr) { ...@@ -4792,7 +4792,10 @@ void HGraphBuilder::VisitObjectLiteral(ObjectLiteral* expr) {
CHECK_ALIVE(VisitForValue(value)); CHECK_ALIVE(VisitForValue(value));
HValue* value = Pop(); HValue* value = Pop();
HInstruction* store; HInstruction* store;
CHECK_ALIVE(store = BuildStoreNamed(literal, value, property)); CHECK_ALIVE(store = BuildStoreNamed(literal,
value,
property->GetReceiverType(),
property->key()));
AddInstruction(store); AddInstruction(store);
if (store->HasObservableSideEffects()) AddSimulate(key->id()); if (store->HasObservableSideEffects()) AddSimulate(key->id());
} else { } else {
...@@ -5030,14 +5033,13 @@ HInstruction* HGraphBuilder::BuildStoreNamedGeneric(HValue* object, ...@@ -5030,14 +5033,13 @@ HInstruction* HGraphBuilder::BuildStoreNamedGeneric(HValue* object,
HInstruction* HGraphBuilder::BuildStoreNamed(HValue* object, HInstruction* HGraphBuilder::BuildStoreNamed(HValue* object,
HValue* value, HValue* value,
ObjectLiteral::Property* prop) { Handle<Map> type,
Literal* key = prop->key()->AsLiteral(); Expression* key) {
Handle<String> name = Handle<String>::cast(key->handle()); Handle<String> name = Handle<String>::cast(key->AsLiteral()->handle());
ASSERT(!name.is_null()); ASSERT(!name.is_null());
LookupResult lookup(isolate()); LookupResult lookup(isolate());
Handle<Map> type = prop->GetReceiverType(); bool is_monomorphic = !type.is_null() &&
bool is_monomorphic = prop->IsMonomorphic() &&
ComputeLoadStoreField(type, name, &lookup, true); ComputeLoadStoreField(type, name, &lookup, true);
return is_monomorphic return is_monomorphic
...@@ -5047,28 +5049,6 @@ HInstruction* HGraphBuilder::BuildStoreNamed(HValue* object, ...@@ -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<String> name = Handle<String>::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, void HGraphBuilder::HandlePolymorphicLoadNamedField(Property* expr,
HValue* object, HValue* object,
SmallMapList* types, SmallMapList* types,
...@@ -5220,7 +5200,10 @@ void HGraphBuilder::HandlePropertyAssignment(Assignment* expr) { ...@@ -5220,7 +5200,10 @@ void HGraphBuilder::HandlePropertyAssignment(Assignment* expr) {
SmallMapList* types = expr->GetReceiverTypes(); SmallMapList* types = expr->GetReceiverTypes();
if (expr->IsMonomorphic()) { 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) { } else if (types != NULL && types->length() > 1) {
HandlePolymorphicStoreNamedField(expr, object, value, types, name); HandlePolymorphicStoreNamedField(expr, object, value, types, name);
...@@ -5380,10 +5363,11 @@ void HGraphBuilder::HandleCompoundAssignment(Assignment* expr) { ...@@ -5380,10 +5363,11 @@ void HGraphBuilder::HandleCompoundAssignment(Assignment* expr) {
CHECK_ALIVE(VisitForValue(prop->obj())); CHECK_ALIVE(VisitForValue(prop->obj()));
HValue* obj = Top(); HValue* obj = Top();
HInstruction* load = NULL; Handle<Map> map;
HInstruction* load;
if (prop->IsMonomorphic()) { if (prop->IsMonomorphic()) {
Handle<String> name = prop->key()->AsLiteral()->AsPropertyName(); Handle<String> name = prop->key()->AsLiteral()->AsPropertyName();
Handle<Map> map = prop->GetReceiverTypes()->first(); map = prop->GetReceiverTypes()->first();
load = BuildLoadNamed(obj, prop, map, name); load = BuildLoadNamed(obj, prop, map, name);
} else { } else {
load = BuildLoadNamedGeneric(obj, prop); load = BuildLoadNamedGeneric(obj, prop);
...@@ -5400,7 +5384,7 @@ void HGraphBuilder::HandleCompoundAssignment(Assignment* expr) { ...@@ -5400,7 +5384,7 @@ void HGraphBuilder::HandleCompoundAssignment(Assignment* expr) {
if (instr->HasObservableSideEffects()) AddSimulate(operation->id()); if (instr->HasObservableSideEffects()) AddSimulate(operation->id());
HInstruction* store; HInstruction* store;
CHECK_ALIVE(store = BuildStoreNamed(obj, instr, prop)); CHECK_ALIVE(store = BuildStoreNamed(obj, instr, map, prop->key()));
AddInstruction(store); AddInstruction(store);
// Drop the simulated receiver and value. Return the value. // Drop the simulated receiver and value. Return the value.
Drop(2); Drop(2);
...@@ -7786,10 +7770,11 @@ void HGraphBuilder::VisitCountOperation(CountOperation* expr) { ...@@ -7786,10 +7770,11 @@ void HGraphBuilder::VisitCountOperation(CountOperation* expr) {
CHECK_ALIVE(VisitForValue(prop->obj())); CHECK_ALIVE(VisitForValue(prop->obj()));
HValue* obj = Top(); HValue* obj = Top();
HInstruction* load = NULL; Handle<Map> map;
HInstruction* load;
if (prop->IsMonomorphic()) { if (prop->IsMonomorphic()) {
Handle<String> name = prop->key()->AsLiteral()->AsPropertyName(); Handle<String> name = prop->key()->AsLiteral()->AsPropertyName();
Handle<Map> map = prop->GetReceiverTypes()->first(); map = prop->GetReceiverTypes()->first();
load = BuildLoadNamed(obj, prop, map, name); load = BuildLoadNamed(obj, prop, map, name);
} else { } else {
load = BuildLoadNamedGeneric(obj, prop); load = BuildLoadNamedGeneric(obj, prop);
...@@ -7801,7 +7786,7 @@ void HGraphBuilder::VisitCountOperation(CountOperation* expr) { ...@@ -7801,7 +7786,7 @@ void HGraphBuilder::VisitCountOperation(CountOperation* expr) {
input = Pop(); input = Pop();
HInstruction* store; HInstruction* store;
CHECK_ALIVE(store = BuildStoreNamed(obj, after, prop)); CHECK_ALIVE(store = BuildStoreNamed(obj, after, map, prop->key()));
AddInstruction(store); AddInstruction(store);
// Overwrite the receiver in the bailout environment with the result // Overwrite the receiver in the bailout environment with the result
......
...@@ -1149,10 +1149,8 @@ class HGraphBuilder: public AstVisitor { ...@@ -1149,10 +1149,8 @@ class HGraphBuilder: public AstVisitor {
Handle<String> name); Handle<String> name);
HInstruction* BuildStoreNamed(HValue* object, HInstruction* BuildStoreNamed(HValue* object,
HValue* value, HValue* value,
Expression* expr); Handle<Map> type,
HInstruction* BuildStoreNamed(HValue* object, Expression* key);
HValue* value,
ObjectLiteral::Property* prop);
HInstruction* BuildStoreNamedField(HValue* object, HInstruction* BuildStoreNamedField(HValue* object,
Handle<String> name, Handle<String> name,
HValue* value, HValue* value,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment