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 "src/compiler/code-stub-assembler.h" | 5 #include "src/compiler/code-stub-assembler.h" |
6 | 6 |
7 #include <ostream> | 7 #include <ostream> |
8 | 8 |
9 #include "src/code-factory.h" | 9 #include "src/code-factory.h" |
10 #include "src/compiler/graph.h" | 10 #include "src/compiler/graph.h" |
(...skipping 864 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
875 Goto(&if_join); | 875 Goto(&if_join); |
876 Bind(&if_notoverflow); | 876 Bind(&if_notoverflow); |
877 { | 877 { |
878 Node* result = Projection(0, pair); | 878 Node* result = Projection(0, pair); |
879 var_result.Bind(result); | 879 var_result.Bind(result); |
880 } | 880 } |
881 Goto(&if_join); | 881 Goto(&if_join); |
882 Bind(&if_join); | 882 Bind(&if_join); |
883 return var_result.value(); | 883 return var_result.value(); |
884 } | 884 } |
885 | |
886 Node* CodeStubAssembler::ChangeUint32ToTagged(Node* value) { | |
887 Label if_overflow(this, Label::kDeferred), if_not_overflow(this), | |
888 if_join(this); | |
889 Variable var_result(this, MachineRepresentation::kTagged); | |
890 // If {value} > 2^31 - 1, we need to store it in a HeapNumber. | |
891 Branch(Int32LessThan(value, Int32Constant(0)), &if_overflow, | |
892 &if_not_overflow); | |
893 Bind(&if_not_overflow); | |
894 { | |
895 if (raw_assembler_->machine()->Is64()) { | |
896 var_result.Bind(SmiTag(ChangeUint32ToUint64(value))); | |
897 } else { | |
898 // If tagging {value} results in an overflow, we need to use a HeapNumber | |
899 // to represent it. | |
900 Node* pair = Int32AddWithOverflow(value, value); | |
901 Node* overflow = Projection(1, pair); | |
902 GotoIf(overflow, &if_overflow); | |
903 | |
904 Node* result = Projection(0, pair); | |
905 var_result.Bind(result); | |
906 } | |
907 } | |
908 Goto(&if_join); | |
909 | |
910 Bind(&if_overflow); | |
911 { | |
912 Node* float64_value = ChangeUint32ToFloat64(value); | |
913 var_result.Bind(AllocateHeapNumberWithValue(float64_value)); | |
914 } | |
915 Goto(&if_join); | |
916 | |
917 Bind(&if_join); | |
918 return var_result.value(); | |
919 } | |
920 | 885 |
921 Node* CodeStubAssembler::TruncateTaggedToFloat64(Node* context, Node* value) { | 886 Node* CodeStubAssembler::TruncateTaggedToFloat64(Node* context, Node* value) { |
922 // We might need to loop once due to ToNumber conversion. | 887 // We might need to loop once due to ToNumber conversion. |
923 Variable var_value(this, MachineRepresentation::kTagged), | 888 Variable var_value(this, MachineRepresentation::kTagged), |
924 var_result(this, MachineRepresentation::kFloat64); | 889 var_result(this, MachineRepresentation::kFloat64); |
925 Label loop(this, &var_value), done_loop(this, &var_result); | 890 Label loop(this, &var_value), done_loop(this, &var_result); |
926 var_value.Bind(value); | 891 var_value.Bind(value); |
927 Goto(&loop); | 892 Goto(&loop); |
928 Bind(&loop); | 893 Bind(&loop); |
929 { | 894 { |
(...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1754 } | 1719 } |
1755 } | 1720 } |
1756 } | 1721 } |
1757 | 1722 |
1758 bound_ = true; | 1723 bound_ = true; |
1759 } | 1724 } |
1760 | 1725 |
1761 } // namespace compiler | 1726 } // namespace compiler |
1762 } // namespace internal | 1727 } // namespace internal |
1763 } // namespace v8 | 1728 } // namespace v8 |
OLD | NEW |