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

Side by Side Diff: src/compiler/js-builtin-reducer.cc

Issue 2373983004: [turbofan] inline %StringIteratorPrototype%.next in JSBuiltinReducer. (Closed)
Patch Set: some readability changes 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 | « src/compiler/js-builtin-reducer.h ('k') | src/compiler/opcodes.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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/compiler/js-builtin-reducer.h" 5 #include "src/compiler/js-builtin-reducer.h"
6 6
7 #include "src/compilation-dependencies.h" 7 #include "src/compilation-dependencies.h"
8 #include "src/compiler/access-builder.h" 8 #include "src/compiler/access-builder.h"
9 #include "src/compiler/js-graph.h" 9 #include "src/compiler/js-graph.h"
10 #include "src/compiler/node-matchers.h" 10 #include "src/compiler/node-matchers.h"
11 #include "src/compiler/node-properties.h" 11 #include "src/compiler/node-properties.h"
12 #include "src/compiler/operator-properties.h"
12 #include "src/compiler/simplified-operator.h" 13 #include "src/compiler/simplified-operator.h"
13 #include "src/compiler/type-cache.h" 14 #include "src/compiler/type-cache.h"
14 #include "src/compiler/types.h" 15 #include "src/compiler/types.h"
15 #include "src/objects-inl.h" 16 #include "src/objects-inl.h"
16
17 namespace v8 { 17 namespace v8 {
18 namespace internal { 18 namespace internal {
19 namespace compiler { 19 namespace compiler {
20 20
21 21
22 // Helper class to access JSCallFunction nodes that are potential candidates 22 // Helper class to access JSCallFunction nodes that are potential candidates
23 // for reduction when they have a BuiltinFunctionId associated with them. 23 // for reduction when they have a BuiltinFunctionId associated with them.
24 class JSCallReduction { 24 class JSCallReduction {
25 public: 25 public:
26 explicit JSCallReduction(Node* node) : node_(node) {} 26 explicit JSCallReduction(Node* node) : node_(node) {}
(...skipping 992 matching lines...) Expand 10 before | Expand all | Expand 10 after
1019 1019
1020 ReplaceWithValue(node, value, effect, control); 1020 ReplaceWithValue(node, value, effect, control);
1021 return Replace(value); 1021 return Replace(value);
1022 } 1022 }
1023 } 1023 }
1024 } 1024 }
1025 1025
1026 return NoChange(); 1026 return NoChange();
1027 } 1027 }
1028 1028
1029 Reduction JSBuiltinReducer::ReduceStringIteratorPrototypeNext(Node* node) {
1030 Node* receiver = NodeProperties::GetValueInput(node, 1);
1031 Node* effect = NodeProperties::GetEffectInput(node);
1032 Node* control = NodeProperties::GetControlInput(node);
1033 Node* context = NodeProperties::GetContextInput(node);
1034 if (HasInstanceTypeWitness(receiver, effect, JS_STRING_ITERATOR_TYPE)) {
1035 Node* string = effect = graph()->NewNode(
1036 simplified()->LoadField(AccessBuilder::ForJSStringIteratorString()),
1037 receiver, effect, control);
1038 Node* index = effect = graph()->NewNode(
1039 simplified()->LoadField(AccessBuilder::ForJSStringIteratorIndex()),
1040 receiver, effect, control);
1041 Node* length = effect = graph()->NewNode(
1042 simplified()->LoadField(AccessBuilder::ForStringLength()), string,
1043 effect, control);
1044
1045 // branch0: if (index < length)
1046 Node* check0 =
1047 graph()->NewNode(simplified()->NumberLessThan(), index, length);
1048 Node* branch0 =
1049 graph()->NewNode(common()->Branch(BranchHint::kTrue), check0, control);
1050
1051 Node* vtrue0;
1052 Node* if_true0 = graph()->NewNode(common()->IfTrue(), branch0);
1053 Node* done_true;
1054 {
1055 done_true = jsgraph()->FalseConstant();
1056 Node* lead = graph()->NewNode(simplified()->StringCharCodeAt(), string,
1057 index, if_true0);
1058 Node* check1 = graph()->NewNode(simplified()->NumberLessThan(), lead,
1059 jsgraph()->Int32Constant(0xD800));
1060 Node* branch1 = graph()->NewNode(common()->Branch(BranchHint::kTrue),
1061 check1, if_true0);
1062 Node* vfalse1;
1063 Node* if_false1 = graph()->NewNode(common()->IfFalse(), branch1);
1064 {
1065 Node* check2 = graph()->NewNode(simplified()->NumberLessThanOrEqual(),
1066 lead, jsgraph()->Int32Constant(0xDC00));
1067 Node* branch2 = graph()->NewNode(common()->Branch(BranchHint::kTrue),
1068 check2, if_false1);
1069 Node* vtrue2;
1070 Node* if_true2 = graph()->NewNode(common()->IfTrue(), branch2);
1071 {
1072 Node* next_index = graph()->NewNode(simplified()->NumberAdd(), index,
1073 jsgraph()->OneConstant());
1074 Node* check3 = graph()->NewNode(simplified()->NumberLessThan(),
1075 next_index, length);
1076 Node* branch3 = graph()->NewNode(common()->Branch(BranchHint::kTrue),
1077 check3, if_true2);
1078 Node* vtrue3;
1079 Node* if_true3 = graph()->NewNode(common()->IfTrue(), branch3);
1080 {
1081 Node* trail = graph()->NewNode(simplified()->StringCharCodeAt(),
1082 string, next_index, if_true3);
1083 Node* check4 =
1084 graph()->NewNode(simplified()->NumberLessThanOrEqual(),
1085 jsgraph()->Int32Constant(0xDC00), trail);
1086 Node* branch4 = graph()->NewNode(
1087 common()->Branch(BranchHint::kTrue), check4, if_true3);
1088 Node* vtrue4;
1089 Node* if_true4 = graph()->NewNode(common()->IfTrue(), branch4);
1090 {
1091 Node* check5 =
1092 graph()->NewNode(simplified()->NumberLessThanOrEqual(), trail,
1093 jsgraph()->Int32Constant(0xDFFF));
1094 Node* branch5 = graph()->NewNode(
1095 common()->Branch(BranchHint::kTrue), check5, if_true4);
1096 Node* vtrue5;
1097 Node* if_true5 = graph()->NewNode(common()->IfTrue(), branch5);
1098 {
1099 vtrue5 = graph()->NewNode(
1100 simplified()->NumberBitwiseOr(),
1101 graph()->NewNode(simplified()->NumberShiftLeft(), trail,
1102 jsgraph()->Int32Constant(16)),
1103 lead);
1104 }
1105
1106 Node* if_false5 = graph()->NewNode(common()->IfFalse(), branch5);
1107 Node* control =
1108 graph()->NewNode(common()->Merge(2), if_true5, if_false5);
1109 vtrue4 = graph()->NewNode(
1110 common()->Phi(MachineRepresentation::kWord32, 2), vtrue5,
1111 lead, control);
1112 }
1113
1114 Node* if_false4 = graph()->NewNode(common()->IfFalse(), branch4);
1115 Node* control =
1116 graph()->NewNode(common()->Merge(2), if_true4, if_false4);
1117 vtrue3 = graph()->NewNode(
1118 common()->Phi(MachineRepresentation::kWord32, 2), vtrue4, lead,
1119 control);
1120 }
1121 Node* if_false3 = graph()->NewNode(common()->IfFalse(), branch3);
1122 Node* control =
1123 graph()->NewNode(common()->Merge(2), if_true3, if_false3);
1124 vtrue2 =
1125 graph()->NewNode(common()->Phi(MachineRepresentation::kWord32, 2),
1126 vtrue3, lead, control);
1127 }
1128 Node* if_false2 = graph()->NewNode(common()->IfFalse(), branch2);
1129 Node* control =
1130 graph()->NewNode(common()->Merge(2), if_true2, if_false2);
1131 vfalse1 =
1132 graph()->NewNode(common()->Phi(MachineRepresentation::kWord32, 2),
1133 vtrue2, lead, control);
1134 }
1135 Node* if_true1 = graph()->NewNode(common()->IfTrue(), branch1);
1136 Node* control = graph()->NewNode(common()->Merge(2), if_true1, if_false1);
1137 Node* codepoint =
1138 graph()->NewNode(common()->Phi(MachineRepresentation::kWord32, 2),
1139 vfalse1, lead, control);
1140 vtrue0 = graph()->NewNode(
1141 simplified()->StringFromCodePoint(UnicodeEncoding::UTF16), codepoint);
1142 }
1143
1144 Node* if_false0 = graph()->NewNode(common()->IfFalse(), branch0);
1145 Node* vfalse0;
1146 Node* done_false;
1147 { done_false = vfalse0 = jsgraph()->UndefinedConstant(); }
Benedikt Meurer 2016/09/29 17:19:05 You should really set done to False in this case,
caitp 2016/09/29 17:21:45 Er, something went wrong here --- this is supposed
1148
1149 control = graph()->NewNode(common()->Merge(2), if_true0, if_false0);
1150 Node* value_phi =
1151 graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2),
1152 vtrue0, vfalse0, control);
1153 Node* done_phi =
1154 graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2),
1155 done_true, done_false, control);
1156
1157 Node* native_context = effect =
1158 graph()->NewNode(jsgraph()->javascript()->LoadContext(
1159 0, Context::NATIVE_CONTEXT_INDEX, true),
1160 context, context, effect);
1161 Node* map = effect =
1162 graph()->NewNode(jsgraph()->javascript()->LoadContext(
1163 0, Context::ITERATOR_RESULT_MAP_INDEX, true),
1164 context, native_context, effect);
1165
1166 Node* value = effect = graph()->NewNode(
1167 simplified()->Allocate(NOT_TENURED),
1168 jsgraph()->Int32Constant(JSIteratorResult::kSize), effect, control);
1169 effect = graph()->NewNode(simplified()->StoreField(AccessBuilder::ForMap()),
1170 value, map, effect, control);
1171 effect = graph()->NewNode(
1172 simplified()->StoreField(AccessBuilder::ForJSIteratorResultDone()),
1173 value, done_phi, effect, control);
1174 effect = graph()->NewNode(
1175 simplified()->StoreField(AccessBuilder::ForJSIteratorResultValue()),
1176 value, value_phi, effect, control);
1177
1178 ReplaceWithValue(node, value, effect, control);
1179 return Replace(value);
1180 }
1181 return NoChange();
1182 }
1183
1029 Reduction JSBuiltinReducer::ReduceArrayBufferViewAccessor( 1184 Reduction JSBuiltinReducer::ReduceArrayBufferViewAccessor(
1030 Node* node, InstanceType instance_type, FieldAccess const& access) { 1185 Node* node, InstanceType instance_type, FieldAccess const& access) {
1031 Node* receiver = NodeProperties::GetValueInput(node, 1); 1186 Node* receiver = NodeProperties::GetValueInput(node, 1);
1032 Node* effect = NodeProperties::GetEffectInput(node); 1187 Node* effect = NodeProperties::GetEffectInput(node);
1033 Node* control = NodeProperties::GetControlInput(node); 1188 Node* control = NodeProperties::GetControlInput(node);
1034 if (HasInstanceTypeWitness(receiver, effect, instance_type)) { 1189 if (HasInstanceTypeWitness(receiver, effect, instance_type)) {
1035 // Load the {receiver}s field. 1190 // Load the {receiver}s field.
1036 Node* receiver_value = effect = graph()->NewNode( 1191 Node* receiver_value = effect = graph()->NewNode(
1037 simplified()->LoadField(access), receiver, effect, control); 1192 simplified()->LoadField(access), receiver, effect, control);
1038 1193
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
1188 case kNumberParseInt: 1343 case kNumberParseInt:
1189 reduction = ReduceNumberParseInt(node); 1344 reduction = ReduceNumberParseInt(node);
1190 break; 1345 break;
1191 case kStringFromCharCode: 1346 case kStringFromCharCode:
1192 reduction = ReduceStringFromCharCode(node); 1347 reduction = ReduceStringFromCharCode(node);
1193 break; 1348 break;
1194 case kStringCharAt: 1349 case kStringCharAt:
1195 return ReduceStringCharAt(node); 1350 return ReduceStringCharAt(node);
1196 case kStringCharCodeAt: 1351 case kStringCharCodeAt:
1197 return ReduceStringCharCodeAt(node); 1352 return ReduceStringCharCodeAt(node);
1353 case kStringIteratorPrototypeNext:
1354 return ReduceStringIteratorPrototypeNext(node);
1198 case kDataViewByteLength: 1355 case kDataViewByteLength:
1199 return ReduceArrayBufferViewAccessor( 1356 return ReduceArrayBufferViewAccessor(
1200 node, JS_DATA_VIEW_TYPE, 1357 node, JS_DATA_VIEW_TYPE,
1201 AccessBuilder::ForJSArrayBufferViewByteLength()); 1358 AccessBuilder::ForJSArrayBufferViewByteLength());
1202 case kDataViewByteOffset: 1359 case kDataViewByteOffset:
1203 return ReduceArrayBufferViewAccessor( 1360 return ReduceArrayBufferViewAccessor(
1204 node, JS_DATA_VIEW_TYPE, 1361 node, JS_DATA_VIEW_TYPE,
1205 AccessBuilder::ForJSArrayBufferViewByteOffset()); 1362 AccessBuilder::ForJSArrayBufferViewByteOffset());
1206 case kTypedArrayByteLength: 1363 case kTypedArrayByteLength:
1207 return ReduceArrayBufferViewAccessor( 1364 return ReduceArrayBufferViewAccessor(
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1250 } 1407 }
1251 1408
1252 1409
1253 SimplifiedOperatorBuilder* JSBuiltinReducer::simplified() const { 1410 SimplifiedOperatorBuilder* JSBuiltinReducer::simplified() const {
1254 return jsgraph()->simplified(); 1411 return jsgraph()->simplified();
1255 } 1412 }
1256 1413
1257 } // namespace compiler 1414 } // namespace compiler
1258 } // namespace internal 1415 } // namespace internal
1259 } // namespace v8 1416 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/js-builtin-reducer.h ('k') | src/compiler/opcodes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698