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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 effect, CaptureEq(&if_false)), | 122 effect, CaptureEq(&if_false)), |
123 effect, _), | 123 effect, _), |
124 IsNumberConstant(JS_TYPED_ARRAY_TYPE)), | 124 IsNumberConstant(JS_TYPED_ARRAY_TYPE)), |
125 IsMerge(IsIfTrue(AllOf(CaptureEq(&branch), | 125 IsMerge(IsIfTrue(AllOf(CaptureEq(&branch), |
126 IsBranch(IsObjectIsSmi(input), control))), | 126 IsBranch(IsObjectIsSmi(input), control))), |
127 AllOf(CaptureEq(&if_false), IsIfFalse(CaptureEq(&branch)))))); | 127 AllOf(CaptureEq(&if_false), IsIfFalse(CaptureEq(&branch)))))); |
128 } | 128 } |
129 | 129 |
130 | 130 |
131 // ----------------------------------------------------------------------------- | 131 // ----------------------------------------------------------------------------- |
| 132 // %_IsRegExp |
| 133 |
| 134 |
| 135 TEST_F(JSIntrinsicLoweringTest, InlineIsRegExp) { |
| 136 Node* const input = Parameter(0); |
| 137 Node* const context = Parameter(1); |
| 138 Node* const effect = graph()->start(); |
| 139 Node* const control = graph()->start(); |
| 140 Reduction const r = Reduce( |
| 141 graph()->NewNode(javascript()->CallRuntime(Runtime::kInlineIsRegExp, 1), |
| 142 input, context, effect, control)); |
| 143 ASSERT_TRUE(r.Changed()); |
| 144 |
| 145 Node* phi = r.replacement(); |
| 146 Capture<Node*> branch, if_false; |
| 147 EXPECT_THAT( |
| 148 phi, |
| 149 IsPhi( |
| 150 MachineRepresentation::kTagged, IsFalseConstant(), |
| 151 IsNumberEqual(IsLoadField(AccessBuilder::ForMapInstanceType(), |
| 152 IsLoadField(AccessBuilder::ForMap(), input, |
| 153 effect, CaptureEq(&if_false)), |
| 154 effect, _), |
| 155 IsNumberConstant(JS_REGEXP_TYPE)), |
| 156 IsMerge(IsIfTrue(AllOf(CaptureEq(&branch), |
| 157 IsBranch(IsObjectIsSmi(input), control))), |
| 158 AllOf(CaptureEq(&if_false), IsIfFalse(CaptureEq(&branch)))))); |
| 159 } |
| 160 |
| 161 |
| 162 // ----------------------------------------------------------------------------- |
132 // %_IsJSReceiver | 163 // %_IsJSReceiver |
133 | 164 |
134 | 165 |
135 TEST_F(JSIntrinsicLoweringTest, InlineIsJSReceiver) { | 166 TEST_F(JSIntrinsicLoweringTest, InlineIsJSReceiver) { |
136 Node* const input = Parameter(0); | 167 Node* const input = Parameter(0); |
137 Node* const context = Parameter(1); | 168 Node* const context = Parameter(1); |
138 Node* const effect = graph()->start(); | 169 Node* const effect = graph()->start(); |
139 Node* const control = graph()->start(); | 170 Node* const control = graph()->start(); |
140 Reduction const r = Reduce(graph()->NewNode( | 171 Reduction const r = Reduce(graph()->NewNode( |
141 javascript()->CallRuntime(Runtime::kInlineIsJSReceiver, 1), input, | 172 javascript()->CallRuntime(Runtime::kInlineIsJSReceiver, 1), input, |
142 context, effect, control)); | 173 context, effect, control)); |
143 ASSERT_TRUE(r.Changed()); | 174 ASSERT_TRUE(r.Changed()); |
144 EXPECT_THAT(r.replacement(), IsObjectIsReceiver(input)); | 175 EXPECT_THAT(r.replacement(), IsObjectIsReceiver(input)); |
145 } | 176 } |
146 | 177 |
147 } // namespace compiler | 178 } // namespace compiler |
148 } // namespace internal | 179 } // namespace internal |
149 } // namespace v8 | 180 } // namespace v8 |
OLD | NEW |