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/code-factory.h" |
5 #include "src/compiler/access-builder.h" | 6 #include "src/compiler/access-builder.h" |
6 #include "src/compiler/diamond.h" | 7 #include "src/compiler/diamond.h" |
7 #include "src/compiler/js-graph.h" | 8 #include "src/compiler/js-graph.h" |
8 #include "src/compiler/js-intrinsic-lowering.h" | 9 #include "src/compiler/js-intrinsic-lowering.h" |
9 #include "src/compiler/js-operator.h" | 10 #include "src/compiler/js-operator.h" |
10 #include "test/unittests/compiler/graph-unittest.h" | 11 #include "test/unittests/compiler/graph-unittest.h" |
11 #include "test/unittests/compiler/node-test-utils.h" | 12 #include "test/unittests/compiler/node-test-utils.h" |
12 #include "testing/gmock-support.h" | 13 #include "testing/gmock-support.h" |
13 | 14 |
14 | 15 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 input1, context, effect, control)); | 60 input1, context, effect, control)); |
60 ASSERT_TRUE(r.Changed()); | 61 ASSERT_TRUE(r.Changed()); |
61 EXPECT_THAT(r.replacement(), IsFloat64InsertHighWord32( | 62 EXPECT_THAT(r.replacement(), IsFloat64InsertHighWord32( |
62 IsFloat64InsertLowWord32( | 63 IsFloat64InsertLowWord32( |
63 IsNumberConstant(BitEq(0.0)), input1), | 64 IsNumberConstant(BitEq(0.0)), input1), |
64 input0)); | 65 input0)); |
65 } | 66 } |
66 | 67 |
67 | 68 |
68 // ----------------------------------------------------------------------------- | 69 // ----------------------------------------------------------------------------- |
| 70 // %_CreateArrayLiteral |
| 71 |
| 72 |
| 73 TEST_F(JSIntrinsicLoweringTest, InlineCreateArrayLiteral) { |
| 74 i::FLAG_turbo_deoptimization = false; |
| 75 Node* const input0 = Parameter(0); |
| 76 Node* const input1 = Parameter(1); |
| 77 Node* const input2 = HeapConstant(factory()->NewFixedArray(12)); |
| 78 Node* const input3 = NumberConstant(ArrayLiteral::kShallowElements); |
| 79 Node* const context = Parameter(2); |
| 80 Node* const effect = graph()->start(); |
| 81 Node* const control = graph()->start(); |
| 82 Reduction const r = Reduce(graph()->NewNode( |
| 83 javascript()->CallRuntime(Runtime::kInlineCreateArrayLiteral, 4), input0, |
| 84 input1, input2, input3, context, effect, control)); |
| 85 ASSERT_TRUE(r.Changed()); |
| 86 EXPECT_THAT( |
| 87 r.replacement(), |
| 88 IsCall(_, IsHeapConstant(Unique<HeapObject>::CreateImmovable( |
| 89 CodeFactory::FastCloneShallowArray(isolate()).code())), |
| 90 input0, input1, input2, effect, control)); |
| 91 } |
| 92 |
| 93 |
| 94 // ----------------------------------------------------------------------------- |
| 95 // %_CreateObjectLiteral |
| 96 |
| 97 |
| 98 TEST_F(JSIntrinsicLoweringTest, InlineCreateObjectLiteral) { |
| 99 i::FLAG_turbo_deoptimization = false; |
| 100 Node* const input0 = Parameter(0); |
| 101 Node* const input1 = Parameter(1); |
| 102 Node* const input2 = HeapConstant(factory()->NewFixedArray(2 * 6)); |
| 103 Node* const input3 = NumberConstant(ObjectLiteral::kShallowProperties); |
| 104 Node* const context = Parameter(2); |
| 105 Node* const effect = graph()->start(); |
| 106 Node* const control = graph()->start(); |
| 107 Reduction const r = Reduce(graph()->NewNode( |
| 108 javascript()->CallRuntime(Runtime::kInlineCreateObjectLiteral, 4), input0, |
| 109 input1, input2, input3, context, effect, control)); |
| 110 ASSERT_TRUE(r.Changed()); |
| 111 EXPECT_THAT( |
| 112 r.replacement(), |
| 113 IsCall(_, IsHeapConstant(Unique<HeapObject>::CreateImmovable( |
| 114 CodeFactory::FastCloneShallowObject(isolate(), 6).code())), |
| 115 input0, input1, input2, effect, control)); |
| 116 } |
| 117 |
| 118 |
| 119 // ----------------------------------------------------------------------------- |
69 // %_DoubleLo | 120 // %_DoubleLo |
70 | 121 |
71 | 122 |
72 TEST_F(JSIntrinsicLoweringTest, InlineOptimizedDoubleLo) { | 123 TEST_F(JSIntrinsicLoweringTest, InlineOptimizedDoubleLo) { |
73 Node* const input = Parameter(0); | 124 Node* const input = Parameter(0); |
74 Node* const context = Parameter(1); | 125 Node* const context = Parameter(1); |
75 Node* const effect = graph()->start(); | 126 Node* const effect = graph()->start(); |
76 Node* const control = graph()->start(); | 127 Node* const control = graph()->start(); |
77 Reduction const r = Reduce( | 128 Reduction const r = Reduce( |
78 graph()->NewNode(javascript()->CallRuntime(Runtime::kInlineDoubleLo, 1), | 129 graph()->NewNode(javascript()->CallRuntime(Runtime::kInlineDoubleLo, 1), |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 CaptureEq(&if_false0)))))), | 452 CaptureEq(&if_false0)))))), |
402 IsMerge( | 453 IsMerge( |
403 IsIfTrue(AllOf(CaptureEq(&branch0), | 454 IsIfTrue(AllOf(CaptureEq(&branch0), |
404 IsBranch(IsObjectIsSmi(input), control))), | 455 IsBranch(IsObjectIsSmi(input), control))), |
405 AllOf(CaptureEq(&if_false0), IsIfFalse(CaptureEq(&branch0)))))); | 456 AllOf(CaptureEq(&if_false0), IsIfFalse(CaptureEq(&branch0)))))); |
406 } | 457 } |
407 | 458 |
408 } // namespace compiler | 459 } // namespace compiler |
409 } // namespace internal | 460 } // namespace internal |
410 } // namespace v8 | 461 } // namespace v8 |
OLD | NEW |