Commit 5f11a5fa authored by bmeurer's avatar bmeurer Committed by Commit bot

[turbofan] Don't mix up name/property accesses.

R=mstarzinger@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#28575}
parent 4c2690a4
......@@ -353,11 +353,8 @@ void JSGenericLowering::LowerJSLoadProperty(Node* node) {
void JSGenericLowering::LowerJSLoadNamed(Node* node) {
CallDescriptor::Flags flags = AdjustFrameStatesForCall(node);
const LoadNamedParameters& p = LoadNamedParametersOf(node->op());
Callable callable =
p.load_ic() == NAMED
? CodeFactory::LoadICInOptimizedCode(isolate(), p.contextual_mode(),
UNINITIALIZED)
: CodeFactory::KeyedLoadICInOptimizedCode(isolate(), UNINITIALIZED);
Callable callable = CodeFactory::LoadICInOptimizedCode(
isolate(), p.contextual_mode(), UNINITIALIZED);
node->InsertInput(zone(), 1, jsgraph()->HeapConstant(p.name()));
node->InsertInput(zone(), 2, jsgraph()->SmiConstant(p.feedback().index()));
node->InsertInput(zone(), 3, jsgraph()->HeapConstant(p.feedback().vector()));
......@@ -379,10 +376,7 @@ void JSGenericLowering::LowerJSStoreProperty(Node* node) {
void JSGenericLowering::LowerJSStoreNamed(Node* node) {
CallDescriptor::Flags flags = AdjustFrameStatesForCall(node);
const StoreNamedParameters& p = StoreNamedParametersOf(node->op());
Callable callable = p.store_ic() == NAMED
? CodeFactory::StoreIC(isolate(), p.language_mode())
: CodeFactory::KeyedStoreICInOptimizedCode(
isolate(), p.language_mode(), UNINITIALIZED);
Callable callable = CodeFactory::StoreIC(isolate(), p.language_mode());
node->InsertInput(zone(), 1, jsgraph()->HeapConstant(p.name()));
ReplaceWithStubCall(node, callable,
CallDescriptor::kPatchableCallSite | flags);
......
......@@ -372,9 +372,8 @@ const Operator* JSOperatorBuilder::CallConstruct(int arguments) {
const Operator* JSOperatorBuilder::LoadNamed(const Unique<Name>& name,
const VectorSlotPair& feedback,
ContextualMode contextual_mode,
PropertyICMode load_ic) {
LoadNamedParameters parameters(name, feedback, contextual_mode, load_ic);
ContextualMode contextual_mode) {
LoadNamedParameters parameters(name, feedback, contextual_mode);
return new (zone()) Operator1<LoadNamedParameters>( // --
IrOpcode::kJSLoadNamed, Operator::kNoProperties, // opcode
"JSLoadNamed", // name
......@@ -395,9 +394,8 @@ const Operator* JSOperatorBuilder::LoadProperty(
const Operator* JSOperatorBuilder::StoreNamed(LanguageMode language_mode,
const Unique<Name>& name,
PropertyICMode store_ic) {
StoreNamedParameters parameters(language_mode, name, store_ic);
const Unique<Name>& name) {
StoreNamedParameters parameters(language_mode, name);
return new (zone()) Operator1<StoreNamedParameters>( // --
IrOpcode::kJSStoreNamed, Operator::kNoProperties, // opcode
"JSStoreNamed", // name
......
......@@ -131,26 +131,16 @@ class VectorSlotPair {
bool operator==(VectorSlotPair const& lhs, VectorSlotPair const& rhs);
// For (Load|Store)Named operators, the mode of the IC that needs
// to be called. This is needed because (Load|Store)Property nodes can be
// reduced to named versions, but still need to call the correct original
// IC mode because of the layout of feedback vectors.
enum PropertyICMode { NAMED, KEYED };
// Defines the property being loaded from an object by a named load. This is
// used as a parameter by JSLoadNamed operators.
class LoadNamedParameters final {
public:
LoadNamedParameters(const Unique<Name>& name, const VectorSlotPair& feedback,
ContextualMode contextual_mode, PropertyICMode load_ic)
: name_(name),
feedback_(feedback),
contextual_mode_(contextual_mode),
load_ic_(load_ic) {}
ContextualMode contextual_mode)
: name_(name), feedback_(feedback), contextual_mode_(contextual_mode) {}
const Unique<Name>& name() const { return name_; }
ContextualMode contextual_mode() const { return contextual_mode_; }
PropertyICMode load_ic() const { return load_ic_; }
const VectorSlotPair& feedback() const { return feedback_; }
......@@ -158,7 +148,6 @@ class LoadNamedParameters final {
const Unique<Name> name_;
const VectorSlotPair feedback_;
const ContextualMode contextual_mode_;
const PropertyICMode load_ic_;
};
bool operator==(LoadNamedParameters const&, LoadNamedParameters const&);
......@@ -198,18 +187,15 @@ 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,
PropertyICMode store_ic)
: language_mode_(language_mode), name_(name), store_ic_(store_ic) {}
StoreNamedParameters(LanguageMode language_mode, const Unique<Name>& name)
: language_mode_(language_mode), name_(name) {}
LanguageMode language_mode() const { return language_mode_; }
const Unique<Name>& name() const { return name_; }
PropertyICMode store_ic() const { return store_ic_; }
private:
const LanguageMode language_mode_;
const Unique<Name> name_;
const PropertyICMode store_ic_;
};
bool operator==(StoreNamedParameters const&, StoreNamedParameters const&);
......@@ -298,13 +284,11 @@ class JSOperatorBuilder final : public ZoneObject {
const Operator* LoadProperty(const VectorSlotPair& feedback);
const Operator* LoadNamed(const Unique<Name>& name,
const VectorSlotPair& feedback,
ContextualMode contextual_mode = NOT_CONTEXTUAL,
PropertyICMode load_ic = NAMED);
ContextualMode contextual_mode = NOT_CONTEXTUAL);
const Operator* StoreProperty(LanguageMode language_mode);
const Operator* StoreNamed(LanguageMode language_mode,
const Unique<Name>& name,
PropertyICMode store_ic = NAMED);
const Unique<Name>& name);
const Operator* DeleteProperty(LanguageMode language_mode);
......
......@@ -48,37 +48,14 @@ void JSTypeFeedbackTable::Record(Node* node, FeedbackVectorICSlot slot) {
Reduction JSTypeFeedbackSpecializer::Reduce(Node* node) {
switch (node->opcode()) {
case IrOpcode::kJSLoadProperty: {
HeapObjectMatcher<Name> match(node->InputAt(1));
if (match.HasValue() && match.Value().handle()->IsName()) {
// LoadProperty(o, "constant") => LoadNamed["constant"](o).
Unique<Name> name = match.Value();
const VectorSlotPair& feedback =
LoadPropertyParametersOf(node->op()).feedback();
node->set_op(jsgraph()->javascript()->LoadNamed(name, feedback,
NOT_CONTEXTUAL, KEYED));
node->RemoveInput(1);
return ReduceJSLoadNamed(node);
}
case IrOpcode::kJSLoadProperty:
return ReduceJSLoadProperty(node);
}
case IrOpcode::kJSLoadNamed:
return ReduceJSLoadNamed(node);
case IrOpcode::kJSStoreNamed:
return ReduceJSStoreNamed(node);
case IrOpcode::kJSStoreProperty: {
HeapObjectMatcher<Name> match(node->InputAt(1));
if (match.HasValue() && match.Value().handle()->IsName()) {
// StoreProperty(o, "constant", v) => StoreNamed["constant"](o, v).
Unique<Name> name = match.Value();
LanguageMode language_mode = OpParameter<LanguageMode>(node);
node->set_op(
jsgraph()->javascript()->StoreNamed(language_mode, name, KEYED));
node->RemoveInput(1);
return ReduceJSStoreNamed(node);
}
case IrOpcode::kJSStoreProperty:
return ReduceJSStoreProperty(node);
}
default:
break;
}
......@@ -187,14 +164,7 @@ Reduction JSTypeFeedbackSpecializer::ReduceJSLoadNamed(Node* node) {
// No type feedback ids or the load is uninitialized.
return NoChange();
}
if (p.load_ic() == NAMED) {
oracle()->PropertyReceiverTypes(slot, name, &maps);
} else {
// The load named was originally a load property.
bool is_string; // Unused.
IcCheckType key_type; // Unused.
oracle()->KeyedPropertyReceiverTypes(slot, &maps, &is_string, &key_type);
}
Node* effect = NodeProperties::GetEffectInput(node);
......@@ -313,14 +283,7 @@ Reduction JSTypeFeedbackSpecializer::ReduceJSStoreNamed(Node* node) {
// TODO(titzer): no feedback from vector ICs from stores.
return NoChange();
} else {
if (p.store_ic() == NAMED) {
oracle()->PropertyReceiverTypes(id, name, &maps);
} else {
// The named store was originally a store property.
bool is_string; // Unused.
IcCheckType key_type; // Unused.
oracle()->KeyedPropertyReceiverTypes(id, &maps, &is_string, &key_type);
}
}
Node* receiver = node->InputAt(0);
......
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