Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(215)

Side by Side Diff: test/unittests/compiler/js-intrinsic-lowering-unittest.cc

Issue 1028553002: [turbofan] Fix unit test coverage for JSIntrinsicLowering. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/js-graph.h" 6 #include "src/compiler/js-graph.h"
7 #include "src/compiler/js-intrinsic-lowering.h" 7 #include "src/compiler/js-intrinsic-lowering.h"
8 #include "src/compiler/js-operator.h" 8 #include "src/compiler/js-operator.h"
9 #include "test/unittests/compiler/graph-unittest.h" 9 #include "test/unittests/compiler/graph-unittest.h"
10 #include "test/unittests/compiler/node-test-utils.h" 10 #include "test/unittests/compiler/node-test-utils.h"
11 #include "testing/gmock-support.h" 11 #include "testing/gmock-support.h"
12 12
13 using testing::_; 13 using testing::_;
14 using testing::AllOf; 14 using testing::AllOf;
15 using testing::BitEq; 15 using testing::BitEq;
16 using testing::Capture; 16 using testing::Capture;
17 using testing::CaptureEq; 17 using testing::CaptureEq;
18 18
19 19
20 namespace v8 { 20 namespace v8 {
21 namespace internal { 21 namespace internal {
22 namespace compiler { 22 namespace compiler {
23 23
24 class JSIntrinsicLoweringTest : public GraphTest { 24 class JSIntrinsicLoweringTest : public GraphTest {
25 public: 25 public:
26 JSIntrinsicLoweringTest() : GraphTest(3), javascript_(zone()) {} 26 JSIntrinsicLoweringTest() : GraphTest(3), javascript_(zone()) {}
27 ~JSIntrinsicLoweringTest() OVERRIDE {} 27 ~JSIntrinsicLoweringTest() OVERRIDE {}
28 28
29 protected: 29 protected:
30 Reduction Reduce(Node* node) { 30 Reduction Reduce(Node* node, MachineOperatorBuilder::Flags flags =
31 MachineOperatorBuilder machine(zone()); 31 MachineOperatorBuilder::kNoFlags) {
32 MachineOperatorBuilder machine(zone(), kMachPtr, flags);
32 JSGraph jsgraph(isolate(), graph(), common(), javascript(), &machine); 33 JSGraph jsgraph(isolate(), graph(), common(), javascript(), &machine);
33 JSIntrinsicLowering reducer(&jsgraph); 34 JSIntrinsicLowering reducer(&jsgraph);
34 return reducer.Reduce(node); 35 return reducer.Reduce(node);
35 } 36 }
36 37
37 JSOperatorBuilder* javascript() { return &javascript_; } 38 JSOperatorBuilder* javascript() { return &javascript_; }
38 39
39 private: 40 private:
40 JSOperatorBuilder javascript_; 41 JSOperatorBuilder javascript_;
41 }; 42 };
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 effect, CaptureEq(&if_false)), 218 effect, CaptureEq(&if_false)),
218 effect, _), 219 effect, _),
219 IsInt32Constant(JS_REGEXP_TYPE)), 220 IsInt32Constant(JS_REGEXP_TYPE)),
220 IsMerge(IsIfTrue(AllOf(CaptureEq(&branch), 221 IsMerge(IsIfTrue(AllOf(CaptureEq(&branch),
221 IsBranch(IsObjectIsSmi(input), control))), 222 IsBranch(IsObjectIsSmi(input), control))),
222 AllOf(CaptureEq(&if_false), IsIfFalse(CaptureEq(&branch)))))); 223 AllOf(CaptureEq(&if_false), IsIfFalse(CaptureEq(&branch))))));
223 } 224 }
224 225
225 226
226 // ----------------------------------------------------------------------------- 227 // -----------------------------------------------------------------------------
228 // %_JSValueGetValue
229
230
231 TEST_F(JSIntrinsicLoweringTest, InlineJSValueGetValue) {
232 Node* const input = Parameter(0);
233 Node* const context = Parameter(1);
234 Node* const effect = graph()->start();
235 Node* const control = graph()->start();
236 Reduction const r = Reduce(graph()->NewNode(
237 javascript()->CallRuntime(Runtime::kInlineJSValueGetValue, 1), input,
238 context, effect, control));
239 ASSERT_TRUE(r.Changed());
240 EXPECT_THAT(r.replacement(),
241 IsLoadField(AccessBuilder::ForValue(), input, effect, control));
242 }
243
244
245 // -----------------------------------------------------------------------------
246 // %_MathFloor
247
248
249 TEST_F(JSIntrinsicLoweringTest, InlineMathFloor) {
250 Node* const input = Parameter(0);
251 Node* const context = Parameter(1);
252 Node* const effect = graph()->start();
253 Node* const control = graph()->start();
254 Reduction const r = Reduce(
255 graph()->NewNode(javascript()->CallRuntime(Runtime::kInlineMathFloor, 1),
256 input, context, effect, control),
257 MachineOperatorBuilder::kFloat64RoundDown);
258 ASSERT_TRUE(r.Changed());
259 EXPECT_THAT(r.replacement(), IsFloat64RoundDown(input));
260 }
261
262
263 // -----------------------------------------------------------------------------
264 // %_MathSqrt
265
266
267 TEST_F(JSIntrinsicLoweringTest, InlineMathSqrt) {
268 Node* const input = Parameter(0);
269 Node* const context = Parameter(1);
270 Node* const effect = graph()->start();
271 Node* const control = graph()->start();
272 Reduction const r = Reduce(
273 graph()->NewNode(javascript()->CallRuntime(Runtime::kInlineMathSqrt, 1),
274 input, context, effect, control));
275 ASSERT_TRUE(r.Changed());
276 EXPECT_THAT(r.replacement(), IsFloat64Sqrt(input));
277 }
278
279
280 // -----------------------------------------------------------------------------
281 // %_StringGetLength
282
283
284 TEST_F(JSIntrinsicLoweringTest, InlineStringGetLength) {
285 Node* const input = Parameter(0);
286 Node* const context = Parameter(1);
287 Node* const effect = graph()->start();
288 Node* const control = graph()->start();
289 Reduction const r = Reduce(graph()->NewNode(
290 javascript()->CallRuntime(Runtime::kInlineStringGetLength, 1), input,
291 context, effect, control));
292 ASSERT_TRUE(r.Changed());
293 EXPECT_THAT(r.replacement(), IsLoadField(AccessBuilder::ForStringLength(),
294 input, effect, control));
295 }
296
297
298 // -----------------------------------------------------------------------------
227 // %_ValueOf 299 // %_ValueOf
228 300
229 301
230 TEST_F(JSIntrinsicLoweringTest, InlineValueOf) { 302 TEST_F(JSIntrinsicLoweringTest, InlineValueOf) {
231 Node* const input = Parameter(0); 303 Node* const input = Parameter(0);
232 Node* const context = Parameter(1); 304 Node* const context = Parameter(1);
233 Node* const effect = graph()->start(); 305 Node* const effect = graph()->start();
234 Node* const control = graph()->start(); 306 Node* const control = graph()->start();
235 Reduction const r = Reduce( 307 Reduction const r = Reduce(
236 graph()->NewNode(javascript()->CallRuntime(Runtime::kInlineValueOf, 1), 308 graph()->NewNode(javascript()->CallRuntime(Runtime::kInlineValueOf, 1),
(...skipping 24 matching lines...) Expand all
261 CaptureEq(&if_false0)))))), 333 CaptureEq(&if_false0)))))),
262 IsMerge( 334 IsMerge(
263 IsIfTrue(AllOf(CaptureEq(&branch0), 335 IsIfTrue(AllOf(CaptureEq(&branch0),
264 IsBranch(IsObjectIsSmi(input), control))), 336 IsBranch(IsObjectIsSmi(input), control))),
265 AllOf(CaptureEq(&if_false0), IsIfFalse(CaptureEq(&branch0)))))); 337 AllOf(CaptureEq(&if_false0), IsIfFalse(CaptureEq(&branch0))))));
266 } 338 }
267 339
268 } // namespace compiler 340 } // namespace compiler
269 } // namespace internal 341 } // namespace internal
270 } // namespace v8 342 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698