Commit 4579f28d authored by neis's avatar neis Committed by Commit bot

[turbofan] Simplify typed lowering of generator-related operators.

Instead of changing existing nodes in a very fragile (and in one case expensive)
way, just create new ones instead.

Also properly chain effects, which was not done quite right before.

BUG=v8:4907

Review-Url: https://codereview.chromium.org/1997373002
Cr-Commit-Position: refs/heads/master@{#36442}
parent 0fd18acb
...@@ -1633,6 +1633,7 @@ Reduction JSTypedLowering::ReduceJSForInStep(Node* node) { ...@@ -1633,6 +1633,7 @@ Reduction JSTypedLowering::ReduceJSForInStep(Node* node) {
Reduction JSTypedLowering::ReduceJSGeneratorStore(Node* node) { Reduction JSTypedLowering::ReduceJSGeneratorStore(Node* node) {
DCHECK_EQ(IrOpcode::kJSGeneratorStore, node->opcode()); DCHECK_EQ(IrOpcode::kJSGeneratorStore, node->opcode());
Node* generator = NodeProperties::GetValueInput(node, 0); Node* generator = NodeProperties::GetValueInput(node, 0);
Node* continuation = NodeProperties::GetValueInput(node, 1);
Node* context = NodeProperties::GetContextInput(node); Node* context = NodeProperties::GetContextInput(node);
Node* effect = NodeProperties::GetEffectInput(node); Node* effect = NodeProperties::GetEffectInput(node);
Node* control = NodeProperties::GetControlInput(node); Node* control = NodeProperties::GetControlInput(node);
...@@ -1643,8 +1644,8 @@ Reduction JSTypedLowering::ReduceJSGeneratorStore(Node* node) { ...@@ -1643,8 +1644,8 @@ Reduction JSTypedLowering::ReduceJSGeneratorStore(Node* node) {
FieldAccess continuation_field = FieldAccess continuation_field =
AccessBuilder::ForJSGeneratorObjectContinuation(); AccessBuilder::ForJSGeneratorObjectContinuation();
Node* array = graph()->NewNode(simplified()->LoadField(array_field), Node* array = effect = graph()->NewNode(simplified()->LoadField(array_field),
generator, effect, control); generator, effect, control);
for (int i = 0; i < register_count; ++i) { for (int i = 0; i < register_count; ++i) {
Node* value = NodeProperties::GetValueInput(node, 2 + i); Node* value = NodeProperties::GetValueInput(node, 2 + i);
...@@ -1655,20 +1656,11 @@ Reduction JSTypedLowering::ReduceJSGeneratorStore(Node* node) { ...@@ -1655,20 +1656,11 @@ Reduction JSTypedLowering::ReduceJSGeneratorStore(Node* node) {
effect = graph()->NewNode(simplified()->StoreField(context_field), generator, effect = graph()->NewNode(simplified()->StoreField(context_field), generator,
context, effect, control); context, effect, control);
effect = graph()->NewNode(simplified()->StoreField(continuation_field),
generator, continuation, effect, control);
// Change the JSGeneratorStore node to a StoreField node. ReplaceWithValue(node, effect, effect, control);
DCHECK_EQ(0, OperatorProperties::GetFrameStateInputCount(node->op())); return Changed(effect);
DCHECK_EQ(1, OperatorProperties::GetContextInputCount(node->op()));
node->RemoveInput(NodeProperties::FirstContextIndex(node));
for (int i = 0; i < register_count; ++i) {
node->RemoveInput(NodeProperties::FirstValueIndex(node) + 2);
}
NodeProperties::RemoveType(node);
NodeProperties::ChangeOp(node, simplified()->StoreField(continuation_field));
NodeProperties::ReplaceEffectInput(node, effect);
return Changed(node);
} }
Reduction JSTypedLowering::ReduceJSGeneratorRestoreContinuation(Node* node) { Reduction JSTypedLowering::ReduceJSGeneratorRestoreContinuation(Node* node) {
...@@ -1680,23 +1672,14 @@ Reduction JSTypedLowering::ReduceJSGeneratorRestoreContinuation(Node* node) { ...@@ -1680,23 +1672,14 @@ Reduction JSTypedLowering::ReduceJSGeneratorRestoreContinuation(Node* node) {
FieldAccess continuation_field = FieldAccess continuation_field =
AccessBuilder::ForJSGeneratorObjectContinuation(); AccessBuilder::ForJSGeneratorObjectContinuation();
Node* continuation = graph()->NewNode( Node* continuation = effect = graph()->NewNode(
simplified()->LoadField(continuation_field), generator, effect, control); simplified()->LoadField(continuation_field), generator, effect, control);
Node* executing = jsgraph()->Constant(JSGeneratorObject::kGeneratorExecuting);
effect = graph()->NewNode(simplified()->StoreField(continuation_field),
generator, executing, effect, control);
// Change the JSGeneratorRestoreContinuation node to a StoreField node. ReplaceWithValue(node, continuation, effect, control);
DCHECK_EQ(0, OperatorProperties::GetFrameStateInputCount(node->op())); return Changed(continuation);
DCHECK_EQ(1, OperatorProperties::GetContextInputCount(node->op()));
node->RemoveInput(NodeProperties::FirstContextIndex(node));
node->InsertInput(
graph()->zone(), 1,
jsgraph()->Constant(JSGeneratorObject::kGeneratorExecuting));
NodeProperties::RemoveType(node);
NodeProperties::ChangeOp(node, simplified()->StoreField(continuation_field));
NodeProperties::ReplaceEffectInput(node, continuation);
ReplaceWithValue(node, continuation, node, control);
return Changed(node);
} }
Reduction JSTypedLowering::ReduceJSGeneratorRestoreRegister(Node* node) { Reduction JSTypedLowering::ReduceJSGeneratorRestoreRegister(Node* node) {
...@@ -1709,24 +1692,16 @@ Reduction JSTypedLowering::ReduceJSGeneratorRestoreRegister(Node* node) { ...@@ -1709,24 +1692,16 @@ Reduction JSTypedLowering::ReduceJSGeneratorRestoreRegister(Node* node) {
FieldAccess array_field = AccessBuilder::ForJSGeneratorObjectOperandStack(); FieldAccess array_field = AccessBuilder::ForJSGeneratorObjectOperandStack();
FieldAccess element_field = AccessBuilder::ForFixedArraySlot(index); FieldAccess element_field = AccessBuilder::ForFixedArraySlot(index);
Node* array = graph()->NewNode(simplified()->LoadField(array_field), Node* array = effect = graph()->NewNode(simplified()->LoadField(array_field),
generator, effect, control); generator, effect, control);
Node* element = graph()->NewNode(simplified()->LoadField(element_field), Node* element = effect = graph()->NewNode(
array, array, control); simplified()->LoadField(element_field), array, effect, control);
Node* stale = jsgraph()->StaleRegisterConstant();
// Change the JSGeneratorRestoreRegister node to a StoreField node. effect = graph()->NewNode(simplified()->StoreField(element_field), array,
DCHECK_EQ(0, OperatorProperties::GetFrameStateInputCount(node->op())); stale, effect, control);
DCHECK_EQ(1, OperatorProperties::GetContextInputCount(node->op()));
node->RemoveInput(NodeProperties::FirstContextIndex(node));
node->ReplaceInput(0, array);
node->InsertInput(graph()->zone(), 1, jsgraph()->StaleRegisterConstant());
NodeProperties::RemoveType(node);
NodeProperties::ChangeOp(node, simplified()->StoreField(element_field));
NodeProperties::ReplaceEffectInput(node, element); ReplaceWithValue(node, element, effect, control);
ReplaceWithValue(node, element, node, control); return Changed(element);
return Changed(node);
} }
Reduction JSTypedLowering::ReduceSelect(Node* node) { Reduction JSTypedLowering::ReduceSelect(Node* node) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment