OLD | NEW |
---|---|
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" |
(...skipping 1008 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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::ReduceStringIterator(Node* node) { | |
1030 if (Node* receiver = GetStringWitness(node)) { | |
1031 Node* effect = NodeProperties::GetEffectInput(node); | |
1032 Node* control = NodeProperties::GetControlInput(node); | |
1033 Node* context = NodeProperties::GetContextInput(node); | |
1034 | |
1035 Node* native_context = effect = graph()->NewNode( | |
1036 javascript()->LoadContext(0, Context::NATIVE_CONTEXT_INDEX, true), | |
1037 context, effect); | |
caitp
2016/10/17 21:54:29
I mentioned this in the meeting, but other uses in
| |
1038 Node* map = effect = graph()->NewNode( | |
1039 javascript()->LoadContext(0, Context::STRING_ITERATOR_MAP_INDEX, true), | |
1040 native_context, effect); | |
1041 | |
1042 // allocate new iterator | |
1043 effect = graph()->NewNode( | |
1044 common()->BeginRegion(RegionObservability::kNotObservable), effect); | |
1045 Node* value = effect = graph()->NewNode( | |
1046 simplified()->Allocate(NOT_TENURED), | |
1047 jsgraph()->Int32Constant(JSStringIterator::kSize), effect, control); | |
1048 effect = graph()->NewNode(simplified()->StoreField(AccessBuilder::ForMap()), | |
1049 value, map, effect, control); | |
1050 effect = graph()->NewNode( | |
1051 simplified()->StoreField(AccessBuilder::ForJSObjectProperties()), value, | |
1052 jsgraph()->EmptyFixedArrayConstant(), effect, control); | |
1053 effect = graph()->NewNode( | |
1054 simplified()->StoreField(AccessBuilder::ForJSObjectElements()), value, | |
1055 jsgraph()->EmptyFixedArrayConstant(), effect, control); | |
1056 | |
1057 // attach the iterator to this string | |
1058 effect = graph()->NewNode( | |
1059 simplified()->StoreField(AccessBuilder::ForJSStringIteratorString()), | |
1060 value, receiver, effect, control); | |
1061 effect = graph()->NewNode( | |
1062 simplified()->StoreField(AccessBuilder::ForJSStringIteratorIndex()), | |
1063 value, jsgraph()->SmiConstant(0), effect, control); | |
1064 | |
1065 value = effect = graph()->NewNode(common()->FinishRegion(), value, effect); | |
1066 | |
1067 // replace it | |
1068 ReplaceWithValue(node, value, effect, control); | |
1069 return Replace(value); | |
1070 } | |
1071 return NoChange(); | |
1072 } | |
1073 | |
1029 Reduction JSBuiltinReducer::ReduceStringIteratorNext(Node* node) { | 1074 Reduction JSBuiltinReducer::ReduceStringIteratorNext(Node* node) { |
1030 Node* receiver = NodeProperties::GetValueInput(node, 1); | 1075 Node* receiver = NodeProperties::GetValueInput(node, 1); |
1031 Node* effect = NodeProperties::GetEffectInput(node); | 1076 Node* effect = NodeProperties::GetEffectInput(node); |
1032 Node* control = NodeProperties::GetControlInput(node); | 1077 Node* control = NodeProperties::GetControlInput(node); |
1033 Node* context = NodeProperties::GetContextInput(node); | 1078 Node* context = NodeProperties::GetContextInput(node); |
1034 if (HasInstanceTypeWitness(receiver, effect, JS_STRING_ITERATOR_TYPE)) { | 1079 if (HasInstanceTypeWitness(receiver, effect, JS_STRING_ITERATOR_TYPE)) { |
1035 Node* string = effect = graph()->NewNode( | 1080 Node* string = effect = graph()->NewNode( |
1036 simplified()->LoadField(AccessBuilder::ForJSStringIteratorString()), | 1081 simplified()->LoadField(AccessBuilder::ForJSStringIteratorString()), |
1037 receiver, effect, control); | 1082 receiver, effect, control); |
1038 Node* index = effect = graph()->NewNode( | 1083 Node* index = effect = graph()->NewNode( |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1321 case kNumberParseInt: | 1366 case kNumberParseInt: |
1322 reduction = ReduceNumberParseInt(node); | 1367 reduction = ReduceNumberParseInt(node); |
1323 break; | 1368 break; |
1324 case kStringFromCharCode: | 1369 case kStringFromCharCode: |
1325 reduction = ReduceStringFromCharCode(node); | 1370 reduction = ReduceStringFromCharCode(node); |
1326 break; | 1371 break; |
1327 case kStringCharAt: | 1372 case kStringCharAt: |
1328 return ReduceStringCharAt(node); | 1373 return ReduceStringCharAt(node); |
1329 case kStringCharCodeAt: | 1374 case kStringCharCodeAt: |
1330 return ReduceStringCharCodeAt(node); | 1375 return ReduceStringCharCodeAt(node); |
1376 case kStringIterator: | |
1377 return ReduceStringIterator(node); | |
1331 case kStringIteratorNext: | 1378 case kStringIteratorNext: |
1332 return ReduceStringIteratorNext(node); | 1379 return ReduceStringIteratorNext(node); |
1333 case kDataViewByteLength: | 1380 case kDataViewByteLength: |
1334 return ReduceArrayBufferViewAccessor( | 1381 return ReduceArrayBufferViewAccessor( |
1335 node, JS_DATA_VIEW_TYPE, | 1382 node, JS_DATA_VIEW_TYPE, |
1336 AccessBuilder::ForJSArrayBufferViewByteLength()); | 1383 AccessBuilder::ForJSArrayBufferViewByteLength()); |
1337 case kDataViewByteOffset: | 1384 case kDataViewByteOffset: |
1338 return ReduceArrayBufferViewAccessor( | 1385 return ReduceArrayBufferViewAccessor( |
1339 node, JS_DATA_VIEW_TYPE, | 1386 node, JS_DATA_VIEW_TYPE, |
1340 AccessBuilder::ForJSArrayBufferViewByteOffset()); | 1387 AccessBuilder::ForJSArrayBufferViewByteOffset()); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1389 return jsgraph()->simplified(); | 1436 return jsgraph()->simplified(); |
1390 } | 1437 } |
1391 | 1438 |
1392 JSOperatorBuilder* JSBuiltinReducer::javascript() const { | 1439 JSOperatorBuilder* JSBuiltinReducer::javascript() const { |
1393 return jsgraph()->javascript(); | 1440 return jsgraph()->javascript(); |
1394 } | 1441 } |
1395 | 1442 |
1396 } // namespace compiler | 1443 } // namespace compiler |
1397 } // namespace internal | 1444 } // namespace internal |
1398 } // namespace v8 | 1445 } // namespace v8 |
OLD | NEW |