OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/access-builder.h" | 5 #include "src/compiler/access-builder.h" |
6 #include "src/compiler/diamond.h" | 6 #include "src/compiler/diamond.h" |
7 #include "src/compiler/js-graph.h" | 7 #include "src/compiler/js-graph.h" |
8 #include "src/compiler/js-intrinsic-lowering.h" | 8 #include "src/compiler/js-intrinsic-lowering.h" |
9 #include "src/compiler/js-operator.h" | 9 #include "src/compiler/js-operator.h" |
10 #include "test/unittests/compiler/graph-unittest.h" | 10 #include "test/unittests/compiler/graph-unittest.h" |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 Reduction const r = Reduce(graph()->NewNode( | 295 Reduction const r = Reduce(graph()->NewNode( |
296 javascript()->CallRuntime(Runtime::kInlineJSValueGetValue, 1), input, | 296 javascript()->CallRuntime(Runtime::kInlineJSValueGetValue, 1), input, |
297 context, effect, control)); | 297 context, effect, control)); |
298 ASSERT_TRUE(r.Changed()); | 298 ASSERT_TRUE(r.Changed()); |
299 EXPECT_THAT(r.replacement(), | 299 EXPECT_THAT(r.replacement(), |
300 IsLoadField(AccessBuilder::ForValue(), input, effect, control)); | 300 IsLoadField(AccessBuilder::ForValue(), input, effect, control)); |
301 } | 301 } |
302 | 302 |
303 | 303 |
304 // ----------------------------------------------------------------------------- | 304 // ----------------------------------------------------------------------------- |
305 // %_Likely | |
306 | |
307 TEST_F(JSIntrinsicLoweringTest, Likely) { | |
308 Node* const input = Parameter(0); | |
309 Node* const context = Parameter(1); | |
310 Node* const effect = graph()->start(); | |
311 Node* const control = graph()->start(); | |
312 Node* const likely = | |
313 graph()->NewNode(javascript()->CallRuntime(Runtime::kInlineLikely, 1), | |
314 input, context, effect, control); | |
315 Node* const to_boolean = | |
316 graph()->NewNode(javascript()->ToBoolean(), likely, context, effect); | |
317 Diamond d(graph(), common(), to_boolean); | |
318 graph()->SetEnd(graph()->NewNode(common()->End(1), d.merge)); | |
319 | |
320 ASSERT_EQ(BranchHint::kNone, BranchHintOf(d.branch->op())); | |
321 Reduction const r = Reduce(likely); | |
322 ASSERT_TRUE(r.Changed()); | |
323 EXPECT_THAT(r.replacement(), input); | |
324 ASSERT_EQ(BranchHint::kTrue, BranchHintOf(d.branch->op())); | |
325 } | |
326 | |
327 | |
328 // ----------------------------------------------------------------------------- | |
329 // %_MathFloor | 305 // %_MathFloor |
330 | 306 |
331 | 307 |
332 TEST_F(JSIntrinsicLoweringTest, InlineMathFloor) { | 308 TEST_F(JSIntrinsicLoweringTest, InlineMathFloor) { |
333 Node* const input = Parameter(0); | 309 Node* const input = Parameter(0); |
334 Node* const context = Parameter(1); | 310 Node* const context = Parameter(1); |
335 Node* const effect = graph()->start(); | 311 Node* const effect = graph()->start(); |
336 Node* const control = graph()->start(); | 312 Node* const control = graph()->start(); |
337 Reduction const r = Reduce( | 313 Reduction const r = Reduce( |
338 graph()->NewNode(javascript()->CallRuntime(Runtime::kInlineMathFloor, 1), | 314 graph()->NewNode(javascript()->CallRuntime(Runtime::kInlineMathFloor, 1), |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 Node* const control = graph()->start(); | 365 Node* const control = graph()->start(); |
390 Reduction const r = Reduce( | 366 Reduction const r = Reduce( |
391 graph()->NewNode(javascript()->CallRuntime(Runtime::kInlineMathClz32, 1), | 367 graph()->NewNode(javascript()->CallRuntime(Runtime::kInlineMathClz32, 1), |
392 input, context, effect, control)); | 368 input, context, effect, control)); |
393 ASSERT_TRUE(r.Changed()); | 369 ASSERT_TRUE(r.Changed()); |
394 EXPECT_THAT(r.replacement(), IsWord32Clz(input)); | 370 EXPECT_THAT(r.replacement(), IsWord32Clz(input)); |
395 } | 371 } |
396 | 372 |
397 | 373 |
398 // ----------------------------------------------------------------------------- | 374 // ----------------------------------------------------------------------------- |
399 // %_Unlikely | |
400 | |
401 TEST_F(JSIntrinsicLoweringTest, Unlikely) { | |
402 Node* const input = Parameter(0); | |
403 Node* const context = Parameter(1); | |
404 Node* const effect = graph()->start(); | |
405 Node* const control = graph()->start(); | |
406 Node* const unlikely = | |
407 graph()->NewNode(javascript()->CallRuntime(Runtime::kInlineUnlikely, 1), | |
408 input, context, effect, control); | |
409 Node* const to_boolean = | |
410 graph()->NewNode(javascript()->ToBoolean(), unlikely, context, effect); | |
411 Diamond d(graph(), common(), to_boolean); | |
412 graph()->SetEnd(graph()->NewNode(common()->End(1), d.merge)); | |
413 | |
414 ASSERT_EQ(BranchHint::kNone, BranchHintOf(d.branch->op())); | |
415 Reduction const r = Reduce(unlikely); | |
416 ASSERT_TRUE(r.Changed()); | |
417 EXPECT_THAT(r.replacement(), input); | |
418 ASSERT_EQ(BranchHint::kFalse, BranchHintOf(d.branch->op())); | |
419 } | |
420 | |
421 | |
422 // ----------------------------------------------------------------------------- | |
423 // %_ValueOf | 375 // %_ValueOf |
424 | 376 |
425 | 377 |
426 TEST_F(JSIntrinsicLoweringTest, InlineValueOf) { | 378 TEST_F(JSIntrinsicLoweringTest, InlineValueOf) { |
427 Node* const input = Parameter(0); | 379 Node* const input = Parameter(0); |
428 Node* const context = Parameter(1); | 380 Node* const context = Parameter(1); |
429 Node* const effect = graph()->start(); | 381 Node* const effect = graph()->start(); |
430 Node* const control = graph()->start(); | 382 Node* const control = graph()->start(); |
431 Reduction const r = Reduce( | 383 Reduction const r = Reduce( |
432 graph()->NewNode(javascript()->CallRuntime(Runtime::kInlineValueOf, 1), | 384 graph()->NewNode(javascript()->CallRuntime(Runtime::kInlineValueOf, 1), |
(...skipping 24 matching lines...) Expand all Loading... |
457 CaptureEq(&if_false0)))))), | 409 CaptureEq(&if_false0)))))), |
458 IsMerge( | 410 IsMerge( |
459 IsIfTrue(AllOf(CaptureEq(&branch0), | 411 IsIfTrue(AllOf(CaptureEq(&branch0), |
460 IsBranch(IsObjectIsSmi(input), control))), | 412 IsBranch(IsObjectIsSmi(input), control))), |
461 AllOf(CaptureEq(&if_false0), IsIfFalse(CaptureEq(&branch0)))))); | 413 AllOf(CaptureEq(&if_false0), IsIfFalse(CaptureEq(&branch0)))))); |
462 } | 414 } |
463 | 415 |
464 } // namespace compiler | 416 } // namespace compiler |
465 } // namespace internal | 417 } // namespace internal |
466 } // namespace v8 | 418 } // namespace v8 |
OLD | NEW |