From c1a08679dca4889ea4424f469fae5a6d24f88ba2 Mon Sep 17 00:00:00 2001 From: "verwaest@chromium.org" Date: Mon, 10 Feb 2014 14:58:25 +0000 Subject: [PATCH] Merge BuildLoadKeyedGeneric and BuildStoreKeyedGeneric, switch on AccessType R=ishell@chromium.org Review URL: https://codereview.chromium.org/146623007 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@19228 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/hydrogen.cc | 43 +++++++++++++++---------------------------- src/hydrogen.h | 9 ++++----- 2 files changed, 19 insertions(+), 33 deletions(-) diff --git a/src/hydrogen.cc b/src/hydrogen.cc index 05d4764..da415d4 100644 --- a/src/hydrogen.cc +++ b/src/hydrogen.cc @@ -6167,9 +6167,17 @@ HInstruction* HOptimizedGraphBuilder::BuildNamedGeneric( -HInstruction* HOptimizedGraphBuilder::BuildLoadKeyedGeneric(HValue* object, - HValue* key) { - return New(object, key); +HInstruction* HOptimizedGraphBuilder::BuildKeyedGeneric( + PropertyAccessType access_type, + HValue* object, + HValue* key, + HValue* value) { + if (access_type == LOAD) { + return New(object, key); + } else { + return New( + object, key, value, function_strict_mode_flag()); + } } @@ -6357,9 +6365,7 @@ HValue* HOptimizedGraphBuilder::HandlePolymorphicElementAccess( HInstruction* instr = NULL; if (untransitionable_map->has_slow_elements_kind() || !untransitionable_map->IsJSObjectMap()) { - instr = AddInstruction(access_type == STORE - ? BuildStoreKeyedGeneric(object, key, val) - : BuildLoadKeyedGeneric(object, key)); + instr = AddInstruction(BuildKeyedGeneric(access_type, object, key, val)); } else { instr = BuildMonomorphicElementAccess( object, key, val, transition, untransitionable_map, access_type, @@ -6384,9 +6390,7 @@ HValue* HOptimizedGraphBuilder::HandlePolymorphicElementAccess( set_current_block(this_map); HInstruction* access = NULL; if (IsDictionaryElementsKind(elements_kind)) { - access = access_type == STORE - ? AddInstruction(BuildStoreKeyedGeneric(object, key, val)) - : AddInstruction(BuildLoadKeyedGeneric(object, key)); + access = AddInstruction(BuildKeyedGeneric(access_type, object, key, val)); } else { ASSERT(IsFastElementsKind(elements_kind) || IsExternalArrayElementsKind(elements_kind)); @@ -6452,10 +6456,7 @@ HValue* HOptimizedGraphBuilder::HandleKeyedElementAccess( if (monomorphic) { Handle map = types->first(); if (map->has_slow_elements_kind() || !map->IsJSObjectMap()) { - instr = access_type == STORE - ? BuildStoreKeyedGeneric(obj, key, val) - : BuildLoadKeyedGeneric(obj, key); - AddInstruction(instr); + instr = AddInstruction(BuildKeyedGeneric(access_type, obj, key, val)); } else { BuildCheckHeapObject(obj); instr = BuildMonomorphicElementAccess( @@ -6472,33 +6473,19 @@ HValue* HOptimizedGraphBuilder::HandleKeyedElementAccess( Add("Insufficient type feedback for keyed store", Deoptimizer::SOFT); } - instr = BuildStoreKeyedGeneric(obj, key, val); } else { if (expr->AsProperty()->HasNoTypeInformation()) { Add("Insufficient type feedback for keyed load", Deoptimizer::SOFT); } - instr = BuildLoadKeyedGeneric(obj, key); } - AddInstruction(instr); + instr = AddInstruction(BuildKeyedGeneric(access_type, obj, key, val)); } *has_side_effects = instr->HasObservableSideEffects(); return instr; } -HInstruction* HOptimizedGraphBuilder::BuildStoreKeyedGeneric( - HValue* object, - HValue* key, - HValue* value) { - return New( - object, - key, - value, - function_strict_mode_flag()); -} - - void HOptimizedGraphBuilder::EnsureArgumentsArePushedForAccess() { // Outermost function already has arguments on the stack. if (function_state()->outer() == NULL) return; diff --git a/src/hydrogen.h b/src/hydrogen.h index d25bb5f..e01a280 100644 --- a/src/hydrogen.h +++ b/src/hydrogen.h @@ -2439,8 +2439,10 @@ class HOptimizedGraphBuilder : public HGraphBuilder, public AstVisitor { PushBeforeSimulateBehavior push_sim_result); HInstruction* BuildIncrement(bool returns_original_input, CountOperation* expr); - HInstruction* BuildLoadKeyedGeneric(HValue* object, - HValue* key); + HInstruction* BuildKeyedGeneric(PropertyAccessType access_type, + HValue* object, + HValue* key, + HValue* value); HInstruction* TryBuildConsolidatedElementLoad(HValue* object, HValue* key, @@ -2503,9 +2505,6 @@ class HOptimizedGraphBuilder : public HGraphBuilder, public AstVisitor { HInstruction* BuildStoreNamedField(PropertyAccessInfo* info, HValue* checked_object, HValue* value); - HInstruction* BuildStoreKeyedGeneric(HValue* object, - HValue* key, - HValue* value); HValue* BuildContextChainWalk(Variable* var); -- 2.7.4