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

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

Issue 829303002: [turbofan] Generalize constant propagation. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix compilation on Mac Created 5 years, 11 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
OLDNEW
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 <climits>
6
5 #include "src/compiler/access-builder.h" 7 #include "src/compiler/access-builder.h"
6 #include "src/compiler/js-graph.h" 8 #include "src/compiler/js-graph.h"
7 #include "src/compiler/js-operator.h" 9 #include "src/compiler/js-operator.h"
8 #include "src/compiler/js-typed-lowering.h" 10 #include "src/compiler/js-typed-lowering.h"
9 #include "src/compiler/machine-operator.h" 11 #include "src/compiler/machine-operator.h"
10 #include "src/compiler/node-properties-inl.h" 12 #include "src/compiler/node-properties-inl.h"
11 #include "src/compiler/typer.h" 13 #include "src/compiler/typer.h"
12 #include "test/unittests/compiler/compiler-test-utils.h" 14 #include "test/unittests/compiler/compiler-test-utils.h"
13 #include "test/unittests/compiler/graph-unittest.h" 15 #include "test/unittests/compiler/graph-unittest.h"
14 #include "test/unittests/compiler/node-test-utils.h" 16 #include "test/unittests/compiler/node-test-utils.h"
17 #include "testing/gmock-support.h"
18
19 using testing::IsNaN;
20
15 21
16 namespace v8 { 22 namespace v8 {
17 namespace internal { 23 namespace internal {
18 namespace compiler { 24 namespace compiler {
19 25
20 namespace { 26 namespace {
21 27
22 const ExternalArrayType kExternalArrayTypes[] = { 28 const ExternalArrayType kExternalArrayTypes[] = {
23 kExternalUint8Array, kExternalInt8Array, kExternalUint16Array, 29 kExternalUint8Array, kExternalInt8Array, kExternalUint16Array,
24 kExternalInt16Array, kExternalUint32Array, kExternalInt32Array, 30 kExternalInt16Array, kExternalUint32Array, kExternalInt32Array,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 } 68 }
63 69
64 JSOperatorBuilder* javascript() { return &javascript_; } 70 JSOperatorBuilder* javascript() { return &javascript_; }
65 71
66 private: 72 private:
67 JSOperatorBuilder javascript_; 73 JSOperatorBuilder javascript_;
68 }; 74 };
69 75
70 76
71 // ----------------------------------------------------------------------------- 77 // -----------------------------------------------------------------------------
78 // Constant propagation
79
80
81 TEST_F(JSTypedLoweringTest, ParameterWithMinusZero) {
82 Reduction r = Reduce(Parameter(Type::MinusZero()));
83 ASSERT_TRUE(r.Changed());
84 EXPECT_THAT(r.replacement(), IsNumberConstant(-0.0));
85 }
Jarin 2015/01/05 09:41:21 Could we have test checking that type 0 <union> -0
Benedikt Meurer 2015/01/05 12:37:12 Done.
86
87
88 TEST_F(JSTypedLoweringTest, ParameterWithNaN) {
89 Reduction r = Reduce(Parameter(Type::NaN()));
90 ASSERT_TRUE(r.Changed());
91 EXPECT_THAT(r.replacement(), IsNumberConstant(IsNaN()));
92 }
93
94
95 TEST_F(JSTypedLoweringTest, ParameterWithSingletonRange) {
96 static const double kValues[] = {
97 -V8_INFINITY, INT_MIN, -1000.0, -42.0, -1.0, 0.0,
98 1.0, 42.0, 1000.0, INT_MAX, UINT_MAX, +V8_INFINITY};
99 TRACED_FOREACH(double, value, kValues) {
100 Handle<Object> constant = factory()->NewNumber(value);
101 Reduction r = Reduce(Parameter(Type::Range(constant, constant, zone())));
102 ASSERT_TRUE(r.Changed());
103 EXPECT_THAT(r.replacement(), IsNumberConstant(value));
104 }
105 }
106
107
108 // -----------------------------------------------------------------------------
72 // JSToBoolean 109 // JSToBoolean
73 110
74 111
75 TEST_F(JSTypedLoweringTest, JSToBooleanWithBoolean) { 112 TEST_F(JSTypedLoweringTest, JSToBooleanWithBoolean) {
76 Node* input = Parameter(Type::Boolean()); 113 Node* input = Parameter(Type::Boolean());
77 Node* context = UndefinedConstant(); 114 Node* context = UndefinedConstant();
78 115
79 Reduction r = 116 Reduction r =
80 Reduce(graph()->NewNode(javascript()->ToBoolean(), input, context)); 117 Reduce(graph()->NewNode(javascript()->ToBoolean(), input, context));
81 ASSERT_TRUE(r.Changed()); 118 ASSERT_TRUE(r.Changed());
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 IsStoreElement( 663 IsStoreElement(
627 access, IsIntPtrConstant(bit_cast<intptr_t>(&backing_store[0])), 664 access, IsIntPtrConstant(bit_cast<intptr_t>(&backing_store[0])),
628 key, value, effect, control)); 665 key, value, effect, control));
629 } 666 }
630 } 667 }
631 } 668 }
632 669
633 } // namespace compiler 670 } // namespace compiler
634 } // namespace internal 671 } // namespace internal
635 } // namespace v8 672 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698