Commit a94a6122 authored by Benedikt Meurer's avatar Benedikt Meurer

[turbofan] Cache the JSStoreProperty operator(s).

TEST=unittests
R=dcarney@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#25609}
parent 71d166ee
......@@ -259,6 +259,16 @@ struct JSOperatorGlobalCache FINAL {
Name##Operator k##Name##Operator;
CACHED_OP_LIST(CACHED)
#undef CACHED
template <StrictMode kStrictMode>
struct StorePropertyOperator FINAL : public Operator1<StrictMode> {
StorePropertyOperator()
: Operator1<StrictMode>(IrOpcode::kJSStoreProperty,
Operator::kNoProperties, "JSStoreProperty", 3,
1, 1, 0, 1, 0, kStrictMode) {}
};
StorePropertyOperator<SLOPPY> kStorePropertySloppyOperator;
StorePropertyOperator<STRICT> kStorePropertyStrictOperator;
};
......@@ -335,11 +345,14 @@ const Operator* JSOperatorBuilder::LoadProperty(
const Operator* JSOperatorBuilder::StoreProperty(StrictMode strict_mode) {
return new (zone()) Operator1<StrictMode>( // --
IrOpcode::kJSStoreProperty, Operator::kNoProperties, // opcode
"JSStoreProperty", // name
3, 1, 1, 0, 1, 0, // counts
strict_mode); // parameter
switch (strict_mode) {
case SLOPPY:
return &cache_.kStorePropertySloppyOperator;
case STRICT:
return &cache_.kStorePropertyStrictOperator;
}
UNREACHABLE();
return nullptr;
}
......
......@@ -13,6 +13,7 @@ namespace compiler {
// -----------------------------------------------------------------------------
// Shared operators.
namespace {
struct SharedOperator {
......@@ -142,6 +143,73 @@ TEST_P(JSSharedOperatorTest, Properties) {
INSTANTIATE_TEST_CASE_P(JSOperatorTest, JSSharedOperatorTest,
::testing::ValuesIn(kSharedOperators));
// -----------------------------------------------------------------------------
// JSStoreProperty.
class JSStorePropertyOperatorTest
: public TestWithZone,
public ::testing::WithParamInterface<StrictMode> {};
TEST_P(JSStorePropertyOperatorTest, InstancesAreGloballyShared) {
const StrictMode mode = GetParam();
JSOperatorBuilder javascript1(zone());
JSOperatorBuilder javascript2(zone());
EXPECT_EQ(javascript1.StoreProperty(mode), javascript2.StoreProperty(mode));
}
TEST_P(JSStorePropertyOperatorTest, NumberOfInputsAndOutputs) {
JSOperatorBuilder javascript(zone());
const StrictMode mode = GetParam();
const Operator* op = javascript.StoreProperty(mode);
// TODO(jarin): Get rid of this hack.
const int frame_state_input_count = FLAG_turbo_deoptimization ? 1 : 0;
EXPECT_EQ(3, op->ValueInputCount());
EXPECT_EQ(1, OperatorProperties::GetContextInputCount(op));
EXPECT_EQ(frame_state_input_count,
OperatorProperties::GetFrameStateInputCount(op));
EXPECT_EQ(1, op->EffectInputCount());
EXPECT_EQ(1, op->ControlInputCount());
EXPECT_EQ(6 + frame_state_input_count,
OperatorProperties::GetTotalInputCount(op));
EXPECT_EQ(0, op->ValueOutputCount());
EXPECT_EQ(1, op->EffectOutputCount());
EXPECT_EQ(0, op->ControlOutputCount());
}
TEST_P(JSStorePropertyOperatorTest, OpcodeIsCorrect) {
JSOperatorBuilder javascript(zone());
const StrictMode mode = GetParam();
const Operator* op = javascript.StoreProperty(mode);
EXPECT_EQ(IrOpcode::kJSStoreProperty, op->opcode());
}
TEST_P(JSStorePropertyOperatorTest, OpParameter) {
JSOperatorBuilder javascript(zone());
const StrictMode mode = GetParam();
const Operator* op = javascript.StoreProperty(mode);
EXPECT_EQ(mode, OpParameter<StrictMode>(op));
}
TEST_P(JSStorePropertyOperatorTest, Properties) {
JSOperatorBuilder javascript(zone());
const StrictMode mode = GetParam();
const Operator* op = javascript.StoreProperty(mode);
EXPECT_EQ(Operator::kNoProperties, op->properties());
}
INSTANTIATE_TEST_CASE_P(JSOperatorTest, JSStorePropertyOperatorTest,
::testing::Values(SLOPPY, STRICT));
} // namespace compiler
} // namespace internal
} // namespace v8
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