Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(221)

Unified Diff: src/compiler/memory-optimizer.cc

Issue 2183043002: [turbofan] Perform element index computation in word64 on 64-bit platforms. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/cctest/compiler/test-simplified-lowering.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/memory-optimizer.cc
diff --git a/src/compiler/memory-optimizer.cc b/src/compiler/memory-optimizer.cc
index 8c66347a6e1210494f0f8d372f4f468d211e4a92..abf5ef5ae969c79bae2d6c802ad99e5eba7cb0a1 100644
--- a/src/compiler/memory-optimizer.cc
+++ b/src/compiler/memory-optimizer.cc
@@ -370,23 +370,28 @@ void MemoryOptimizer::VisitOtherEffect(Node* node,
}
Node* MemoryOptimizer::ComputeIndex(ElementAccess const& access, Node* key) {
- Node* index = key;
- int element_size_shift =
+ Node* index;
+ if (machine()->Is64()) {
+ // On 64-bit platforms, we need to feed a Word64 index to the Load and
+ // Store operators. Since LoadElement or StoreElement don't do any bounds
+ // checking themselves, we can be sure that the {key} was already checked
+ // and is in valid range, so we can do the further address computation on
+ // Word64 below, which ideally allows us to fuse the address computation
+ // with the actual memory access operation on Intel platforms.
+ index = graph()->NewNode(machine()->ChangeUint32ToUint64(), key);
+ } else {
+ index = key;
+ }
+ int const element_size_shift =
ElementSizeLog2Of(access.machine_type.representation());
if (element_size_shift) {
- index = graph()->NewNode(machine()->Word32Shl(), index,
- jsgraph()->Int32Constant(element_size_shift));
+ index = graph()->NewNode(machine()->WordShl(), index,
+ jsgraph()->IntPtrConstant(element_size_shift));
}
- const int fixed_offset = access.header_size - access.tag();
+ int const fixed_offset = access.header_size - access.tag();
if (fixed_offset) {
- index = graph()->NewNode(machine()->Int32Add(), index,
- jsgraph()->Int32Constant(fixed_offset));
- }
- if (machine()->Is64()) {
- // TODO(turbofan): This is probably only correct for typed arrays, and only
- // if the typed arrays are at most 2GiB in size, which happens to match
- // exactly our current situation.
- index = graph()->NewNode(machine()->ChangeUint32ToUint64(), index);
+ index = graph()->NewNode(machine()->IntAdd(), index,
+ jsgraph()->IntPtrConstant(fixed_offset));
}
return index;
}
« no previous file with comments | « no previous file | test/cctest/compiler/test-simplified-lowering.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698