Commit 392c1d8e authored by bmeurer's avatar bmeurer Committed by Commit bot

[stubs] Enforce correct index representation on 64-bit.

Address computation on 64-bit platforms must be done in Word64, mixing
Word32 here is unsound.

TBR=danno@chromium.org

Review-Url: https://codereview.chromium.org/1997223002
Cr-Commit-Position: refs/heads/master@{#36428}
parent cc71837f
...@@ -1565,13 +1565,16 @@ compiler::Node* CodeStubAssembler::ElementOffsetFromIndex(Node* index_node, ...@@ -1565,13 +1565,16 @@ compiler::Node* CodeStubAssembler::ElementOffsetFromIndex(Node* index_node,
if (constant_index) { if (constant_index) {
return IntPtrConstant(base_size + element_size * index); return IntPtrConstant(base_size + element_size * index);
} }
if (Is64() && mode == INTEGER_PARAMETERS) {
index_node = ChangeInt32ToInt64(index_node);
}
if (base_size == 0) { if (base_size == 0) {
return (element_size_shift >= 0) return (element_size_shift >= 0)
? WordShl(index_node, IntPtrConstant(element_size_shift)) ? WordShl(index_node, IntPtrConstant(element_size_shift))
: WordShr(index_node, IntPtrConstant(-element_size_shift)); : WordShr(index_node, IntPtrConstant(-element_size_shift));
} }
return IntPtrAdd( return IntPtrAdd(
Int32Constant(base_size), IntPtrConstant(base_size),
(element_size_shift >= 0) (element_size_shift >= 0)
? WordShl(index_node, IntPtrConstant(element_size_shift)) ? WordShl(index_node, IntPtrConstant(element_size_shift))
: WordShr(index_node, IntPtrConstant(-element_size_shift))); : WordShr(index_node, IntPtrConstant(-element_size_shift)));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment