Commit 23077519 authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[Liftoff] Adapt to ptrsize memory mask

Since https://crrev.com/c/1112003, the memory size is stored as size_t
instead of uint32_t in order to support 4GB memories.
This CL fixes Liftoff to load and handle that field as ptrsized field
instead of 32 bit integer.
Drive-by: Fix wrong machine type on Phi in TF wasm compiler.

R=titzer@chromium.org

Bug: v8:8130
Change-Id: I40a92a2c24f6311e05b5e2608a0902674a2ce411
Reviewed-on: https://chromium-review.googlesource.com/1206008
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Reviewed-by: 's avatarBen Titzer <titzer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55702}
parent 0dba4b90
......@@ -2818,9 +2818,9 @@ void WasmGraphBuilder::PrepareInstanceCacheForLoop(
instance_cache->field, control);
INTRODUCE_PHI(mem_start, MachineType::PointerRepresentation());
INTRODUCE_PHI(mem_size, MachineRepresentation::kWord32);
INTRODUCE_PHI(mem_size, MachineType::PointerRepresentation());
if (untrusted_code_mitigations_) {
INTRODUCE_PHI(mem_mask, MachineRepresentation::kWord32);
INTRODUCE_PHI(mem_mask, MachineType::PointerRepresentation());
}
#undef INTRODUCE_PHI
......
......@@ -455,6 +455,14 @@ class LiftoffAssembler : public TurboAssembler {
emit_i32_sub(dst, lhs, rhs);
}
}
inline void emit_ptrsize_and(Register dst, Register lhs, Register rhs) {
if (kPointerSize == 8) {
emit_i64_and(LiftoffRegister(dst), LiftoffRegister(lhs),
LiftoffRegister(rhs));
} else {
emit_i32_and(dst, lhs, rhs);
}
}
inline void emit_ptrsize_shr(Register dst, Register src, int amount) {
if (kPointerSize == 8) {
emit_i64_shr(LiftoffRegister(dst), LiftoffRegister(src), amount);
......
......@@ -1477,12 +1477,9 @@ class LiftoffCompiler {
}
LiftoffRegister tmp = __ GetUnusedRegister(kGpReg, pinned);
__ LoadConstant(tmp, WasmValue(*offset));
__ emit_i32_add(index.gp(), index.gp(), tmp.gp());
// TODO(clemensh): Use LOAD_INSTANCE_FIELD once the type is fixed.
// LOAD_INSTANCE_FIELD(tmp, MemoryMask, kUInt32Size);
__ LoadFromInstance(tmp.gp(), WASM_INSTANCE_OBJECT_OFFSET(MemoryMask),
kUInt32Size);
__ emit_i32_and(index.gp(), index.gp(), tmp.gp());
__ emit_ptrsize_add(index.gp(), index.gp(), tmp.gp());
LOAD_INSTANCE_FIELD(tmp, MemoryMask, kPointerSize);
__ emit_ptrsize_and(index.gp(), index.gp(), tmp.gp());
*offset = 0;
return index;
}
......
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