From 9bcc823064d097c5e10523e5283940725b0a648c Mon Sep 17 00:00:00 2001 From: "svenpanne@chromium.org" Date: Mon, 9 Jul 2012 13:59:28 +0000 Subject: [PATCH] Removed one copy-n-paste clone of HGraphBuilder::BuildStoreNamed. Review URL: https://chromiumcodereview.appspot.com/10689129 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@12018 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/ast.h | 6 +++++- src/hydrogen.cc | 53 ++++++++++++++++++++----------------------------- src/hydrogen.h | 6 ++---- 3 files changed, 29 insertions(+), 36 deletions(-) diff --git a/src/ast.h b/src/ast.h index 156b879d08..592e44996f 100644 --- a/src/ast.h +++ b/src/ast.h @@ -1325,7 +1325,6 @@ class ObjectLiteral: public MaterializedLiteral { // Type feedback information. void RecordTypeFeedback(TypeFeedbackOracle* oracle); - bool IsMonomorphic() { return !receiver_type_.is_null(); } Handle GetReceiverType() { return receiver_type_; } bool IsCompileTimeValue(); @@ -1529,6 +1528,11 @@ class Property: public Expression { void RecordTypeFeedback(TypeFeedbackOracle* oracle, Zone* zone); virtual bool IsMonomorphic() { return is_monomorphic_; } virtual SmallMapList* GetReceiverTypes() { return &receiver_types_; } + + Handle GetReceiverType() { + return IsMonomorphic() ? GetReceiverTypes()->first() : Handle(); + } + bool IsArrayLength() { return is_array_length_; } bool IsUninitialized() { return is_uninitialized_; } diff --git a/src/hydrogen.cc b/src/hydrogen.cc index 539b48aafc..86445f6797 100644 --- a/src/hydrogen.cc +++ b/src/hydrogen.cc @@ -4778,7 +4778,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 { @@ -5016,14 +5019,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 @@ -5033,28 +5035,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, @@ -5206,7 +5186,12 @@ void HGraphBuilder::HandlePropertyAssignment(Assignment* expr) { SmallMapList* types = expr->GetReceiverTypes(); if (expr->IsMonomorphic()) { - CHECK_ALIVE(instr = BuildStoreNamed(object, value, expr)); + CHECK(expr->AsProperty() == NULL); + Property* prop = expr->AsAssignment()->target()->AsProperty(); + CHECK_ALIVE(instr = BuildStoreNamed(object, + value, + prop->GetReceiverType(), + prop->key())); } else if (types != NULL && types->length() > 1) { HandlePolymorphicStoreNamedField(expr, object, value, types, name); @@ -5386,7 +5371,10 @@ 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, + prop->GetReceiverType(), + prop->key())); AddInstruction(store); // Drop the simulated receiver and value. Return the value. Drop(2); @@ -7787,7 +7775,10 @@ void HGraphBuilder::VisitCountOperation(CountOperation* expr) { input = Pop(); HInstruction* store; - CHECK_ALIVE(store = BuildStoreNamed(obj, after, prop)); + CHECK_ALIVE(store = BuildStoreNamed(obj, + after, + prop->GetReceiverType(), + 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,