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

Side by Side Diff: src/code-stubs.cc

Issue 2392533002: Reland of [interpreter] Add string type feedback to add (Closed)
Patch Set: 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/globals.h » ('j') | src/globals.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1079 matching lines...) Expand 10 before | Expand all | Expand 10 after
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),
1100 &call_add_stub); 1100 &call_add_stub);
rmcilroy 2016/10/04 08:05:31 We also need a check here. My suggestion would be
Leszek Swirski 2016/10/04 08:30:40 Ah, this patch was only adding string + string = s
1101 1101
1102 var_fadd_lhs.Bind(assembler->SmiToFloat64(lhs)); 1102 var_fadd_lhs.Bind(assembler->SmiToFloat64(lhs));
1103 var_fadd_rhs.Bind(assembler->LoadHeapNumberValue(rhs)); 1103 var_fadd_rhs.Bind(assembler->LoadHeapNumberValue(rhs));
1104 assembler->Goto(&do_fadd); 1104 assembler->Goto(&do_fadd);
1105 } 1105 }
1106 } 1106 }
1107 1107
1108 assembler->Bind(&if_lhsisnotsmi); 1108 assembler->Bind(&if_lhsisnotsmi);
1109 { 1109 {
1110 Label check_string(assembler);
1111
1110 // Load the map of {lhs}. 1112 // Load the map of {lhs}.
1111 Node* lhs_map = assembler->LoadMap(lhs); 1113 Node* lhs_map = assembler->LoadMap(lhs);
1112 1114
1113 // Check if {lhs} is a HeapNumber. 1115 // Check if {lhs} is a HeapNumber.
1114 Label if_lhsisnumber(assembler), if_lhsisnotnumber(assembler); 1116 Label if_lhsisnumber(assembler), if_lhsisnotnumber(assembler);
1115 assembler->GotoUnless(assembler->IsHeapNumberMap(lhs_map), &call_add_stub); 1117 assembler->GotoUnless(assembler->IsHeapNumberMap(lhs_map), &check_string);
1116 1118
1117 // Check if the {rhs} is Smi. 1119 // Check if the {rhs} is Smi.
1118 Label if_rhsissmi(assembler), if_rhsisnotsmi(assembler); 1120 Label if_rhsissmi(assembler), if_rhsisnotsmi(assembler);
1119 assembler->Branch(assembler->WordIsSmi(rhs), &if_rhsissmi, &if_rhsisnotsmi); 1121 assembler->Branch(assembler->WordIsSmi(rhs), &if_rhsissmi, &if_rhsisnotsmi);
1120 1122
1121 assembler->Bind(&if_rhsissmi); 1123 assembler->Bind(&if_rhsissmi);
1122 { 1124 {
1123 var_fadd_lhs.Bind(assembler->LoadHeapNumberValue(lhs)); 1125 var_fadd_lhs.Bind(assembler->LoadHeapNumberValue(lhs));
1124 var_fadd_rhs.Bind(assembler->SmiToFloat64(rhs)); 1126 var_fadd_rhs.Bind(assembler->SmiToFloat64(rhs));
1125 assembler->Goto(&do_fadd); 1127 assembler->Goto(&do_fadd);
1126 } 1128 }
1127 1129
1128 assembler->Bind(&if_rhsisnotsmi); 1130 assembler->Bind(&if_rhsisnotsmi);
1129 { 1131 {
1130 // Load the map of {rhs}. 1132 // Load the map of {rhs}.
1131 Node* rhs_map = assembler->LoadMap(rhs); 1133 Node* rhs_map = assembler->LoadMap(rhs);
1132 1134
1133 // Check if the {rhs} is a HeapNumber. 1135 // Check if the {rhs} is a HeapNumber.
1134 assembler->GotoUnless(assembler->IsHeapNumberMap(rhs_map), 1136 assembler->GotoUnless(assembler->IsHeapNumberMap(rhs_map),
1135 &call_add_stub); 1137 &call_add_stub);
rmcilroy 2016/10/04 08:05:31 Same comment here as above - here you know that lh
Leszek Swirski 2016/10/04 08:30:40 As above.
1136 1138
1137 var_fadd_lhs.Bind(assembler->LoadHeapNumberValue(lhs)); 1139 var_fadd_lhs.Bind(assembler->LoadHeapNumberValue(lhs));
1138 var_fadd_rhs.Bind(assembler->LoadHeapNumberValue(rhs)); 1140 var_fadd_rhs.Bind(assembler->LoadHeapNumberValue(rhs));
1139 assembler->Goto(&do_fadd); 1141 assembler->Goto(&do_fadd);
1140 } 1142 }
1143
1144 assembler->Bind(&check_string);
1145 {
1146 // Check if the {rhs} is a smi, and exit the string check early if it is.
1147 assembler->GotoIf(assembler->WordIsSmi(rhs), &call_add_stub);
rmcilroy 2016/10/04 08:05:31 We should still count this as a string if the lhs
Leszek Swirski 2016/10/04 08:30:40 As above.
1148
1149 Node* lhs_instance_type = assembler->LoadMapInstanceType(lhs_map);
1150
1151 assembler->GotoUnless(assembler->Int32LessThan(
1152 lhs_instance_type,
1153 assembler->Int32Constant(FIRST_NONSTRING_TYPE)),
1154 &call_add_stub);
1155
1156 Node* rhs_instance_type = assembler->LoadInstanceType(rhs);
1157
1158 assembler->GotoUnless(assembler->Int32LessThan(
1159 rhs_instance_type,
1160 assembler->Int32Constant(FIRST_NONSTRING_TYPE)),
1161 &call_add_stub);
1162
1163 var_type_feedback.Bind(
1164 assembler->Int32Constant(BinaryOperationFeedback::kString));
1165 Callable callable = CodeFactory::Add(assembler->isolate());
1166 var_result.Bind(assembler->CallStub(callable, context, lhs, rhs));
rmcilroy 2016/10/04 08:05:31 Let's keep the calling of the stub and updating of
Leszek Swirski 2016/10/04 08:30:40 Not sure about this, calling the stub is a small a
1167 assembler->Goto(&end);
1168 }
1141 } 1169 }
1142 1170
1143 assembler->Bind(&do_fadd); 1171 assembler->Bind(&do_fadd);
1144 { 1172 {
1145 var_type_feedback.Bind( 1173 var_type_feedback.Bind(
1146 assembler->Int32Constant(BinaryOperationFeedback::kNumber)); 1174 assembler->Int32Constant(BinaryOperationFeedback::kNumber));
1147 Node* value = 1175 Node* value =
1148 assembler->Float64Add(var_fadd_lhs.value(), var_fadd_rhs.value()); 1176 assembler->Float64Add(var_fadd_lhs.value(), var_fadd_rhs.value());
1149 Node* result = assembler->ChangeFloat64ToTagged(value); 1177 Node* result = assembler->ChangeFloat64ToTagged(value);
1150 var_result.Bind(result); 1178 var_result.Bind(result);
1151 assembler->Goto(&end); 1179 assembler->Goto(&end);
1152 } 1180 }
1153 1181
1154 assembler->Bind(&call_add_stub); 1182 assembler->Bind(&call_add_stub);
1155 { 1183 {
1184 assembler->Comment("Calling the stub");
1156 var_type_feedback.Bind( 1185 var_type_feedback.Bind(
1157 assembler->Int32Constant(BinaryOperationFeedback::kAny)); 1186 assembler->Int32Constant(BinaryOperationFeedback::kAny));
1158 Callable callable = CodeFactory::Add(assembler->isolate()); 1187 Callable callable = CodeFactory::Add(assembler->isolate());
1159 var_result.Bind(assembler->CallStub(callable, context, lhs, rhs)); 1188 var_result.Bind(assembler->CallStub(callable, context, lhs, rhs));
1160 assembler->Goto(&end); 1189 assembler->Goto(&end);
1161 } 1190 }
1162 1191
1163 assembler->Bind(&end); 1192 assembler->Bind(&end);
1193 assembler->Comment("Updating the feedback");
1164 assembler->UpdateFeedback(var_type_feedback.value(), type_feedback_vector, 1194 assembler->UpdateFeedback(var_type_feedback.value(), type_feedback_vector,
1165 slot_id); 1195 slot_id);
1166 return var_result.value(); 1196 return var_result.value();
1167 } 1197 }
1168 1198
1169 // static 1199 // static
1170 compiler::Node* SubtractStub::Generate(CodeStubAssembler* assembler, 1200 compiler::Node* SubtractStub::Generate(CodeStubAssembler* assembler,
1171 compiler::Node* left, 1201 compiler::Node* left,
1172 compiler::Node* right, 1202 compiler::Node* right,
1173 compiler::Node* context) { 1203 compiler::Node* context) {
(...skipping 4698 matching lines...) Expand 10 before | Expand all | Expand 10 after
5872 5902
5873 if (type == MachineType::Pointer()) { 5903 if (type == MachineType::Pointer()) {
5874 return Representation::External(); 5904 return Representation::External();
5875 } 5905 }
5876 5906
5877 return Representation::Tagged(); 5907 return Representation::Tagged();
5878 } 5908 }
5879 5909
5880 } // namespace internal 5910 } // namespace internal
5881 } // namespace v8 5911 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/globals.h » ('j') | src/globals.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698