OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/code-stubs.h" | 5 #include "src/code-stubs.h" |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
8 | 8 |
9 #include "src/ast/ast.h" | 9 #include "src/ast/ast.h" |
10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
(...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
829 | 829 |
830 // Shared entry for floating point subtraction. | 830 // Shared entry for floating point subtraction. |
831 Label do_fsub(assembler), end(assembler), | 831 Label do_fsub(assembler), end(assembler), |
832 call_subtract_stub(assembler, Label::kDeferred); | 832 call_subtract_stub(assembler, Label::kDeferred); |
833 Variable var_fsub_lhs(assembler, MachineRepresentation::kFloat64), | 833 Variable var_fsub_lhs(assembler, MachineRepresentation::kFloat64), |
834 var_fsub_rhs(assembler, MachineRepresentation::kFloat64), | 834 var_fsub_rhs(assembler, MachineRepresentation::kFloat64), |
835 var_type_feedback(assembler, MachineRepresentation::kWord32), | 835 var_type_feedback(assembler, MachineRepresentation::kWord32), |
836 var_result(assembler, MachineRepresentation::kTagged); | 836 var_result(assembler, MachineRepresentation::kTagged); |
837 | 837 |
838 // Check if the {lhs} is a Smi or a HeapObject. | 838 // Check if the {lhs} is a Smi or a HeapObject. |
839 Label if_lhsissmi(assembler), if_lhsisnotsmi(assembler); | 839 Label if_lhsissmi(assembler), if_lhsisnotsmi(assembler), |
840 if_lhsisnotnumber(assembler), check_rhsisoddball(assembler), | |
Leszek Swirski
2016/10/10 11:57:22
move the new label definitions to the above label
mythria
2016/10/10 13:26:00
Thanks, Done.
| |
841 call_with_any_feedback(assembler); | |
840 assembler->Branch(assembler->WordIsSmi(lhs), &if_lhsissmi, &if_lhsisnotsmi); | 842 assembler->Branch(assembler->WordIsSmi(lhs), &if_lhsissmi, &if_lhsisnotsmi); |
841 | 843 |
842 assembler->Bind(&if_lhsissmi); | 844 assembler->Bind(&if_lhsissmi); |
843 { | 845 { |
844 // Check if the {rhs} is also a Smi. | 846 // Check if the {rhs} is also a Smi. |
845 Label if_rhsissmi(assembler), if_rhsisnotsmi(assembler); | 847 Label if_rhsissmi(assembler), if_rhsisnotsmi(assembler); |
846 assembler->Branch(assembler->WordIsSmi(rhs), &if_rhsissmi, &if_rhsisnotsmi); | 848 assembler->Branch(assembler->WordIsSmi(rhs), &if_rhsissmi, &if_rhsisnotsmi); |
847 | 849 |
848 assembler->Bind(&if_rhsissmi); | 850 assembler->Bind(&if_rhsissmi); |
849 { | 851 { |
(...skipping 22 matching lines...) Expand all Loading... | |
872 assembler->Goto(&end); | 874 assembler->Goto(&end); |
873 } | 875 } |
874 | 876 |
875 assembler->Bind(&if_rhsisnotsmi); | 877 assembler->Bind(&if_rhsisnotsmi); |
876 { | 878 { |
877 // Load the map of the {rhs}. | 879 // Load the map of the {rhs}. |
878 Node* rhs_map = assembler->LoadMap(rhs); | 880 Node* rhs_map = assembler->LoadMap(rhs); |
879 | 881 |
880 // Check if {rhs} is a HeapNumber. | 882 // Check if {rhs} is a HeapNumber. |
881 assembler->GotoUnless(assembler->IsHeapNumberMap(rhs_map), | 883 assembler->GotoUnless(assembler->IsHeapNumberMap(rhs_map), |
882 &call_subtract_stub); | 884 &check_rhsisoddball); |
883 | 885 |
884 // Perform a floating point subtraction. | 886 // Perform a floating point subtraction. |
885 var_fsub_lhs.Bind(assembler->SmiToFloat64(lhs)); | 887 var_fsub_lhs.Bind(assembler->SmiToFloat64(lhs)); |
886 var_fsub_rhs.Bind(assembler->LoadHeapNumberValue(rhs)); | 888 var_fsub_rhs.Bind(assembler->LoadHeapNumberValue(rhs)); |
887 assembler->Goto(&do_fsub); | 889 assembler->Goto(&do_fsub); |
888 } | 890 } |
889 } | 891 } |
890 | 892 |
891 assembler->Bind(&if_lhsisnotsmi); | 893 assembler->Bind(&if_lhsisnotsmi); |
892 { | 894 { |
893 // Load the map of the {lhs}. | 895 // Load the map of the {lhs}. |
894 Node* lhs_map = assembler->LoadMap(lhs); | 896 Node* lhs_map = assembler->LoadMap(lhs); |
895 | 897 |
896 // Check if the {lhs} is a HeapNumber. | 898 // Check if the {lhs} is a HeapNumber. |
897 assembler->GotoUnless(assembler->IsHeapNumberMap(lhs_map), | 899 assembler->GotoUnless(assembler->IsHeapNumberMap(lhs_map), |
898 &call_subtract_stub); | 900 &if_lhsisnotnumber); |
899 | 901 |
900 // Check if the {rhs} is a Smi. | 902 // Check if the {rhs} is a Smi. |
901 Label if_rhsissmi(assembler), if_rhsisnotsmi(assembler); | 903 Label if_rhsissmi(assembler), if_rhsisnotsmi(assembler); |
902 assembler->Branch(assembler->WordIsSmi(rhs), &if_rhsissmi, &if_rhsisnotsmi); | 904 assembler->Branch(assembler->WordIsSmi(rhs), &if_rhsissmi, &if_rhsisnotsmi); |
903 | 905 |
904 assembler->Bind(&if_rhsissmi); | 906 assembler->Bind(&if_rhsissmi); |
905 { | 907 { |
906 // Perform a floating point subtraction. | 908 // Perform a floating point subtraction. |
907 var_fsub_lhs.Bind(assembler->LoadHeapNumberValue(lhs)); | 909 var_fsub_lhs.Bind(assembler->LoadHeapNumberValue(lhs)); |
908 var_fsub_rhs.Bind(assembler->SmiToFloat64(rhs)); | 910 var_fsub_rhs.Bind(assembler->SmiToFloat64(rhs)); |
909 assembler->Goto(&do_fsub); | 911 assembler->Goto(&do_fsub); |
910 } | 912 } |
911 | 913 |
912 assembler->Bind(&if_rhsisnotsmi); | 914 assembler->Bind(&if_rhsisnotsmi); |
913 { | 915 { |
914 // Load the map of the {rhs}. | 916 // Load the map of the {rhs}. |
915 Node* rhs_map = assembler->LoadMap(rhs); | 917 Node* rhs_map = assembler->LoadMap(rhs); |
916 | 918 |
917 // Check if the {rhs} is a HeapNumber. | 919 // Check if the {rhs} is a HeapNumber. |
918 assembler->GotoUnless(assembler->IsHeapNumberMap(rhs_map), | 920 assembler->GotoUnless(assembler->IsHeapNumberMap(rhs_map), |
919 &call_subtract_stub); | 921 &check_rhsisoddball); |
920 | 922 |
921 // Perform a floating point subtraction. | 923 // Perform a floating point subtraction. |
922 var_fsub_lhs.Bind(assembler->LoadHeapNumberValue(lhs)); | 924 var_fsub_lhs.Bind(assembler->LoadHeapNumberValue(lhs)); |
923 var_fsub_rhs.Bind(assembler->LoadHeapNumberValue(rhs)); | 925 var_fsub_rhs.Bind(assembler->LoadHeapNumberValue(rhs)); |
924 assembler->Goto(&do_fsub); | 926 assembler->Goto(&do_fsub); |
925 } | 927 } |
926 } | 928 } |
927 | 929 |
928 assembler->Bind(&do_fsub); | 930 assembler->Bind(&do_fsub); |
929 { | 931 { |
930 var_type_feedback.Bind( | 932 var_type_feedback.Bind( |
931 assembler->Int32Constant(BinaryOperationFeedback::kNumber)); | 933 assembler->Int32Constant(BinaryOperationFeedback::kNumber)); |
932 Node* lhs_value = var_fsub_lhs.value(); | 934 Node* lhs_value = var_fsub_lhs.value(); |
933 Node* rhs_value = var_fsub_rhs.value(); | 935 Node* rhs_value = var_fsub_rhs.value(); |
934 Node* value = assembler->Float64Sub(lhs_value, rhs_value); | 936 Node* value = assembler->Float64Sub(lhs_value, rhs_value); |
935 var_result.Bind(assembler->ChangeFloat64ToTagged(value)); | 937 var_result.Bind(assembler->ChangeFloat64ToTagged(value)); |
936 assembler->Goto(&end); | 938 assembler->Goto(&end); |
937 } | 939 } |
938 | 940 |
941 assembler->Bind(&if_lhsisnotnumber); | |
942 { | |
943 // No checks on rhs are done yet. We just know lhs is not number or Smi. | |
944 Label if_rhsissmi(assembler), if_rhsisnotsmi(assembler); | |
Leszek Swirski
2016/10/10 11:57:22
nit: move these declarations to be next to the bra
mythria
2016/10/10 13:26:00
Done.
| |
945 | |
946 // Check if lhs is an oddball. | |
947 Node* lhs_instance_type = assembler->LoadInstanceType(lhs); | |
948 Node* lhs_is_oddball = assembler->Word32Equal( | |
949 lhs_instance_type, assembler->Int32Constant(ODDBALL_TYPE)); | |
950 assembler->GotoUnless(lhs_is_oddball, &call_with_any_feedback); | |
951 | |
952 assembler->Branch(assembler->WordIsSmi(rhs), &if_rhsissmi, &if_rhsisnotsmi); | |
953 | |
954 assembler->Bind(&if_rhsissmi); | |
955 { | |
956 var_type_feedback.Bind( | |
957 assembler->Int32Constant(BinaryOperationFeedback::kNumberOrOddball)); | |
958 assembler->Goto(&call_subtract_stub); | |
Leszek Swirski
2016/10/10 11:57:22
if lhs is an oddball, can we not extract its float
mythria
2016/10/10 13:26:00
As discussed offline, we cannot directly go to fsu
| |
959 } | |
960 | |
961 assembler->Bind(&if_rhsisnotsmi); | |
962 { | |
963 // Load the map of the {rhs}. | |
964 Node* rhs_map = assembler->LoadMap(rhs); | |
965 | |
966 // Check if {rhs} is a HeapNumber. | |
967 assembler->GotoUnless(assembler->IsHeapNumberMap(rhs_map), | |
968 &check_rhsisoddball); | |
969 | |
970 var_type_feedback.Bind( | |
971 assembler->Int32Constant(BinaryOperationFeedback::kNumberOrOddball)); | |
972 assembler->Goto(&call_subtract_stub); | |
Leszek Swirski
2016/10/10 11:57:22
as above
mythria
2016/10/10 13:26:00
reply above.
| |
973 } | |
974 } | |
975 | |
976 assembler->Bind(&check_rhsisoddball); | |
977 { | |
978 // Check if rhs is an oddball. At this point we know lhs is either a | |
979 // Smi or number or oddball and rhs is not a number or Smi. | |
980 Node* rhs_instance_type = assembler->LoadInstanceType(rhs); | |
981 Node* rhs_is_oddball = assembler->Word32Equal( | |
982 rhs_instance_type, assembler->Int32Constant(ODDBALL_TYPE)); | |
983 assembler->GotoUnless(rhs_is_oddball, &call_with_any_feedback); | |
984 | |
985 var_type_feedback.Bind( | |
986 assembler->Int32Constant(BinaryOperationFeedback::kNumberOrOddball)); | |
987 assembler->Goto(&call_subtract_stub); | |
Leszek Swirski
2016/10/10 11:57:22
as above
mythria
2016/10/10 13:26:00
reply above
| |
988 } | |
989 | |
990 assembler->Bind(&call_with_any_feedback); | |
991 { | |
992 var_type_feedback.Bind( | |
993 assembler->Int32Constant(BinaryOperationFeedback::kAny)); | |
994 assembler->Goto(&call_subtract_stub); | |
995 } | |
996 | |
939 assembler->Bind(&call_subtract_stub); | 997 assembler->Bind(&call_subtract_stub); |
940 { | 998 { |
941 var_type_feedback.Bind( | 999 var_type_feedback.Bind( |
942 assembler->Int32Constant(BinaryOperationFeedback::kAny)); | 1000 assembler->Int32Constant(BinaryOperationFeedback::kAny)); |
Leszek Swirski
2016/10/10 11:57:22
this needs to be removed
mythria
2016/10/10 13:26:00
oops. I missed it. Thanks, we might have wasted ti
| |
943 Callable callable = CodeFactory::Subtract(assembler->isolate()); | 1001 Callable callable = CodeFactory::Subtract(assembler->isolate()); |
944 var_result.Bind(assembler->CallStub(callable, context, lhs, rhs)); | 1002 var_result.Bind(assembler->CallStub(callable, context, lhs, rhs)); |
945 assembler->Goto(&end); | 1003 assembler->Goto(&end); |
946 } | 1004 } |
947 | 1005 |
948 assembler->Bind(&end); | 1006 assembler->Bind(&end); |
949 assembler->UpdateFeedback(var_type_feedback.value(), type_feedback_vector, | 1007 assembler->UpdateFeedback(var_type_feedback.value(), type_feedback_vector, |
950 slot_id); | 1008 slot_id); |
951 return var_result.value(); | 1009 return var_result.value(); |
952 } | 1010 } |
(...skipping 2055 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3008 | 3066 |
3009 if (type == MachineType::Pointer()) { | 3067 if (type == MachineType::Pointer()) { |
3010 return Representation::External(); | 3068 return Representation::External(); |
3011 } | 3069 } |
3012 | 3070 |
3013 return Representation::Tagged(); | 3071 return Representation::Tagged(); |
3014 } | 3072 } |
3015 | 3073 |
3016 } // namespace internal | 3074 } // namespace internal |
3017 } // namespace v8 | 3075 } // namespace v8 |
OLD | NEW |