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