| 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 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 access.machine_type.representation(), write_barrier_kind))); | 363 access.machine_type.representation(), write_barrier_kind))); |
| 364 EnqueueUses(node, state); | 364 EnqueueUses(node, state); |
| 365 } | 365 } |
| 366 | 366 |
| 367 void MemoryOptimizer::VisitOtherEffect(Node* node, | 367 void MemoryOptimizer::VisitOtherEffect(Node* node, |
| 368 AllocationState const* state) { | 368 AllocationState const* state) { |
| 369 EnqueueUses(node, state); | 369 EnqueueUses(node, state); |
| 370 } | 370 } |
| 371 | 371 |
| 372 Node* MemoryOptimizer::ComputeIndex(ElementAccess const& access, Node* key) { | 372 Node* MemoryOptimizer::ComputeIndex(ElementAccess const& access, Node* key) { |
| 373 Node* index = key; | 373 Node* index; |
| 374 int element_size_shift = | 374 if (machine()->Is64()) { |
| 375 // On 64-bit platforms, we need to feed a Word64 index to the Load and |
| 376 // Store operators. Since LoadElement or StoreElement don't do any bounds |
| 377 // checking themselves, we can be sure that the {key} was already checked |
| 378 // and is in valid range, so we can do the further address computation on |
| 379 // Word64 below, which ideally allows us to fuse the address computation |
| 380 // with the actual memory access operation on Intel platforms. |
| 381 index = graph()->NewNode(machine()->ChangeUint32ToUint64(), key); |
| 382 } else { |
| 383 index = key; |
| 384 } |
| 385 int const element_size_shift = |
| 375 ElementSizeLog2Of(access.machine_type.representation()); | 386 ElementSizeLog2Of(access.machine_type.representation()); |
| 376 if (element_size_shift) { | 387 if (element_size_shift) { |
| 377 index = graph()->NewNode(machine()->Word32Shl(), index, | 388 index = graph()->NewNode(machine()->WordShl(), index, |
| 378 jsgraph()->Int32Constant(element_size_shift)); | 389 jsgraph()->IntPtrConstant(element_size_shift)); |
| 379 } | 390 } |
| 380 const int fixed_offset = access.header_size - access.tag(); | 391 int const fixed_offset = access.header_size - access.tag(); |
| 381 if (fixed_offset) { | 392 if (fixed_offset) { |
| 382 index = graph()->NewNode(machine()->Int32Add(), index, | 393 index = graph()->NewNode(machine()->IntAdd(), index, |
| 383 jsgraph()->Int32Constant(fixed_offset)); | 394 jsgraph()->IntPtrConstant(fixed_offset)); |
| 384 } | |
| 385 if (machine()->Is64()) { | |
| 386 // TODO(turbofan): This is probably only correct for typed arrays, and only | |
| 387 // if the typed arrays are at most 2GiB in size, which happens to match | |
| 388 // exactly our current situation. | |
| 389 index = graph()->NewNode(machine()->ChangeUint32ToUint64(), index); | |
| 390 } | 395 } |
| 391 return index; | 396 return index; |
| 392 } | 397 } |
| 393 | 398 |
| 394 WriteBarrierKind MemoryOptimizer::ComputeWriteBarrierKind( | 399 WriteBarrierKind MemoryOptimizer::ComputeWriteBarrierKind( |
| 395 Node* object, AllocationState const* state, | 400 Node* object, AllocationState const* state, |
| 396 WriteBarrierKind write_barrier_kind) { | 401 WriteBarrierKind write_barrier_kind) { |
| 397 if (state->IsNewSpaceAllocation() && state->group()->Contains(object)) { | 402 if (state->IsNewSpaceAllocation() && state->group()->Contains(object)) { |
| 398 write_barrier_kind = kNoWriteBarrier; | 403 write_barrier_kind = kNoWriteBarrier; |
| 399 } | 404 } |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 return jsgraph()->common(); | 492 return jsgraph()->common(); |
| 488 } | 493 } |
| 489 | 494 |
| 490 MachineOperatorBuilder* MemoryOptimizer::machine() const { | 495 MachineOperatorBuilder* MemoryOptimizer::machine() const { |
| 491 return jsgraph()->machine(); | 496 return jsgraph()->machine(); |
| 492 } | 497 } |
| 493 | 498 |
| 494 } // namespace compiler | 499 } // namespace compiler |
| 495 } // namespace internal | 500 } // namespace internal |
| 496 } // namespace v8 | 501 } // namespace v8 |
| OLD | NEW |