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

Side by Side Diff: src/compiler/effect-control-linearizer.cc

Issue 2367593003: [turbofan] ChangeFloat64ToTagged shouldn't canonicalize. (Closed)
Patch Set: REBASE Created 4 years, 2 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 | « no previous file | src/compiler/representation-change.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 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 "src/compiler/effect-control-linearizer.h" 5 #include "src/compiler/effect-control-linearizer.h"
6 6
7 #include "src/code-factory.h" 7 #include "src/code-factory.h"
8 #include "src/compiler/access-builder.h" 8 #include "src/compiler/access-builder.h"
9 #include "src/compiler/js-graph.h" 9 #include "src/compiler/js-graph.h"
10 #include "src/compiler/linkage.h" 10 #include "src/compiler/linkage.h"
(...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 } 778 }
779 NodeProperties::ReplaceUses(node, state.value, state.effect, state.control); 779 NodeProperties::ReplaceUses(node, state.value, state.effect, state.control);
780 *effect = state.effect; 780 *effect = state.effect;
781 *control = state.control; 781 *control = state.control;
782 return true; 782 return true;
783 } 783 }
784 784
785 EffectControlLinearizer::ValueEffectControl 785 EffectControlLinearizer::ValueEffectControl
786 EffectControlLinearizer::LowerChangeFloat64ToTagged(Node* node, Node* effect, 786 EffectControlLinearizer::LowerChangeFloat64ToTagged(Node* node, Node* effect,
787 Node* control) { 787 Node* control) {
788 CheckForMinusZeroMode mode = CheckMinusZeroModeOf(node->op());
789 Node* value = node->InputAt(0); 788 Node* value = node->InputAt(0);
790 789 return AllocateHeapNumberWithValue(value, effect, control);
791 Node* value32 = graph()->NewNode(machine()->RoundFloat64ToInt32(), value);
792 Node* check_same = graph()->NewNode(
793 machine()->Float64Equal(), value,
794 graph()->NewNode(machine()->ChangeInt32ToFloat64(), value32));
795 Node* branch_same = graph()->NewNode(common()->Branch(), check_same, control);
796
797 Node* if_smi = graph()->NewNode(common()->IfTrue(), branch_same);
798 Node* vsmi;
799 Node* if_box = graph()->NewNode(common()->IfFalse(), branch_same);
800
801 if (mode == CheckForMinusZeroMode::kCheckForMinusZero) {
802 // Check if {value} is -0.
803 Node* check_zero = graph()->NewNode(machine()->Word32Equal(), value32,
804 jsgraph()->Int32Constant(0));
805 Node* branch_zero = graph()->NewNode(common()->Branch(BranchHint::kFalse),
806 check_zero, if_smi);
807
808 Node* if_zero = graph()->NewNode(common()->IfTrue(), branch_zero);
809 Node* if_notzero = graph()->NewNode(common()->IfFalse(), branch_zero);
810
811 // In case of 0, we need to check the high bits for the IEEE -0 pattern.
812 Node* check_negative = graph()->NewNode(
813 machine()->Int32LessThan(),
814 graph()->NewNode(machine()->Float64ExtractHighWord32(), value),
815 jsgraph()->Int32Constant(0));
816 Node* branch_negative = graph()->NewNode(
817 common()->Branch(BranchHint::kFalse), check_negative, if_zero);
818
819 Node* if_negative = graph()->NewNode(common()->IfTrue(), branch_negative);
820 Node* if_notnegative =
821 graph()->NewNode(common()->IfFalse(), branch_negative);
822
823 // We need to create a box for negative 0.
824 if_smi = graph()->NewNode(common()->Merge(2), if_notzero, if_notnegative);
825 if_box = graph()->NewNode(common()->Merge(2), if_box, if_negative);
826 }
827
828 // On 64-bit machines we can just wrap the 32-bit integer in a smi, for 32-bit
829 // machines we need to deal with potential overflow and fallback to boxing.
830 if (machine()->Is64()) {
831 vsmi = ChangeInt32ToSmi(value32);
832 } else {
833 Node* smi_tag = graph()->NewNode(machine()->Int32AddWithOverflow(), value32,
834 value32, if_smi);
835
836 Node* check_ovf =
837 graph()->NewNode(common()->Projection(1), smi_tag, if_smi);
838 Node* branch_ovf = graph()->NewNode(common()->Branch(BranchHint::kFalse),
839 check_ovf, if_smi);
840
841 Node* if_ovf = graph()->NewNode(common()->IfTrue(), branch_ovf);
842 if_box = graph()->NewNode(common()->Merge(2), if_ovf, if_box);
843
844 if_smi = graph()->NewNode(common()->IfFalse(), branch_ovf);
845 vsmi = graph()->NewNode(common()->Projection(0), smi_tag, if_smi);
846 }
847
848 // Allocate the box for the {value}.
849 ValueEffectControl box = AllocateHeapNumberWithValue(value, effect, if_box);
850
851 control = graph()->NewNode(common()->Merge(2), if_smi, box.control);
852 value = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2),
853 vsmi, box.value, control);
854 effect =
855 graph()->NewNode(common()->EffectPhi(2), effect, box.effect, control);
856 return ValueEffectControl(value, effect, control);
857 } 790 }
858 791
859 EffectControlLinearizer::ValueEffectControl 792 EffectControlLinearizer::ValueEffectControl
860 EffectControlLinearizer::LowerChangeBitToTagged(Node* node, Node* effect, 793 EffectControlLinearizer::LowerChangeBitToTagged(Node* node, Node* effect,
861 Node* control) { 794 Node* control) {
862 Node* value = node->InputAt(0); 795 Node* value = node->InputAt(0);
863 796
864 Node* branch = graph()->NewNode(common()->Branch(), value, control); 797 Node* branch = graph()->NewNode(common()->Branch(), value, control);
865 798
866 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); 799 Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
(...skipping 2688 matching lines...) Expand 10 before | Expand all | Expand 10 after
3555 isolate(), graph()->zone(), callable.descriptor(), 0, flags, 3488 isolate(), graph()->zone(), callable.descriptor(), 0, flags,
3556 Operator::kEliminatable); 3489 Operator::kEliminatable);
3557 to_number_operator_.set(common()->Call(desc)); 3490 to_number_operator_.set(common()->Call(desc));
3558 } 3491 }
3559 return to_number_operator_.get(); 3492 return to_number_operator_.get();
3560 } 3493 }
3561 3494
3562 } // namespace compiler 3495 } // namespace compiler
3563 } // namespace internal 3496 } // namespace internal
3564 } // namespace v8 3497 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/compiler/representation-change.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698