Vector ICs: Turbofan vector store ic support

Turbofan needs to pass vector slots around for named and keyed stores.
Also, the CL addresses a missing slot for ClassLiterals.

BUG=

Review URL: https://codereview.chromium.org/1178363002

Cr-Commit-Position: refs/heads/master@{#29173}
This commit is contained in:
mvstanton 2015-06-21 06:55:16 -07:00 committed by Commit bot
parent ed0bd59440
commit 17c8ffeaa3
15 changed files with 222 additions and 127 deletions

View File

@ -2550,7 +2550,8 @@ void FullCodeGenerator::EmitInlineSmiBinaryOp(BinaryOperation* expr,
}
void FullCodeGenerator::EmitClassDefineProperties(ClassLiteral* lit) {
void FullCodeGenerator::EmitClassDefineProperties(ClassLiteral* lit,
int* used_store_slots) {
// Constructor is in r0.
DCHECK(lit != NULL);
__ push(r0);
@ -2562,10 +2563,6 @@ void FullCodeGenerator::EmitClassDefineProperties(ClassLiteral* lit) {
FieldMemOperand(r0, JSFunction::kPrototypeOrInitialMapOffset));
__ push(scratch);
// store_slot_index points to the vector IC slot for the next store IC used.
// ClassLiteral::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 (int i = 0; i < lit->properties()->length(); i++) {
ObjectLiteral::Property* property = lit->properties()->at(i);
Expression* value = property->value();
@ -2589,7 +2586,7 @@ void FullCodeGenerator::EmitClassDefineProperties(ClassLiteral* lit) {
VisitForStackValue(value);
EmitSetHomeObjectIfNeeded(value, 2,
lit->SlotForHomeObject(value, &store_slot_index));
lit->SlotForHomeObject(value, used_store_slots));
switch (property->kind()) {
case ObjectLiteral::Property::CONSTANT:
@ -2622,10 +2619,6 @@ void FullCodeGenerator::EmitClassDefineProperties(ClassLiteral* lit) {
// constructor
__ CallRuntime(Runtime::kToFastProperties, 1);
// Verify that compilation exactly consumed the number of store ic slots that
// the ClassLiteral node had to offer.
DCHECK(!FLAG_vector_stores || store_slot_index == lit->slot_count());
}

View File

@ -2239,7 +2239,8 @@ void FullCodeGenerator::EmitBinaryOp(BinaryOperation* expr, Token::Value op) {
}
void FullCodeGenerator::EmitClassDefineProperties(ClassLiteral* lit) {
void FullCodeGenerator::EmitClassDefineProperties(ClassLiteral* lit,
int* used_store_slots) {
// Constructor is in x0.
DCHECK(lit != NULL);
__ push(x0);
@ -2251,10 +2252,6 @@ void FullCodeGenerator::EmitClassDefineProperties(ClassLiteral* lit) {
FieldMemOperand(x0, JSFunction::kPrototypeOrInitialMapOffset));
__ Push(scratch);
// store_slot_index points to the vector IC slot for the next store IC used.
// ClassLiteral::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 (int i = 0; i < lit->properties()->length(); i++) {
ObjectLiteral::Property* property = lit->properties()->at(i);
Expression* value = property->value();
@ -2278,7 +2275,7 @@ void FullCodeGenerator::EmitClassDefineProperties(ClassLiteral* lit) {
VisitForStackValue(value);
EmitSetHomeObjectIfNeeded(value, 2,
lit->SlotForHomeObject(value, &store_slot_index));
lit->SlotForHomeObject(value, used_store_slots));
switch (property->kind()) {
case ObjectLiteral::Property::CONSTANT:
@ -2311,10 +2308,6 @@ void FullCodeGenerator::EmitClassDefineProperties(ClassLiteral* lit) {
// constructor
__ CallRuntime(Runtime::kToFastProperties, 1);
// Verify that compilation exactly consumed the number of store ic slots that
// the ClassLiteral node had to offer.
DCHECK(!FLAG_vector_stores || store_slot_index == lit->slot_count());
}

View File

@ -289,6 +289,10 @@ FeedbackVectorRequirements ClassLiteral::ComputeFeedbackRequirements(
if (FunctionLiteral::NeedsHomeObject(value)) ic_slots++;
}
if (scope() != NULL && class_variable_proxy()->var()->IsUnallocated()) {
ic_slots++;
}
#ifdef DEBUG
// FullCodeGenerator::VisitClassLiteral verifies that it consumes slot_count_
// slots.

View File

@ -1365,7 +1365,9 @@ void AstGraphBuilder::VisitForInStatement(ForInStatement* stmt) {
test_value.Else();
{
// Bind value and do loop body.
VisitForInAssignment(stmt->each(), value, stmt->AssignmentId());
ResolvedFeedbackSlot slot =
ResolveFeedbackSlot(stmt->EachFeedbackSlot());
VisitForInAssignment(stmt->each(), value, slot, stmt->AssignmentId());
VisitIterationBody(stmt, &for_loop);
}
test_value.End();
@ -1586,6 +1588,7 @@ void AstGraphBuilder::VisitClassLiteralContents(ClassLiteral* expr) {
environment()->Push(proto);
// Create nodes to store method values into the literal.
int store_slot_index = 0;
for (int i = 0; i < expr->properties()->length(); i++) {
ObjectLiteral::Property* property = expr->properties()->at(i);
environment()->Push(property->is_static() ? literal : proto);
@ -1608,7 +1611,9 @@ void AstGraphBuilder::VisitClassLiteralContents(ClassLiteral* expr) {
Node* value = environment()->Pop();
Node* key = environment()->Pop();
Node* receiver = environment()->Pop();
BuildSetHomeObject(value, receiver, property->value());
ResolvedFeedbackSlot slot = ResolveFeedbackSlot(
expr->SlotForHomeObject(property->value(), &store_slot_index));
BuildSetHomeObject(value, receiver, property->value(), slot);
switch (property->kind()) {
case ObjectLiteral::Property::CONSTANT:
@ -1648,8 +1653,11 @@ void AstGraphBuilder::VisitClassLiteralContents(ClassLiteral* expr) {
DCHECK_NOT_NULL(expr->class_variable_proxy());
Variable* var = expr->class_variable_proxy()->var();
FrameStateBeforeAndAfter states(this, BailoutId::None());
BuildVariableAssignment(var, literal, Token::INIT_CONST, BailoutId::None(),
states);
ResolvedFeedbackSlot slot = ResolveFeedbackSlot(
FLAG_vector_stores ? expr->GetNthSlot(store_slot_index++)
: FeedbackVectorICSlot::Invalid());
BuildVariableAssignment(var, literal, Token::INIT_CONST, slot,
BailoutId::None(), states);
}
ast_context()->ProduceValue(literal);
@ -1727,6 +1735,7 @@ void AstGraphBuilder::VisitObjectLiteral(ObjectLiteral* expr) {
// Create nodes to store computed values into the literal.
int property_index = 0;
int store_slot_index = 0;
AccessorTable accessor_table(zone());
for (; property_index < expr->properties()->length(); property_index++) {
ObjectLiteral::Property* property = expr->properties()->at(property_index);
@ -1749,11 +1758,17 @@ void AstGraphBuilder::VisitObjectLiteral(ObjectLiteral* expr) {
FrameStateBeforeAndAfter states(this, property->value()->id());
Node* value = environment()->Pop();
Handle<Name> name = key->AsPropertyName();
Node* store =
BuildNamedStore(literal, name, value, TypeFeedbackId::None());
ResolvedFeedbackSlot slot =
FLAG_vector_stores
? ResolveFeedbackSlot(expr->GetNthSlot(store_slot_index++))
: ResolvedFeedbackSlot();
Node* store = BuildNamedStore(literal, name, value, slot,
TypeFeedbackId::None());
states.AddToNode(store, key->id(),
OutputFrameStateCombine::Ignore());
BuildSetHomeObject(value, literal, property->value());
ResolvedFeedbackSlot home_slot = ResolveFeedbackSlot(
expr->SlotForHomeObject(property->value(), &store_slot_index));
BuildSetHomeObject(value, literal, property->value(), home_slot);
} else {
VisitForEffect(property->value());
}
@ -1772,7 +1787,9 @@ void AstGraphBuilder::VisitObjectLiteral(ObjectLiteral* expr) {
Node* set_property = NewNode(op, receiver, key, value, language);
// SetProperty should not lazy deopt on an object literal.
PrepareFrameState(set_property, BailoutId::None());
BuildSetHomeObject(value, receiver, property->value());
ResolvedFeedbackSlot home_slot = ResolveFeedbackSlot(
expr->SlotForHomeObject(property->value(), &store_slot_index));
BuildSetHomeObject(value, receiver, property->value(), home_slot);
}
break;
}
@ -1808,9 +1825,15 @@ void AstGraphBuilder::VisitObjectLiteral(ObjectLiteral* expr) {
it != accessor_table.end(); ++it) {
VisitForValue(it->first);
VisitForValueOrNull(it->second->getter);
BuildSetHomeObject(environment()->Top(), literal, it->second->getter);
ResolvedFeedbackSlot slot_getter = ResolveFeedbackSlot(
expr->SlotForHomeObject(it->second->getter, &store_slot_index));
BuildSetHomeObject(environment()->Top(), literal, it->second->getter,
slot_getter);
VisitForValueOrNull(it->second->setter);
BuildSetHomeObject(environment()->Top(), literal, it->second->setter);
ResolvedFeedbackSlot slot_setter = ResolveFeedbackSlot(
expr->SlotForHomeObject(it->second->getter, &store_slot_index));
BuildSetHomeObject(environment()->Top(), literal, it->second->setter,
slot_setter);
Node* setter = environment()->Pop();
Node* getter = environment()->Pop();
Node* name = environment()->Pop();
@ -1855,8 +1878,9 @@ void AstGraphBuilder::VisitObjectLiteral(ObjectLiteral* expr) {
Node* value = environment()->Pop();
Node* key = environment()->Pop();
Node* receiver = environment()->Pop();
BuildSetHomeObject(value, receiver, property->value());
ResolvedFeedbackSlot slot = ResolveFeedbackSlot(
expr->SlotForHomeObject(property->value(), &store_slot_index));
BuildSetHomeObject(value, receiver, property->value(), slot);
switch (property->kind()) {
case ObjectLiteral::Property::CONSTANT:
case ObjectLiteral::Property::COMPUTED:
@ -1897,6 +1921,10 @@ void AstGraphBuilder::VisitObjectLiteral(ObjectLiteral* expr) {
NewNode(op, literal);
}
// 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());
ast_context()->ProduceValue(environment()->Pop());
}
@ -1935,7 +1963,8 @@ void AstGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) {
Node* value = environment()->Pop();
Node* index = jsgraph()->Constant(array_index);
Node* store =
BuildKeyedStore(literal, index, value, TypeFeedbackId::None());
BuildKeyedStore(literal, index, value, ResolvedFeedbackSlot(),
TypeFeedbackId::None());
states.AddToNode(store, expr->GetIdForElement(array_index),
OutputFrameStateCombine::Ignore());
}
@ -1979,6 +2008,7 @@ void AstGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) {
void AstGraphBuilder::VisitForInAssignment(Expression* expr, Node* value,
const ResolvedFeedbackSlot& slot,
BailoutId bailout_id) {
DCHECK(expr->IsValidReferenceExpression());
@ -1991,7 +2021,8 @@ void AstGraphBuilder::VisitForInAssignment(Expression* expr, Node* value,
case VARIABLE: {
Variable* var = expr->AsVariableProxy()->var();
FrameStateBeforeAndAfter states(this, BailoutId::None());
BuildVariableAssignment(var, value, Token::ASSIGN, bailout_id, states);
BuildVariableAssignment(var, value, Token::ASSIGN, slot, bailout_id,
states);
break;
}
case NAMED_PROPERTY: {
@ -2002,7 +2033,7 @@ void AstGraphBuilder::VisitForInAssignment(Expression* expr, Node* value,
value = environment()->Pop();
Handle<Name> name = property->key()->AsLiteral()->AsPropertyName();
Node* store =
BuildNamedStore(object, name, value, TypeFeedbackId::None());
BuildNamedStore(object, name, value, slot, TypeFeedbackId::None());
states.AddToNode(store, bailout_id, OutputFrameStateCombine::Ignore());
break;
}
@ -2014,7 +2045,8 @@ void AstGraphBuilder::VisitForInAssignment(Expression* expr, Node* value,
Node* key = environment()->Pop();
Node* object = environment()->Pop();
value = environment()->Pop();
Node* store = BuildKeyedStore(object, key, value, TypeFeedbackId::None());
Node* store =
BuildKeyedStore(object, key, value, slot, TypeFeedbackId::None());
states.AddToNode(store, bailout_id, OutputFrameStateCombine::Ignore());
break;
}
@ -2176,18 +2208,19 @@ void AstGraphBuilder::VisitAssignment(Assignment* expr) {
FrameStateBeforeAndAfter store_states(this, before_store_id);
// Store the value.
Node* value = environment()->Pop();
ResolvedFeedbackSlot slot = ResolveFeedbackSlot(expr->AssignmentSlot());
switch (assign_type) {
case VARIABLE: {
Variable* variable = expr->target()->AsVariableProxy()->var();
BuildVariableAssignment(variable, value, expr->op(), expr->id(),
BuildVariableAssignment(variable, value, expr->op(), slot, expr->id(),
store_states, ast_context()->GetStateCombine());
break;
}
case NAMED_PROPERTY: {
Node* object = environment()->Pop();
Handle<Name> name = property->key()->AsLiteral()->AsPropertyName();
Node* store =
BuildNamedStore(object, name, value, expr->AssignmentFeedbackId());
Node* store = BuildNamedStore(object, name, value, slot,
expr->AssignmentFeedbackId());
store_states.AddToNode(store, expr->id(),
ast_context()->GetStateCombine());
break;
@ -2195,8 +2228,8 @@ void AstGraphBuilder::VisitAssignment(Assignment* expr) {
case KEYED_PROPERTY: {
Node* key = environment()->Pop();
Node* object = environment()->Pop();
Node* store =
BuildKeyedStore(object, key, value, expr->AssignmentFeedbackId());
Node* store = BuildKeyedStore(object, key, value, slot,
expr->AssignmentFeedbackId());
store_states.AddToNode(store, expr->id(),
ast_context()->GetStateCombine());
break;
@ -2647,20 +2680,21 @@ void AstGraphBuilder::VisitCountOperation(CountOperation* expr) {
}
// Store the value.
ResolvedFeedbackSlot slot = ResolveFeedbackSlot(expr->CountSlot());
switch (assign_type) {
case VARIABLE: {
Variable* variable = expr->expression()->AsVariableProxy()->var();
environment()->Push(value);
BuildVariableAssignment(variable, value, expr->op(), expr->AssignmentId(),
store_states);
BuildVariableAssignment(variable, value, expr->op(), slot,
expr->AssignmentId(), store_states);
environment()->Pop();
break;
}
case NAMED_PROPERTY: {
Node* object = environment()->Pop();
Handle<Name> name = property->key()->AsLiteral()->AsPropertyName();
Node* store =
BuildNamedStore(object, name, value, expr->CountStoreFeedbackId());
Node* store = BuildNamedStore(object, name, value, slot,
expr->CountStoreFeedbackId());
environment()->Push(value);
store_states.AddToNode(store, expr->AssignmentId(),
OutputFrameStateCombine::Ignore());
@ -2670,8 +2704,8 @@ void AstGraphBuilder::VisitCountOperation(CountOperation* expr) {
case KEYED_PROPERTY: {
Node* key = environment()->Pop();
Node* object = environment()->Pop();
Node* store =
BuildKeyedStore(object, key, value, expr->CountStoreFeedbackId());
Node* store = BuildKeyedStore(object, key, value, slot,
expr->CountStoreFeedbackId());
environment()->Push(value);
store_states.AddToNode(store, expr->AssignmentId(),
OutputFrameStateCombine::Ignore());
@ -3112,8 +3146,9 @@ Node* AstGraphBuilder::BuildArgumentsObject(Variable* arguments) {
DCHECK(arguments->IsContextSlot() || arguments->IsStackAllocated());
// This should never lazy deopt, so it is fine to send invalid bailout id.
FrameStateBeforeAndAfter states(this, BailoutId::None());
BuildVariableAssignment(arguments, object, Token::ASSIGN, BailoutId::None(),
states);
ResolvedFeedbackSlot slot;
BuildVariableAssignment(arguments, object, Token::ASSIGN, slot,
BailoutId::None(), states);
return object;
}
@ -3131,7 +3166,8 @@ Node* AstGraphBuilder::BuildRestArgumentsArray(Variable* rest, int index) {
DCHECK(rest->IsContextSlot() || rest->IsStackAllocated());
// This should never lazy deopt, so it is fine to send invalid bailout id.
FrameStateBeforeAndAfter states(this, BailoutId::None());
BuildVariableAssignment(rest, object, Token::ASSIGN, BailoutId::None(),
ResolvedFeedbackSlot slot;
BuildVariableAssignment(rest, object, Token::ASSIGN, slot, BailoutId::None(),
states);
return object;
@ -3143,8 +3179,9 @@ Node* AstGraphBuilder::BuildThisFunctionVar(Variable* this_function_var) {
Node* this_function = GetFunctionClosure();
FrameStateBeforeAndAfter states(this, BailoutId::None());
ResolvedFeedbackSlot slot;
BuildVariableAssignment(this_function_var, this_function, Token::INIT_CONST,
BailoutId::None(), states);
slot, BailoutId::None(), states);
return this_function;
}
@ -3329,7 +3366,8 @@ Node* AstGraphBuilder::BuildVariableDelete(Variable* variable,
Node* AstGraphBuilder::BuildVariableAssignment(
Variable* variable, Node* value, Token::Value op, BailoutId bailout_id,
Variable* variable, Node* value, Token::Value op,
const ResolvedFeedbackSlot& slot, BailoutId bailout_id,
FrameStateBeforeAndAfter& states, OutputFrameStateCombine combine) {
Node* the_hole = jsgraph()->TheHoleConstant();
VariableMode mode = variable->mode();
@ -3339,7 +3377,7 @@ Node* AstGraphBuilder::BuildVariableAssignment(
Node* global = BuildLoadGlobalObject();
Handle<Name> name = variable->name();
Node* store =
BuildNamedStore(global, name, value, TypeFeedbackId::None());
BuildNamedStore(global, name, value, slot, TypeFeedbackId::None());
states.AddToNode(store, bailout_id, combine);
return store;
}
@ -3472,16 +3510,19 @@ Node* AstGraphBuilder::BuildNamedLoad(Node* object, Handle<Name> name,
Node* AstGraphBuilder::BuildKeyedStore(Node* object, Node* key, Node* value,
const ResolvedFeedbackSlot& feedback,
TypeFeedbackId id) {
const Operator* op = javascript()->StoreProperty(language_mode());
const Operator* op = javascript()->StoreProperty(language_mode(), feedback);
return Record(js_type_feedback_, NewNode(op, object, key, value), id);
}
Node* AstGraphBuilder::BuildNamedStore(Node* object, Handle<Name> name,
Node* value, TypeFeedbackId id) {
Node* value,
const ResolvedFeedbackSlot& feedback,
TypeFeedbackId id) {
const Operator* op =
javascript()->StoreNamed(language_mode(), MakeUnique(name));
javascript()->StoreNamed(language_mode(), MakeUnique(name), feedback);
return Record(js_type_feedback_, NewNode(op, object, value), id);
}
@ -3626,12 +3667,13 @@ Node* AstGraphBuilder::BuildToObject(Node* input, BailoutId bailout_id) {
Node* AstGraphBuilder::BuildSetHomeObject(Node* value, Node* home_object,
Expression* expr) {
Expression* expr,
const ResolvedFeedbackSlot& slot) {
if (!FunctionLiteral::NeedsHomeObject(expr)) return value;
Handle<Name> name = isolate()->factory()->home_object_symbol();
FrameStateBeforeAndAfter states(this, BailoutId::None());
Node* store =
BuildNamedStore(value, name, home_object, TypeFeedbackId::None());
BuildNamedStore(value, name, home_object, slot, TypeFeedbackId::None());
states.AddToNode(store, BailoutId::None(), OutputFrameStateCombine::Ignore());
return store;
}

View File

@ -269,7 +269,9 @@ class AstGraphBuilder : public AstVisitor {
// Builders for variable load and assignment.
Node* BuildVariableAssignment(Variable* variable, Node* value,
Token::Value op, BailoutId bailout_id,
Token::Value op,
const ResolvedFeedbackSlot& slot,
BailoutId bailout_id,
FrameStateBeforeAndAfter& states,
OutputFrameStateCombine framestate_combine =
OutputFrameStateCombine::Ignore());
@ -288,8 +290,10 @@ class AstGraphBuilder : public AstVisitor {
const ResolvedFeedbackSlot& feedback,
ContextualMode mode = NOT_CONTEXTUAL);
Node* BuildKeyedStore(Node* receiver, Node* key, Node* value,
const ResolvedFeedbackSlot& feedback,
TypeFeedbackId id);
Node* BuildNamedStore(Node* receiver, Handle<Name>, Node* value,
const ResolvedFeedbackSlot& feedback,
TypeFeedbackId id);
// Builders for super property loads and stores.
@ -321,7 +325,8 @@ class AstGraphBuilder : public AstVisitor {
// Builder for adding the [[HomeObject]] to a value if the value came from a
// function literal and needs a home object. Do nothing otherwise.
Node* BuildSetHomeObject(Node* value, Node* home_object, Expression* expr);
Node* BuildSetHomeObject(Node* value, Node* home_object, Expression* expr,
const ResolvedFeedbackSlot& slot);
// Builders for error reporting at runtime.
Node* BuildThrowError(Node* exception, BailoutId bailout_id);
@ -387,6 +392,7 @@ class AstGraphBuilder : public AstVisitor {
// Dispatched from VisitForInStatement.
void VisitForInAssignment(Expression* expr, Node* value,
const ResolvedFeedbackSlot& slot,
BailoutId bailout_id);
// Dispatched from VisitClassLiteral.

View File

@ -248,7 +248,8 @@ const LoadNamedParameters& LoadNamedParametersOf(const Operator* op) {
bool operator==(StoreNamedParameters const& lhs,
StoreNamedParameters const& rhs) {
return lhs.language_mode() == rhs.language_mode() && lhs.name() == rhs.name();
return lhs.language_mode() == rhs.language_mode() &&
lhs.name() == rhs.name() && lhs.feedback() == rhs.feedback();
}
@ -259,7 +260,7 @@ bool operator!=(StoreNamedParameters const& lhs,
size_t hash_value(StoreNamedParameters const& p) {
return base::hash_combine(p.language_mode(), p.name());
return base::hash_combine(p.language_mode(), p.name(), p.feedback());
}
@ -274,6 +275,35 @@ const StoreNamedParameters& StoreNamedParametersOf(const Operator* op) {
}
bool operator==(StorePropertyParameters const& lhs,
StorePropertyParameters const& rhs) {
return lhs.language_mode() == rhs.language_mode() &&
lhs.feedback() == rhs.feedback();
}
bool operator!=(StorePropertyParameters const& lhs,
StorePropertyParameters const& rhs) {
return !(lhs == rhs);
}
size_t hash_value(StorePropertyParameters const& p) {
return base::hash_combine(p.language_mode(), p.feedback());
}
std::ostream& operator<<(std::ostream& os, StorePropertyParameters const& p) {
return os << p.language_mode();
}
const StorePropertyParameters& StorePropertyParametersOf(const Operator* op) {
DCHECK_EQ(IrOpcode::kJSStoreProperty, op->opcode());
return OpParameter<StorePropertyParameters>(op);
}
bool operator==(CreateClosureParameters const& lhs,
CreateClosureParameters const& rhs) {
return lhs.pretenure() == rhs.pretenure() &&
@ -348,8 +378,7 @@ const CreateClosureParameters& CreateClosureParametersOf(const Operator* op) {
V(Subtract, Operator::kNoProperties, 2, 1) \
V(Multiply, Operator::kNoProperties, 2, 1) \
V(Divide, Operator::kNoProperties, 2, 1) \
V(Modulus, Operator::kNoProperties, 2, 1) \
V(StoreProperty, Operator::kNoProperties, 3, 0)
V(Modulus, Operator::kNoProperties, 2, 1)
struct JSOperatorGlobalCache final {
@ -480,9 +509,10 @@ const Operator* JSOperatorBuilder::LoadProperty(
}
const Operator* JSOperatorBuilder::StoreNamed(LanguageMode language_mode,
const Unique<Name>& name) {
StoreNamedParameters parameters(language_mode, name);
const Operator* JSOperatorBuilder::StoreNamed(
LanguageMode language_mode, const Unique<Name>& name,
const ResolvedFeedbackSlot& feedback) {
StoreNamedParameters parameters(language_mode, feedback, name);
return new (zone()) Operator1<StoreNamedParameters>( // --
IrOpcode::kJSStoreNamed, Operator::kNoProperties, // opcode
"JSStoreNamed", // name
@ -491,6 +521,17 @@ const Operator* JSOperatorBuilder::StoreNamed(LanguageMode language_mode,
}
const Operator* JSOperatorBuilder::StoreProperty(
LanguageMode language_mode, const ResolvedFeedbackSlot& feedback) {
StorePropertyParameters parameters(language_mode, feedback);
return new (zone()) Operator1<StorePropertyParameters>( // --
IrOpcode::kJSStoreProperty, Operator::kNoProperties, // opcode
"JSStoreProperty", // name
3, 1, 1, 0, 1, 2, // counts
parameters); // parameter
}
const Operator* JSOperatorBuilder::DeleteProperty(LanguageMode language_mode) {
return new (zone()) Operator1<LanguageMode>( // --
IrOpcode::kJSDeleteProperty, Operator::kNoProperties, // opcode

View File

@ -274,15 +274,19 @@ const LoadPropertyParameters& LoadPropertyParametersOf(const Operator* op);
// used as a parameter by JSStoreNamed operators.
class StoreNamedParameters final {
public:
StoreNamedParameters(LanguageMode language_mode, const Unique<Name>& name)
: language_mode_(language_mode), name_(name) {}
StoreNamedParameters(LanguageMode language_mode,
const ResolvedFeedbackSlot& feedback,
const Unique<Name>& name)
: language_mode_(language_mode), name_(name), feedback_(feedback) {}
LanguageMode language_mode() const { return language_mode_; }
const ResolvedFeedbackSlot& feedback() const { return feedback_; }
const Unique<Name>& name() const { return name_; }
private:
const LanguageMode language_mode_;
const Unique<Name> name_;
const ResolvedFeedbackSlot feedback_;
};
bool operator==(StoreNamedParameters const&, StoreNamedParameters const&);
@ -295,6 +299,32 @@ std::ostream& operator<<(std::ostream&, StoreNamedParameters const&);
const StoreNamedParameters& StoreNamedParametersOf(const Operator* op);
// Defines the property being stored to an object. This is used as a parameter
// by JSStoreProperty operators.
class StorePropertyParameters final {
public:
StorePropertyParameters(LanguageMode language_mode,
const ResolvedFeedbackSlot& feedback)
: language_mode_(language_mode), feedback_(feedback) {}
LanguageMode language_mode() const { return language_mode_; }
const ResolvedFeedbackSlot& feedback() const { return feedback_; }
private:
const LanguageMode language_mode_;
const ResolvedFeedbackSlot feedback_;
};
bool operator==(StorePropertyParameters const&, StorePropertyParameters const&);
bool operator!=(StorePropertyParameters const&, StorePropertyParameters const&);
size_t hash_value(StorePropertyParameters const&);
std::ostream& operator<<(std::ostream&, StorePropertyParameters const&);
const StorePropertyParameters& StorePropertyParametersOf(const Operator* op);
// Defines shared information for the closure that should be created. This is
// used as a parameter by JSCreateClosure operators.
class CreateClosureParameters final {
@ -373,9 +403,11 @@ class JSOperatorBuilder final : public ZoneObject {
const ResolvedFeedbackSlot& feedback,
ContextualMode contextual_mode = NOT_CONTEXTUAL);
const Operator* StoreProperty(LanguageMode language_mode);
const Operator* StoreProperty(LanguageMode language_mode,
const ResolvedFeedbackSlot& feedback);
const Operator* StoreNamed(LanguageMode language_mode,
const Unique<Name>& name);
const Unique<Name>& name,
const ResolvedFeedbackSlot& feedback);
const Operator* DeleteProperty(LanguageMode language_mode);

View File

@ -1424,13 +1424,22 @@ void FullCodeGenerator::VisitClassLiteral(ClassLiteral* lit) {
__ CallRuntime(Runtime::kDefineClass, 6);
PrepareForBailoutForId(lit->CreateLiteralId(), TOS_REG);
EmitClassDefineProperties(lit);
int store_slot_index = 0;
EmitClassDefineProperties(lit, &store_slot_index);
if (lit->scope() != NULL) {
DCHECK_NOT_NULL(lit->class_variable_proxy());
FeedbackVectorICSlot slot = FLAG_vector_stores
? lit->GetNthSlot(store_slot_index++)
: FeedbackVectorICSlot::Invalid();
EmitVariableAssignment(lit->class_variable_proxy()->var(),
Token::INIT_CONST);
Token::INIT_CONST, slot);
}
// Verify that compilation exactly consumed the number of store ic slots
// that the ClassLiteral node had to offer.
DCHECK(!FLAG_vector_stores || store_slot_index == lit->slot_count());
}
context()->Plug(result_register());

View File

@ -615,7 +615,7 @@ class FullCodeGenerator: public AstVisitor {
// Adds the properties to the class (function) object and to its prototype.
// Expects the class (function) in the accumulator. The class (function) is
// in the accumulator after installing all the properties.
void EmitClassDefineProperties(ClassLiteral* lit);
void EmitClassDefineProperties(ClassLiteral* lit, int* used_store_slots);
// Pushes the property key as a Name on the stack.
void EmitPropertyKey(ObjectLiteralProperty* property, BailoutId bailout_id);
@ -634,14 +634,12 @@ class FullCodeGenerator: public AstVisitor {
// Assign to the given expression as if via '='. The right-hand-side value
// is expected in the accumulator. slot is only used if FLAG_vector_stores
// is true.
void EmitAssignment(Expression* expr, FeedbackVectorICSlot slot =
FeedbackVectorICSlot::Invalid());
void EmitAssignment(Expression* expr, FeedbackVectorICSlot slot);
// Complete a variable assignment. The right-hand-side value is expected
// in the accumulator.
void EmitVariableAssignment(
Variable* var, Token::Value op,
FeedbackVectorICSlot slot = FeedbackVectorICSlot::Invalid());
void EmitVariableAssignment(Variable* var, Token::Value op,
FeedbackVectorICSlot slot);
// Helper functions to EmitVariableAssignment
void EmitStoreToStackLocalOrContextSlot(Variable* var,

View File

@ -2463,7 +2463,8 @@ void FullCodeGenerator::EmitInlineSmiBinaryOp(BinaryOperation* expr,
}
void FullCodeGenerator::EmitClassDefineProperties(ClassLiteral* lit) {
void FullCodeGenerator::EmitClassDefineProperties(ClassLiteral* lit,
int* used_store_slots) {
// Constructor is in eax.
DCHECK(lit != NULL);
__ push(eax);
@ -2474,10 +2475,6 @@ void FullCodeGenerator::EmitClassDefineProperties(ClassLiteral* lit) {
__ mov(scratch, FieldOperand(eax, JSFunction::kPrototypeOrInitialMapOffset));
__ Push(scratch);
// store_slot_index points to the vector IC slot for the next store IC used.
// ClassLiteral::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 (int i = 0; i < lit->properties()->length(); i++) {
ObjectLiteral::Property* property = lit->properties()->at(i);
Expression* value = property->value();
@ -2500,7 +2497,7 @@ void FullCodeGenerator::EmitClassDefineProperties(ClassLiteral* lit) {
VisitForStackValue(value);
EmitSetHomeObjectIfNeeded(value, 2,
lit->SlotForHomeObject(value, &store_slot_index));
lit->SlotForHomeObject(value, used_store_slots));
switch (property->kind()) {
case ObjectLiteral::Property::CONSTANT:
@ -2528,10 +2525,6 @@ void FullCodeGenerator::EmitClassDefineProperties(ClassLiteral* lit) {
// constructor
__ CallRuntime(Runtime::kToFastProperties, 1);
// Verify that compilation exactly consumed the number of store ic slots that
// the ClassLiteral node had to offer.
DCHECK(!FLAG_vector_stores || store_slot_index == lit->slot_count());
}

View File

@ -2526,7 +2526,8 @@ void FullCodeGenerator::EmitInlineSmiBinaryOp(BinaryOperation* expr,
}
void FullCodeGenerator::EmitClassDefineProperties(ClassLiteral* lit) {
void FullCodeGenerator::EmitClassDefineProperties(ClassLiteral* lit,
int* used_store_slots) {
// Constructor is in v0.
DCHECK(lit != NULL);
__ push(v0);
@ -2538,10 +2539,6 @@ void FullCodeGenerator::EmitClassDefineProperties(ClassLiteral* lit) {
FieldMemOperand(v0, JSFunction::kPrototypeOrInitialMapOffset));
__ push(scratch);
// store_slot_index points to the vector IC slot for the next store IC used.
// ClassLiteral::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 (int i = 0; i < lit->properties()->length(); i++) {
ObjectLiteral::Property* property = lit->properties()->at(i);
Expression* value = property->value();
@ -2565,7 +2562,7 @@ void FullCodeGenerator::EmitClassDefineProperties(ClassLiteral* lit) {
VisitForStackValue(value);
EmitSetHomeObjectIfNeeded(value, 2,
lit->SlotForHomeObject(value, &store_slot_index));
lit->SlotForHomeObject(value, used_store_slots));
switch (property->kind()) {
case ObjectLiteral::Property::CONSTANT:
@ -2598,10 +2595,6 @@ void FullCodeGenerator::EmitClassDefineProperties(ClassLiteral* lit) {
// constructor
__ CallRuntime(Runtime::kToFastProperties, 1);
// Verify that compilation exactly consumed the number of store ic slots that
// the ClassLiteral node had to offer.
DCHECK(!FLAG_vector_stores || store_slot_index == lit->slot_count());
}

View File

@ -2525,7 +2525,8 @@ void FullCodeGenerator::EmitInlineSmiBinaryOp(BinaryOperation* expr,
}
void FullCodeGenerator::EmitClassDefineProperties(ClassLiteral* lit) {
void FullCodeGenerator::EmitClassDefineProperties(ClassLiteral* lit,
int* used_store_slots) {
// Constructor is in v0.
DCHECK(lit != NULL);
__ push(v0);
@ -2537,10 +2538,6 @@ void FullCodeGenerator::EmitClassDefineProperties(ClassLiteral* lit) {
FieldMemOperand(v0, JSFunction::kPrototypeOrInitialMapOffset));
__ push(scratch);
// store_slot_index points to the vector IC slot for the next store IC used.
// ClassLiteral::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 (int i = 0; i < lit->properties()->length(); i++) {
ObjectLiteral::Property* property = lit->properties()->at(i);
Expression* value = property->value();
@ -2564,7 +2561,7 @@ void FullCodeGenerator::EmitClassDefineProperties(ClassLiteral* lit) {
VisitForStackValue(value);
EmitSetHomeObjectIfNeeded(value, 2,
lit->SlotForHomeObject(value, &store_slot_index));
lit->SlotForHomeObject(value, used_store_slots));
switch (property->kind()) {
case ObjectLiteral::Property::CONSTANT:
@ -2597,10 +2594,6 @@ void FullCodeGenerator::EmitClassDefineProperties(ClassLiteral* lit) {
// constructor
__ CallRuntime(Runtime::kToFastProperties, 1);
// Verify that compilation exactly consumed the number of store ic slots that
// the ClassLiteral node had to offer.
DCHECK(!FLAG_vector_stores || store_slot_index == lit->slot_count());
}
@ -5089,7 +5082,7 @@ void FullCodeGenerator::VisitCountOperation(CountOperation* expr) {
}
} else {
EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(),
Token::ASSIGN);
Token::ASSIGN, expr->CountSlot());
PrepareForBailoutForId(expr->AssignmentId(), TOS_REG);
context()->Plug(v0);
}

View File

@ -2458,7 +2458,8 @@ void FullCodeGenerator::EmitInlineSmiBinaryOp(BinaryOperation* expr,
}
void FullCodeGenerator::EmitClassDefineProperties(ClassLiteral* lit) {
void FullCodeGenerator::EmitClassDefineProperties(ClassLiteral* lit,
int* used_store_slots) {
// Constructor is in rax.
DCHECK(lit != NULL);
__ Push(rax);
@ -2469,10 +2470,6 @@ void FullCodeGenerator::EmitClassDefineProperties(ClassLiteral* lit) {
__ movp(scratch, FieldOperand(rax, JSFunction::kPrototypeOrInitialMapOffset));
__ Push(scratch);
// store_slot_index points to the vector IC slot for the next store IC used.
// ClassLiteral::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 (int i = 0; i < lit->properties()->length(); i++) {
ObjectLiteral::Property* property = lit->properties()->at(i);
Expression* value = property->value();
@ -2495,7 +2492,7 @@ void FullCodeGenerator::EmitClassDefineProperties(ClassLiteral* lit) {
VisitForStackValue(value);
EmitSetHomeObjectIfNeeded(value, 2,
lit->SlotForHomeObject(value, &store_slot_index));
lit->SlotForHomeObject(value, used_store_slots));
switch (property->kind()) {
case ObjectLiteral::Property::CONSTANT:
@ -2526,10 +2523,6 @@ void FullCodeGenerator::EmitClassDefineProperties(ClassLiteral* lit) {
// constructor
__ CallRuntime(Runtime::kToFastProperties, 1);
// Verify that compilation exactly consumed the number of store ic slots that
// the ClassLiteral node had to offer.
DCHECK(!FLAG_vector_stores || store_slot_index == lit->slot_count());
}

View File

@ -201,7 +201,6 @@ const SharedOperatorWithLanguageMode kSharedOperatorsWithLanguageMode[] = {
SHARED(Multiply, Operator::kNoProperties, 2, 2, 1, 1, 1, 1, 2),
SHARED(Divide, Operator::kNoProperties, 2, 2, 1, 1, 1, 1, 2),
SHARED(Modulus, Operator::kNoProperties, 2, 2, 1, 1, 1, 1, 2),
SHARED(StoreProperty, Operator::kNoProperties, 3, 2, 1, 1, 0, 1, 2),
#undef SHARED
};

View File

@ -739,8 +739,10 @@ TEST_F(JSTypedLoweringTest, JSStorePropertyToExternalTypedArray) {
Node* context = UndefinedConstant();
Node* effect = graph()->start();
Node* control = graph()->start();
Node* node = graph()->NewNode(javascript()->StoreProperty(language_mode),
base, key, value, context);
ResolvedFeedbackSlot slot;
Node* node =
graph()->NewNode(javascript()->StoreProperty(language_mode, slot),
base, key, value, context);
for (int i = 0;
i < OperatorProperties::GetFrameStateInputCount(node->op()); i++) {
node->AppendInput(zone(), EmptyFrameState());
@ -785,8 +787,10 @@ TEST_F(JSTypedLoweringTest, JSStorePropertyToExternalTypedArrayWithConversion) {
Node* context = UndefinedConstant();
Node* effect = graph()->start();
Node* control = graph()->start();
Node* node = graph()->NewNode(javascript()->StoreProperty(language_mode),
base, key, value, context);
ResolvedFeedbackSlot slot;
Node* node =
graph()->NewNode(javascript()->StoreProperty(language_mode, slot),
base, key, value, context);
for (int i = 0;
i < OperatorProperties::GetFrameStateInputCount(node->op()); i++) {
node->AppendInput(zone(), EmptyFrameState());
@ -844,8 +848,10 @@ TEST_F(JSTypedLoweringTest, JSStorePropertyToExternalTypedArrayWithSafeKey) {
Node* context = UndefinedConstant();
Node* effect = graph()->start();
Node* control = graph()->start();
Node* node = graph()->NewNode(javascript()->StoreProperty(language_mode),
base, key, value, context);
ResolvedFeedbackSlot slot;
Node* node =
graph()->NewNode(javascript()->StoreProperty(language_mode, slot),
base, key, value, context);
for (int i = 0;
i < OperatorProperties::GetFrameStateInputCount(node->op()); i++) {
node->AppendInput(zone(), EmptyFrameState());