Chromium Code Reviews| Index: src/compiler/js-typed-lowering.cc |
| diff --git a/src/compiler/js-typed-lowering.cc b/src/compiler/js-typed-lowering.cc |
| index de07f5a52e960a796678cf31c1ef6361d5a5b4a8..031c6f9781b07cd133d425c61b361bc9f2473243 100644 |
| --- a/src/compiler/js-typed-lowering.cc |
| +++ b/src/compiler/js-typed-lowering.cc |
| @@ -37,15 +37,22 @@ JSTypedLowering::JSTypedLowering(Editor* editor, JSGraph* jsgraph, Zone* zone) |
| class AllocationBuilder final { |
| public: |
| AllocationBuilder(JSGraph* jsgraph, SimplifiedOperatorBuilder* simplified, |
| - Node* effect, Node* control) |
| + Node* node, Node* effect, Node* control) |
| : jsgraph_(jsgraph), |
| simplified_(simplified), |
| allocation_(nullptr), |
| + node_(node), |
| effect_(effect), |
| control_(control) {} |
| + ~AllocationBuilder() { |
| + // Make sure we are finished. |
| + DCHECK_EQ(IrOpcode::kFinishRegion, node_->opcode()); |
| + } |
| + |
| // Primitive allocation of static size. |
| void Allocate(int size) { |
| + effect_ = graph()->NewNode(jsgraph()->common()->BeginRegion(), effect_); |
| allocation_ = graph()->NewNode( |
| simplified()->Allocate(), jsgraph()->Constant(size), effect_, control_); |
| effect_ = allocation_; |
| @@ -70,8 +77,13 @@ class AllocationBuilder final { |
| Store(access, jsgraph()->Constant(value)); |
| } |
| - Node* allocation() const { return allocation_; } |
| - Node* effect() const { return effect_; } |
| + void Finish() { |
|
Benedikt Meurer
2015/10/13 19:12:09
Nit: I think this helper should return the Reducti
Jarin
2015/10/14 06:37:20
Ack. I will leave the decision to Michi, I do not
|
| + NodeProperties::SetType(allocation_, NodeProperties::GetType(node_)); |
| + node_->ReplaceInput(0, allocation_); |
| + node_->ReplaceInput(1, effect_); |
| + node_->TrimInputCount(2); |
| + NodeProperties::ChangeOp(node_, jsgraph()->common()->FinishRegion()); |
| + } |
| protected: |
| JSGraph* jsgraph() { return jsgraph_; } |
| @@ -82,6 +94,7 @@ class AllocationBuilder final { |
| JSGraph* const jsgraph_; |
| SimplifiedOperatorBuilder* simplified_; |
| Node* allocation_; |
| + Node* node_; |
| Node* effect_; |
| Node* control_; |
| }; |
| @@ -1263,7 +1276,8 @@ Reduction JSTypedLowering::ReduceJSCreateFunctionContext(Node* node) { |
| simplified()->LoadField( |
| AccessBuilder::ForContextSlot(Context::GLOBAL_OBJECT_INDEX)), |
| context, effect, control); |
| - AllocationBuilder a(jsgraph(), simplified(), effect, control); |
| + RelaxControls(node); |
| + AllocationBuilder a(jsgraph(), simplified(), node, effect, control); |
| STATIC_ASSERT(Context::MIN_CONTEXT_SLOTS == 4); // Ensure fully covered. |
| int context_length = slot_count + Context::MIN_CONTEXT_SLOTS; |
| a.AllocateArray(context_length, factory()->function_context_map()); |
| @@ -1274,13 +1288,7 @@ Reduction JSTypedLowering::ReduceJSCreateFunctionContext(Node* node) { |
| for (int i = Context::MIN_CONTEXT_SLOTS; i < context_length; ++i) { |
| a.Store(AccessBuilder::ForContextSlot(i), jsgraph()->TheHoleConstant()); |
| } |
| - // TODO(mstarzinger): We could mutate {node} into the allocation instead. |
| - NodeProperties::SetType(a.allocation(), NodeProperties::GetType(node)); |
| - ReplaceWithValue(node, node, a.effect()); |
| - node->ReplaceInput(0, a.allocation()); |
| - node->ReplaceInput(1, a.effect()); |
| - node->TrimInputCount(2); |
| - NodeProperties::ChangeOp(node, common()->Finish(1)); |
| + a.Finish(); |
| return Changed(node); |
| } |
| @@ -1318,20 +1326,15 @@ Reduction JSTypedLowering::ReduceJSCreateWithContext(Node* node) { |
| simplified()->LoadField( |
| AccessBuilder::ForContextSlot(Context::GLOBAL_OBJECT_INDEX)), |
| context, effect, control); |
| - AllocationBuilder a(jsgraph(), simplified(), effect, control); |
| + RelaxControls(node); |
| + AllocationBuilder a(jsgraph(), simplified(), node, effect, control); |
| STATIC_ASSERT(Context::MIN_CONTEXT_SLOTS == 4); // Ensure fully covered. |
| a.AllocateArray(Context::MIN_CONTEXT_SLOTS, factory()->with_context_map()); |
| a.Store(AccessBuilder::ForContextSlot(Context::CLOSURE_INDEX), closure); |
| a.Store(AccessBuilder::ForContextSlot(Context::PREVIOUS_INDEX), context); |
| a.Store(AccessBuilder::ForContextSlot(Context::EXTENSION_INDEX), input); |
| a.Store(AccessBuilder::ForContextSlot(Context::GLOBAL_OBJECT_INDEX), load); |
| - // TODO(mstarzinger): We could mutate {node} into the allocation instead. |
| - NodeProperties::SetType(a.allocation(), NodeProperties::GetType(node)); |
| - ReplaceWithValue(node, node, a.effect()); |
| - node->ReplaceInput(0, a.allocation()); |
| - node->ReplaceInput(1, a.effect()); |
| - node->TrimInputCount(2); |
| - NodeProperties::ChangeOp(node, common()->Finish(1)); |
| + a.Finish(); |
| return Changed(node); |
| } |
| @@ -1356,7 +1359,8 @@ Reduction JSTypedLowering::ReduceJSCreateBlockContext(Node* node) { |
| simplified()->LoadField( |
| AccessBuilder::ForContextSlot(Context::GLOBAL_OBJECT_INDEX)), |
| context, effect, control); |
| - AllocationBuilder a(jsgraph(), simplified(), effect, control); |
| + RelaxControls(node); |
| + AllocationBuilder a(jsgraph(), simplified(), node, effect, control); |
| STATIC_ASSERT(Context::MIN_CONTEXT_SLOTS == 4); // Ensure fully covered. |
| a.AllocateArray(context_length, factory()->block_context_map()); |
| a.Store(AccessBuilder::ForContextSlot(Context::CLOSURE_INDEX), closure); |
| @@ -1366,13 +1370,7 @@ Reduction JSTypedLowering::ReduceJSCreateBlockContext(Node* node) { |
| for (int i = Context::MIN_CONTEXT_SLOTS; i < context_length; ++i) { |
| a.Store(AccessBuilder::ForContextSlot(i), jsgraph()->TheHoleConstant()); |
| } |
| - // TODO(mstarzinger): We could mutate {node} into the allocation instead. |
| - NodeProperties::SetType(a.allocation(), NodeProperties::GetType(node)); |
| - ReplaceWithValue(node, node, a.effect()); |
| - node->ReplaceInput(0, a.allocation()); |
| - node->ReplaceInput(1, a.effect()); |
| - node->TrimInputCount(2); |
| - NodeProperties::ChangeOp(node, common()->Finish(1)); |
| + a.Finish(); |
| return Changed(node); |
| } |