Index: src/x64/full-codegen-x64.cc |
diff --git a/src/x64/full-codegen-x64.cc b/src/x64/full-codegen-x64.cc |
index 74f69bbaf01a35c4e2fd0e72891c77edce12838c..ac0be465f5c3affdf42e87334208ea9817022d9a 100644 |
--- a/src/x64/full-codegen-x64.cc |
+++ b/src/x64/full-codegen-x64.cc |
@@ -1225,7 +1225,7 @@ void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) { |
__ movp(result_register(), rbx); |
// Perform the assignment as if via '='. |
{ EffectContext context(this); |
- EmitAssignment(stmt->each()); |
+ EmitAssignment(stmt->each(), stmt->EachFeedbackSlot()); |
PrepareForBailoutForId(stmt->AssignmentId(), NO_REGISTERS); |
} |
@@ -1307,13 +1307,15 @@ void FullCodeGenerator::EmitLoadHomeObject(SuperReference* expr) { |
void FullCodeGenerator::EmitSetHomeObjectIfNeeded(Expression* initializer, |
- int offset) { |
+ int offset, |
+ FeedbackVectorICSlot slot) { |
if (NeedsHomeObject(initializer)) { |
__ movp(StoreDescriptor::ReceiverRegister(), Operand(rsp, 0)); |
__ Move(StoreDescriptor::NameRegister(), |
isolate()->factory()->home_object_symbol()); |
__ movp(StoreDescriptor::ValueRegister(), |
Operand(rsp, offset * kPointerSize)); |
+ if (FLAG_vector_stores) EmitLoadStoreICSlot(slot); |
CallStoreIC(); |
} |
} |
@@ -1645,6 +1647,10 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { |
AccessorTable accessor_table(zone()); |
int property_index = 0; |
+ // store_slot_index points to the vector ic slot for the next store ic used. |
+ // ObjectLiteral::ComputeFeedbackRequirements controls the allocation of slots |
+ // and must be updated if the number of store ics emitted here changes. |
+ int store_slot_index = 0; |
for (; property_index < expr->properties()->length(); property_index++) { |
ObjectLiteral::Property* property = expr->properties()->at(property_index); |
if (property->is_computed_name()) break; |
@@ -1671,7 +1677,12 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { |
DCHECK(StoreDescriptor::ValueRegister().is(rax)); |
__ Move(StoreDescriptor::NameRegister(), key->value()); |
__ movp(StoreDescriptor::ReceiverRegister(), Operand(rsp, 0)); |
- CallStoreIC(key->LiteralFeedbackId()); |
+ if (FLAG_vector_stores) { |
+ EmitLoadStoreICSlot(expr->GetNthSlot(store_slot_index++)); |
+ CallStoreIC(); |
+ } else { |
+ CallStoreIC(key->LiteralFeedbackId()); |
+ } |
PrepareForBailoutForId(key->id(), NO_REGISTERS); |
if (NeedsHomeObject(value)) { |
@@ -1679,6 +1690,9 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { |
__ Move(StoreDescriptor::NameRegister(), |
isolate()->factory()->home_object_symbol()); |
__ movp(StoreDescriptor::ValueRegister(), Operand(rsp, 0)); |
+ if (FLAG_vector_stores) { |
+ EmitLoadStoreICSlot(expr->GetNthSlot(store_slot_index++)); |
+ } |
CallStoreIC(); |
} |
} else { |
@@ -1690,7 +1704,8 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { |
VisitForStackValue(key); |
VisitForStackValue(value); |
if (property->emit_store()) { |
- EmitSetHomeObjectIfNeeded(value, 2); |
+ EmitSetHomeObjectIfNeeded( |
+ value, 2, expr->SlotForHomeObject(value, &store_slot_index)); |
__ Push(Smi::FromInt(SLOPPY)); // Language mode |
__ CallRuntime(Runtime::kSetProperty, 4); |
} else { |
@@ -1724,9 +1739,13 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { |
__ Push(Operand(rsp, 0)); // Duplicate receiver. |
VisitForStackValue(it->first); |
EmitAccessor(it->second->getter); |
- EmitSetHomeObjectIfNeeded(it->second->getter, 2); |
+ EmitSetHomeObjectIfNeeded( |
+ it->second->getter, 2, |
+ expr->SlotForHomeObject(it->second->getter, &store_slot_index)); |
EmitAccessor(it->second->setter); |
- EmitSetHomeObjectIfNeeded(it->second->setter, 3); |
+ EmitSetHomeObjectIfNeeded( |
+ it->second->setter, 3, |
+ expr->SlotForHomeObject(it->second->setter, &store_slot_index)); |
__ Push(Smi::FromInt(NONE)); |
__ CallRuntime(Runtime::kDefineAccessorPropertyUnchecked, 5); |
} |
@@ -1759,7 +1778,8 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { |
} else { |
EmitPropertyKey(property, expr->GetIdForProperty(property_index)); |
VisitForStackValue(value); |
- EmitSetHomeObjectIfNeeded(value, 2); |
+ EmitSetHomeObjectIfNeeded( |
+ value, 2, expr->SlotForHomeObject(value, &store_slot_index)); |
switch (property->kind()) { |
case ObjectLiteral::Property::CONSTANT: |
@@ -1801,6 +1821,10 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { |
} else { |
context()->Plug(rax); |
} |
+ |
+ // Verify that compilation exactly consumed the number of store ic slots that |
+ // the ObjectLiteral node had to offer. |
+ DCHECK(!FLAG_vector_stores || store_slot_index == expr->slot_count()); |
} |
@@ -1921,7 +1945,7 @@ void FullCodeGenerator::VisitAssignment(Assignment* expr) { |
Comment cmnt(masm_, "[ Assignment"); |
Property* property = expr->target()->AsProperty(); |
- LhsKind assign_type = GetAssignType(property); |
+ LhsKind assign_type = Property::GetAssignType(property); |
// Evaluate LHS expression. |
switch (assign_type) { |
@@ -2027,7 +2051,7 @@ void FullCodeGenerator::VisitAssignment(Assignment* expr) { |
switch (assign_type) { |
case VARIABLE: |
EmitVariableAssignment(expr->target()->AsVariableProxy()->var(), |
- expr->op()); |
+ expr->op(), expr->AssignmentSlot()); |
PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
context()->Plug(rax); |
break; |
@@ -2514,17 +2538,18 @@ void FullCodeGenerator::EmitBinaryOp(BinaryOperation* expr, Token::Value op) { |
} |
-void FullCodeGenerator::EmitAssignment(Expression* expr) { |
+void FullCodeGenerator::EmitAssignment(Expression* expr, |
+ FeedbackVectorICSlot slot) { |
DCHECK(expr->IsValidReferenceExpression()); |
Property* prop = expr->AsProperty(); |
- LhsKind assign_type = GetAssignType(prop); |
+ LhsKind assign_type = Property::GetAssignType(prop); |
switch (assign_type) { |
case VARIABLE: { |
Variable* var = expr->AsVariableProxy()->var(); |
EffectContext context(this); |
- EmitVariableAssignment(var, Token::ASSIGN); |
+ EmitVariableAssignment(var, Token::ASSIGN, slot); |
break; |
} |
case NAMED_PROPERTY: { |
@@ -2534,6 +2559,7 @@ void FullCodeGenerator::EmitAssignment(Expression* expr) { |
__ Pop(StoreDescriptor::ValueRegister()); // Restore value. |
__ Move(StoreDescriptor::NameRegister(), |
prop->key()->AsLiteral()->value()); |
+ if (FLAG_vector_stores) EmitLoadStoreICSlot(slot); |
CallStoreIC(); |
break; |
} |
@@ -2580,6 +2606,7 @@ void FullCodeGenerator::EmitAssignment(Expression* expr) { |
__ Move(StoreDescriptor::NameRegister(), rax); |
__ Pop(StoreDescriptor::ReceiverRegister()); |
__ Pop(StoreDescriptor::ValueRegister()); // Restore value. |
+ if (FLAG_vector_stores) EmitLoadStoreICSlot(slot); |
Handle<Code> ic = |
CodeFactory::KeyedStoreIC(isolate(), language_mode()).code(); |
CallIC(ic); |
@@ -2601,12 +2628,13 @@ void FullCodeGenerator::EmitStoreToStackLocalOrContextSlot( |
} |
-void FullCodeGenerator::EmitVariableAssignment(Variable* var, |
- Token::Value op) { |
+void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op, |
+ FeedbackVectorICSlot slot) { |
if (var->IsUnallocated()) { |
// Global var, const, or let. |
__ Move(StoreDescriptor::NameRegister(), var->name()); |
__ movp(StoreDescriptor::ReceiverRegister(), GlobalObjectOperand()); |
+ if (FLAG_vector_stores) EmitLoadStoreICSlot(slot); |
CallStoreIC(); |
} else if (var->mode() == LET && op != Token::INIT_LET) { |
@@ -2699,7 +2727,12 @@ void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) { |
SetSourcePosition(expr->position()); |
__ Move(StoreDescriptor::NameRegister(), prop->key()->AsLiteral()->value()); |
__ Pop(StoreDescriptor::ReceiverRegister()); |
- CallStoreIC(expr->AssignmentFeedbackId()); |
+ if (FLAG_vector_stores) { |
+ EmitLoadStoreICSlot(expr->AssignmentSlot()); |
+ CallStoreIC(); |
+ } else { |
+ CallStoreIC(expr->AssignmentFeedbackId()); |
+ } |
PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
context()->Plug(rax); |
@@ -2746,7 +2779,12 @@ void FullCodeGenerator::EmitKeyedPropertyAssignment(Assignment* expr) { |
SetSourcePosition(expr->position()); |
Handle<Code> ic = |
CodeFactory::KeyedStoreIC(isolate(), language_mode()).code(); |
- CallIC(ic, expr->AssignmentFeedbackId()); |
+ if (FLAG_vector_stores) { |
+ EmitLoadStoreICSlot(expr->AssignmentSlot()); |
+ CallIC(ic); |
+ } else { |
+ CallIC(ic, expr->AssignmentFeedbackId()); |
+ } |
PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
context()->Plug(rax); |
@@ -2984,7 +3022,7 @@ void FullCodeGenerator::EmitLoadSuperConstructor() { |
void FullCodeGenerator::EmitInitializeThisAfterSuper( |
- SuperReference* super_ref) { |
+ SuperReference* super_ref, FeedbackVectorICSlot slot) { |
Variable* this_var = super_ref->this_var()->var(); |
GetVar(rcx, this_var); |
__ CompareRoot(rcx, Heap::kTheHoleValueRootIndex); |
@@ -2994,7 +3032,7 @@ void FullCodeGenerator::EmitInitializeThisAfterSuper( |
__ CallRuntime(Runtime::kThrowReferenceError, 1); |
__ bind(&uninitialized_this); |
- EmitVariableAssignment(this_var, Token::INIT_CONST); |
+ EmitVariableAssignment(this_var, Token::INIT_CONST, slot); |
} |
@@ -3212,7 +3250,8 @@ void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) { |
RecordJSReturnSite(expr); |
- EmitInitializeThisAfterSuper(expr->expression()->AsSuperReference()); |
+ EmitInitializeThisAfterSuper(expr->expression()->AsSuperReference(), |
+ expr->CallFeedbackICSlot()); |
context()->Plug(rax); |
} |
@@ -4565,6 +4604,7 @@ void FullCodeGenerator::EmitCallSuperWithSpread(CallRuntime* expr) { |
__ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); |
context()->DropAndPlug(1, rax); |
+ // TODO(mvstanton): with FLAG_vector_stores this needs a slot id. |
EmitInitializeThisAfterSuper(super_reference); |
} |
@@ -4769,7 +4809,7 @@ void FullCodeGenerator::VisitCountOperation(CountOperation* expr) { |
SetSourcePosition(expr->position()); |
Property* prop = expr->expression()->AsProperty(); |
- LhsKind assign_type = GetAssignType(prop); |
+ LhsKind assign_type = Property::GetAssignType(prop); |
// Evaluate expression and get value. |
if (assign_type == VARIABLE) { |
@@ -4931,7 +4971,7 @@ void FullCodeGenerator::VisitCountOperation(CountOperation* expr) { |
// Perform the assignment as if via '='. |
{ EffectContext context(this); |
EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(), |
- Token::ASSIGN); |
+ Token::ASSIGN, expr->CountSlot()); |
PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
context.Plug(rax); |
} |
@@ -4943,7 +4983,7 @@ void FullCodeGenerator::VisitCountOperation(CountOperation* expr) { |
} else { |
// Perform the assignment as if via '='. |
EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(), |
- Token::ASSIGN); |
+ Token::ASSIGN, expr->CountSlot()); |
PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
context()->Plug(rax); |
} |
@@ -4952,7 +4992,12 @@ void FullCodeGenerator::VisitCountOperation(CountOperation* expr) { |
__ Move(StoreDescriptor::NameRegister(), |
prop->key()->AsLiteral()->value()); |
__ Pop(StoreDescriptor::ReceiverRegister()); |
- CallStoreIC(expr->CountStoreFeedbackId()); |
+ if (FLAG_vector_stores) { |
+ EmitLoadStoreICSlot(expr->CountSlot()); |
+ CallStoreIC(); |
+ } else { |
+ CallStoreIC(expr->CountStoreFeedbackId()); |
+ } |
PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
if (expr->is_postfix()) { |
if (!context()->IsEffect()) { |
@@ -4990,7 +5035,12 @@ void FullCodeGenerator::VisitCountOperation(CountOperation* expr) { |
__ Pop(StoreDescriptor::ReceiverRegister()); |
Handle<Code> ic = |
CodeFactory::KeyedStoreIC(isolate(), language_mode()).code(); |
- CallIC(ic, expr->CountStoreFeedbackId()); |
+ if (FLAG_vector_stores) { |
+ EmitLoadStoreICSlot(expr->CountSlot()); |
+ CallIC(ic); |
+ } else { |
+ CallIC(ic, expr->CountStoreFeedbackId()); |
+ } |
PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
if (expr->is_postfix()) { |
if (!context()->IsEffect()) { |
@@ -5325,6 +5375,12 @@ void FullCodeGenerator::ClearPendingMessage() { |
} |
+void FullCodeGenerator::EmitLoadStoreICSlot(FeedbackVectorICSlot slot) { |
+ DCHECK(FLAG_vector_stores && !slot.IsInvalid()); |
+ __ Move(VectorStoreICTrampolineDescriptor::SlotRegister(), SmiFromSlot(slot)); |
+} |
+ |
+ |
#undef __ |