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

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

Issue 2392533002: Reland of [interpreter] Add string type feedback to add (Closed)
Patch Set: Use the fancy new IsStringInstanceType method 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') | no next file with comments »
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 1014 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 call_add_stub(assembler, Label::kDeferred); 1035 do_add_any(assembler, Label::kDeferred), call_add_stub(assembler);
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
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), 1083 assembler->GotoUnless(assembler->IsHeapNumberMap(rhs_map), &do_add_any);
1084 &call_add_stub);
1085 1084
1086 var_fadd_lhs.Bind(assembler->SmiToFloat64(lhs)); 1085 var_fadd_lhs.Bind(assembler->SmiToFloat64(lhs));
1087 var_fadd_rhs.Bind(assembler->LoadHeapNumberValue(rhs)); 1086 var_fadd_rhs.Bind(assembler->LoadHeapNumberValue(rhs));
1088 assembler->Goto(&do_fadd); 1087 assembler->Goto(&do_fadd);
1089 } 1088 }
1090 } 1089 }
1091 1090
1092 assembler->Bind(&if_lhsisnotsmi); 1091 assembler->Bind(&if_lhsisnotsmi);
1093 { 1092 {
1093 Label check_string(assembler);
1094
1094 // Load the map of {lhs}. 1095 // Load the map of {lhs}.
1095 Node* lhs_map = assembler->LoadMap(lhs); 1096 Node* lhs_map = assembler->LoadMap(lhs);
1096 1097
1097 // Check if {lhs} is a HeapNumber. 1098 // Check if {lhs} is a HeapNumber.
1098 Label if_lhsisnumber(assembler), if_lhsisnotnumber(assembler); 1099 Label if_lhsisnumber(assembler), if_lhsisnotnumber(assembler);
1099 assembler->GotoUnless(assembler->IsHeapNumberMap(lhs_map), &call_add_stub); 1100 assembler->GotoUnless(assembler->IsHeapNumberMap(lhs_map), &check_string);
1100 1101
1101 // Check if the {rhs} is Smi. 1102 // Check if the {rhs} is Smi.
1102 Label if_rhsissmi(assembler), if_rhsisnotsmi(assembler); 1103 Label if_rhsissmi(assembler), if_rhsisnotsmi(assembler);
1103 assembler->Branch(assembler->WordIsSmi(rhs), &if_rhsissmi, &if_rhsisnotsmi); 1104 assembler->Branch(assembler->WordIsSmi(rhs), &if_rhsissmi, &if_rhsisnotsmi);
1104 1105
1105 assembler->Bind(&if_rhsissmi); 1106 assembler->Bind(&if_rhsissmi);
1106 { 1107 {
1107 var_fadd_lhs.Bind(assembler->LoadHeapNumberValue(lhs)); 1108 var_fadd_lhs.Bind(assembler->LoadHeapNumberValue(lhs));
1108 var_fadd_rhs.Bind(assembler->SmiToFloat64(rhs)); 1109 var_fadd_rhs.Bind(assembler->SmiToFloat64(rhs));
1109 assembler->Goto(&do_fadd); 1110 assembler->Goto(&do_fadd);
1110 } 1111 }
1111 1112
1112 assembler->Bind(&if_rhsisnotsmi); 1113 assembler->Bind(&if_rhsisnotsmi);
1113 { 1114 {
1114 // Load the map of {rhs}. 1115 // Load the map of {rhs}.
1115 Node* rhs_map = assembler->LoadMap(rhs); 1116 Node* rhs_map = assembler->LoadMap(rhs);
1116 1117
1117 // Check if the {rhs} is a HeapNumber. 1118 // Check if the {rhs} is a HeapNumber.
1118 assembler->GotoUnless(assembler->IsHeapNumberMap(rhs_map), 1119 assembler->GotoUnless(assembler->IsHeapNumberMap(rhs_map), &do_add_any);
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 }
1125 } 1147 }
1126 1148
1127 assembler->Bind(&do_fadd); 1149 assembler->Bind(&do_fadd);
1128 { 1150 {
1129 var_type_feedback.Bind( 1151 var_type_feedback.Bind(
1130 assembler->Int32Constant(BinaryOperationFeedback::kNumber)); 1152 assembler->Int32Constant(BinaryOperationFeedback::kNumber));
1131 Node* value = 1153 Node* value =
1132 assembler->Float64Add(var_fadd_lhs.value(), var_fadd_rhs.value()); 1154 assembler->Float64Add(var_fadd_lhs.value(), var_fadd_rhs.value());
1133 Node* result = assembler->ChangeFloat64ToTagged(value); 1155 Node* result = assembler->ChangeFloat64ToTagged(value);
1134 var_result.Bind(result); 1156 var_result.Bind(result);
1135 assembler->Goto(&end); 1157 assembler->Goto(&end);
1136 } 1158 }
1137 1159
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
1138 assembler->Bind(&call_add_stub); 1167 assembler->Bind(&call_add_stub);
1139 { 1168 {
1140 var_type_feedback.Bind(
1141 assembler->Int32Constant(BinaryOperationFeedback::kAny));
1142 Callable callable = CodeFactory::Add(assembler->isolate()); 1169 Callable callable = CodeFactory::Add(assembler->isolate());
1143 var_result.Bind(assembler->CallStub(callable, context, lhs, rhs)); 1170 var_result.Bind(assembler->CallStub(callable, context, lhs, rhs));
1144 assembler->Goto(&end); 1171 assembler->Goto(&end);
1145 } 1172 }
1146 1173
1147 assembler->Bind(&end); 1174 assembler->Bind(&end);
1148 assembler->UpdateFeedback(var_type_feedback.value(), type_feedback_vector, 1175 assembler->UpdateFeedback(var_type_feedback.value(), type_feedback_vector,
1149 slot_id); 1176 slot_id);
1150 return var_result.value(); 1177 return var_result.value();
1151 } 1178 }
(...skipping 4674 matching lines...) Expand 10 before | Expand all | Expand 10 after
5826 5853
5827 if (type == MachineType::Pointer()) { 5854 if (type == MachineType::Pointer()) {
5828 return Representation::External(); 5855 return Representation::External();
5829 } 5856 }
5830 5857
5831 return Representation::Tagged(); 5858 return Representation::Tagged();
5832 } 5859 }
5833 5860
5834 } // namespace internal 5861 } // namespace internal
5835 } // namespace v8 5862 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/globals.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698