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/code-factory.h" |
6 #include "src/compiler/access-builder.h" | 6 #include "src/compiler/access-builder.h" |
7 #include "src/compiler/diamond.h" | 7 #include "src/compiler/diamond.h" |
8 #include "src/compiler/js-graph.h" | 8 #include "src/compiler/js-graph.h" |
9 #include "src/compiler/js-intrinsic-lowering.h" | 9 #include "src/compiler/js-intrinsic-lowering.h" |
10 #include "src/compiler/js-operator.h" | 10 #include "src/compiler/js-operator.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 | 31 |
32 protected: | 32 protected: |
33 Reduction Reduce(Node* node, MachineOperatorBuilder::Flags flags = | 33 Reduction Reduce(Node* node, MachineOperatorBuilder::Flags flags = |
34 MachineOperatorBuilder::kNoFlags) { | 34 MachineOperatorBuilder::kNoFlags) { |
35 MachineOperatorBuilder machine(zone(), kMachPtr, flags); | 35 MachineOperatorBuilder machine(zone(), kMachPtr, flags); |
36 JSGraph jsgraph(isolate(), graph(), common(), javascript(), &machine); | 36 JSGraph jsgraph(isolate(), graph(), common(), javascript(), &machine); |
37 JSIntrinsicLowering reducer(&jsgraph); | 37 JSIntrinsicLowering reducer(&jsgraph); |
38 return reducer.Reduce(node); | 38 return reducer.Reduce(node); |
39 } | 39 } |
40 | 40 |
| 41 Node* EmptyFrameState() { |
| 42 MachineOperatorBuilder machine(zone()); |
| 43 JSGraph jsgraph(isolate(), graph(), common(), javascript(), &machine); |
| 44 return jsgraph.EmptyFrameState(); |
| 45 } |
| 46 |
41 JSOperatorBuilder* javascript() { return &javascript_; } | 47 JSOperatorBuilder* javascript() { return &javascript_; } |
42 | 48 |
43 private: | 49 private: |
44 JSOperatorBuilder javascript_; | 50 JSOperatorBuilder javascript_; |
45 }; | 51 }; |
46 | 52 |
47 | 53 |
48 // ----------------------------------------------------------------------------- | 54 // ----------------------------------------------------------------------------- |
49 // %_ConstructDouble | 55 // %_ConstructDouble |
50 | 56 |
(...skipping 13 matching lines...) Expand all Loading... |
64 IsNumberConstant(BitEq(0.0)), input1), | 70 IsNumberConstant(BitEq(0.0)), input1), |
65 input0)); | 71 input0)); |
66 } | 72 } |
67 | 73 |
68 | 74 |
69 // ----------------------------------------------------------------------------- | 75 // ----------------------------------------------------------------------------- |
70 // %_CreateArrayLiteral | 76 // %_CreateArrayLiteral |
71 | 77 |
72 | 78 |
73 TEST_F(JSIntrinsicLoweringTest, InlineCreateArrayLiteral) { | 79 TEST_F(JSIntrinsicLoweringTest, InlineCreateArrayLiteral) { |
74 i::FLAG_turbo_deoptimization = false; | |
75 Node* const input0 = Parameter(0); | 80 Node* const input0 = Parameter(0); |
76 Node* const input1 = Parameter(1); | 81 Node* const input1 = Parameter(1); |
77 Node* const input2 = HeapConstant(factory()->NewFixedArray(12)); | 82 Node* const input2 = HeapConstant(factory()->NewFixedArray(12)); |
78 Node* const input3 = NumberConstant(ArrayLiteral::kShallowElements); | 83 Node* const input3 = NumberConstant(ArrayLiteral::kShallowElements); |
79 Node* const context = Parameter(2); | 84 Node* const context = Parameter(2); |
| 85 Node* const frame_state = EmptyFrameState(); |
80 Node* const effect = graph()->start(); | 86 Node* const effect = graph()->start(); |
81 Node* const control = graph()->start(); | 87 Node* const control = graph()->start(); |
82 Reduction const r = Reduce(graph()->NewNode( | 88 Reduction const r = Reduce(graph()->NewNode( |
83 javascript()->CallRuntime(Runtime::kInlineCreateArrayLiteral, 4), input0, | 89 javascript()->CallRuntime(Runtime::kInlineCreateArrayLiteral, 4), input0, |
84 input1, input2, input3, context, effect, control)); | 90 input1, input2, input3, context, frame_state, effect, control)); |
85 ASSERT_TRUE(r.Changed()); | 91 ASSERT_TRUE(r.Changed()); |
86 EXPECT_THAT( | 92 EXPECT_THAT( |
87 r.replacement(), | 93 r.replacement(), |
88 IsCall(_, IsHeapConstant(Unique<HeapObject>::CreateImmovable( | 94 IsCall(_, IsHeapConstant(Unique<HeapObject>::CreateImmovable( |
89 CodeFactory::FastCloneShallowArray(isolate()).code())), | 95 CodeFactory::FastCloneShallowArray(isolate()).code())), |
90 input0, input1, input2, effect, control)); | 96 input0, input1, input2, context, frame_state, effect, control)); |
91 } | 97 } |
92 | 98 |
93 | 99 |
94 // ----------------------------------------------------------------------------- | 100 // ----------------------------------------------------------------------------- |
95 // %_CreateObjectLiteral | 101 // %_CreateObjectLiteral |
96 | 102 |
97 | 103 |
98 TEST_F(JSIntrinsicLoweringTest, InlineCreateObjectLiteral) { | 104 TEST_F(JSIntrinsicLoweringTest, InlineCreateObjectLiteral) { |
99 i::FLAG_turbo_deoptimization = false; | |
100 Node* const input0 = Parameter(0); | 105 Node* const input0 = Parameter(0); |
101 Node* const input1 = Parameter(1); | 106 Node* const input1 = Parameter(1); |
102 Node* const input2 = HeapConstant(factory()->NewFixedArray(2 * 6)); | 107 Node* const input2 = HeapConstant(factory()->NewFixedArray(2 * 6)); |
103 Node* const input3 = NumberConstant(ObjectLiteral::kShallowProperties); | 108 Node* const input3 = NumberConstant(ObjectLiteral::kShallowProperties); |
104 Node* const context = Parameter(2); | 109 Node* const context = Parameter(2); |
| 110 Node* const frame_state = EmptyFrameState(); |
105 Node* const effect = graph()->start(); | 111 Node* const effect = graph()->start(); |
106 Node* const control = graph()->start(); | 112 Node* const control = graph()->start(); |
107 Reduction const r = Reduce(graph()->NewNode( | 113 Reduction const r = Reduce(graph()->NewNode( |
108 javascript()->CallRuntime(Runtime::kInlineCreateObjectLiteral, 4), input0, | 114 javascript()->CallRuntime(Runtime::kInlineCreateObjectLiteral, 4), input0, |
109 input1, input2, input3, context, effect, control)); | 115 input1, input2, input3, context, frame_state, effect, control)); |
110 ASSERT_TRUE(r.Changed()); | 116 ASSERT_TRUE(r.Changed()); |
111 EXPECT_THAT( | 117 EXPECT_THAT( |
112 r.replacement(), | 118 r.replacement(), |
113 IsCall(_, IsHeapConstant(Unique<HeapObject>::CreateImmovable( | 119 IsCall(_, IsHeapConstant(Unique<HeapObject>::CreateImmovable( |
114 CodeFactory::FastCloneShallowObject(isolate(), 6).code())), | 120 CodeFactory::FastCloneShallowObject(isolate(), 6).code())), |
115 input0, input1, input2, effect, control)); | 121 input0, input1, input2, input3, context, frame_state, effect, |
| 122 control)); |
116 } | 123 } |
117 | 124 |
118 | 125 |
119 // ----------------------------------------------------------------------------- | 126 // ----------------------------------------------------------------------------- |
120 // %_DoubleLo | 127 // %_DoubleLo |
121 | 128 |
122 | 129 |
123 TEST_F(JSIntrinsicLoweringTest, InlineOptimizedDoubleLo) { | 130 TEST_F(JSIntrinsicLoweringTest, InlineOptimizedDoubleLo) { |
124 Node* const input = Parameter(0); | 131 Node* const input = Parameter(0); |
125 Node* const context = Parameter(1); | 132 Node* const context = Parameter(1); |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 CaptureEq(&if_false0)))))), | 459 CaptureEq(&if_false0)))))), |
453 IsMerge( | 460 IsMerge( |
454 IsIfTrue(AllOf(CaptureEq(&branch0), | 461 IsIfTrue(AllOf(CaptureEq(&branch0), |
455 IsBranch(IsObjectIsSmi(input), control))), | 462 IsBranch(IsObjectIsSmi(input), control))), |
456 AllOf(CaptureEq(&if_false0), IsIfFalse(CaptureEq(&branch0)))))); | 463 AllOf(CaptureEq(&if_false0), IsIfFalse(CaptureEq(&branch0)))))); |
457 } | 464 } |
458 | 465 |
459 } // namespace compiler | 466 } // namespace compiler |
460 } // namespace internal | 467 } // namespace internal |
461 } // namespace v8 | 468 } // namespace v8 |
OLD | NEW |