[wasm] Use int type for small offsets

The uint32_t type can easily be confused with the memory offsets that
are currently 32 bit and will become 64 bit with the memory64 proposal.
Since the offsets into the instance are always small anyway, the type of
the integer does not really matter, and we should stick to the default
'int'.

R=manoskouk@chromium.org

Bug: v8:10949
Change-Id: I742334483bbc80c4cc03f40f046b5d2d3b17d1d8
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2489691
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Reviewed-by: Manos Koukoutos <manoskouk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70712}
This commit is contained in:
Clemens Backes 2020-10-21 17:40:43 +02:00 committed by Commit Bot
parent 6f73c6c816
commit ba5646046b
5 changed files with 17 additions and 25 deletions

View File

@ -532,16 +532,14 @@ void LiftoffAssembler::LoadConstant(LiftoffRegister reg, WasmValue value,
} }
} }
void LiftoffAssembler::LoadFromInstance(Register dst, uint32_t offset, void LiftoffAssembler::LoadFromInstance(Register dst, int offset, int size) {
int size) { DCHECK_LE(0, offset);
DCHECK_LE(offset, kMaxInt);
DCHECK_EQ(4, size); DCHECK_EQ(4, size);
ldr(dst, liftoff::GetInstanceOperand()); ldr(dst, liftoff::GetInstanceOperand());
ldr(dst, MemOperand(dst, offset)); ldr(dst, MemOperand(dst, offset));
} }
void LiftoffAssembler::LoadTaggedPointerFromInstance(Register dst, void LiftoffAssembler::LoadTaggedPointerFromInstance(Register dst, int offset) {
uint32_t offset) {
LoadFromInstance(dst, offset, kTaggedSize); LoadFromInstance(dst, offset, kTaggedSize);
} }

View File

@ -313,9 +313,8 @@ void LiftoffAssembler::LoadConstant(LiftoffRegister reg, WasmValue value,
} }
} }
void LiftoffAssembler::LoadFromInstance(Register dst, uint32_t offset, void LiftoffAssembler::LoadFromInstance(Register dst, int offset, int size) {
int size) { DCHECK_LE(0, offset);
DCHECK_LE(offset, kMaxInt);
Ldr(dst, liftoff::GetInstanceOperand()); Ldr(dst, liftoff::GetInstanceOperand());
DCHECK(size == 4 || size == 8); DCHECK(size == 4 || size == 8);
if (size == 4) { if (size == 4) {
@ -325,9 +324,8 @@ void LiftoffAssembler::LoadFromInstance(Register dst, uint32_t offset,
} }
} }
void LiftoffAssembler::LoadTaggedPointerFromInstance(Register dst, void LiftoffAssembler::LoadTaggedPointerFromInstance(Register dst, int offset) {
uint32_t offset) { DCHECK_LE(0, offset);
DCHECK_LE(offset, kMaxInt);
Ldr(dst, liftoff::GetInstanceOperand()); Ldr(dst, liftoff::GetInstanceOperand());
LoadTaggedPointerField(dst, MemOperand(dst, offset)); LoadTaggedPointerField(dst, MemOperand(dst, offset));
} }

View File

@ -261,16 +261,14 @@ void LiftoffAssembler::LoadConstant(LiftoffRegister reg, WasmValue value,
} }
} }
void LiftoffAssembler::LoadFromInstance(Register dst, uint32_t offset, void LiftoffAssembler::LoadFromInstance(Register dst, int offset, int size) {
int size) { DCHECK_LE(0, offset);
DCHECK_LE(offset, kMaxInt);
mov(dst, liftoff::GetInstanceOperand()); mov(dst, liftoff::GetInstanceOperand());
DCHECK_EQ(4, size); DCHECK_EQ(4, size);
mov(dst, Operand(dst, offset)); mov(dst, Operand(dst, offset));
} }
void LiftoffAssembler::LoadTaggedPointerFromInstance(Register dst, void LiftoffAssembler::LoadTaggedPointerFromInstance(Register dst, int offset) {
uint32_t offset) {
LoadFromInstance(dst, offset, kTaggedSize); LoadFromInstance(dst, offset, kTaggedSize);
} }

View File

@ -478,8 +478,8 @@ class LiftoffAssembler : public TurboAssembler {
inline void LoadConstant(LiftoffRegister, WasmValue, inline void LoadConstant(LiftoffRegister, WasmValue,
RelocInfo::Mode rmode = RelocInfo::NONE); RelocInfo::Mode rmode = RelocInfo::NONE);
inline void LoadFromInstance(Register dst, uint32_t offset, int size); inline void LoadFromInstance(Register dst, int offset, int size);
inline void LoadTaggedPointerFromInstance(Register dst, uint32_t offset); inline void LoadTaggedPointerFromInstance(Register dst, int offset);
inline void SpillInstance(Register instance); inline void SpillInstance(Register instance);
inline void FillInstanceInto(Register dst); inline void FillInstanceInto(Register dst);
inline void LoadTaggedPointer(Register dst, Register src_addr, inline void LoadTaggedPointer(Register dst, Register src_addr,

View File

@ -236,11 +236,10 @@ void LiftoffAssembler::LoadConstant(LiftoffRegister reg, WasmValue value,
} }
} }
void LiftoffAssembler::LoadFromInstance(Register dst, uint32_t offset, void LiftoffAssembler::LoadFromInstance(Register dst, int offset, int size) {
int size) { DCHECK_LE(0, offset);
DCHECK_LE(offset, kMaxInt);
movq(dst, liftoff::GetInstanceOperand());
DCHECK(size == 4 || size == 8); DCHECK(size == 4 || size == 8);
movq(dst, liftoff::GetInstanceOperand());
if (size == 4) { if (size == 4) {
movl(dst, Operand(dst, offset)); movl(dst, Operand(dst, offset));
} else { } else {
@ -248,9 +247,8 @@ void LiftoffAssembler::LoadFromInstance(Register dst, uint32_t offset,
} }
} }
void LiftoffAssembler::LoadTaggedPointerFromInstance(Register dst, void LiftoffAssembler::LoadTaggedPointerFromInstance(Register dst, int offset) {
uint32_t offset) { DCHECK_LE(0, offset);
DCHECK_LE(offset, kMaxInt);
movq(dst, liftoff::GetInstanceOperand()); movq(dst, liftoff::GetInstanceOperand());
LoadTaggedPointerField(dst, Operand(dst, offset)); LoadTaggedPointerField(dst, Operand(dst, offset));
} }