OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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/memory-optimizer.h" | 5 #include "src/compiler/memory-optimizer.h" |
6 | 6 |
7 #include "src/compiler/js-graph.h" | 7 #include "src/compiler/js-graph.h" |
8 #include "src/compiler/linkage.h" | 8 #include "src/compiler/linkage.h" |
9 #include "src/compiler/node-matchers.h" | 9 #include "src/compiler/node-matchers.h" |
10 #include "src/compiler/node-properties.h" | 10 #include "src/compiler/node-properties.h" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 } | 100 } |
101 DCHECK_EQ(0, node->op()->EffectOutputCount()); | 101 DCHECK_EQ(0, node->op()->EffectOutputCount()); |
102 } | 102 } |
103 | 103 |
104 void MemoryOptimizer::VisitAllocate(Node* node, AllocationState const* state) { | 104 void MemoryOptimizer::VisitAllocate(Node* node, AllocationState const* state) { |
105 DCHECK_EQ(IrOpcode::kAllocate, node->opcode()); | 105 DCHECK_EQ(IrOpcode::kAllocate, node->opcode()); |
106 Node* value; | 106 Node* value; |
107 Node* size = node->InputAt(0); | 107 Node* size = node->InputAt(0); |
108 Node* effect = node->InputAt(1); | 108 Node* effect = node->InputAt(1); |
109 Node* control = node->InputAt(2); | 109 Node* control = node->InputAt(2); |
110 PretenureFlag pretenure = OpParameter<PretenureFlag>(node->op()); | 110 PretenureFlag pretenure = PretenureFlagOf(node->op()); |
111 | 111 |
112 // Propagate tenuring from outer allocations to inner allocations, i.e. | 112 // Propagate tenuring from outer allocations to inner allocations, i.e. |
113 // when we allocate an object in old space and store a newly allocated | 113 // when we allocate an object in old space and store a newly allocated |
114 // child object into the pretenured object, then the newly allocated | 114 // child object into the pretenured object, then the newly allocated |
115 // child object also should get pretenured to old space. | 115 // child object also should get pretenured to old space. |
116 if (pretenure == TENURED) { | 116 if (pretenure == TENURED) { |
117 for (Edge const edge : node->use_edges()) { | 117 for (Edge const edge : node->use_edges()) { |
118 Node* const user = edge.from(); | 118 Node* const user = edge.from(); |
119 if (user->opcode() == IrOpcode::kStoreField && edge.index() == 0) { | 119 if (user->opcode() == IrOpcode::kStoreField && edge.index() == 0) { |
120 Node* const child = user->InputAt(1); | 120 Node* const child = user->InputAt(1); |
121 if (child->opcode() == IrOpcode::kAllocate && | 121 if (child->opcode() == IrOpcode::kAllocate && |
122 OpParameter<PretenureFlag>(child) == NOT_TENURED) { | 122 PretenureFlagOf(child->op()) == NOT_TENURED) { |
123 NodeProperties::ChangeOp(child, node->op()); | 123 NodeProperties::ChangeOp(child, node->op()); |
124 break; | 124 break; |
125 } | 125 } |
126 } | 126 } |
127 } | 127 } |
128 } else { | 128 } else { |
129 DCHECK_EQ(NOT_TENURED, pretenure); | 129 DCHECK_EQ(NOT_TENURED, pretenure); |
130 for (Edge const edge : node->use_edges()) { | 130 for (Edge const edge : node->use_edges()) { |
131 Node* const user = edge.from(); | 131 Node* const user = edge.from(); |
132 if (user->opcode() == IrOpcode::kStoreField && edge.index() == 1) { | 132 if (user->opcode() == IrOpcode::kStoreField && edge.index() == 1) { |
133 Node* const parent = user->InputAt(0); | 133 Node* const parent = user->InputAt(0); |
134 if (parent->opcode() == IrOpcode::kAllocate && | 134 if (parent->opcode() == IrOpcode::kAllocate && |
135 OpParameter<PretenureFlag>(parent) == TENURED) { | 135 PretenureFlagOf(parent->op()) == TENURED) { |
136 pretenure = TENURED; | 136 pretenure = TENURED; |
137 break; | 137 break; |
138 } | 138 } |
139 } | 139 } |
140 } | 140 } |
141 } | 141 } |
142 | 142 |
143 // Determine the top/limit addresses. | 143 // Determine the top/limit addresses. |
144 Node* top_address = jsgraph()->ExternalConstant( | 144 Node* top_address = jsgraph()->ExternalConstant( |
145 pretenure == NOT_TENURED | 145 pretenure == NOT_TENURED |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 return jsgraph()->common(); | 526 return jsgraph()->common(); |
527 } | 527 } |
528 | 528 |
529 MachineOperatorBuilder* MemoryOptimizer::machine() const { | 529 MachineOperatorBuilder* MemoryOptimizer::machine() const { |
530 return jsgraph()->machine(); | 530 return jsgraph()->machine(); |
531 } | 531 } |
532 | 532 |
533 } // namespace compiler | 533 } // namespace compiler |
534 } // namespace internal | 534 } // namespace internal |
535 } // namespace v8 | 535 } // namespace v8 |
OLD | NEW |