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 { | 15 namespace { |
16 | 16 |
| 17 const LanguageMode kLanguageModes[] = {SLOPPY, STRICT, STRONG}; |
| 18 |
| 19 |
17 #if GTEST_HAS_COMBINE | 20 #if GTEST_HAS_COMBINE |
18 | 21 |
19 template <typename T> | 22 template <typename T> |
20 class JSOperatorTestWithLanguageModeAndParam | 23 class JSOperatorTestWithLanguageModeAndParam |
21 : public TestWithZone, | 24 : public TestWithZone, |
22 public ::testing::WithParamInterface<::testing::tuple<LanguageMode, T>> { | 25 public ::testing::WithParamInterface<::testing::tuple<LanguageMode, T>> { |
23 protected: | 26 protected: |
24 LanguageMode language_mode() const { | 27 LanguageMode language_mode() const { |
25 return ::testing::get<0>(B::GetParam()); | 28 return ::testing::get<0>(B::GetParam()); |
26 } | 29 } |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 | 155 |
153 | 156 |
154 // ----------------------------------------------------------------------------- | 157 // ----------------------------------------------------------------------------- |
155 // Shared operators with language mode. | 158 // Shared operators with language mode. |
156 | 159 |
157 | 160 |
158 #if GTEST_HAS_COMBINE | 161 #if GTEST_HAS_COMBINE |
159 | 162 |
160 namespace { | 163 namespace { |
161 | 164 |
162 const LanguageMode kLanguageModes[] = {SLOPPY, STRICT, STRONG}; | |
163 | |
164 | |
165 struct SharedOperatorWithLanguageMode { | 165 struct SharedOperatorWithLanguageMode { |
166 const Operator* (JSOperatorBuilder::*constructor)(LanguageMode); | 166 const Operator* (JSOperatorBuilder::*constructor)(LanguageMode); |
167 IrOpcode::Value opcode; | 167 IrOpcode::Value opcode; |
168 Operator::Properties properties; | 168 Operator::Properties properties; |
169 int value_input_count; | 169 int value_input_count; |
170 int frame_state_input_count; | 170 int frame_state_input_count; |
171 int effect_input_count; | 171 int effect_input_count; |
172 int control_input_count; | 172 int control_input_count; |
173 int value_output_count; | 173 int value_output_count; |
174 int effect_output_count; | 174 int effect_output_count; |
(...skipping 19 matching lines...) Expand all Loading... |
194 SHARED(BitwiseXor, 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), | 195 SHARED(BitwiseAnd, Operator::kNoProperties, 2, 2, 1, 1, 1, 1, 2), |
196 SHARED(ShiftLeft, 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), | 197 SHARED(ShiftRight, Operator::kNoProperties, 2, 2, 1, 1, 1, 1, 2), |
198 SHARED(ShiftRightLogical, 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), | 199 SHARED(Add, Operator::kNoProperties, 2, 2, 1, 1, 1, 1, 2), |
200 SHARED(Subtract, 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), | 201 SHARED(Multiply, Operator::kNoProperties, 2, 2, 1, 1, 1, 1, 2), |
202 SHARED(Divide, 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), | 203 SHARED(Modulus, Operator::kNoProperties, 2, 2, 1, 1, 1, 1, 2), |
| 204 SHARED(StoreProperty, Operator::kNoProperties, 3, 2, 1, 1, 0, 1, 2), |
204 #undef SHARED | 205 #undef SHARED |
205 }; | 206 }; |
206 | 207 |
207 | 208 |
208 std::ostream& operator<<(std::ostream& os, | 209 std::ostream& operator<<(std::ostream& os, |
209 const SharedOperatorWithLanguageMode& sop) { | 210 const SharedOperatorWithLanguageMode& sop) { |
210 return os << IrOpcode::Mnemonic(sop.opcode); | 211 return os << IrOpcode::Mnemonic(sop.opcode); |
211 } | 212 } |
212 | 213 |
213 } // namespace | 214 } // namespace |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 } | 275 } |
275 | 276 |
276 | 277 |
277 INSTANTIATE_TEST_CASE_P( | 278 INSTANTIATE_TEST_CASE_P( |
278 JSOperatorTest, JSSharedOperatorWithLanguageModeTest, | 279 JSOperatorTest, JSSharedOperatorWithLanguageModeTest, |
279 ::testing::Combine(::testing::ValuesIn(kLanguageModes), | 280 ::testing::Combine(::testing::ValuesIn(kLanguageModes), |
280 ::testing::ValuesIn(kSharedOperatorsWithLanguageMode))); | 281 ::testing::ValuesIn(kSharedOperatorsWithLanguageMode))); |
281 | 282 |
282 #endif // GTEST_HAS_COMBINE | 283 #endif // GTEST_HAS_COMBINE |
283 | 284 |
284 | |
285 // ----------------------------------------------------------------------------- | |
286 // JSStoreProperty. | |
287 | |
288 | |
289 class JSStorePropertyOperatorTest | |
290 : public TestWithZone, | |
291 public ::testing::WithParamInterface<LanguageMode> {}; | |
292 | |
293 | |
294 TEST_P(JSStorePropertyOperatorTest, InstancesAreGloballyShared) { | |
295 const LanguageMode mode = GetParam(); | |
296 JSOperatorBuilder javascript1(zone()); | |
297 JSOperatorBuilder javascript2(zone()); | |
298 EXPECT_EQ(javascript1.StoreProperty(mode), javascript2.StoreProperty(mode)); | |
299 } | |
300 | |
301 | |
302 TEST_P(JSStorePropertyOperatorTest, NumberOfInputsAndOutputs) { | |
303 JSOperatorBuilder javascript(zone()); | |
304 const LanguageMode mode = GetParam(); | |
305 const Operator* op = javascript.StoreProperty(mode); | |
306 | |
307 EXPECT_EQ(3, op->ValueInputCount()); | |
308 EXPECT_EQ(1, OperatorProperties::GetContextInputCount(op)); | |
309 EXPECT_EQ(2, OperatorProperties::GetFrameStateInputCount(op)); | |
310 EXPECT_EQ(1, op->EffectInputCount()); | |
311 EXPECT_EQ(1, op->ControlInputCount()); | |
312 EXPECT_EQ(8, OperatorProperties::GetTotalInputCount(op)); | |
313 | |
314 EXPECT_EQ(0, op->ValueOutputCount()); | |
315 EXPECT_EQ(1, op->EffectOutputCount()); | |
316 EXPECT_EQ(2, op->ControlOutputCount()); | |
317 } | |
318 | |
319 | |
320 TEST_P(JSStorePropertyOperatorTest, OpcodeIsCorrect) { | |
321 JSOperatorBuilder javascript(zone()); | |
322 const LanguageMode mode = GetParam(); | |
323 const Operator* op = javascript.StoreProperty(mode); | |
324 EXPECT_EQ(IrOpcode::kJSStoreProperty, op->opcode()); | |
325 } | |
326 | |
327 | |
328 TEST_P(JSStorePropertyOperatorTest, OpParameter) { | |
329 JSOperatorBuilder javascript(zone()); | |
330 const LanguageMode mode = GetParam(); | |
331 const Operator* op = javascript.StoreProperty(mode); | |
332 EXPECT_EQ(mode, OpParameter<LanguageMode>(op)); | |
333 } | |
334 | |
335 | |
336 TEST_P(JSStorePropertyOperatorTest, Properties) { | |
337 JSOperatorBuilder javascript(zone()); | |
338 const LanguageMode mode = GetParam(); | |
339 const Operator* op = javascript.StoreProperty(mode); | |
340 EXPECT_EQ(Operator::kNoProperties, op->properties()); | |
341 } | |
342 | |
343 | |
344 INSTANTIATE_TEST_CASE_P(JSOperatorTest, JSStorePropertyOperatorTest, | |
345 ::testing::Values(SLOPPY, STRICT)); | |
346 | |
347 } // namespace compiler | 285 } // namespace compiler |
348 } // namespace internal | 286 } // namespace internal |
349 } // namespace v8 | 287 } // namespace v8 |
OLD | NEW |