Commit bb20d7ae authored by bmeurer's avatar bmeurer Committed by Commit bot

[turbofan] Unify NamedAccess and PropertyAccess operator parameters.

Use a unified NamedAccess operator parameter for both JSLoadNamed and
JSStoreNamed, and similar use PropertyAccess for both JSLoadProperty and
JSStoreProperty.

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

Cr-Commit-Position: refs/heads/master@{#31456}
parent b7985aae
......@@ -3614,7 +3614,7 @@ static inline Node* Record(JSTypeFeedbackTable* js_type_feedback, Node* node,
Node* AstGraphBuilder::BuildKeyedLoad(Node* object, Node* key,
const VectorSlotPair& feedback) {
const Operator* op = javascript()->LoadProperty(feedback, language_mode());
const Operator* op = javascript()->LoadProperty(language_mode(), feedback);
Node* node = NewNode(op, object, key, BuildLoadFeedbackVector());
return Record(js_type_feedback_, node, feedback.slot());
}
......@@ -3622,7 +3622,7 @@ Node* AstGraphBuilder::BuildKeyedLoad(Node* object, Node* key,
Node* AstGraphBuilder::BuildNamedLoad(Node* object, Handle<Name> name,
const VectorSlotPair& feedback) {
const Operator* op = javascript()->LoadNamed(name, feedback, language_mode());
const Operator* op = javascript()->LoadNamed(language_mode(), name, feedback);
Node* node = NewNode(op, object, BuildLoadFeedbackVector());
return Record(js_type_feedback_, node, feedback.slot());
}
......
......@@ -286,7 +286,7 @@ void JSGenericLowering::LowerJSToObject(Node* node) {
void JSGenericLowering::LowerJSLoadProperty(Node* node) {
CallDescriptor::Flags flags = AdjustFrameStatesForCall(node);
const LoadPropertyParameters& p = LoadPropertyParametersOf(node->op());
const PropertyAccess& p = PropertyAccessOf(node->op());
Callable callable = CodeFactory::KeyedLoadICInOptimizedCode(
isolate(), p.language_mode(), UNINITIALIZED);
node->InsertInput(zone(), 2, jsgraph()->SmiConstant(p.feedback().index()));
......@@ -296,7 +296,7 @@ void JSGenericLowering::LowerJSLoadProperty(Node* node) {
void JSGenericLowering::LowerJSLoadNamed(Node* node) {
CallDescriptor::Flags flags = AdjustFrameStatesForCall(node);
const LoadNamedParameters& p = LoadNamedParametersOf(node->op());
NamedAccess const& p = NamedAccessOf(node->op());
Callable callable = CodeFactory::LoadICInOptimizedCode(
isolate(), NOT_INSIDE_TYPEOF, p.language_mode(), UNINITIALIZED);
node->InsertInput(zone(), 1, jsgraph()->HeapConstant(p.name()));
......@@ -330,7 +330,7 @@ void JSGenericLowering::LowerJSLoadGlobal(Node* node) {
void JSGenericLowering::LowerJSStoreProperty(Node* node) {
CallDescriptor::Flags flags = AdjustFrameStatesForCall(node);
const StorePropertyParameters& p = StorePropertyParametersOf(node->op());
PropertyAccess const& p = PropertyAccessOf(node->op());
LanguageMode language_mode = p.language_mode();
Callable callable = CodeFactory::KeyedStoreICInOptimizedCode(
isolate(), language_mode, UNINITIALIZED);
......@@ -347,7 +347,7 @@ void JSGenericLowering::LowerJSStoreProperty(Node* node) {
void JSGenericLowering::LowerJSStoreNamed(Node* node) {
CallDescriptor::Flags flags = AdjustFrameStatesForCall(node);
const StoreNamedParameters& p = StoreNamedParametersOf(node->op());
NamedAccess const& p = NamedAccessOf(node->op());
Callable callable = CodeFactory::StoreICInOptimizedCode(
isolate(), p.language_mode(), UNINITIALIZED);
node->InsertInput(zone(), 1, jsgraph()->HeapConstant(p.name()));
......
......@@ -428,7 +428,7 @@ bool JSNativeContextSpecialization::ComputePropertyAccessInfos(
Reduction JSNativeContextSpecialization::ReduceJSLoadNamed(Node* node) {
DCHECK_EQ(IrOpcode::kJSLoadNamed, node->opcode());
LoadNamedParameters const p = LoadNamedParametersOf(node->op());
NamedAccess const& p = NamedAccessOf(node->op());
Handle<Name> name = p.name();
Node* receiver = NodeProperties::GetValueInput(node, 0);
Node* frame_state = NodeProperties::GetFrameStateInput(node, 1);
......
......@@ -205,66 +205,64 @@ DynamicContextAccess const& DynamicContextAccessOf(Operator const* op) {
}
bool operator==(LoadNamedParameters const& lhs,
LoadNamedParameters const& rhs) {
bool operator==(NamedAccess const& lhs, NamedAccess const& rhs) {
return lhs.name().location() == rhs.name().location() &&
lhs.language_mode() == rhs.language_mode() &&
lhs.feedback() == rhs.feedback();
}
bool operator!=(LoadNamedParameters const& lhs,
LoadNamedParameters const& rhs) {
bool operator!=(NamedAccess const& lhs, NamedAccess const& rhs) {
return !(lhs == rhs);
}
size_t hash_value(LoadNamedParameters const& p) {
size_t hash_value(NamedAccess const& p) {
return base::hash_combine(p.name().location(), p.language_mode(),
p.feedback());
}
std::ostream& operator<<(std::ostream& os, LoadNamedParameters const& p) {
std::ostream& operator<<(std::ostream& os, NamedAccess const& p) {
return os << Brief(*p.name()) << ", " << p.language_mode();
}
std::ostream& operator<<(std::ostream& os, LoadPropertyParameters const& p) {
NamedAccess const& NamedAccessOf(const Operator* op) {
DCHECK(op->opcode() == IrOpcode::kJSLoadNamed ||
op->opcode() == IrOpcode::kJSStoreNamed);
return OpParameter<NamedAccess>(op);
}
std::ostream& operator<<(std::ostream& os, PropertyAccess const& p) {
return os << p.language_mode();
}
bool operator==(LoadPropertyParameters const& lhs,
LoadPropertyParameters const& rhs) {
bool operator==(PropertyAccess const& lhs, PropertyAccess const& rhs) {
return lhs.language_mode() == rhs.language_mode() &&
lhs.feedback() == rhs.feedback();
}
bool operator!=(LoadPropertyParameters const& lhs,
LoadPropertyParameters const& rhs) {
bool operator!=(PropertyAccess const& lhs, PropertyAccess const& rhs) {
return !(lhs == rhs);
}
const LoadPropertyParameters& LoadPropertyParametersOf(const Operator* op) {
DCHECK_EQ(IrOpcode::kJSLoadProperty, op->opcode());
return OpParameter<LoadPropertyParameters>(op);
PropertyAccess const& PropertyAccessOf(const Operator* op) {
DCHECK(op->opcode() == IrOpcode::kJSLoadProperty ||
op->opcode() == IrOpcode::kJSStoreProperty);
return OpParameter<PropertyAccess>(op);
}
size_t hash_value(LoadPropertyParameters const& p) {
size_t hash_value(PropertyAccess const& p) {
return base::hash_combine(p.language_mode(), p.feedback());
}
const LoadNamedParameters& LoadNamedParametersOf(const Operator* op) {
DCHECK_EQ(IrOpcode::kJSLoadNamed, op->opcode());
return OpParameter<LoadNamedParameters>(op);
}
bool operator==(LoadGlobalParameters const& lhs,
LoadGlobalParameters const& rhs) {
return lhs.name().location() == rhs.name().location() &&
......@@ -331,66 +329,6 @@ const StoreGlobalParameters& StoreGlobalParametersOf(const Operator* op) {
}
bool operator==(StoreNamedParameters const& lhs,
StoreNamedParameters const& rhs) {
return lhs.language_mode() == rhs.language_mode() &&
lhs.name().location() == rhs.name().location() &&
lhs.feedback() == rhs.feedback();
}
bool operator!=(StoreNamedParameters const& lhs,
StoreNamedParameters const& rhs) {
return !(lhs == rhs);
}
size_t hash_value(StoreNamedParameters const& p) {
return base::hash_combine(p.language_mode(), p.name().location(),
p.feedback());
}
std::ostream& operator<<(std::ostream& os, StoreNamedParameters const& p) {
return os << p.language_mode() << ", " << Brief(*p.name());
}
const StoreNamedParameters& StoreNamedParametersOf(const Operator* op) {
DCHECK_EQ(IrOpcode::kJSStoreNamed, op->opcode());
return OpParameter<StoreNamedParameters>(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==(CreateArgumentsParameters const& lhs,
CreateArgumentsParameters const& rhs) {
return lhs.type() == rhs.type() && lhs.start_index() == rhs.start_index();
......@@ -600,49 +538,49 @@ const Operator* JSOperatorBuilder::CallConstruct(int arguments) {
}
const Operator* JSOperatorBuilder::LoadNamed(const Handle<Name>& name,
const VectorSlotPair& feedback,
LanguageMode language_mode) {
LoadNamedParameters parameters(name, feedback, language_mode);
return new (zone()) Operator1<LoadNamedParameters>( // --
const Operator* JSOperatorBuilder::LoadNamed(LanguageMode language_mode,
Handle<Name> name,
const VectorSlotPair& feedback) {
NamedAccess access(language_mode, name, feedback);
return new (zone()) Operator1<NamedAccess>( // --
IrOpcode::kJSLoadNamed, Operator::kNoProperties, // opcode
"JSLoadNamed", // name
2, 1, 1, 1, 1, 2, // counts
parameters); // parameter
access); // parameter
}
const Operator* JSOperatorBuilder::LoadProperty(const VectorSlotPair& feedback,
LanguageMode language_mode) {
LoadPropertyParameters parameters(feedback, language_mode);
return new (zone()) Operator1<LoadPropertyParameters>( // --
const Operator* JSOperatorBuilder::LoadProperty(
LanguageMode language_mode, VectorSlotPair const& feedback) {
PropertyAccess access(language_mode, feedback);
return new (zone()) Operator1<PropertyAccess>( // --
IrOpcode::kJSLoadProperty, Operator::kNoProperties, // opcode
"JSLoadProperty", // name
3, 1, 1, 1, 1, 2, // counts
parameters); // parameter
access); // parameter
}
const Operator* JSOperatorBuilder::StoreNamed(LanguageMode language_mode,
const Handle<Name>& name,
const VectorSlotPair& feedback) {
StoreNamedParameters parameters(language_mode, feedback, name);
return new (zone()) Operator1<StoreNamedParameters>( // --
Handle<Name> name,
VectorSlotPair const& feedback) {
NamedAccess access(language_mode, name, feedback);
return new (zone()) Operator1<NamedAccess>( // --
IrOpcode::kJSStoreNamed, Operator::kNoProperties, // opcode
"JSStoreNamed", // name
3, 1, 1, 0, 1, 2, // counts
parameters); // parameter
access); // parameter
}
const Operator* JSOperatorBuilder::StoreProperty(
LanguageMode language_mode, const VectorSlotPair& feedback) {
StorePropertyParameters parameters(language_mode, feedback);
return new (zone()) Operator1<StorePropertyParameters>( // --
LanguageMode language_mode, VectorSlotPair const& feedback) {
PropertyAccess access(language_mode, feedback);
return new (zone()) Operator1<PropertyAccess>( // --
IrOpcode::kJSStoreProperty, Operator::kNoProperties, // opcode
"JSStoreProperty", // name
4, 1, 1, 0, 1, 2, // counts
parameters); // parameter
access); // parameter
}
......
......@@ -228,33 +228,32 @@ std::ostream& operator<<(std::ostream&, DynamicContextAccess const&);
DynamicContextAccess const& DynamicContextAccessOf(Operator const*);
// Defines the property being loaded from an object by a named load. This is
// used as a parameter by JSLoadNamed operators.
class LoadNamedParameters final {
// Defines the property of an object for a named access. This is
// used as a parameter by the JSLoadNamed and JSStoreNamed operators.
class NamedAccess final {
public:
LoadNamedParameters(const Handle<Name>& name, const VectorSlotPair& feedback,
LanguageMode language_mode)
NamedAccess(LanguageMode language_mode, Handle<Name> name,
VectorSlotPair const& feedback)
: name_(name), feedback_(feedback), language_mode_(language_mode) {}
const Handle<Name>& name() const { return name_; }
Handle<Name> name() const { return name_; }
LanguageMode language_mode() const { return language_mode_; }
const VectorSlotPair& feedback() const { return feedback_; }
VectorSlotPair const& feedback() const { return feedback_; }
private:
const Handle<Name> name_;
const VectorSlotPair feedback_;
const LanguageMode language_mode_;
Handle<Name> const name_;
VectorSlotPair const feedback_;
LanguageMode const language_mode_;
};
bool operator==(LoadNamedParameters const&, LoadNamedParameters const&);
bool operator!=(LoadNamedParameters const&, LoadNamedParameters const&);
bool operator==(NamedAccess const&, NamedAccess const&);
bool operator!=(NamedAccess const&, NamedAccess const&);
size_t hash_value(LoadNamedParameters const&);
size_t hash_value(NamedAccess const&);
std::ostream& operator<<(std::ostream&, LoadNamedParameters const&);
std::ostream& operator<<(std::ostream&, NamedAccess const&);
const LoadNamedParameters& LoadNamedParametersOf(const Operator* op);
const NamedAccess& NamedAccessOf(const Operator* op);
// Defines the property being loaded from an object by a named load. This is
......@@ -326,85 +325,29 @@ std::ostream& operator<<(std::ostream&, StoreGlobalParameters const&);
const StoreGlobalParameters& StoreGlobalParametersOf(const Operator* op);
// Defines the property being loaded from an object. This is
// used as a parameter by JSLoadProperty operators.
class LoadPropertyParameters final {
// Defines the property of an object for a keyed access. This is used
// as a parameter by the JSLoadProperty and JSStoreProperty operators.
class PropertyAccess final {
public:
explicit LoadPropertyParameters(const VectorSlotPair& feedback,
LanguageMode language_mode)
PropertyAccess(LanguageMode language_mode, VectorSlotPair const& feedback)
: feedback_(feedback), language_mode_(language_mode) {}
const VectorSlotPair& feedback() const { return feedback_; }
LanguageMode language_mode() const { return language_mode_; }
private:
const VectorSlotPair feedback_;
const LanguageMode language_mode_;
};
bool operator==(LoadPropertyParameters const&, LoadPropertyParameters const&);
bool operator!=(LoadPropertyParameters const&, LoadPropertyParameters const&);
size_t hash_value(LoadPropertyParameters const&);
std::ostream& operator<<(std::ostream&, LoadPropertyParameters const&);
const LoadPropertyParameters& LoadPropertyParametersOf(const Operator* op);
// Defines the property being stored to an object by a named store. This is
// used as a parameter by JSStoreNamed operator.
class StoreNamedParameters final {
public:
StoreNamedParameters(LanguageMode language_mode,
const VectorSlotPair& feedback, const Handle<Name>& name)
: language_mode_(language_mode), name_(name), feedback_(feedback) {}
LanguageMode language_mode() const { return language_mode_; }
const VectorSlotPair& feedback() const { return feedback_; }
const Handle<Name>& name() const { return name_; }
private:
const LanguageMode language_mode_;
const Handle<Name> name_;
const VectorSlotPair feedback_;
};
bool operator==(StoreNamedParameters const&, StoreNamedParameters const&);
bool operator!=(StoreNamedParameters const&, StoreNamedParameters const&);
size_t hash_value(StoreNamedParameters const&);
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 VectorSlotPair& feedback)
: language_mode_(language_mode), feedback_(feedback) {}
LanguageMode language_mode() const { return language_mode_; }
const VectorSlotPair& feedback() const { return feedback_; }
VectorSlotPair const& feedback() const { return feedback_; }
private:
const LanguageMode language_mode_;
const VectorSlotPair feedback_;
VectorSlotPair const feedback_;
LanguageMode const language_mode_;
};
bool operator==(StorePropertyParameters const&, StorePropertyParameters const&);
bool operator!=(StorePropertyParameters const&, StorePropertyParameters const&);
bool operator==(PropertyAccess const&, PropertyAccess const&);
bool operator!=(PropertyAccess const&, PropertyAccess const&);
size_t hash_value(StorePropertyParameters const&);
size_t hash_value(PropertyAccess const&);
std::ostream& operator<<(std::ostream&, StorePropertyParameters const&);
std::ostream& operator<<(std::ostream&, PropertyAccess const&);
const StorePropertyParameters& StorePropertyParametersOf(const Operator* op);
PropertyAccess const& PropertyAccessOf(const Operator* op);
// Defines specifics about arguments object or rest parameter creation. This is
......@@ -513,17 +456,15 @@ class JSOperatorBuilder final : public ZoneObject {
const Operator* CallConstruct(int arguments);
const Operator* LoadProperty(const VectorSlotPair& feedback,
LanguageMode language_mode);
const Operator* LoadNamed(const Handle<Name>& name,
const VectorSlotPair& feedback,
LanguageMode language_mode);
const Operator* LoadProperty(LanguageMode language_mode,
VectorSlotPair const& feedback);
const Operator* LoadNamed(LanguageMode language_mode, Handle<Name> name,
VectorSlotPair const& feedback);
const Operator* StoreProperty(LanguageMode language_mode,
const VectorSlotPair& feedback);
const Operator* StoreNamed(LanguageMode language_mode,
const Handle<Name>& name,
const VectorSlotPair& feedback);
VectorSlotPair const& feedback);
const Operator* StoreNamed(LanguageMode language_mode, Handle<Name> name,
VectorSlotPair const& feedback);
const Operator* DeleteProperty(LanguageMode language_mode);
......
......@@ -39,7 +39,7 @@ Reduction JSTypeFeedbackLowering::ReduceJSLoadNamed(Node* node) {
Node* control = NodeProperties::GetControlInput(node);
// We need to make optimistic assumptions to continue.
if (!(flags() & kDeoptimizationEnabled)) return NoChange();
LoadNamedParameters const& p = LoadNamedParametersOf(node->op());
NamedAccess const& p = NamedAccessOf(node->op());
if (!p.feedback().IsValid()) return NoChange(); // No feedback.
if (p.name().is_identical_to(factory()->length_string())) {
LoadICNexus nexus(p.feedback().vector(), p.feedback().slot());
......
......@@ -145,7 +145,7 @@ Reduction JSTypeFeedbackSpecializer::ReduceJSLoadNamed(Node* node) {
Node* frame_state_before = GetFrameStateBefore(node);
if (frame_state_before == nullptr) return NoChange();
const LoadNamedParameters& p = LoadNamedParametersOf(node->op());
NamedAccess const& p = NamedAccessOf(node->op());
SmallMapList maps;
FeedbackVectorSlot slot = js_type_feedback_->FindFeedbackVectorSlot(node);
......@@ -255,7 +255,7 @@ Reduction JSTypeFeedbackSpecializer::ReduceJSStoreNamed(Node* node) {
Node* frame_state_before = GetFrameStateBefore(node);
if (frame_state_before == nullptr) return NoChange();
const StoreNamedParameters& p = StoreNamedParametersOf(node->op());
NamedAccess const& p = NamedAccessOf(node->op());
SmallMapList maps;
TypeFeedbackId id = js_type_feedback_->FindTypeFeedbackId(node);
if (id.IsNone() || oracle()->StoreIsUninitialized(id) == UNINITIALIZED) {
......
......@@ -826,7 +826,7 @@ Reduction JSTypedLowering::ReduceJSLoadNamed(Node* node) {
Type* receiver_type = NodeProperties::GetType(receiver);
Node* effect = NodeProperties::GetEffectInput(node);
Node* control = NodeProperties::GetControlInput(node);
Handle<Name> name = LoadNamedParametersOf(node->op()).name();
Handle<Name> name = NamedAccessOf(node->op()).name();
// Optimize "length" property of strings.
if (name.is_identical_to(factory()->length_string()) &&
receiver_type->Is(Type::String())) {
......
......@@ -661,7 +661,7 @@ TEST_F(JSTypedLoweringTest, JSLoadPropertyFromExternalTypedArray) {
Node* effect = graph()->start();
Node* control = graph()->start();
Reduction r = Reduce(
graph()->NewNode(javascript()->LoadProperty(feedback, language_mode),
graph()->NewNode(javascript()->LoadProperty(language_mode, feedback),
base, key, vector, context, EmptyFrameState(),
EmptyFrameState(), effect, control));
......@@ -705,7 +705,7 @@ TEST_F(JSTypedLoweringTest, JSLoadPropertyFromExternalTypedArrayWithSafeKey) {
Node* effect = graph()->start();
Node* control = graph()->start();
Reduction r = Reduce(
graph()->NewNode(javascript()->LoadProperty(feedback, language_mode),
graph()->NewNode(javascript()->LoadProperty(language_mode, feedback),
base, key, vector, context, EmptyFrameState(),
EmptyFrameState(), effect, control));
......@@ -877,7 +877,7 @@ TEST_F(JSTypedLoweringTest, JSLoadNamedStringLength) {
Node* const control = graph()->start();
TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) {
Reduction const r = Reduce(
graph()->NewNode(javascript()->LoadNamed(name, feedback, language_mode),
graph()->NewNode(javascript()->LoadNamed(language_mode, name, feedback),
receiver, vector, context, EmptyFrameState(),
EmptyFrameState(), effect, control));
ASSERT_TRUE(r.Changed());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment