| 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 <functional> | 5 #include <functional> |
| 6 | 6 |
| 7 #include "src/codegen.h" | 7 #include "src/codegen.h" |
| 8 #include "src/compiler/js-operator.h" | 8 #include "src/compiler/js-operator.h" |
| 9 #include "src/compiler/node-properties.h" | 9 #include "src/compiler/node-properties.h" |
| 10 #include "src/compiler/operator-properties.h" | 10 #include "src/compiler/operator-properties.h" |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 for (int width = 0; width < max_width; width++) { | 128 for (int width = 0; width < max_width; width++) { |
| 129 for (int lmin = min_min; lmin <= max_min; lmin++) { | 129 for (int lmin = min_min; lmin <= max_min; lmin++) { |
| 130 for (int rmin = min_min; rmin <= max_min; rmin++) { | 130 for (int rmin = min_min; rmin <= max_min; rmin++) { |
| 131 Type* r1 = NewRange(lmin, lmin + width); | 131 Type* r1 = NewRange(lmin, lmin + width); |
| 132 Type* r2 = NewRange(rmin, rmin + width); | 132 Type* r2 = NewRange(rmin, rmin + width); |
| 133 Type* expected_type = TypeBinaryOp(op, r1, r2); | 133 Type* expected_type = TypeBinaryOp(op, r1, r2); |
| 134 | 134 |
| 135 for (int x1 = lmin; x1 < lmin + width; x1++) { | 135 for (int x1 = lmin; x1 < lmin + width; x1++) { |
| 136 for (int x2 = rmin; x2 < rmin + width; x2++) { | 136 for (int x2 = rmin; x2 < rmin + width; x2++) { |
| 137 double result_value = opfun(x1, x2); | 137 double result_value = opfun(x1, x2); |
| 138 Type* result_type = Type::Constant( | 138 Type* result_type = Type::NewConstant( |
| 139 isolate()->factory()->NewNumber(result_value), zone()); | 139 isolate()->factory()->NewNumber(result_value), zone()); |
| 140 EXPECT_TRUE(result_type->Is(expected_type)); | 140 EXPECT_TRUE(result_type->Is(expected_type)); |
| 141 } | 141 } |
| 142 } | 142 } |
| 143 } | 143 } |
| 144 } | 144 } |
| 145 } | 145 } |
| 146 } | 146 } |
| 147 | 147 |
| 148 template <class BinaryFunction> | 148 template <class BinaryFunction> |
| 149 void TestBinaryArithOp(const Operator* op, BinaryFunction opfun) { | 149 void TestBinaryArithOp(const Operator* op, BinaryFunction opfun) { |
| 150 TestBinaryArithOpCloseToZero(op, opfun, 8); | 150 TestBinaryArithOpCloseToZero(op, opfun, 8); |
| 151 for (int i = 0; i < 100; ++i) { | 151 for (int i = 0; i < 100; ++i) { |
| 152 Type* r1 = RandomRange(); | 152 Type* r1 = RandomRange(); |
| 153 Type* r2 = RandomRange(); | 153 Type* r2 = RandomRange(); |
| 154 Type* expected_type = TypeBinaryOp(op, r1, r2); | 154 Type* expected_type = TypeBinaryOp(op, r1, r2); |
| 155 for (int i = 0; i < 10; i++) { | 155 for (int i = 0; i < 10; i++) { |
| 156 double x1 = RandomInt(r1->AsRange()); | 156 double x1 = RandomInt(r1->AsRange()); |
| 157 double x2 = RandomInt(r2->AsRange()); | 157 double x2 = RandomInt(r2->AsRange()); |
| 158 double result_value = opfun(x1, x2); | 158 double result_value = opfun(x1, x2); |
| 159 Type* result_type = Type::Constant( | 159 Type* result_type = Type::NewConstant( |
| 160 isolate()->factory()->NewNumber(result_value), zone()); | 160 isolate()->factory()->NewNumber(result_value), zone()); |
| 161 EXPECT_TRUE(result_type->Is(expected_type)); | 161 EXPECT_TRUE(result_type->Is(expected_type)); |
| 162 } | 162 } |
| 163 } | 163 } |
| 164 } | 164 } |
| 165 | 165 |
| 166 template <class BinaryFunction> | 166 template <class BinaryFunction> |
| 167 void TestBinaryCompareOp(const Operator* op, BinaryFunction opfun) { | 167 void TestBinaryCompareOp(const Operator* op, BinaryFunction opfun) { |
| 168 for (int i = 0; i < 100; ++i) { | 168 for (int i = 0; i < 100; ++i) { |
| 169 Type* r1 = RandomRange(); | 169 Type* r1 = RandomRange(); |
| 170 Type* r2 = RandomRange(); | 170 Type* r2 = RandomRange(); |
| 171 Type* expected_type = TypeBinaryOp(op, r1, r2); | 171 Type* expected_type = TypeBinaryOp(op, r1, r2); |
| 172 for (int i = 0; i < 10; i++) { | 172 for (int i = 0; i < 10; i++) { |
| 173 double x1 = RandomInt(r1->AsRange()); | 173 double x1 = RandomInt(r1->AsRange()); |
| 174 double x2 = RandomInt(r2->AsRange()); | 174 double x2 = RandomInt(r2->AsRange()); |
| 175 bool result_value = opfun(x1, x2); | 175 bool result_value = opfun(x1, x2); |
| 176 Type* result_type = | 176 Type* result_type = Type::NewConstant( |
| 177 Type::Constant(result_value ? isolate()->factory()->true_value() | 177 result_value ? isolate()->factory()->true_value() |
| 178 : isolate()->factory()->false_value(), | 178 : isolate()->factory()->false_value(), |
| 179 zone()); | 179 zone()); |
| 180 EXPECT_TRUE(result_type->Is(expected_type)); | 180 EXPECT_TRUE(result_type->Is(expected_type)); |
| 181 } | 181 } |
| 182 } | 182 } |
| 183 } | 183 } |
| 184 | 184 |
| 185 template <class BinaryFunction> | 185 template <class BinaryFunction> |
| 186 void TestBinaryBitOp(const Operator* op, BinaryFunction opfun) { | 186 void TestBinaryBitOp(const Operator* op, BinaryFunction opfun) { |
| 187 for (int i = 0; i < 100; ++i) { | 187 for (int i = 0; i < 100; ++i) { |
| 188 Type* r1 = RandomRange(true); | 188 Type* r1 = RandomRange(true); |
| 189 Type* r2 = RandomRange(true); | 189 Type* r2 = RandomRange(true); |
| 190 Type* expected_type = TypeBinaryOp(op, r1, r2); | 190 Type* expected_type = TypeBinaryOp(op, r1, r2); |
| 191 for (int i = 0; i < 10; i++) { | 191 for (int i = 0; i < 10; i++) { |
| 192 int32_t x1 = static_cast<int32_t>(RandomInt(r1->AsRange())); | 192 int32_t x1 = static_cast<int32_t>(RandomInt(r1->AsRange())); |
| 193 int32_t x2 = static_cast<int32_t>(RandomInt(r2->AsRange())); | 193 int32_t x2 = static_cast<int32_t>(RandomInt(r2->AsRange())); |
| 194 double result_value = opfun(x1, x2); | 194 double result_value = opfun(x1, x2); |
| 195 Type* result_type = Type::Constant( | 195 Type* result_type = Type::NewConstant( |
| 196 isolate()->factory()->NewNumber(result_value), zone()); | 196 isolate()->factory()->NewNumber(result_value), zone()); |
| 197 EXPECT_TRUE(result_type->Is(expected_type)); | 197 EXPECT_TRUE(result_type->Is(expected_type)); |
| 198 } | 198 } |
| 199 } | 199 } |
| 200 } | 200 } |
| 201 | 201 |
| 202 Type* RandomSubtype(Type* type) { | 202 Type* RandomSubtype(Type* type) { |
| 203 Type* subtype; | 203 Type* subtype; |
| 204 do { | 204 do { |
| 205 subtype = types_.Fuzz(); | 205 subtype = types_.Fuzz(); |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 for (auto i : values) { | 383 for (auto i : values) { |
| 384 Node* c = graph()->NewNode(common()->Int32Constant(i)); | 384 Node* c = graph()->NewNode(common()->Int32Constant(i)); |
| 385 Type* type = NodeProperties::GetType(c); | 385 Type* type = NodeProperties::GetType(c); |
| 386 EXPECT_TRUE(type->Is(NewRange(i, i))); | 386 EXPECT_TRUE(type->Is(NewRange(i, i))); |
| 387 } | 387 } |
| 388 } | 388 } |
| 389 | 389 |
| 390 } // namespace compiler | 390 } // namespace compiler |
| 391 } // namespace internal | 391 } // namespace internal |
| 392 } // namespace v8 | 392 } // namespace v8 |
| OLD | NEW |