| 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/v8.h" | 5 #include "src/v8.h" |
| 6 #include "test/cctest/cctest.h" | 6 #include "test/cctest/cctest.h" |
| 7 | 7 |
| 8 #include "src/compiler/graph-inl.h" | 8 #include "src/compiler/graph-inl.h" |
| 9 #include "src/compiler/js-typed-lowering.h" | 9 #include "src/compiler/js-typed-lowering.h" |
| 10 #include "src/compiler/node-properties-inl.h" | 10 #include "src/compiler/node-properties-inl.h" |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 CHECK_EQ(p0, r->InputAt(0)); | 255 CHECK_EQ(p0, r->InputAt(0)); |
| 256 CHECK_EQ(p1, r->InputAt(1)); | 256 CHECK_EQ(p1, r->InputAt(1)); |
| 257 } | 257 } |
| 258 } | 258 } |
| 259 } | 259 } |
| 260 } | 260 } |
| 261 | 261 |
| 262 | 262 |
| 263 static void CheckToI32(Node* old_input, Node* new_input, bool is_signed) { | 263 static void CheckToI32(Node* old_input, Node* new_input, bool is_signed) { |
| 264 Type* old_type = NodeProperties::GetBounds(old_input).upper; | 264 Type* old_type = NodeProperties::GetBounds(old_input).upper; |
| 265 Type* new_type = NodeProperties::GetBounds(new_input).upper; |
| 265 Type* expected_type = I32Type(is_signed); | 266 Type* expected_type = I32Type(is_signed); |
| 267 CHECK(new_type->Is(expected_type)); |
| 266 if (old_type->Is(expected_type)) { | 268 if (old_type->Is(expected_type)) { |
| 267 CHECK_EQ(old_input, new_input); | 269 CHECK_EQ(old_input, new_input); |
| 268 } else if (new_input->opcode() == IrOpcode::kNumberConstant) { | 270 } else if (new_input->opcode() == IrOpcode::kNumberConstant) { |
| 269 CHECK(NodeProperties::GetBounds(new_input).upper->Is(expected_type)); | |
| 270 double v = OpParameter<double>(new_input); | 271 double v = OpParameter<double>(new_input); |
| 271 double e = static_cast<double>(is_signed ? FastD2I(v) : FastD2UI(v)); | 272 double e = static_cast<double>(is_signed ? FastD2I(v) : FastD2UI(v)); |
| 272 CHECK_EQ(e, v); | 273 CHECK_EQ(e, v); |
| 273 } else { | |
| 274 CHECK_EQ(NumberToI32(is_signed), new_input->opcode()); | |
| 275 } | 274 } |
| 276 } | 275 } |
| 277 | 276 |
| 278 | 277 |
| 279 // A helper class for testing lowering of bitwise shift operators. | 278 // A helper class for testing lowering of bitwise shift operators. |
| 280 class JSBitwiseShiftTypedLoweringTester : public JSTypedLoweringTester { | 279 class JSBitwiseShiftTypedLoweringTester : public JSTypedLoweringTester { |
| 281 public: | 280 public: |
| 282 static const int kNumberOps = 6; | 281 static const int kNumberOps = 6; |
| 283 const Operator* ops[kNumberOps]; | 282 const Operator* ops[kNumberOps]; |
| 284 bool signedness[kNumberOps]; | 283 bool signedness[kNumberOps]; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 ops[idx] = op; | 357 ops[idx] = op; |
| 359 signedness[idx] = s; | 358 signedness[idx] = s; |
| 360 } | 359 } |
| 361 }; | 360 }; |
| 362 | 361 |
| 363 | 362 |
| 364 TEST(Int32BitwiseBinops) { | 363 TEST(Int32BitwiseBinops) { |
| 365 JSBitwiseTypedLoweringTester R; | 364 JSBitwiseTypedLoweringTester R; |
| 366 | 365 |
| 367 Type* types[] = { | 366 Type* types[] = { |
| 368 Type::SignedSmall(), Type::UnsignedSmall(), Type::OtherSigned32(), | 367 Type::SignedSmall(), Type::UnsignedSmall(), Type::Unsigned32(), |
| 369 Type::Unsigned32(), Type::Signed32(), Type::MinusZero(), | 368 Type::Signed32(), Type::MinusZero(), Type::NaN(), |
| 370 Type::NaN(), Type::OtherNumber(), Type::Undefined(), | 369 Type::OtherNumber(), Type::Undefined(), Type::Null(), |
| 371 Type::Null(), Type::Boolean(), Type::Number(), | 370 Type::Boolean(), Type::Number(), Type::String(), |
| 372 Type::String(), Type::Object()}; | 371 Type::Object()}; |
| 373 | 372 |
| 374 for (size_t i = 0; i < arraysize(types); ++i) { | 373 for (size_t i = 0; i < arraysize(types); ++i) { |
| 375 Node* p0 = R.Parameter(types[i], 0); | 374 Node* p0 = R.Parameter(types[i], 0); |
| 376 | 375 |
| 377 for (size_t j = 0; j < arraysize(types); ++j) { | 376 for (size_t j = 0; j < arraysize(types); ++j) { |
| 378 Node* p1 = R.Parameter(types[j], 1); | 377 Node* p1 = R.Parameter(types[j], 1); |
| 379 | 378 |
| 380 for (int k = 0; k < R.kNumberOps; k += 2) { | 379 for (int k = 0; k < R.kNumberOps; k += 2) { |
| 381 Node* add = R.Binop(R.ops[k], p0, p1); | 380 Node* add = R.Binop(R.ops[k], p0, p1); |
| 382 Node* r = R.reduce(add); | 381 Node* r = R.reduce(add); |
| (...skipping 995 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1378 CHECK_EQ(p1, r->InputAt(0)); | 1377 CHECK_EQ(p1, r->InputAt(0)); |
| 1379 CHECK_EQ(p0, r->InputAt(1)); | 1378 CHECK_EQ(p0, r->InputAt(1)); |
| 1380 } else { | 1379 } else { |
| 1381 CHECK_EQ(p0, r->InputAt(0)); | 1380 CHECK_EQ(p0, r->InputAt(0)); |
| 1382 CHECK_EQ(p1, r->InputAt(1)); | 1381 CHECK_EQ(p1, r->InputAt(1)); |
| 1383 } | 1382 } |
| 1384 } | 1383 } |
| 1385 } | 1384 } |
| 1386 } | 1385 } |
| 1387 } | 1386 } |
| OLD | NEW |