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

Side by Side Diff: src/compiler/simplified-lowering.cc

Issue 1225993002: [turbofan] Add TruncationMode for TruncateFloat64ToInt32. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 5 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
« no previous file with comments | « src/compiler/representation-change.h ('k') | src/compiler/x64/instruction-selector-x64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "src/compiler/simplified-lowering.h" 5 #include "src/compiler/simplified-lowering.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/code-factory.h" 10 #include "src/code-factory.h"
(...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 if (lower()) DeferReplacement(node, node->InputAt(0)); 720 if (lower()) DeferReplacement(node, node->InputAt(0));
721 } else if ((in & kTypeMask) == kTypeInt32 || 721 } else if ((in & kTypeMask) == kTypeInt32 ||
722 (in & kRepMask) == kRepWord32) { 722 (in & kRepMask) == kRepWord32) {
723 // Just change representation if necessary. 723 // Just change representation if necessary.
724 VisitUnop(node, kTypeInt32 | kRepWord32, kTypeInt32 | kRepWord32); 724 VisitUnop(node, kTypeInt32 | kRepWord32, kTypeInt32 | kRepWord32);
725 if (lower()) DeferReplacement(node, node->InputAt(0)); 725 if (lower()) DeferReplacement(node, node->InputAt(0));
726 } else { 726 } else {
727 // Require the input in float64 format and perform truncation. 727 // Require the input in float64 format and perform truncation.
728 // TODO(turbofan): avoid a truncation with a smi check. 728 // TODO(turbofan): avoid a truncation with a smi check.
729 VisitUnop(node, kTypeInt32 | kRepFloat64, kTypeInt32 | kRepWord32); 729 VisitUnop(node, kTypeInt32 | kRepFloat64, kTypeInt32 | kRepWord32);
730 if (lower()) 730 if (lower()) {
731 node->set_op(lowering->machine()->TruncateFloat64ToInt32()); 731 node->set_op(lowering->machine()->TruncateFloat64ToInt32(
732 TruncationMode::kJavaScript));
733 }
732 } 734 }
733 break; 735 break;
734 } 736 }
735 case IrOpcode::kNumberToUint32: { 737 case IrOpcode::kNumberToUint32: {
736 MachineTypeUnion use_rep = use & kRepMask; 738 MachineTypeUnion use_rep = use & kRepMask;
737 Node* input = node->InputAt(0); 739 Node* input = node->InputAt(0);
738 Type* in_upper = NodeProperties::GetBounds(input).upper; 740 Type* in_upper = NodeProperties::GetBounds(input).upper;
739 MachineTypeUnion in = GetInfo(input)->output; 741 MachineTypeUnion in = GetInfo(input)->output;
740 if (in_upper->Is(Type::Unsigned32())) { 742 if (in_upper->Is(Type::Unsigned32())) {
741 // If the input has type uint32, pass through representation. 743 // If the input has type uint32, pass through representation.
742 VisitUnop(node, kTypeUint32 | use_rep, kTypeUint32 | use_rep); 744 VisitUnop(node, kTypeUint32 | use_rep, kTypeUint32 | use_rep);
743 if (lower()) DeferReplacement(node, node->InputAt(0)); 745 if (lower()) DeferReplacement(node, node->InputAt(0));
744 } else if ((in & kTypeMask) == kTypeInt32 || 746 } else if ((in & kTypeMask) == kTypeInt32 ||
745 in_upper->Is(Type::Signed32())) { 747 in_upper->Is(Type::Signed32())) {
746 // Just change representation if necessary. 748 // Just change representation if necessary.
747 VisitUnop(node, kTypeInt32 | kRepWord32, kTypeUint32 | kRepWord32); 749 VisitUnop(node, kTypeInt32 | kRepWord32, kTypeUint32 | kRepWord32);
748 if (lower()) DeferReplacement(node, node->InputAt(0)); 750 if (lower()) DeferReplacement(node, node->InputAt(0));
749 } else if ((in & kTypeMask) == kTypeUint32 || 751 } else if ((in & kTypeMask) == kTypeUint32 ||
750 (in & kRepMask) == kRepWord32) { 752 (in & kRepMask) == kRepWord32) {
751 // Just change representation if necessary. 753 // Just change representation if necessary.
752 VisitUnop(node, kTypeUint32 | kRepWord32, kTypeUint32 | kRepWord32); 754 VisitUnop(node, kTypeUint32 | kRepWord32, kTypeUint32 | kRepWord32);
753 if (lower()) DeferReplacement(node, node->InputAt(0)); 755 if (lower()) DeferReplacement(node, node->InputAt(0));
754 } else { 756 } else {
755 // Require the input in float64 format and perform truncation. 757 // Require the input in float64 format and perform truncation.
756 // TODO(turbofan): avoid a truncation with a smi check. 758 // TODO(turbofan): avoid a truncation with a smi check.
757 VisitUnop(node, kTypeUint32 | kRepFloat64, kTypeUint32 | kRepWord32); 759 VisitUnop(node, kTypeUint32 | kRepFloat64, kTypeUint32 | kRepWord32);
758 if (lower()) 760 if (lower()) {
759 node->set_op(lowering->machine()->TruncateFloat64ToInt32()); 761 node->set_op(lowering->machine()->TruncateFloat64ToInt32(
762 TruncationMode::kJavaScript));
763 }
760 } 764 }
761 break; 765 break;
762 } 766 }
763 case IrOpcode::kPlainPrimitiveToNumber: { 767 case IrOpcode::kPlainPrimitiveToNumber: {
764 VisitUnop(node, kMachAnyTagged, kTypeNumber | kRepTagged); 768 VisitUnop(node, kMachAnyTagged, kTypeNumber | kRepTagged);
765 if (lower()) { 769 if (lower()) {
766 // PlainPrimitiveToNumber(x) => Call(ToNumberStub, x, no-context) 770 // PlainPrimitiveToNumber(x) => Call(ToNumberStub, x, no-context)
767 Operator::Properties properties = node->op()->properties(); 771 Operator::Properties properties = node->op()->properties();
768 Callable callable = CodeFactory::ToNumber(jsgraph_->isolate()); 772 Callable callable = CodeFactory::ToNumber(jsgraph_->isolate());
769 CallDescriptor::Flags flags = CallDescriptor::kNoFlags; 773 CallDescriptor::Flags flags = CallDescriptor::kNoFlags;
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
1001 1005
1002 case IrOpcode::kChangeInt32ToInt64: 1006 case IrOpcode::kChangeInt32ToInt64:
1003 return VisitUnop(node, kTypeInt32 | kRepWord32, 1007 return VisitUnop(node, kTypeInt32 | kRepWord32,
1004 kTypeInt32 | kRepWord64); 1008 kTypeInt32 | kRepWord64);
1005 case IrOpcode::kChangeUint32ToUint64: 1009 case IrOpcode::kChangeUint32ToUint64:
1006 return VisitUnop(node, kTypeUint32 | kRepWord32, 1010 return VisitUnop(node, kTypeUint32 | kRepWord32,
1007 kTypeUint32 | kRepWord64); 1011 kTypeUint32 | kRepWord64);
1008 case IrOpcode::kTruncateFloat64ToFloat32: 1012 case IrOpcode::kTruncateFloat64ToFloat32:
1009 return VisitUnop(node, kTypeNumber | kRepFloat64, 1013 return VisitUnop(node, kTypeNumber | kRepFloat64,
1010 kTypeNumber | kRepFloat32); 1014 kTypeNumber | kRepFloat32);
1015 case IrOpcode::kTruncateFloat64ToInt32:
1016 return VisitUnop(node, kTypeNumber | kRepFloat64,
1017 kTypeInt32 | kRepWord32);
1011 case IrOpcode::kTruncateInt64ToInt32: 1018 case IrOpcode::kTruncateInt64ToInt32:
1012 // TODO(titzer): Is kTypeInt32 correct here? 1019 // TODO(titzer): Is kTypeInt32 correct here?
1013 return VisitUnop(node, kTypeInt32 | kRepWord64, 1020 return VisitUnop(node, kTypeInt32 | kRepWord64,
1014 kTypeInt32 | kRepWord32); 1021 kTypeInt32 | kRepWord32);
1015 1022
1016 case IrOpcode::kChangeFloat32ToFloat64: 1023 case IrOpcode::kChangeFloat32ToFloat64:
1017 return VisitUnop(node, kTypeNumber | kRepFloat32, 1024 return VisitUnop(node, kTypeNumber | kRepFloat32,
1018 kTypeNumber | kRepFloat64); 1025 kTypeNumber | kRepFloat64);
1019 case IrOpcode::kChangeInt32ToFloat64: 1026 case IrOpcode::kChangeInt32ToFloat64:
1020 return VisitUnop(node, kTypeInt32 | kRepWord32, 1027 return VisitUnop(node, kTypeInt32 | kRepWord32,
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after
1626 1633
1627 void SimplifiedLowering::DoStringLessThanOrEqual(Node* node) { 1634 void SimplifiedLowering::DoStringLessThanOrEqual(Node* node) {
1628 node->set_op(machine()->IntLessThanOrEqual()); 1635 node->set_op(machine()->IntLessThanOrEqual());
1629 node->ReplaceInput(0, StringComparison(node, true)); 1636 node->ReplaceInput(0, StringComparison(node, true));
1630 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL)); 1637 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL));
1631 } 1638 }
1632 1639
1633 } // namespace compiler 1640 } // namespace compiler
1634 } // namespace internal 1641 } // namespace internal
1635 } // namespace v8 1642 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/representation-change.h ('k') | src/compiler/x64/instruction-selector-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698