Commit ecf499ef authored by Benedikt Meurer's avatar Benedikt Meurer

[turbofan] Sanitize language mode for JSStoreProperty operator.

R=mstarzinger@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#28061}
parent 3383f628
......@@ -263,22 +263,23 @@ const CreateClosureParameters& CreateClosureParametersOf(const Operator* op) {
V(CreateScriptContext, Operator::kNoProperties, 2, 1)
#define CACHED_OP_LIST_WITH_LANGUAGE_MODE(V) \
V(LessThan, Operator::kNoProperties, 2, 1) \
V(GreaterThan, Operator::kNoProperties, 2, 1) \
V(LessThanOrEqual, Operator::kNoProperties, 2, 1) \
V(GreaterThanOrEqual, Operator::kNoProperties, 2, 1) \
V(BitwiseOr, Operator::kNoProperties, 2, 1) \
V(BitwiseXor, Operator::kNoProperties, 2, 1) \
V(BitwiseAnd, Operator::kNoProperties, 2, 1) \
V(ShiftLeft, Operator::kNoProperties, 2, 1) \
V(ShiftRight, Operator::kNoProperties, 2, 1) \
V(ShiftRightLogical, Operator::kNoProperties, 2, 1) \
V(Add, Operator::kNoProperties, 2, 1) \
V(Subtract, Operator::kNoProperties, 2, 1) \
V(Multiply, Operator::kNoProperties, 2, 1) \
V(Divide, Operator::kNoProperties, 2, 1) \
V(Modulus, Operator::kNoProperties, 2, 1)
#define CACHED_OP_LIST_WITH_LANGUAGE_MODE(V) \
V(LessThan, Operator::kNoProperties, 2, 1) \
V(GreaterThan, Operator::kNoProperties, 2, 1) \
V(LessThanOrEqual, Operator::kNoProperties, 2, 1) \
V(GreaterThanOrEqual, Operator::kNoProperties, 2, 1) \
V(BitwiseOr, Operator::kNoProperties, 2, 1) \
V(BitwiseXor, Operator::kNoProperties, 2, 1) \
V(BitwiseAnd, Operator::kNoProperties, 2, 1) \
V(ShiftLeft, Operator::kNoProperties, 2, 1) \
V(ShiftRight, Operator::kNoProperties, 2, 1) \
V(ShiftRightLogical, Operator::kNoProperties, 2, 1) \
V(Add, Operator::kNoProperties, 2, 1) \
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)
struct JSOperatorGlobalCache final {
......@@ -313,17 +314,6 @@ struct JSOperatorGlobalCache final {
Name##Operator<STRONG> k##Name##StrongOperator;
CACHED_OP_LIST_WITH_LANGUAGE_MODE(CACHED_WITH_LANGUAGE_MODE)
#undef CACHED_WITH_LANGUAGE_MODE
template <LanguageMode kLanguageMode>
struct StorePropertyOperator final : public Operator1<LanguageMode> {
StorePropertyOperator()
: Operator1<LanguageMode>(IrOpcode::kJSStoreProperty,
Operator::kNoProperties, "JSStoreProperty", 3,
1, 1, 0, 1, 2, kLanguageMode) {}
};
StorePropertyOperator<SLOPPY> kStorePropertySloppyOperator;
StorePropertyOperator<STRICT> kStorePropertyStrictOperator;
};
......@@ -420,17 +410,6 @@ const Operator* JSOperatorBuilder::LoadProperty(
}
const Operator* JSOperatorBuilder::StoreProperty(LanguageMode language_mode) {
if (is_strict(language_mode)) {
return &cache_.kStorePropertyStrictOperator;
} else {
return &cache_.kStorePropertySloppyOperator;
}
UNREACHABLE();
return nullptr;
}
const Operator* JSOperatorBuilder::StoreNamed(LanguageMode language_mode,
const Unique<Name>& name,
PropertyICMode store_ic) {
......
......@@ -14,6 +14,9 @@ namespace compiler {
namespace {
const LanguageMode kLanguageModes[] = {SLOPPY, STRICT, STRONG};
#if GTEST_HAS_COMBINE
template <typename T>
......@@ -159,9 +162,6 @@ INSTANTIATE_TEST_CASE_P(JSOperatorTest, JSSharedOperatorTest,
namespace {
const LanguageMode kLanguageModes[] = {SLOPPY, STRICT, STRONG};
struct SharedOperatorWithLanguageMode {
const Operator* (JSOperatorBuilder::*constructor)(LanguageMode);
IrOpcode::Value opcode;
......@@ -201,6 +201,7 @@ 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
};
......@@ -281,69 +282,6 @@ INSTANTIATE_TEST_CASE_P(
#endif // GTEST_HAS_COMBINE
// -----------------------------------------------------------------------------
// JSStoreProperty.
class JSStorePropertyOperatorTest
: public TestWithZone,
public ::testing::WithParamInterface<LanguageMode> {};
TEST_P(JSStorePropertyOperatorTest, InstancesAreGloballyShared) {
const LanguageMode mode = GetParam();
JSOperatorBuilder javascript1(zone());
JSOperatorBuilder javascript2(zone());
EXPECT_EQ(javascript1.StoreProperty(mode), javascript2.StoreProperty(mode));
}
TEST_P(JSStorePropertyOperatorTest, NumberOfInputsAndOutputs) {
JSOperatorBuilder javascript(zone());
const LanguageMode mode = GetParam();
const Operator* op = javascript.StoreProperty(mode);
EXPECT_EQ(3, op->ValueInputCount());
EXPECT_EQ(1, OperatorProperties::GetContextInputCount(op));
EXPECT_EQ(2, OperatorProperties::GetFrameStateInputCount(op));
EXPECT_EQ(1, op->EffectInputCount());
EXPECT_EQ(1, op->ControlInputCount());
EXPECT_EQ(8, OperatorProperties::GetTotalInputCount(op));
EXPECT_EQ(0, op->ValueOutputCount());
EXPECT_EQ(1, op->EffectOutputCount());
EXPECT_EQ(2, op->ControlOutputCount());
}
TEST_P(JSStorePropertyOperatorTest, OpcodeIsCorrect) {
JSOperatorBuilder javascript(zone());
const LanguageMode mode = GetParam();
const Operator* op = javascript.StoreProperty(mode);
EXPECT_EQ(IrOpcode::kJSStoreProperty, op->opcode());
}
TEST_P(JSStorePropertyOperatorTest, OpParameter) {
JSOperatorBuilder javascript(zone());
const LanguageMode mode = GetParam();
const Operator* op = javascript.StoreProperty(mode);
EXPECT_EQ(mode, OpParameter<LanguageMode>(op));
}
TEST_P(JSStorePropertyOperatorTest, Properties) {
JSOperatorBuilder javascript(zone());
const LanguageMode 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