From 878071af3e4ecf403f3a4ba7833245e0f5ddf579 Mon Sep 17 00:00:00 2001 From: mvstanton Date: Fri, 24 Jul 2015 07:08:29 -0700 Subject: [PATCH] VectorICs: VisitClassLiteral needs adjustment for IC slot usage. Also, generic lowering for keyed stores needs to handle the case when there is no IC slot available (it can use the generic keyed store). BUG= R=mstarzinger@chromium.org Review URL: https://codereview.chromium.org/1252303002 Cr-Commit-Position: refs/heads/master@{#29847} --- src/compiler/ast-graph-builder.cc | 10 +++++++--- src/compiler/js-generic-lowering.cc | 10 +++++++--- src/full-codegen/full-codegen.cc | 8 +++++--- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/compiler/ast-graph-builder.cc b/src/compiler/ast-graph-builder.cc index 706d2efc13..7ccb8aa320 100644 --- a/src/compiler/ast-graph-builder.cc +++ b/src/compiler/ast-graph-builder.cc @@ -1663,9 +1663,10 @@ void AstGraphBuilder::VisitClassLiteralContents(ClassLiteral* expr) { DCHECK_NOT_NULL(expr->class_variable_proxy()); Variable* var = expr->class_variable_proxy()->var(); FrameStateBeforeAndAfter states(this, BailoutId::None()); - VectorSlotPair feedback = CreateVectorSlotPair( - FLAG_vector_stores ? expr->GetNthSlot(store_slot_index++) - : FeedbackVectorICSlot::Invalid()); + VectorSlotPair feedback = + CreateVectorSlotPair(FLAG_vector_stores && var->IsUnallocated() + ? expr->GetNthSlot(store_slot_index++) + : FeedbackVectorICSlot::Invalid()); BuildVariableAssignment(var, literal, Token::INIT_CONST, feedback, BailoutId::None(), states); } @@ -1972,6 +1973,9 @@ void AstGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) { FrameStateBeforeAndAfter states(this, subexpr->id()); Node* value = environment()->Pop(); Node* index = jsgraph()->Constant(array_index); + // TODO(turbofan): More efficient code could be generated here. Consider + // that the store will be generic because we don't have a feedback vector + // slot. Node* store = BuildKeyedStore(literal, index, value, VectorSlotPair(), TypeFeedbackId::None()); states.AddToNode(store, expr->GetIdForElement(array_index), diff --git a/src/compiler/js-generic-lowering.cc b/src/compiler/js-generic-lowering.cc index 17b1597edb..29a2a4a97e 100644 --- a/src/compiler/js-generic-lowering.cc +++ b/src/compiler/js-generic-lowering.cc @@ -359,10 +359,14 @@ void JSGenericLowering::LowerJSStoreProperty(Node* node) { CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); const StorePropertyParameters& p = StorePropertyParametersOf(node->op()); LanguageMode language_mode = OpParameter(node); + // We have a special case where we do keyed stores but don't have a type + // feedback vector slot allocated to support it. In this case, install + // the megamorphic keyed store stub which needs neither vector nor slot. + bool use_vector_slot = FLAG_vector_stores && p.feedback().index() != -1; Callable callable = CodeFactory::KeyedStoreICInOptimizedCode( - isolate(), language_mode, UNINITIALIZED); - if (FLAG_vector_stores) { - DCHECK(p.feedback().index() != -1); + isolate(), language_mode, + (use_vector_slot || !FLAG_vector_stores) ? UNINITIALIZED : MEGAMORPHIC); + if (use_vector_slot) { node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.feedback().index())); } else { node->RemoveInput(3); diff --git a/src/full-codegen/full-codegen.cc b/src/full-codegen/full-codegen.cc index c1512ac3bc..137b2463e8 100644 --- a/src/full-codegen/full-codegen.cc +++ b/src/full-codegen/full-codegen.cc @@ -1309,9 +1309,11 @@ void FullCodeGenerator::VisitClassLiteral(ClassLiteral* lit) { if (lit->scope() != NULL) { DCHECK_NOT_NULL(lit->class_variable_proxy()); - FeedbackVectorICSlot slot = FLAG_vector_stores - ? lit->GetNthSlot(store_slot_index++) - : FeedbackVectorICSlot::Invalid(); + FeedbackVectorICSlot slot = + FLAG_vector_stores && + lit->class_variable_proxy()->var()->IsUnallocated() + ? lit->GetNthSlot(store_slot_index++) + : FeedbackVectorICSlot::Invalid(); EmitVariableAssignment(lit->class_variable_proxy()->var(), Token::INIT_CONST, slot); }