| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/compiler/js-operator.h" | 5 #include "src/compiler/js-operator.h" |
| 6 #include "src/compiler/opcodes.h" | 6 #include "src/compiler/opcodes.h" |
| 7 #include "src/compiler/operator.h" | 7 #include "src/compiler/operator.h" |
| 8 #include "src/compiler/operator-properties.h" | 8 #include "src/compiler/operator-properties.h" |
| 9 #include "test/unittests/test-utils.h" | 9 #include "test/unittests/test-utils.h" |
| 10 | 10 |
| 11 namespace v8 { | 11 namespace v8 { |
| 12 namespace internal { | 12 namespace internal { |
| 13 namespace compiler { | 13 namespace compiler { |
| 14 | 14 |
| 15 namespace { |
| 16 |
| 17 #if GTEST_HAS_COMBINE |
| 18 |
| 19 template <typename T> |
| 20 class JSOperatorTestWithLanguageModeAndParam |
| 21 : public TestWithZone, |
| 22 public ::testing::WithParamInterface<::testing::tuple<LanguageMode, T>> { |
| 23 protected: |
| 24 LanguageMode language_mode() const { |
| 25 return ::testing::get<0>(B::GetParam()); |
| 26 } |
| 27 const T& GetParam() const { return ::testing::get<1>(B::GetParam()); } |
| 28 |
| 29 private: |
| 30 typedef ::testing::WithParamInterface<::testing::tuple<LanguageMode, T>> B; |
| 31 }; |
| 32 |
| 33 #endif // GTEST_HAS_COMBINE |
| 34 |
| 35 } // namespace |
| 36 |
| 37 |
| 38 // ----------------------------------------------------------------------------- |
| 39 // Shared operators without language mode. |
| 15 | 40 |
| 16 namespace { | 41 namespace { |
| 17 | 42 |
| 18 typedef const Operator* (JSOperatorBuilder::*no_params_t) () ; | |
| 19 | |
| 20 typedef const Operator* (JSOperatorBuilder::*with_language_mode_t) | |
| 21 (LanguageMode language_mode) ; | |
| 22 | |
| 23 | |
| 24 template <typename T> | |
| 25 struct SharedOperator { | 43 struct SharedOperator { |
| 26 T constructor; | 44 const Operator* (JSOperatorBuilder::*constructor)(); |
| 27 IrOpcode::Value opcode; | 45 IrOpcode::Value opcode; |
| 28 Operator::Properties properties; | 46 Operator::Properties properties; |
| 29 int value_input_count; | 47 int value_input_count; |
| 30 int frame_state_input_count; | 48 int frame_state_input_count; |
| 31 int effect_input_count; | 49 int effect_input_count; |
| 32 int control_input_count; | 50 int control_input_count; |
| 33 int value_output_count; | 51 int value_output_count; |
| 34 int effect_output_count; | 52 int effect_output_count; |
| 35 int control_output_count; | 53 int control_output_count; |
| 36 }; | 54 }; |
| 37 | 55 |
| 38 | 56 |
| 39 const SharedOperator<no_params_t> kSharedOperators[] = { | 57 const SharedOperator kSharedOperators[] = { |
| 40 #define SHARED(Name, properties, value_input_count, frame_state_input_count, \ | 58 #define SHARED(Name, properties, value_input_count, frame_state_input_count, \ |
| 41 effect_input_count, control_input_count, value_output_count, \ | 59 effect_input_count, control_input_count, value_output_count, \ |
| 42 effect_output_count, control_output_count) \ | 60 effect_output_count, control_output_count) \ |
| 43 { \ | 61 { \ |
| 44 &JSOperatorBuilder::Name, IrOpcode::kJS##Name, properties, \ | 62 &JSOperatorBuilder::Name, IrOpcode::kJS##Name, properties, \ |
| 45 value_input_count, frame_state_input_count, effect_input_count, \ | 63 value_input_count, frame_state_input_count, effect_input_count, \ |
| 46 control_input_count, value_output_count, effect_output_count, \ | 64 control_input_count, value_output_count, effect_output_count, \ |
| 47 control_output_count \ | 65 control_output_count \ |
| 48 } | 66 } |
| 49 SHARED(Equal, Operator::kNoProperties, 2, 1, 1, 1, 1, 1, 2), | 67 SHARED(Equal, Operator::kNoProperties, 2, 1, 1, 1, 1, 1, 2), |
| (...skipping 13 matching lines...) Expand all Loading... |
| 63 SHARED(InstanceOf, Operator::kNoProperties, 2, 1, 1, 1, 1, 1, 2), | 81 SHARED(InstanceOf, Operator::kNoProperties, 2, 1, 1, 1, 1, 1, 2), |
| 64 SHARED(CreateFunctionContext, Operator::kNoProperties, 1, 0, 1, 1, 1, 1, 2), | 82 SHARED(CreateFunctionContext, Operator::kNoProperties, 1, 0, 1, 1, 1, 1, 2), |
| 65 SHARED(CreateWithContext, Operator::kNoProperties, 2, 1, 1, 1, 1, 1, 2), | 83 SHARED(CreateWithContext, Operator::kNoProperties, 2, 1, 1, 1, 1, 1, 2), |
| 66 SHARED(CreateBlockContext, Operator::kNoProperties, 2, 0, 1, 1, 1, 1, 2), | 84 SHARED(CreateBlockContext, Operator::kNoProperties, 2, 0, 1, 1, 1, 1, 2), |
| 67 SHARED(CreateModuleContext, Operator::kNoProperties, 2, 0, 1, 1, 1, 1, 2), | 85 SHARED(CreateModuleContext, Operator::kNoProperties, 2, 0, 1, 1, 1, 1, 2), |
| 68 SHARED(CreateScriptContext, Operator::kNoProperties, 2, 1, 1, 1, 1, 1, 2) | 86 SHARED(CreateScriptContext, Operator::kNoProperties, 2, 1, 1, 1, 1, 1, 2) |
| 69 #undef SHARED | 87 #undef SHARED |
| 70 }; | 88 }; |
| 71 | 89 |
| 72 | 90 |
| 73 const SharedOperator<with_language_mode_t> | 91 std::ostream& operator<<(std::ostream& os, const SharedOperator& sop) { |
| 74 kSharedOperatorsWithlanguageMode[] = { | |
| 75 #define SHARED(Name, properties, value_input_count, frame_state_input_count, \ | |
| 76 effect_input_count, control_input_count, value_output_count, \ | |
| 77 effect_output_count, control_output_count) \ | |
| 78 { \ | |
| 79 &JSOperatorBuilder::Name, IrOpcode::kJS##Name, properties, \ | |
| 80 value_input_count, frame_state_input_count, effect_input_count, \ | |
| 81 control_input_count, value_output_count, effect_output_count, \ | |
| 82 control_output_count \ | |
| 83 } | |
| 84 SHARED(LessThan, Operator::kNoProperties, 2, 1, 1, 1, 1, 1, 2), | |
| 85 SHARED(GreaterThan, Operator::kNoProperties, 2, 1, 1, 1, 1, 1, 2), | |
| 86 SHARED(LessThanOrEqual, Operator::kNoProperties, 2, 1, 1, 1, 1, 1, 2), | |
| 87 SHARED(GreaterThanOrEqual, Operator::kNoProperties, 2, 1, 1, 1, 1, 1, 2), | |
| 88 SHARED(BitwiseOr, Operator::kNoProperties, 2, 2, 1, 1, 1, 1, 2), | |
| 89 SHARED(BitwiseXor, Operator::kNoProperties, 2, 2, 1, 1, 1, 1, 2), | |
| 90 SHARED(BitwiseAnd, Operator::kNoProperties, 2, 2, 1, 1, 1, 1, 2), | |
| 91 SHARED(ShiftLeft, Operator::kNoProperties, 2, 2, 1, 1, 1, 1, 2), | |
| 92 SHARED(ShiftRight, Operator::kNoProperties, 2, 2, 1, 1, 1, 1, 2), | |
| 93 SHARED(ShiftRightLogical, Operator::kNoProperties, 2, 2, 1, 1, 1, 1, 2), | |
| 94 SHARED(Add, Operator::kNoProperties, 2, 2, 1, 1, 1, 1, 2), | |
| 95 SHARED(Subtract, Operator::kNoProperties, 2, 2, 1, 1, 1, 1, 2), | |
| 96 SHARED(Multiply, Operator::kNoProperties, 2, 2, 1, 1, 1, 1, 2), | |
| 97 SHARED(Divide, Operator::kNoProperties, 2, 2, 1, 1, 1, 1, 2), | |
| 98 SHARED(Modulus, Operator::kNoProperties, 2, 2, 1, 1, 1, 1, 2), | |
| 99 #undef SHARED | |
| 100 }; | |
| 101 | |
| 102 | |
| 103 template <typename T> | |
| 104 void testNumberOfInputsAndOutputs(const SharedOperator<T>& sop, | |
| 105 const Operator* op) { | |
| 106 const int context_input_count = 1; | |
| 107 EXPECT_EQ(sop.value_input_count, op->ValueInputCount()); | |
| 108 EXPECT_EQ(context_input_count, OperatorProperties::GetContextInputCount(op)); | |
| 109 EXPECT_EQ(sop.frame_state_input_count, | |
| 110 OperatorProperties::GetFrameStateInputCount(op)); | |
| 111 EXPECT_EQ(sop.effect_input_count, op->EffectInputCount()); | |
| 112 EXPECT_EQ(sop.control_input_count, op->ControlInputCount()); | |
| 113 EXPECT_EQ(sop.value_input_count + context_input_count + | |
| 114 sop.frame_state_input_count + sop.effect_input_count + | |
| 115 sop.control_input_count, | |
| 116 OperatorProperties::GetTotalInputCount(op)); | |
| 117 | |
| 118 EXPECT_EQ(sop.value_output_count, op->ValueOutputCount()); | |
| 119 EXPECT_EQ(sop.effect_output_count, op->EffectOutputCount()); | |
| 120 EXPECT_EQ(sop.control_output_count, op->ControlOutputCount()); | |
| 121 } | |
| 122 | |
| 123 | |
| 124 std::ostream& operator<<(std::ostream& os, | |
| 125 const SharedOperator<no_params_t>& sop) { | |
| 126 return os << IrOpcode::Mnemonic(sop.opcode); | |
| 127 } | |
| 128 | |
| 129 | |
| 130 std::ostream& operator<<(std::ostream& os, | |
| 131 const SharedOperator<with_language_mode_t>& sop) { | |
| 132 return os << IrOpcode::Mnemonic(sop.opcode); | 92 return os << IrOpcode::Mnemonic(sop.opcode); |
| 133 } | 93 } |
| 134 | 94 |
| 135 } // namespace | 95 } // namespace |
| 136 | 96 |
| 137 | 97 |
| 138 // ----------------------------------------------------------------------------- | |
| 139 // Shared operators. | |
| 140 | |
| 141 | |
| 142 class JSSharedOperatorTest | 98 class JSSharedOperatorTest |
| 143 : public TestWithZone, | 99 : public TestWithZone, |
| 144 public ::testing::WithParamInterface<SharedOperator<no_params_t>> {}; | 100 public ::testing::WithParamInterface<SharedOperator> {}; |
| 145 | 101 |
| 146 | 102 |
| 147 TEST_P(JSSharedOperatorTest, InstancesAreGloballyShared) { | 103 TEST_P(JSSharedOperatorTest, InstancesAreGloballyShared) { |
| 148 const SharedOperator<no_params_t>& sop = GetParam(); | 104 const SharedOperator& sop = GetParam(); |
| 149 JSOperatorBuilder javascript1(zone()); | 105 JSOperatorBuilder javascript1(zone()); |
| 150 JSOperatorBuilder javascript2(zone()); | 106 JSOperatorBuilder javascript2(zone()); |
| 151 EXPECT_EQ((javascript1.*sop.constructor)(), (javascript2.*sop.constructor)()); | 107 EXPECT_EQ((javascript1.*sop.constructor)(), (javascript2.*sop.constructor)()); |
| 152 } | 108 } |
| 153 | 109 |
| 154 | 110 |
| 155 TEST_P(JSSharedOperatorTest, NumberOfInputsAndOutputs) { | 111 TEST_P(JSSharedOperatorTest, NumberOfInputsAndOutputs) { |
| 156 JSOperatorBuilder javascript(zone()); | 112 JSOperatorBuilder javascript(zone()); |
| 157 const SharedOperator<no_params_t>& sop = GetParam(); | 113 const SharedOperator& sop = GetParam(); |
| 158 const Operator* op = (javascript.*sop.constructor)(); | 114 const Operator* op = (javascript.*sop.constructor)(); |
| 159 testNumberOfInputsAndOutputs(sop, op); | 115 |
| 116 const int context_input_count = 1; |
| 117 EXPECT_EQ(sop.value_input_count, op->ValueInputCount()); |
| 118 EXPECT_EQ(context_input_count, OperatorProperties::GetContextInputCount(op)); |
| 119 EXPECT_EQ(sop.frame_state_input_count, |
| 120 OperatorProperties::GetFrameStateInputCount(op)); |
| 121 EXPECT_EQ(sop.effect_input_count, op->EffectInputCount()); |
| 122 EXPECT_EQ(sop.control_input_count, op->ControlInputCount()); |
| 123 EXPECT_EQ(sop.value_input_count + context_input_count + |
| 124 sop.frame_state_input_count + sop.effect_input_count + |
| 125 sop.control_input_count, |
| 126 OperatorProperties::GetTotalInputCount(op)); |
| 127 |
| 128 EXPECT_EQ(sop.value_output_count, op->ValueOutputCount()); |
| 129 EXPECT_EQ(sop.effect_output_count, op->EffectOutputCount()); |
| 130 EXPECT_EQ(sop.control_output_count, op->ControlOutputCount()); |
| 160 } | 131 } |
| 161 | 132 |
| 162 | 133 |
| 163 TEST_P(JSSharedOperatorTest, OpcodeIsCorrect) { | 134 TEST_P(JSSharedOperatorTest, OpcodeIsCorrect) { |
| 164 JSOperatorBuilder javascript(zone()); | 135 JSOperatorBuilder javascript(zone()); |
| 165 const SharedOperator<no_params_t>& sop = GetParam(); | 136 const SharedOperator& sop = GetParam(); |
| 166 const Operator* op = (javascript.*sop.constructor)(); | 137 const Operator* op = (javascript.*sop.constructor)(); |
| 167 EXPECT_EQ(sop.opcode, op->opcode()); | 138 EXPECT_EQ(sop.opcode, op->opcode()); |
| 168 } | 139 } |
| 169 | 140 |
| 170 | 141 |
| 171 TEST_P(JSSharedOperatorTest, Properties) { | 142 TEST_P(JSSharedOperatorTest, Properties) { |
| 172 JSOperatorBuilder javascript(zone()); | 143 JSOperatorBuilder javascript(zone()); |
| 173 const SharedOperator<no_params_t>& sop = GetParam(); | 144 const SharedOperator& sop = GetParam(); |
| 174 const Operator* op = (javascript.*sop.constructor)(); | 145 const Operator* op = (javascript.*sop.constructor)(); |
| 175 EXPECT_EQ(sop.properties, op->properties()); | 146 EXPECT_EQ(sop.properties, op->properties()); |
| 176 } | 147 } |
| 177 | 148 |
| 178 | 149 |
| 179 INSTANTIATE_TEST_CASE_P(JSOperatorTest, JSSharedOperatorTest, | 150 INSTANTIATE_TEST_CASE_P(JSOperatorTest, JSSharedOperatorTest, |
| 180 ::testing::ValuesIn(kSharedOperators)); | 151 ::testing::ValuesIn(kSharedOperators)); |
| 181 | 152 |
| 153 |
| 182 // ----------------------------------------------------------------------------- | 154 // ----------------------------------------------------------------------------- |
| 183 // Shared operators which behave differently in strong mode | 155 // Shared operators with language mode. |
| 184 | 156 |
| 185 | 157 |
| 186 class JSSharedOperatorWithStrongTest | 158 #if GTEST_HAS_COMBINE |
| 187 : public TestWithZone, | 159 |
| 188 public ::testing::WithParamInterface< | 160 namespace { |
| 189 SharedOperator<with_language_mode_t>>{}; | 161 |
| 162 const LanguageMode kLanguageModes[] = {SLOPPY, STRICT, STRONG}; |
| 190 | 163 |
| 191 | 164 |
| 192 TEST_P(JSSharedOperatorWithStrongTest, InstancesAreGloballyShared) { | 165 struct SharedOperatorWithLanguageMode { |
| 193 const SharedOperator<with_language_mode_t>& sop = GetParam(); | 166 const Operator* (JSOperatorBuilder::*constructor)(LanguageMode); |
| 167 IrOpcode::Value opcode; |
| 168 Operator::Properties properties; |
| 169 int value_input_count; |
| 170 int frame_state_input_count; |
| 171 int effect_input_count; |
| 172 int control_input_count; |
| 173 int value_output_count; |
| 174 int effect_output_count; |
| 175 int control_output_count; |
| 176 }; |
| 177 |
| 178 |
| 179 const SharedOperatorWithLanguageMode kSharedOperatorsWithLanguageMode[] = { |
| 180 #define SHARED(Name, properties, value_input_count, frame_state_input_count, \ |
| 181 effect_input_count, control_input_count, value_output_count, \ |
| 182 effect_output_count, control_output_count) \ |
| 183 { \ |
| 184 &JSOperatorBuilder::Name, IrOpcode::kJS##Name, properties, \ |
| 185 value_input_count, frame_state_input_count, effect_input_count, \ |
| 186 control_input_count, value_output_count, effect_output_count, \ |
| 187 control_output_count \ |
| 188 } |
| 189 SHARED(LessThan, Operator::kNoProperties, 2, 1, 1, 1, 1, 1, 2), |
| 190 SHARED(GreaterThan, Operator::kNoProperties, 2, 1, 1, 1, 1, 1, 2), |
| 191 SHARED(LessThanOrEqual, Operator::kNoProperties, 2, 1, 1, 1, 1, 1, 2), |
| 192 SHARED(GreaterThanOrEqual, Operator::kNoProperties, 2, 1, 1, 1, 1, 1, 2), |
| 193 SHARED(BitwiseOr, Operator::kNoProperties, 2, 2, 1, 1, 1, 1, 2), |
| 194 SHARED(BitwiseXor, Operator::kNoProperties, 2, 2, 1, 1, 1, 1, 2), |
| 195 SHARED(BitwiseAnd, Operator::kNoProperties, 2, 2, 1, 1, 1, 1, 2), |
| 196 SHARED(ShiftLeft, Operator::kNoProperties, 2, 2, 1, 1, 1, 1, 2), |
| 197 SHARED(ShiftRight, Operator::kNoProperties, 2, 2, 1, 1, 1, 1, 2), |
| 198 SHARED(ShiftRightLogical, Operator::kNoProperties, 2, 2, 1, 1, 1, 1, 2), |
| 199 SHARED(Add, Operator::kNoProperties, 2, 2, 1, 1, 1, 1, 2), |
| 200 SHARED(Subtract, Operator::kNoProperties, 2, 2, 1, 1, 1, 1, 2), |
| 201 SHARED(Multiply, Operator::kNoProperties, 2, 2, 1, 1, 1, 1, 2), |
| 202 SHARED(Divide, Operator::kNoProperties, 2, 2, 1, 1, 1, 1, 2), |
| 203 SHARED(Modulus, Operator::kNoProperties, 2, 2, 1, 1, 1, 1, 2), |
| 204 #undef SHARED |
| 205 }; |
| 206 |
| 207 |
| 208 std::ostream& operator<<(std::ostream& os, |
| 209 const SharedOperatorWithLanguageMode& sop) { |
| 210 return os << IrOpcode::Mnemonic(sop.opcode); |
| 211 } |
| 212 |
| 213 } // namespace |
| 214 |
| 215 |
| 216 class JSSharedOperatorWithLanguageModeTest |
| 217 : public JSOperatorTestWithLanguageModeAndParam< |
| 218 SharedOperatorWithLanguageMode> {}; |
| 219 |
| 220 |
| 221 TEST_P(JSSharedOperatorWithLanguageModeTest, InstancesAreGloballyShared) { |
| 222 const SharedOperatorWithLanguageMode& sop = GetParam(); |
| 194 JSOperatorBuilder javascript1(zone()); | 223 JSOperatorBuilder javascript1(zone()); |
| 195 JSOperatorBuilder javascript2(zone()); | 224 JSOperatorBuilder javascript2(zone()); |
| 196 EXPECT_EQ((javascript1.*sop.constructor)(LanguageMode::SLOPPY), | 225 EXPECT_EQ((javascript1.*sop.constructor)(language_mode()), |
| 197 (javascript2.*sop.constructor)(LanguageMode::SLOPPY)); | 226 (javascript2.*sop.constructor)(language_mode())); |
| 198 EXPECT_EQ((javascript1.*sop.constructor)(LanguageMode::STRONG), | |
| 199 (javascript2.*sop.constructor)(LanguageMode::STRONG)); | |
| 200 } | 227 } |
| 201 | 228 |
| 202 | 229 |
| 203 TEST_P(JSSharedOperatorWithStrongTest, NumberOfInputsAndOutputs) { | 230 TEST_P(JSSharedOperatorWithLanguageModeTest, NumberOfInputsAndOutputs) { |
| 204 JSOperatorBuilder javascript(zone()); | 231 JSOperatorBuilder javascript(zone()); |
| 205 const SharedOperator<with_language_mode_t>& sop = GetParam(); | 232 const SharedOperatorWithLanguageMode& sop = GetParam(); |
| 206 const Operator* op_sloppy = (javascript.*sop.constructor) | 233 const Operator* op = (javascript.*sop.constructor)(language_mode()); |
| 207 (LanguageMode::SLOPPY); | 234 |
| 208 testNumberOfInputsAndOutputs(sop, op_sloppy); | 235 const int context_input_count = 1; |
| 209 const Operator* op_strong = (javascript.*sop.constructor) | 236 EXPECT_EQ(sop.value_input_count, op->ValueInputCount()); |
| 210 (LanguageMode::STRONG); | 237 EXPECT_EQ(context_input_count, OperatorProperties::GetContextInputCount(op)); |
| 211 testNumberOfInputsAndOutputs(sop, op_strong); | 238 EXPECT_EQ(sop.frame_state_input_count, |
| 239 OperatorProperties::GetFrameStateInputCount(op)); |
| 240 EXPECT_EQ(sop.effect_input_count, op->EffectInputCount()); |
| 241 EXPECT_EQ(sop.control_input_count, op->ControlInputCount()); |
| 242 EXPECT_EQ(sop.value_input_count + context_input_count + |
| 243 sop.frame_state_input_count + sop.effect_input_count + |
| 244 sop.control_input_count, |
| 245 OperatorProperties::GetTotalInputCount(op)); |
| 246 |
| 247 EXPECT_EQ(sop.value_output_count, op->ValueOutputCount()); |
| 248 EXPECT_EQ(sop.effect_output_count, op->EffectOutputCount()); |
| 249 EXPECT_EQ(sop.control_output_count, op->ControlOutputCount()); |
| 212 } | 250 } |
| 213 | 251 |
| 214 | 252 |
| 215 TEST_P(JSSharedOperatorWithStrongTest, OpcodeIsCorrect) { | 253 TEST_P(JSSharedOperatorWithLanguageModeTest, OpcodeIsCorrect) { |
| 216 JSOperatorBuilder javascript(zone()); | 254 JSOperatorBuilder javascript(zone()); |
| 217 const SharedOperator<with_language_mode_t>& sop = GetParam(); | 255 const SharedOperatorWithLanguageMode& sop = GetParam(); |
| 218 const Operator* op_sloppy = (javascript.*sop.constructor) | 256 const Operator* op = (javascript.*sop.constructor)(language_mode()); |
| 219 (LanguageMode::SLOPPY); | 257 EXPECT_EQ(sop.opcode, op->opcode()); |
| 220 EXPECT_EQ(sop.opcode, op_sloppy->opcode()); | |
| 221 const Operator* op_strong = (javascript.*sop.constructor) | |
| 222 (LanguageMode::STRONG); | |
| 223 EXPECT_EQ(sop.opcode, op_strong->opcode()); | |
| 224 } | 258 } |
| 225 | 259 |
| 226 | 260 |
| 227 TEST_P(JSSharedOperatorWithStrongTest, Properties) { | 261 TEST_P(JSSharedOperatorWithLanguageModeTest, Parameter) { |
| 228 JSOperatorBuilder javascript(zone()); | 262 JSOperatorBuilder javascript(zone()); |
| 229 const SharedOperator<with_language_mode_t>& sop = GetParam(); | 263 const SharedOperatorWithLanguageMode& sop = GetParam(); |
| 230 const Operator* op_sloppy = (javascript.*sop.constructor) | 264 const Operator* op = (javascript.*sop.constructor)(language_mode()); |
| 231 (LanguageMode::SLOPPY); | 265 EXPECT_EQ(language_mode(), OpParameter<LanguageMode>(op)); |
| 232 EXPECT_EQ(sop.properties, op_sloppy->properties()); | |
| 233 const Operator* op_strong = (javascript.*sop.constructor) | |
| 234 (LanguageMode::STRONG); | |
| 235 EXPECT_EQ(sop.properties, op_strong->properties()); | |
| 236 } | 266 } |
| 237 | 267 |
| 238 | 268 |
| 239 INSTANTIATE_TEST_CASE_P(JSOperatorTest, JSSharedOperatorWithStrongTest, | 269 TEST_P(JSSharedOperatorWithLanguageModeTest, Properties) { |
| 240 ::testing::ValuesIn(kSharedOperatorsWithlanguageMode)); | 270 JSOperatorBuilder javascript(zone()); |
| 271 const SharedOperatorWithLanguageMode& sop = GetParam(); |
| 272 const Operator* op = (javascript.*sop.constructor)(language_mode()); |
| 273 EXPECT_EQ(sop.properties, op->properties()); |
| 274 } |
| 275 |
| 276 |
| 277 INSTANTIATE_TEST_CASE_P( |
| 278 JSOperatorTest, JSSharedOperatorWithLanguageModeTest, |
| 279 ::testing::Combine(::testing::ValuesIn(kLanguageModes), |
| 280 ::testing::ValuesIn(kSharedOperatorsWithLanguageMode))); |
| 281 |
| 282 #endif // GTEST_HAS_COMBINE |
| 283 |
| 241 | 284 |
| 242 // ----------------------------------------------------------------------------- | 285 // ----------------------------------------------------------------------------- |
| 243 // JSStoreProperty. | 286 // JSStoreProperty. |
| 244 | 287 |
| 245 | 288 |
| 246 class JSStorePropertyOperatorTest | 289 class JSStorePropertyOperatorTest |
| 247 : public TestWithZone, | 290 : public TestWithZone, |
| 248 public ::testing::WithParamInterface<LanguageMode> {}; | 291 public ::testing::WithParamInterface<LanguageMode> {}; |
| 249 | 292 |
| 250 | 293 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 EXPECT_EQ(Operator::kNoProperties, op->properties()); | 340 EXPECT_EQ(Operator::kNoProperties, op->properties()); |
| 298 } | 341 } |
| 299 | 342 |
| 300 | 343 |
| 301 INSTANTIATE_TEST_CASE_P(JSOperatorTest, JSStorePropertyOperatorTest, | 344 INSTANTIATE_TEST_CASE_P(JSOperatorTest, JSStorePropertyOperatorTest, |
| 302 ::testing::Values(SLOPPY, STRICT)); | 345 ::testing::Values(SLOPPY, STRICT)); |
| 303 | 346 |
| 304 } // namespace compiler | 347 } // namespace compiler |
| 305 } // namespace internal | 348 } // namespace internal |
| 306 } // namespace v8 | 349 } // namespace v8 |
| OLD | NEW |