OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/node-properties.h" | 7 #include "src/compiler/node-properties.h" |
8 #include "src/compiler/simplified-operator.h" | 8 #include "src/compiler/simplified-operator.h" |
9 #include "src/compiler/simplified-operator-reducer.h" | 9 #include "src/compiler/simplified-operator-reducer.h" |
10 #include "src/conversions.h" | 10 #include "src/conversions.h" |
11 #include "src/types.h" | 11 #include "src/types.h" |
12 #include "test/unittests/compiler/graph-unittest.h" | 12 #include "test/unittests/compiler/graph-unittest.h" |
13 #include "test/unittests/compiler/node-test-utils.h" | 13 #include "test/unittests/compiler/node-test-utils.h" |
14 #include "testing/gmock-support.h" | 14 #include "testing/gmock-support.h" |
15 | 15 |
16 using testing::BitEq; | 16 using testing::BitEq; |
17 | 17 |
18 | 18 |
19 namespace v8 { | 19 namespace v8 { |
20 namespace internal { | 20 namespace internal { |
21 namespace compiler { | 21 namespace compiler { |
22 | 22 |
23 class SimplifiedOperatorReducerTest : public TypedGraphTest { | 23 class SimplifiedOperatorReducerTest : public TypedGraphTest { |
24 public: | 24 public: |
25 explicit SimplifiedOperatorReducerTest(int num_parameters = 1) | 25 explicit SimplifiedOperatorReducerTest(int num_parameters = 1) |
26 : TypedGraphTest(num_parameters), simplified_(zone()) {} | 26 : TypedGraphTest(num_parameters), simplified_(zone()) {} |
27 ~SimplifiedOperatorReducerTest() OVERRIDE {} | 27 ~SimplifiedOperatorReducerTest() override {} |
28 | 28 |
29 protected: | 29 protected: |
30 Reduction Reduce(Node* node) { | 30 Reduction Reduce(Node* node) { |
31 MachineOperatorBuilder machine(zone()); | 31 MachineOperatorBuilder machine(zone()); |
32 JSOperatorBuilder javascript(zone()); | 32 JSOperatorBuilder javascript(zone()); |
33 JSGraph jsgraph(isolate(), graph(), common(), &javascript, &machine); | 33 JSGraph jsgraph(isolate(), graph(), common(), &javascript, &machine); |
34 SimplifiedOperatorReducer reducer(&jsgraph); | 34 SimplifiedOperatorReducer reducer(&jsgraph); |
35 return reducer.Reduce(node); | 35 return reducer.Reduce(node); |
36 } | 36 } |
37 | 37 |
38 SimplifiedOperatorBuilder* simplified() { return &simplified_; } | 38 SimplifiedOperatorBuilder* simplified() { return &simplified_; } |
39 | 39 |
40 private: | 40 private: |
41 SimplifiedOperatorBuilder simplified_; | 41 SimplifiedOperatorBuilder simplified_; |
42 }; | 42 }; |
43 | 43 |
44 | 44 |
45 template <typename T> | 45 template <typename T> |
46 class SimplifiedOperatorReducerTestWithParam | 46 class SimplifiedOperatorReducerTestWithParam |
47 : public SimplifiedOperatorReducerTest, | 47 : public SimplifiedOperatorReducerTest, |
48 public ::testing::WithParamInterface<T> { | 48 public ::testing::WithParamInterface<T> { |
49 public: | 49 public: |
50 explicit SimplifiedOperatorReducerTestWithParam(int num_parameters = 1) | 50 explicit SimplifiedOperatorReducerTestWithParam(int num_parameters = 1) |
51 : SimplifiedOperatorReducerTest(num_parameters) {} | 51 : SimplifiedOperatorReducerTest(num_parameters) {} |
52 ~SimplifiedOperatorReducerTestWithParam() OVERRIDE {} | 52 ~SimplifiedOperatorReducerTestWithParam() override {} |
53 }; | 53 }; |
54 | 54 |
55 | 55 |
56 namespace { | 56 namespace { |
57 | 57 |
58 const double kFloat64Values[] = { | 58 const double kFloat64Values[] = { |
59 -V8_INFINITY, -6.52696e+290, -1.05768e+290, -5.34203e+268, -1.01997e+268, | 59 -V8_INFINITY, -6.52696e+290, -1.05768e+290, -5.34203e+268, -1.01997e+268, |
60 -8.22758e+266, -1.58402e+261, -5.15246e+241, -5.92107e+226, -1.21477e+226, | 60 -8.22758e+266, -1.58402e+261, -5.15246e+241, -5.92107e+226, -1.21477e+226, |
61 -1.67913e+188, -1.6257e+184, -2.60043e+170, -2.52941e+168, -3.06033e+116, | 61 -1.67913e+188, -1.6257e+184, -2.60043e+170, -2.52941e+168, -3.06033e+116, |
62 -4.56201e+52, -3.56788e+50, -9.9066e+38, -3.07261e+31, -2.1271e+09, | 62 -4.56201e+52, -3.56788e+50, -9.9066e+38, -3.07261e+31, -2.1271e+09, |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 Reduce(graph()->NewNode(simplified()->ChangeUint32ToTagged(), | 396 Reduce(graph()->NewNode(simplified()->ChangeUint32ToTagged(), |
397 Int32Constant(bit_cast<int32_t>(n)))); | 397 Int32Constant(bit_cast<int32_t>(n)))); |
398 ASSERT_TRUE(reduction.Changed()); | 398 ASSERT_TRUE(reduction.Changed()); |
399 EXPECT_THAT(reduction.replacement(), IsNumberConstant(BitEq(FastUI2D(n)))); | 399 EXPECT_THAT(reduction.replacement(), IsNumberConstant(BitEq(FastUI2D(n)))); |
400 } | 400 } |
401 } | 401 } |
402 | 402 |
403 } // namespace compiler | 403 } // namespace compiler |
404 } // namespace internal | 404 } // namespace internal |
405 } // namespace v8 | 405 } // namespace v8 |
OLD | NEW |