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 1030 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1041 compiler::Node* AddWithFeedbackStub::Generate( | 1041 compiler::Node* AddWithFeedbackStub::Generate( |
1042 CodeStubAssembler* assembler, compiler::Node* lhs, compiler::Node* rhs, | 1042 CodeStubAssembler* assembler, compiler::Node* lhs, compiler::Node* rhs, |
1043 compiler::Node* slot_id, compiler::Node* type_feedback_vector, | 1043 compiler::Node* slot_id, compiler::Node* type_feedback_vector, |
1044 compiler::Node* context) { | 1044 compiler::Node* context) { |
1045 typedef CodeStubAssembler::Label Label; | 1045 typedef CodeStubAssembler::Label Label; |
1046 typedef compiler::Node Node; | 1046 typedef compiler::Node Node; |
1047 typedef CodeStubAssembler::Variable Variable; | 1047 typedef CodeStubAssembler::Variable Variable; |
1048 | 1048 |
1049 // Shared entry for floating point addition. | 1049 // Shared entry for floating point addition. |
1050 Label do_fadd(assembler), end(assembler), | 1050 Label do_fadd(assembler), end(assembler), |
1051 call_add_stub(assembler, Label::kDeferred); | 1051 do_add_any(assembler, Label::kDeferred), call_add_stub(assembler); |
1052 Variable var_fadd_lhs(assembler, MachineRepresentation::kFloat64), | 1052 Variable var_fadd_lhs(assembler, MachineRepresentation::kFloat64), |
1053 var_fadd_rhs(assembler, MachineRepresentation::kFloat64), | 1053 var_fadd_rhs(assembler, MachineRepresentation::kFloat64), |
1054 var_type_feedback(assembler, MachineRepresentation::kWord32), | 1054 var_type_feedback(assembler, MachineRepresentation::kWord32), |
1055 var_result(assembler, MachineRepresentation::kTagged); | 1055 var_result(assembler, MachineRepresentation::kTagged); |
1056 | 1056 |
1057 // Check if the {lhs} is a Smi or a HeapObject. | 1057 // Check if the {lhs} is a Smi or a HeapObject. |
1058 Label if_lhsissmi(assembler), if_lhsisnotsmi(assembler); | 1058 Label if_lhsissmi(assembler), if_lhsisnotsmi(assembler); |
1059 assembler->Branch(assembler->WordIsSmi(lhs), &if_lhsissmi, &if_lhsisnotsmi); | 1059 assembler->Branch(assembler->WordIsSmi(lhs), &if_lhsissmi, &if_lhsisnotsmi); |
1060 | 1060 |
1061 assembler->Bind(&if_lhsissmi); | 1061 assembler->Bind(&if_lhsissmi); |
(...skipping 27 matching lines...) Expand all Loading... | |
1089 assembler->Goto(&end); | 1089 assembler->Goto(&end); |
1090 } | 1090 } |
1091 } | 1091 } |
1092 | 1092 |
1093 assembler->Bind(&if_rhsisnotsmi); | 1093 assembler->Bind(&if_rhsisnotsmi); |
1094 { | 1094 { |
1095 // Load the map of {rhs}. | 1095 // Load the map of {rhs}. |
1096 Node* rhs_map = assembler->LoadMap(rhs); | 1096 Node* rhs_map = assembler->LoadMap(rhs); |
1097 | 1097 |
1098 // Check if the {rhs} is a HeapNumber. | 1098 // Check if the {rhs} is a HeapNumber. |
1099 assembler->GotoUnless(assembler->IsHeapNumberMap(rhs_map), | 1099 assembler->GotoUnless(assembler->IsHeapNumberMap(rhs_map), &do_add_any); |
1100 &call_add_stub); | |
1101 | 1100 |
1102 var_fadd_lhs.Bind(assembler->SmiToFloat64(lhs)); | 1101 var_fadd_lhs.Bind(assembler->SmiToFloat64(lhs)); |
1103 var_fadd_rhs.Bind(assembler->LoadHeapNumberValue(rhs)); | 1102 var_fadd_rhs.Bind(assembler->LoadHeapNumberValue(rhs)); |
1104 assembler->Goto(&do_fadd); | 1103 assembler->Goto(&do_fadd); |
1105 } | 1104 } |
1106 } | 1105 } |
1107 | 1106 |
1108 assembler->Bind(&if_lhsisnotsmi); | 1107 assembler->Bind(&if_lhsisnotsmi); |
1109 { | 1108 { |
1109 Label check_string(assembler); | |
1110 | |
1110 // Load the map of {lhs}. | 1111 // Load the map of {lhs}. |
1111 Node* lhs_map = assembler->LoadMap(lhs); | 1112 Node* lhs_map = assembler->LoadMap(lhs); |
1112 | 1113 |
1113 // Check if {lhs} is a HeapNumber. | 1114 // Check if {lhs} is a HeapNumber. |
1114 Label if_lhsisnumber(assembler), if_lhsisnotnumber(assembler); | 1115 Label if_lhsisnumber(assembler), if_lhsisnotnumber(assembler); |
1115 assembler->GotoUnless(assembler->IsHeapNumberMap(lhs_map), &call_add_stub); | 1116 assembler->GotoUnless(assembler->IsHeapNumberMap(lhs_map), &check_string); |
1116 | 1117 |
1117 // Check if the {rhs} is Smi. | 1118 // Check if the {rhs} is Smi. |
1118 Label if_rhsissmi(assembler), if_rhsisnotsmi(assembler); | 1119 Label if_rhsissmi(assembler), if_rhsisnotsmi(assembler); |
1119 assembler->Branch(assembler->WordIsSmi(rhs), &if_rhsissmi, &if_rhsisnotsmi); | 1120 assembler->Branch(assembler->WordIsSmi(rhs), &if_rhsissmi, &if_rhsisnotsmi); |
1120 | 1121 |
1121 assembler->Bind(&if_rhsissmi); | 1122 assembler->Bind(&if_rhsissmi); |
1122 { | 1123 { |
1123 var_fadd_lhs.Bind(assembler->LoadHeapNumberValue(lhs)); | 1124 var_fadd_lhs.Bind(assembler->LoadHeapNumberValue(lhs)); |
1124 var_fadd_rhs.Bind(assembler->SmiToFloat64(rhs)); | 1125 var_fadd_rhs.Bind(assembler->SmiToFloat64(rhs)); |
1125 assembler->Goto(&do_fadd); | 1126 assembler->Goto(&do_fadd); |
1126 } | 1127 } |
1127 | 1128 |
1128 assembler->Bind(&if_rhsisnotsmi); | 1129 assembler->Bind(&if_rhsisnotsmi); |
1129 { | 1130 { |
1130 // Load the map of {rhs}. | 1131 // Load the map of {rhs}. |
1131 Node* rhs_map = assembler->LoadMap(rhs); | 1132 Node* rhs_map = assembler->LoadMap(rhs); |
1132 | 1133 |
1133 // Check if the {rhs} is a HeapNumber. | 1134 // Check if the {rhs} is a HeapNumber. |
1134 assembler->GotoUnless(assembler->IsHeapNumberMap(rhs_map), | 1135 assembler->GotoUnless(assembler->IsHeapNumberMap(rhs_map), &do_add_any); |
1135 &call_add_stub); | |
1136 | 1136 |
1137 var_fadd_lhs.Bind(assembler->LoadHeapNumberValue(lhs)); | 1137 var_fadd_lhs.Bind(assembler->LoadHeapNumberValue(lhs)); |
1138 var_fadd_rhs.Bind(assembler->LoadHeapNumberValue(rhs)); | 1138 var_fadd_rhs.Bind(assembler->LoadHeapNumberValue(rhs)); |
1139 assembler->Goto(&do_fadd); | 1139 assembler->Goto(&do_fadd); |
1140 } | 1140 } |
1141 | |
1142 assembler->Bind(&check_string); | |
1143 { | |
1144 // Check if the {rhs} is a smi, and exit the string check early if it is. | |
1145 assembler->GotoIf(assembler->WordIsSmi(rhs), &do_add_any); | |
1146 | |
1147 Node* lhs_instance_type = assembler->LoadMapInstanceType(lhs_map); | |
1148 | |
1149 // Exit unless {lhs} is a string | |
1150 assembler->GotoUnless(assembler->Int32LessThan( | |
1151 lhs_instance_type, | |
1152 assembler->Int32Constant(FIRST_NONSTRING_TYPE)), | |
1153 &do_add_any); | |
rmcilroy
2016/10/05 11:03:12
Could you use IsStringInstanceType (as added in ht
Leszek Swirski
2016/10/05 13:10:55
Done.
| |
1154 | |
1155 Node* rhs_instance_type = assembler->LoadInstanceType(rhs); | |
1156 | |
1157 // Exit unless {rhs} is a string | |
1158 assembler->GotoUnless(assembler->Int32LessThan( | |
1159 rhs_instance_type, | |
1160 assembler->Int32Constant(FIRST_NONSTRING_TYPE)), | |
1161 &do_add_any); | |
rmcilroy
2016/10/05 11:03:12
ditto
Leszek Swirski
2016/10/05 13:10:55
Done.
| |
1162 | |
1163 var_type_feedback.Bind( | |
1164 assembler->Int32Constant(BinaryOperationFeedback::kString)); | |
1165 assembler->Goto(&call_add_stub); | |
mythria
2016/10/05 08:28:00
I am not sure if it makes sense, but would it be p
Leszek Swirski
2016/10/05 13:10:55
Nice idea, I'll punt on this for this CL and will
| |
1166 } | |
1141 } | 1167 } |
1142 | 1168 |
1143 assembler->Bind(&do_fadd); | 1169 assembler->Bind(&do_fadd); |
1144 { | 1170 { |
1145 var_type_feedback.Bind( | 1171 var_type_feedback.Bind( |
1146 assembler->Int32Constant(BinaryOperationFeedback::kNumber)); | 1172 assembler->Int32Constant(BinaryOperationFeedback::kNumber)); |
1147 Node* value = | 1173 Node* value = |
1148 assembler->Float64Add(var_fadd_lhs.value(), var_fadd_rhs.value()); | 1174 assembler->Float64Add(var_fadd_lhs.value(), var_fadd_rhs.value()); |
1149 Node* result = assembler->ChangeFloat64ToTagged(value); | 1175 Node* result = assembler->ChangeFloat64ToTagged(value); |
1150 var_result.Bind(result); | 1176 var_result.Bind(result); |
1151 assembler->Goto(&end); | 1177 assembler->Goto(&end); |
1152 } | 1178 } |
1153 | 1179 |
1180 assembler->Bind(&do_add_any); | |
1181 { | |
1182 var_type_feedback.Bind( | |
1183 assembler->Int32Constant(BinaryOperationFeedback::kAny)); | |
1184 assembler->Goto(&call_add_stub); | |
1185 } | |
1186 | |
1154 assembler->Bind(&call_add_stub); | 1187 assembler->Bind(&call_add_stub); |
1155 { | 1188 { |
1156 var_type_feedback.Bind( | |
1157 assembler->Int32Constant(BinaryOperationFeedback::kAny)); | |
1158 Callable callable = CodeFactory::Add(assembler->isolate()); | 1189 Callable callable = CodeFactory::Add(assembler->isolate()); |
1159 var_result.Bind(assembler->CallStub(callable, context, lhs, rhs)); | 1190 var_result.Bind(assembler->CallStub(callable, context, lhs, rhs)); |
1160 assembler->Goto(&end); | 1191 assembler->Goto(&end); |
1161 } | 1192 } |
1162 | 1193 |
1163 assembler->Bind(&end); | 1194 assembler->Bind(&end); |
1164 assembler->UpdateFeedback(var_type_feedback.value(), type_feedback_vector, | 1195 assembler->UpdateFeedback(var_type_feedback.value(), type_feedback_vector, |
1165 slot_id); | 1196 slot_id); |
1166 return var_result.value(); | 1197 return var_result.value(); |
1167 } | 1198 } |
(...skipping 4704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5872 | 5903 |
5873 if (type == MachineType::Pointer()) { | 5904 if (type == MachineType::Pointer()) { |
5874 return Representation::External(); | 5905 return Representation::External(); |
5875 } | 5906 } |
5876 | 5907 |
5877 return Representation::Tagged(); | 5908 return Representation::Tagged(); |
5878 } | 5909 } |
5879 | 5910 |
5880 } // namespace internal | 5911 } // namespace internal |
5881 } // namespace v8 | 5912 } // namespace v8 |
OLD | NEW |