Commit 84852475 authored by ivica.bogosavljevic's avatar ivica.bogosavljevic Committed by Commit bot

MIPS64: Fix VirtualObject field offset calculation on Big-endian architectures

If a HeapObject field is 8 bytes long and 8 bytes aligned, but we use only four bytes of it
on little endian architectures we will access to lower 4 bytes of the field using the same
base address as accessing the whole eight bytes
On big-endian architectures however we use base address to access the full 8 bytes, but base
address + 4 to access to lower 4 bytes. For this reason, the assert in OffsetForFieldAccess
fails on MIPS64 big endian.
We fix the issue by removing the assert that checks that offset is pointer size aligned.

TEST=mjsunit/regress/regress-crbug-648737
BUG=

Review-Url: https://codereview.chromium.org/2453333002
Cr-Commit-Position: refs/heads/master@{#40772}
parent 4ff2cafe
......@@ -1339,9 +1339,19 @@ bool EscapeAnalysis::CompareVirtualObjects(Node* left, Node* right) {
namespace {
bool IsOffsetForFieldAccessCorrect(const FieldAccess& access) {
#if V8_TARGET_LITTLE_ENDIAN
return (access.offset % kPointerSize) == 0;
#else
return ((access.offset +
(1 << ElementSizeLog2Of(access.machine_type.representation()))) %
kPointerSize) == 0;
#endif
}
int OffsetForFieldAccess(Node* node) {
FieldAccess access = FieldAccessOf(node->op());
DCHECK_EQ(access.offset % kPointerSize, 0);
DCHECK(IsOffsetForFieldAccessCorrect(access));
return access.offset / kPointerSize;
}
......@@ -1420,7 +1430,7 @@ void EscapeAnalysis::ProcessLoadField(Node* node) {
// Record that the load has this alias.
UpdateReplacement(state, node, value);
} else if (from->opcode() == IrOpcode::kPhi &&
FieldAccessOf(node->op()).offset % kPointerSize == 0) {
IsOffsetForFieldAccessCorrect(FieldAccessOf(node->op()))) {
int offset = OffsetForFieldAccess(node);
// Only binary phis are supported for now.
ProcessLoadFromPhi(offset, from, node, state);
......
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