| 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 // Update the allocation top with the new object allocation. | 139 // Update the allocation top with the new object allocation. |
| 140 // TODO(bmeurer): Defer writing back top as much as possible. | 140 // TODO(bmeurer): Defer writing back top as much as possible. |
| 141 Node* top = graph()->NewNode(machine()->IntAdd(), state->top(), | 141 Node* top = graph()->NewNode(machine()->IntAdd(), state->top(), |
| 142 jsgraph()->IntPtrConstant(object_size)); | 142 jsgraph()->IntPtrConstant(object_size)); |
| 143 effect = graph()->NewNode( | 143 effect = graph()->NewNode( |
| 144 machine()->Store(StoreRepresentation( | 144 machine()->Store(StoreRepresentation( |
| 145 MachineType::PointerRepresentation(), kNoWriteBarrier)), | 145 MachineType::PointerRepresentation(), kNoWriteBarrier)), |
| 146 top_address, jsgraph()->IntPtrConstant(0), top, effect, control); | 146 top_address, jsgraph()->IntPtrConstant(0), top, effect, control); |
| 147 | 147 |
| 148 // Compute the effective inner allocated address. | 148 // Compute the effective inner allocated address. |
| 149 value = graph()->NewNode( | 149 value = graph()->NewNode(machine()->BitcastWordToTagged(), state->top()); |
| 150 machine()->BitcastWordToTagged(), | |
| 151 graph()->NewNode(machine()->IntAdd(), state->top(), | |
| 152 jsgraph()->IntPtrConstant(kHeapObjectTag))); | |
| 153 | 150 |
| 154 // Extend the allocation {group}. | 151 // Extend the allocation {group}. |
| 155 group->Add(value); | 152 group->Add(value); |
| 156 state = AllocationState::Open(group, state_size, top, zone()); | 153 state = AllocationState::Open(group, state_size, top, zone()); |
| 157 } else { | 154 } else { |
| 158 // Setup a mutable reservation size node; will be patched as we fold | 155 // Setup a mutable reservation size node; will be patched as we fold |
| 159 // additional allocations into this new group. | 156 // additional allocations into this new group. |
| 160 Node* size = graph()->NewNode(common()->Int32Constant(object_size)); | 157 Node* size = graph()->NewNode(common()->Int32Constant(object_size)); |
| 161 | 158 |
| 162 // Load allocation top and limit. | 159 // Load allocation top and limit. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 191 Node* target = pretenure == NOT_TENURED | 188 Node* target = pretenure == NOT_TENURED |
| 192 ? jsgraph()->AllocateInNewSpaceStubConstant() | 189 ? jsgraph()->AllocateInNewSpaceStubConstant() |
| 193 : jsgraph()->AllocateInOldSpaceStubConstant(); | 190 : jsgraph()->AllocateInOldSpaceStubConstant(); |
| 194 if (!allocate_operator_.is_set()) { | 191 if (!allocate_operator_.is_set()) { |
| 195 CallDescriptor* descriptor = | 192 CallDescriptor* descriptor = |
| 196 Linkage::GetAllocateCallDescriptor(graph()->zone()); | 193 Linkage::GetAllocateCallDescriptor(graph()->zone()); |
| 197 allocate_operator_.set(common()->Call(descriptor)); | 194 allocate_operator_.set(common()->Call(descriptor)); |
| 198 } | 195 } |
| 199 vfalse = efalse = graph()->NewNode(allocate_operator_.get(), target, | 196 vfalse = efalse = graph()->NewNode(allocate_operator_.get(), target, |
| 200 size, efalse, if_false); | 197 size, efalse, if_false); |
| 201 vfalse = graph()->NewNode(machine()->IntSub(), vfalse, | |
| 202 jsgraph()->IntPtrConstant(kHeapObjectTag)); | |
| 203 } | 198 } |
| 204 | 199 |
| 205 control = graph()->NewNode(common()->Merge(2), if_true, if_false); | 200 control = graph()->NewNode(common()->Merge(2), if_true, if_false); |
| 206 effect = graph()->NewNode(common()->EffectPhi(2), etrue, efalse, control); | 201 effect = graph()->NewNode(common()->EffectPhi(2), etrue, efalse, control); |
| 207 value = graph()->NewNode( | 202 value = graph()->NewNode( |
| 208 common()->Phi(MachineType::PointerRepresentation(), 2), vtrue, vfalse, | 203 common()->Phi(MachineType::PointerRepresentation(), 2), vtrue, vfalse, |
| 209 control); | 204 control); |
| 210 | 205 |
| 211 // Compute the new top and write it back. | 206 // Compute the new top and write it back. |
| 212 top = graph()->NewNode(machine()->IntAdd(), value, | 207 top = graph()->NewNode(machine()->IntAdd(), value, |
| 213 jsgraph()->IntPtrConstant(object_size)); | 208 jsgraph()->IntPtrConstant(object_size)); |
| 214 effect = graph()->NewNode( | 209 effect = graph()->NewNode( |
| 215 machine()->Store(StoreRepresentation( | 210 machine()->Store(StoreRepresentation( |
| 216 MachineType::PointerRepresentation(), kNoWriteBarrier)), | 211 MachineType::PointerRepresentation(), kNoWriteBarrier)), |
| 217 top_address, jsgraph()->IntPtrConstant(0), top, effect, control); | 212 top_address, jsgraph()->IntPtrConstant(0), top, effect, control); |
| 218 | 213 |
| 219 // Compute the initial object address. | 214 // Compute the initial object address. |
| 220 value = graph()->NewNode( | 215 value = graph()->NewNode(machine()->BitcastWordToTagged(), value); |
| 221 machine()->BitcastWordToTagged(), | |
| 222 graph()->NewNode(machine()->IntAdd(), value, | |
| 223 jsgraph()->IntPtrConstant(kHeapObjectTag))); | |
| 224 | 216 |
| 225 // Start a new allocation group. | 217 // Start a new allocation group. |
| 226 AllocationGroup* group = | 218 AllocationGroup* group = |
| 227 new (zone()) AllocationGroup(value, pretenure, size, zone()); | 219 new (zone()) AllocationGroup(value, pretenure, size, zone()); |
| 228 state = AllocationState::Open(group, object_size, top, zone()); | 220 state = AllocationState::Open(group, object_size, top, zone()); |
| 229 } | 221 } |
| 230 } else { | 222 } else { |
| 231 // Load allocation top and limit. | 223 // Load allocation top and limit. |
| 232 Node* top = effect = | 224 Node* top = effect = |
| 233 graph()->NewNode(machine()->Load(MachineType::Pointer()), top_address, | 225 graph()->NewNode(machine()->Load(MachineType::Pointer()), top_address, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 249 graph()->NewNode(common()->Branch(BranchHint::kTrue), check, control); | 241 graph()->NewNode(common()->Branch(BranchHint::kTrue), check, control); |
| 250 | 242 |
| 251 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); | 243 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); |
| 252 Node* etrue = effect; | 244 Node* etrue = effect; |
| 253 Node* vtrue; | 245 Node* vtrue; |
| 254 { | 246 { |
| 255 etrue = graph()->NewNode( | 247 etrue = graph()->NewNode( |
| 256 machine()->Store(StoreRepresentation( | 248 machine()->Store(StoreRepresentation( |
| 257 MachineType::PointerRepresentation(), kNoWriteBarrier)), | 249 MachineType::PointerRepresentation(), kNoWriteBarrier)), |
| 258 top_address, jsgraph()->IntPtrConstant(0), new_top, etrue, if_true); | 250 top_address, jsgraph()->IntPtrConstant(0), new_top, etrue, if_true); |
| 259 vtrue = graph()->NewNode( | 251 vtrue = graph()->NewNode(machine()->BitcastWordToTagged(), top); |
| 260 machine()->BitcastWordToTagged(), | |
| 261 graph()->NewNode(machine()->IntAdd(), top, | |
| 262 jsgraph()->IntPtrConstant(kHeapObjectTag))); | |
| 263 } | 252 } |
| 264 | 253 |
| 265 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); | 254 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); |
| 266 Node* efalse = effect; | 255 Node* efalse = effect; |
| 267 Node* vfalse; | 256 Node* vfalse; |
| 268 { | 257 { |
| 269 Node* target = pretenure == NOT_TENURED | 258 Node* target = pretenure == NOT_TENURED |
| 270 ? jsgraph()->AllocateInNewSpaceStubConstant() | 259 ? jsgraph()->AllocateInNewSpaceStubConstant() |
| 271 : jsgraph()->AllocateInOldSpaceStubConstant(); | 260 : jsgraph()->AllocateInOldSpaceStubConstant(); |
| 272 if (!allocate_operator_.is_set()) { | 261 if (!allocate_operator_.is_set()) { |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 return jsgraph()->common(); | 476 return jsgraph()->common(); |
| 488 } | 477 } |
| 489 | 478 |
| 490 MachineOperatorBuilder* MemoryOptimizer::machine() const { | 479 MachineOperatorBuilder* MemoryOptimizer::machine() const { |
| 491 return jsgraph()->machine(); | 480 return jsgraph()->machine(); |
| 492 } | 481 } |
| 493 | 482 |
| 494 } // namespace compiler | 483 } // namespace compiler |
| 495 } // namespace internal | 484 } // namespace internal |
| 496 } // namespace v8 | 485 } // namespace v8 |
| OLD | NEW |