| 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 // TODO(jochen): Remove this after the setting is turned on globally. | 5 // TODO(jochen): Remove this after the setting is turned on globally. |
| 6 #define V8_IMMINENT_DEPRECATION_WARNINGS | 6 #define V8_IMMINENT_DEPRECATION_WARNINGS |
| 7 | 7 |
| 8 #include <limits> | 8 #include <limits> |
| 9 | 9 |
| 10 #include "test/cctest/cctest.h" | 10 #include "test/cctest/cctest.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 } | 74 } |
| 75 | 75 |
| 76 void CheckNumberConstant(Node* n, double expected) { | 76 void CheckNumberConstant(Node* n, double expected) { |
| 77 NumberMatcher m(n); | 77 NumberMatcher m(n); |
| 78 CHECK_EQ(IrOpcode::kNumberConstant, n->opcode()); | 78 CHECK_EQ(IrOpcode::kNumberConstant, n->opcode()); |
| 79 CHECK(m.HasValue()); | 79 CHECK(m.HasValue()); |
| 80 CheckDoubleEq(expected, m.Value()); | 80 CheckDoubleEq(expected, m.Value()); |
| 81 } | 81 } |
| 82 | 82 |
| 83 Node* Parameter(int index = 0) { | 83 Node* Parameter(int index = 0) { |
| 84 return graph()->NewNode(common()->Parameter(index), graph()->start()); | 84 Node* n = graph()->NewNode(common()->Parameter(index), graph()->start()); |
| 85 NodeProperties::SetType(n, Type::Any()); |
| 86 return n; |
| 85 } | 87 } |
| 86 | 88 |
| 87 void CheckTypeError(MachineTypeUnion from, MachineTypeUnion to) { | 89 void CheckTypeError(MachineTypeUnion from, MachineTypeUnion to) { |
| 88 changer()->testing_type_errors_ = true; | 90 changer()->testing_type_errors_ = true; |
| 89 changer()->type_error_ = false; | 91 changer()->type_error_ = false; |
| 90 Node* n = Parameter(0); | 92 Node* n = Parameter(0); |
| 91 Node* c = changer()->GetRepresentationFor(n, from, to); | 93 Node* c = changer()->GetRepresentationFor(n, from, to); |
| 92 CHECK(changer()->type_error_); | 94 CHECK(changer()->type_error_); |
| 93 CHECK_EQ(n, c); | 95 CHECK_EQ(n, c); |
| 94 } | 96 } |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 IrOpcode::kChangeFloat64ToTagged, kRepFloat32, kRepTagged); | 446 IrOpcode::kChangeFloat64ToTagged, kRepFloat32, kRepTagged); |
| 445 CheckTwoChanges(IrOpcode::kChangeTaggedToFloat64, | 447 CheckTwoChanges(IrOpcode::kChangeTaggedToFloat64, |
| 446 IrOpcode::kTruncateFloat64ToFloat32, kRepTagged, kRepFloat32); | 448 IrOpcode::kTruncateFloat64ToFloat32, kRepTagged, kRepFloat32); |
| 447 } | 449 } |
| 448 | 450 |
| 449 | 451 |
| 450 TEST(SignednessInWord32) { | 452 TEST(SignednessInWord32) { |
| 451 RepresentationChangerTester r; | 453 RepresentationChangerTester r; |
| 452 | 454 |
| 453 // TODO(titzer): assume that uses of a word32 without a sign mean kTypeInt32. | 455 // TODO(titzer): assume that uses of a word32 without a sign mean kTypeInt32. |
| 454 CheckChange(IrOpcode::kChangeTaggedToInt32, kRepTagged, | 456 CheckChange(IrOpcode::kChangeTaggedToInt32, kRepTagged | kTypeInt32, |
| 455 kRepWord32 | kTypeInt32); | 457 kRepWord32 | kTypeInt32); |
| 456 CheckChange(IrOpcode::kChangeTaggedToUint32, kRepTagged, | 458 CheckChange(IrOpcode::kChangeTaggedToUint32, kRepTagged | kTypeUint32, |
| 457 kRepWord32 | kTypeUint32); | 459 kRepWord32 | kTypeUint32); |
| 458 CheckChange(IrOpcode::kChangeInt32ToFloat64, kRepWord32, kRepFloat64); | 460 CheckChange(IrOpcode::kChangeInt32ToFloat64, kRepWord32, kRepFloat64); |
| 459 CheckChange(IrOpcode::kChangeFloat64ToInt32, kRepFloat64, kRepWord32); | 461 CheckChange(IrOpcode::kChangeFloat64ToInt32, kRepFloat64 | kTypeInt32, |
| 462 kRepWord32); |
| 463 CheckChange(IrOpcode::kTruncateFloat64ToInt32, kRepFloat64, kRepWord32); |
| 460 | 464 |
| 461 CheckTwoChanges(IrOpcode::kChangeInt32ToFloat64, | 465 CheckTwoChanges(IrOpcode::kChangeInt32ToFloat64, |
| 462 IrOpcode::kTruncateFloat64ToFloat32, kRepWord32, kRepFloat32); | 466 IrOpcode::kTruncateFloat64ToFloat32, kRepWord32, kRepFloat32); |
| 463 CheckTwoChanges(IrOpcode::kChangeFloat32ToFloat64, | 467 CheckTwoChanges(IrOpcode::kChangeFloat32ToFloat64, |
| 464 IrOpcode::kChangeFloat64ToInt32, kRepFloat32, kRepWord32); | 468 IrOpcode::kTruncateFloat64ToInt32, kRepFloat32, kRepWord32); |
| 465 } | 469 } |
| 466 | 470 |
| 467 | 471 |
| 468 TEST(Nops) { | 472 TEST(Nops) { |
| 469 RepresentationChangerTester r; | 473 RepresentationChangerTester r; |
| 470 | 474 |
| 471 // X -> X is always a nop for any single representation X. | 475 // X -> X is always a nop for any single representation X. |
| 472 for (size_t i = 0; i < arraysize(all_reps); i++) { | 476 for (size_t i = 0; i < arraysize(all_reps); i++) { |
| 473 r.CheckNop(all_reps[i], all_reps[i]); | 477 r.CheckNop(all_reps[i], all_reps[i]); |
| 474 } | 478 } |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 544 if (i == j) continue; | 548 if (i == j) continue; |
| 545 // Only a single from representation is allowed. | 549 // Only a single from representation is allowed. |
| 546 r.CheckTypeError(all_reps[i] | all_reps[j], kRepTagged); | 550 r.CheckTypeError(all_reps[i] | all_reps[j], kRepTagged); |
| 547 } | 551 } |
| 548 } | 552 } |
| 549 } | 553 } |
| 550 | 554 |
| 551 } // namespace compiler | 555 } // namespace compiler |
| 552 } // namespace internal | 556 } // namespace internal |
| 553 } // namespace v8 | 557 } // namespace v8 |
| OLD | NEW |