Chromium Code Reviews| Index: src/compiler/js-builtin-reducer.cc |
| diff --git a/src/compiler/js-builtin-reducer.cc b/src/compiler/js-builtin-reducer.cc |
| index 762020438878fdbc5566ba07848fd601c870b6ca..aa38a7f51c01af85dbc1343a72fd8ce81895a1e3 100644 |
| --- a/src/compiler/js-builtin-reducer.cc |
| +++ b/src/compiler/js-builtin-reducer.cc |
| @@ -9,11 +9,11 @@ |
| #include "src/compiler/js-graph.h" |
| #include "src/compiler/node-matchers.h" |
| #include "src/compiler/node-properties.h" |
| +#include "src/compiler/operator-properties.h" |
| #include "src/compiler/simplified-operator.h" |
| #include "src/compiler/type-cache.h" |
| #include "src/compiler/types.h" |
| #include "src/objects-inl.h" |
| - |
| namespace v8 { |
| namespace internal { |
| namespace compiler { |
| @@ -1026,6 +1026,161 @@ Reduction JSBuiltinReducer::ReduceStringCharCodeAt(Node* node) { |
| return NoChange(); |
| } |
| +Reduction JSBuiltinReducer::ReduceStringIteratorPrototypeNext(Node* node) { |
| + Node* receiver = NodeProperties::GetValueInput(node, 1); |
| + Node* effect = NodeProperties::GetEffectInput(node); |
| + Node* control = NodeProperties::GetControlInput(node); |
| + Node* context = NodeProperties::GetContextInput(node); |
| + if (HasInstanceTypeWitness(receiver, effect, JS_STRING_ITERATOR_TYPE)) { |
| + Node* string = effect = graph()->NewNode( |
| + simplified()->LoadField(AccessBuilder::ForJSStringIteratorString()), |
| + receiver, effect, control); |
| + Node* index = effect = graph()->NewNode( |
| + simplified()->LoadField(AccessBuilder::ForJSStringIteratorIndex()), |
| + receiver, effect, control); |
| + Node* length = effect = graph()->NewNode( |
| + simplified()->LoadField(AccessBuilder::ForStringLength()), string, |
| + effect, control); |
| + |
| + // branch0: if (index < length) |
| + Node* check0 = |
| + graph()->NewNode(simplified()->NumberLessThan(), index, length); |
| + Node* branch0 = |
| + graph()->NewNode(common()->Branch(BranchHint::kTrue), check0, control); |
| + |
| + Node* vtrue0; |
| + Node* if_true0 = graph()->NewNode(common()->IfTrue(), branch0); |
| + Node* done_true; |
| + { |
| + done_true = jsgraph()->FalseConstant(); |
| + Node* lead = graph()->NewNode(simplified()->StringCharCodeAt(), string, |
| + index, if_true0); |
| + Node* check1 = graph()->NewNode(simplified()->NumberLessThan(), lead, |
| + jsgraph()->Int32Constant(0xD800)); |
| + Node* branch1 = graph()->NewNode(common()->Branch(BranchHint::kTrue), |
| + check1, if_true0); |
| + Node* vfalse1; |
| + Node* if_false1 = graph()->NewNode(common()->IfFalse(), branch1); |
| + { |
| + Node* check2 = graph()->NewNode(simplified()->NumberLessThanOrEqual(), |
| + lead, jsgraph()->Int32Constant(0xDC00)); |
| + Node* branch2 = graph()->NewNode(common()->Branch(BranchHint::kTrue), |
| + check2, if_false1); |
| + Node* vtrue2; |
| + Node* if_true2 = graph()->NewNode(common()->IfTrue(), branch2); |
| + { |
| + Node* next_index = graph()->NewNode(simplified()->NumberAdd(), index, |
| + jsgraph()->OneConstant()); |
| + Node* check3 = graph()->NewNode(simplified()->NumberLessThan(), |
| + next_index, length); |
| + Node* branch3 = graph()->NewNode(common()->Branch(BranchHint::kTrue), |
| + check3, if_true2); |
| + Node* vtrue3; |
| + Node* if_true3 = graph()->NewNode(common()->IfTrue(), branch3); |
| + { |
| + Node* trail = graph()->NewNode(simplified()->StringCharCodeAt(), |
| + string, next_index, if_true3); |
| + Node* check4 = |
| + graph()->NewNode(simplified()->NumberLessThanOrEqual(), |
| + jsgraph()->Int32Constant(0xDC00), trail); |
| + Node* branch4 = graph()->NewNode( |
| + common()->Branch(BranchHint::kTrue), check4, if_true3); |
| + Node* vtrue4; |
| + Node* if_true4 = graph()->NewNode(common()->IfTrue(), branch4); |
| + { |
| + Node* check5 = |
| + graph()->NewNode(simplified()->NumberLessThanOrEqual(), trail, |
| + jsgraph()->Int32Constant(0xDFFF)); |
| + Node* branch5 = graph()->NewNode( |
| + common()->Branch(BranchHint::kTrue), check5, if_true4); |
| + Node* vtrue5; |
| + Node* if_true5 = graph()->NewNode(common()->IfTrue(), branch5); |
| + { |
| + vtrue5 = graph()->NewNode( |
| + simplified()->NumberBitwiseOr(), |
| + graph()->NewNode(simplified()->NumberShiftLeft(), trail, |
| + jsgraph()->Int32Constant(16)), |
| + lead); |
| + } |
| + |
| + Node* if_false5 = graph()->NewNode(common()->IfFalse(), branch5); |
| + Node* control = |
| + graph()->NewNode(common()->Merge(2), if_true5, if_false5); |
| + vtrue4 = graph()->NewNode( |
| + common()->Phi(MachineRepresentation::kWord32, 2), vtrue5, |
| + lead, control); |
| + } |
| + |
| + Node* if_false4 = graph()->NewNode(common()->IfFalse(), branch4); |
| + Node* control = |
| + graph()->NewNode(common()->Merge(2), if_true4, if_false4); |
| + vtrue3 = graph()->NewNode( |
| + common()->Phi(MachineRepresentation::kWord32, 2), vtrue4, lead, |
| + control); |
| + } |
| + Node* if_false3 = graph()->NewNode(common()->IfFalse(), branch3); |
| + Node* control = |
| + graph()->NewNode(common()->Merge(2), if_true3, if_false3); |
| + vtrue2 = |
| + graph()->NewNode(common()->Phi(MachineRepresentation::kWord32, 2), |
| + vtrue3, lead, control); |
| + } |
| + Node* if_false2 = graph()->NewNode(common()->IfFalse(), branch2); |
| + Node* control = |
| + graph()->NewNode(common()->Merge(2), if_true2, if_false2); |
| + vfalse1 = |
| + graph()->NewNode(common()->Phi(MachineRepresentation::kWord32, 2), |
| + vtrue2, lead, control); |
| + } |
| + Node* if_true1 = graph()->NewNode(common()->IfTrue(), branch1); |
| + Node* control = graph()->NewNode(common()->Merge(2), if_true1, if_false1); |
| + Node* codepoint = |
| + graph()->NewNode(common()->Phi(MachineRepresentation::kWord32, 2), |
| + vfalse1, lead, control); |
| + vtrue0 = graph()->NewNode( |
| + simplified()->StringFromCodePoint(UnicodeEncoding::UTF16), codepoint); |
| + } |
| + |
| + Node* if_false0 = graph()->NewNode(common()->IfFalse(), branch0); |
| + Node* vfalse0; |
| + Node* done_false; |
| + { 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
|
| + |
| + control = graph()->NewNode(common()->Merge(2), if_true0, if_false0); |
| + Node* value_phi = |
| + graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2), |
| + vtrue0, vfalse0, control); |
| + Node* done_phi = |
| + graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2), |
| + done_true, done_false, control); |
| + |
| + Node* native_context = effect = |
| + graph()->NewNode(jsgraph()->javascript()->LoadContext( |
| + 0, Context::NATIVE_CONTEXT_INDEX, true), |
| + context, context, effect); |
| + Node* map = effect = |
| + graph()->NewNode(jsgraph()->javascript()->LoadContext( |
| + 0, Context::ITERATOR_RESULT_MAP_INDEX, true), |
| + context, native_context, effect); |
| + |
| + Node* value = effect = graph()->NewNode( |
| + simplified()->Allocate(NOT_TENURED), |
| + jsgraph()->Int32Constant(JSIteratorResult::kSize), effect, control); |
| + effect = graph()->NewNode(simplified()->StoreField(AccessBuilder::ForMap()), |
| + value, map, effect, control); |
| + effect = graph()->NewNode( |
| + simplified()->StoreField(AccessBuilder::ForJSIteratorResultDone()), |
| + value, done_phi, effect, control); |
| + effect = graph()->NewNode( |
| + simplified()->StoreField(AccessBuilder::ForJSIteratorResultValue()), |
| + value, value_phi, effect, control); |
| + |
| + ReplaceWithValue(node, value, effect, control); |
| + return Replace(value); |
| + } |
| + return NoChange(); |
| +} |
| + |
| Reduction JSBuiltinReducer::ReduceArrayBufferViewAccessor( |
| Node* node, InstanceType instance_type, FieldAccess const& access) { |
| Node* receiver = NodeProperties::GetValueInput(node, 1); |
| @@ -1195,6 +1350,8 @@ Reduction JSBuiltinReducer::Reduce(Node* node) { |
| return ReduceStringCharAt(node); |
| case kStringCharCodeAt: |
| return ReduceStringCharCodeAt(node); |
| + case kStringIteratorPrototypeNext: |
| + return ReduceStringIteratorPrototypeNext(node); |
| case kDataViewByteLength: |
| return ReduceArrayBufferViewAccessor( |
| node, JS_DATA_VIEW_TYPE, |