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 1014 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1025 compiler::Node* AddWithFeedbackStub::Generate( | 1025 compiler::Node* AddWithFeedbackStub::Generate( |
1026 CodeStubAssembler* assembler, compiler::Node* lhs, compiler::Node* rhs, | 1026 CodeStubAssembler* assembler, compiler::Node* lhs, compiler::Node* rhs, |
1027 compiler::Node* slot_id, compiler::Node* type_feedback_vector, | 1027 compiler::Node* slot_id, compiler::Node* type_feedback_vector, |
1028 compiler::Node* context) { | 1028 compiler::Node* context) { |
1029 typedef CodeStubAssembler::Label Label; | 1029 typedef CodeStubAssembler::Label Label; |
1030 typedef compiler::Node Node; | 1030 typedef compiler::Node Node; |
1031 typedef CodeStubAssembler::Variable Variable; | 1031 typedef CodeStubAssembler::Variable Variable; |
1032 | 1032 |
1033 // Shared entry for floating point addition. | 1033 // Shared entry for floating point addition. |
1034 Label do_fadd(assembler), end(assembler), | 1034 Label do_fadd(assembler), end(assembler), |
1035 do_add_any(assembler, Label::kDeferred), call_add_stub(assembler); | 1035 call_add_stub(assembler, Label::kDeferred); |
1036 Variable var_fadd_lhs(assembler, MachineRepresentation::kFloat64), | 1036 Variable var_fadd_lhs(assembler, MachineRepresentation::kFloat64), |
1037 var_fadd_rhs(assembler, MachineRepresentation::kFloat64), | 1037 var_fadd_rhs(assembler, MachineRepresentation::kFloat64), |
1038 var_type_feedback(assembler, MachineRepresentation::kWord32), | 1038 var_type_feedback(assembler, MachineRepresentation::kWord32), |
1039 var_result(assembler, MachineRepresentation::kTagged); | 1039 var_result(assembler, MachineRepresentation::kTagged); |
1040 | 1040 |
1041 // Check if the {lhs} is a Smi or a HeapObject. | 1041 // Check if the {lhs} is a Smi or a HeapObject. |
1042 Label if_lhsissmi(assembler), if_lhsisnotsmi(assembler); | 1042 Label if_lhsissmi(assembler), if_lhsisnotsmi(assembler); |
1043 assembler->Branch(assembler->WordIsSmi(lhs), &if_lhsissmi, &if_lhsisnotsmi); | 1043 assembler->Branch(assembler->WordIsSmi(lhs), &if_lhsissmi, &if_lhsisnotsmi); |
1044 | 1044 |
1045 assembler->Bind(&if_lhsissmi); | 1045 assembler->Bind(&if_lhsissmi); |
(...skipping 27 matching lines...) Expand all Loading... |
1073 assembler->Goto(&end); | 1073 assembler->Goto(&end); |
1074 } | 1074 } |
1075 } | 1075 } |
1076 | 1076 |
1077 assembler->Bind(&if_rhsisnotsmi); | 1077 assembler->Bind(&if_rhsisnotsmi); |
1078 { | 1078 { |
1079 // Load the map of {rhs}. | 1079 // Load the map of {rhs}. |
1080 Node* rhs_map = assembler->LoadMap(rhs); | 1080 Node* rhs_map = assembler->LoadMap(rhs); |
1081 | 1081 |
1082 // Check if the {rhs} is a HeapNumber. | 1082 // Check if the {rhs} is a HeapNumber. |
1083 assembler->GotoUnless(assembler->IsHeapNumberMap(rhs_map), &do_add_any); | 1083 assembler->GotoUnless(assembler->IsHeapNumberMap(rhs_map), |
| 1084 &call_add_stub); |
1084 | 1085 |
1085 var_fadd_lhs.Bind(assembler->SmiToFloat64(lhs)); | 1086 var_fadd_lhs.Bind(assembler->SmiToFloat64(lhs)); |
1086 var_fadd_rhs.Bind(assembler->LoadHeapNumberValue(rhs)); | 1087 var_fadd_rhs.Bind(assembler->LoadHeapNumberValue(rhs)); |
1087 assembler->Goto(&do_fadd); | 1088 assembler->Goto(&do_fadd); |
1088 } | 1089 } |
1089 } | 1090 } |
1090 | 1091 |
1091 assembler->Bind(&if_lhsisnotsmi); | 1092 assembler->Bind(&if_lhsisnotsmi); |
1092 { | 1093 { |
1093 Label check_string(assembler); | |
1094 | |
1095 // Load the map of {lhs}. | 1094 // Load the map of {lhs}. |
1096 Node* lhs_map = assembler->LoadMap(lhs); | 1095 Node* lhs_map = assembler->LoadMap(lhs); |
1097 | 1096 |
1098 // Check if {lhs} is a HeapNumber. | 1097 // Check if {lhs} is a HeapNumber. |
1099 Label if_lhsisnumber(assembler), if_lhsisnotnumber(assembler); | 1098 Label if_lhsisnumber(assembler), if_lhsisnotnumber(assembler); |
1100 assembler->GotoUnless(assembler->IsHeapNumberMap(lhs_map), &check_string); | 1099 assembler->GotoUnless(assembler->IsHeapNumberMap(lhs_map), &call_add_stub); |
1101 | 1100 |
1102 // Check if the {rhs} is Smi. | 1101 // Check if the {rhs} is Smi. |
1103 Label if_rhsissmi(assembler), if_rhsisnotsmi(assembler); | 1102 Label if_rhsissmi(assembler), if_rhsisnotsmi(assembler); |
1104 assembler->Branch(assembler->WordIsSmi(rhs), &if_rhsissmi, &if_rhsisnotsmi); | 1103 assembler->Branch(assembler->WordIsSmi(rhs), &if_rhsissmi, &if_rhsisnotsmi); |
1105 | 1104 |
1106 assembler->Bind(&if_rhsissmi); | 1105 assembler->Bind(&if_rhsissmi); |
1107 { | 1106 { |
1108 var_fadd_lhs.Bind(assembler->LoadHeapNumberValue(lhs)); | 1107 var_fadd_lhs.Bind(assembler->LoadHeapNumberValue(lhs)); |
1109 var_fadd_rhs.Bind(assembler->SmiToFloat64(rhs)); | 1108 var_fadd_rhs.Bind(assembler->SmiToFloat64(rhs)); |
1110 assembler->Goto(&do_fadd); | 1109 assembler->Goto(&do_fadd); |
1111 } | 1110 } |
1112 | 1111 |
1113 assembler->Bind(&if_rhsisnotsmi); | 1112 assembler->Bind(&if_rhsisnotsmi); |
1114 { | 1113 { |
1115 // Load the map of {rhs}. | 1114 // Load the map of {rhs}. |
1116 Node* rhs_map = assembler->LoadMap(rhs); | 1115 Node* rhs_map = assembler->LoadMap(rhs); |
1117 | 1116 |
1118 // Check if the {rhs} is a HeapNumber. | 1117 // Check if the {rhs} is a HeapNumber. |
1119 assembler->GotoUnless(assembler->IsHeapNumberMap(rhs_map), &do_add_any); | 1118 assembler->GotoUnless(assembler->IsHeapNumberMap(rhs_map), |
| 1119 &call_add_stub); |
1120 | 1120 |
1121 var_fadd_lhs.Bind(assembler->LoadHeapNumberValue(lhs)); | 1121 var_fadd_lhs.Bind(assembler->LoadHeapNumberValue(lhs)); |
1122 var_fadd_rhs.Bind(assembler->LoadHeapNumberValue(rhs)); | 1122 var_fadd_rhs.Bind(assembler->LoadHeapNumberValue(rhs)); |
1123 assembler->Goto(&do_fadd); | 1123 assembler->Goto(&do_fadd); |
1124 } | 1124 } |
1125 | |
1126 assembler->Bind(&check_string); | |
1127 { | |
1128 // Check if the {rhs} is a smi, and exit the string check early if it is. | |
1129 assembler->GotoIf(assembler->WordIsSmi(rhs), &do_add_any); | |
1130 | |
1131 Node* lhs_instance_type = assembler->LoadMapInstanceType(lhs_map); | |
1132 | |
1133 // Exit unless {lhs} is a string | |
1134 assembler->GotoUnless(assembler->IsStringInstanceType(lhs_instance_type), | |
1135 &do_add_any); | |
1136 | |
1137 Node* rhs_instance_type = assembler->LoadInstanceType(rhs); | |
1138 | |
1139 // Exit unless {rhs} is a string | |
1140 assembler->GotoUnless(assembler->IsStringInstanceType(rhs_instance_type), | |
1141 &do_add_any); | |
1142 | |
1143 var_type_feedback.Bind( | |
1144 assembler->Int32Constant(BinaryOperationFeedback::kString)); | |
1145 assembler->Goto(&call_add_stub); | |
1146 } | |
1147 } | 1125 } |
1148 | 1126 |
1149 assembler->Bind(&do_fadd); | 1127 assembler->Bind(&do_fadd); |
1150 { | 1128 { |
1151 var_type_feedback.Bind( | 1129 var_type_feedback.Bind( |
1152 assembler->Int32Constant(BinaryOperationFeedback::kNumber)); | 1130 assembler->Int32Constant(BinaryOperationFeedback::kNumber)); |
1153 Node* value = | 1131 Node* value = |
1154 assembler->Float64Add(var_fadd_lhs.value(), var_fadd_rhs.value()); | 1132 assembler->Float64Add(var_fadd_lhs.value(), var_fadd_rhs.value()); |
1155 Node* result = assembler->ChangeFloat64ToTagged(value); | 1133 Node* result = assembler->ChangeFloat64ToTagged(value); |
1156 var_result.Bind(result); | 1134 var_result.Bind(result); |
1157 assembler->Goto(&end); | 1135 assembler->Goto(&end); |
1158 } | 1136 } |
1159 | 1137 |
1160 assembler->Bind(&do_add_any); | |
1161 { | |
1162 var_type_feedback.Bind( | |
1163 assembler->Int32Constant(BinaryOperationFeedback::kAny)); | |
1164 assembler->Goto(&call_add_stub); | |
1165 } | |
1166 | |
1167 assembler->Bind(&call_add_stub); | 1138 assembler->Bind(&call_add_stub); |
1168 { | 1139 { |
| 1140 var_type_feedback.Bind( |
| 1141 assembler->Int32Constant(BinaryOperationFeedback::kAny)); |
1169 Callable callable = CodeFactory::Add(assembler->isolate()); | 1142 Callable callable = CodeFactory::Add(assembler->isolate()); |
1170 var_result.Bind(assembler->CallStub(callable, context, lhs, rhs)); | 1143 var_result.Bind(assembler->CallStub(callable, context, lhs, rhs)); |
1171 assembler->Goto(&end); | 1144 assembler->Goto(&end); |
1172 } | 1145 } |
1173 | 1146 |
1174 assembler->Bind(&end); | 1147 assembler->Bind(&end); |
1175 assembler->UpdateFeedback(var_type_feedback.value(), type_feedback_vector, | 1148 assembler->UpdateFeedback(var_type_feedback.value(), type_feedback_vector, |
1176 slot_id); | 1149 slot_id); |
1177 return var_result.value(); | 1150 return var_result.value(); |
1178 } | 1151 } |
(...skipping 4674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5853 | 5826 |
5854 if (type == MachineType::Pointer()) { | 5827 if (type == MachineType::Pointer()) { |
5855 return Representation::External(); | 5828 return Representation::External(); |
5856 } | 5829 } |
5857 | 5830 |
5858 return Representation::Tagged(); | 5831 return Representation::Tagged(); |
5859 } | 5832 } |
5860 | 5833 |
5861 } // namespace internal | 5834 } // namespace internal |
5862 } // namespace v8 | 5835 } // namespace v8 |
OLD | NEW |