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/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" |
(...skipping 24 matching lines...) Expand all Loading... |
35 } | 35 } |
36 | 36 |
37 JSOperatorBuilder* javascript() { return &javascript_; } | 37 JSOperatorBuilder* javascript() { return &javascript_; } |
38 | 38 |
39 private: | 39 private: |
40 JSOperatorBuilder javascript_; | 40 JSOperatorBuilder javascript_; |
41 }; | 41 }; |
42 | 42 |
43 | 43 |
44 // ----------------------------------------------------------------------------- | 44 // ----------------------------------------------------------------------------- |
| 45 // %_ConstructDouble |
| 46 |
| 47 |
| 48 TEST_F(JSIntrinsicLoweringTest, InlineOptimizedConstructDouble) { |
| 49 Node* const input0 = Parameter(0); |
| 50 Node* const input1 = Parameter(1); |
| 51 Node* const context = Parameter(2); |
| 52 Node* const effect = graph()->start(); |
| 53 Node* const control = graph()->start(); |
| 54 Reduction const r = Reduce(graph()->NewNode( |
| 55 javascript()->CallRuntime(Runtime::kInlineOptimizedConstructDouble, 2), |
| 56 input0, input1, context, effect, control)); |
| 57 ASSERT_TRUE(r.Changed()); |
| 58 EXPECT_THAT( |
| 59 r.replacement(), |
| 60 IsFloat64InsertWord32( |
| 61 1, IsFloat64InsertWord32(0, IsNumberConstant(BitEq(0.0)), input1), |
| 62 input0)); |
| 63 } |
| 64 |
| 65 |
| 66 // ----------------------------------------------------------------------------- |
| 67 // %_DoubleLo |
| 68 |
| 69 |
| 70 TEST_F(JSIntrinsicLoweringTest, InlineOptimizedDoubleLo) { |
| 71 Node* const input = Parameter(0); |
| 72 Node* const context = Parameter(1); |
| 73 Node* const effect = graph()->start(); |
| 74 Node* const control = graph()->start(); |
| 75 Reduction const r = Reduce(graph()->NewNode( |
| 76 javascript()->CallRuntime(Runtime::kInlineOptimizedDoubleLo, 1), input, |
| 77 context, effect, control)); |
| 78 ASSERT_TRUE(r.Changed()); |
| 79 EXPECT_THAT(r.replacement(), IsFloat64ExtractWord32(0, input)); |
| 80 } |
| 81 |
| 82 |
| 83 // ----------------------------------------------------------------------------- |
| 84 // %_DoubleHi |
| 85 |
| 86 |
| 87 TEST_F(JSIntrinsicLoweringTest, InlineOptimizedDoubleHi) { |
| 88 Node* const input = Parameter(0); |
| 89 Node* const context = Parameter(1); |
| 90 Node* const effect = graph()->start(); |
| 91 Node* const control = graph()->start(); |
| 92 Reduction const r = Reduce(graph()->NewNode( |
| 93 javascript()->CallRuntime(Runtime::kInlineOptimizedDoubleHi, 1), input, |
| 94 context, effect, control)); |
| 95 ASSERT_TRUE(r.Changed()); |
| 96 EXPECT_THAT(r.replacement(), IsFloat64ExtractWord32(1, input)); |
| 97 } |
| 98 |
| 99 |
| 100 // ----------------------------------------------------------------------------- |
45 // %_IsSmi | 101 // %_IsSmi |
46 | 102 |
47 | 103 |
48 TEST_F(JSIntrinsicLoweringTest, InlineIsSmi) { | 104 TEST_F(JSIntrinsicLoweringTest, InlineIsSmi) { |
49 Node* const input = Parameter(0); | 105 Node* const input = Parameter(0); |
50 Node* const context = Parameter(1); | 106 Node* const context = Parameter(1); |
51 Node* const effect = graph()->start(); | 107 Node* const effect = graph()->start(); |
52 Node* const control = graph()->start(); | 108 Node* const control = graph()->start(); |
53 Reduction const r = Reduce( | 109 Reduction const r = Reduce( |
54 graph()->NewNode(javascript()->CallRuntime(Runtime::kInlineIsSmi, 1), | 110 graph()->NewNode(javascript()->CallRuntime(Runtime::kInlineIsSmi, 1), |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 CaptureEq(&if_false0)))))), | 262 CaptureEq(&if_false0)))))), |
207 IsMerge( | 263 IsMerge( |
208 IsIfTrue(AllOf(CaptureEq(&branch0), | 264 IsIfTrue(AllOf(CaptureEq(&branch0), |
209 IsBranch(IsObjectIsSmi(input), control))), | 265 IsBranch(IsObjectIsSmi(input), control))), |
210 AllOf(CaptureEq(&if_false0), IsIfFalse(CaptureEq(&branch0)))))); | 266 AllOf(CaptureEq(&if_false0), IsIfFalse(CaptureEq(&branch0)))))); |
211 } | 267 } |
212 | 268 |
213 } // namespace compiler | 269 } // namespace compiler |
214 } // namespace internal | 270 } // namespace internal |
215 } // namespace v8 | 271 } // namespace v8 |
OLD | NEW |