Commit 7d167bde authored by Clemens Backes's avatar Clemens Backes Committed by Commit Bot

[wasm][memory64] Fix typing of memory.size

memory.size returns in i64 if memory64 is enabled.
This CL fixes typing and adds a decoder test. Execution will be tested
and fixed in a follow-up CL.

R=manoskouk@chromium.org

Bug: v8:10949
Change-Id: I15818a6273b579d0faacec7f77dc813ae9ba218f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2632593Reviewed-by: 's avatarManos Koukoutos <manoskouk@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#72132}
parent 51474635
......@@ -3045,7 +3045,8 @@ class WasmFullDecoder : public WasmDecoder<validate> {
DECODE(MemorySize) {
if (!CheckHasMemory()) return 0;
MemoryIndexImmediate<validate> imm(this, this->pc_ + 1);
Value* result = Push(kWasmI32);
ValueType result_type = this->module_->is_memory64 ? kWasmI64 : kWasmI32;
Value* result = Push(result_type);
CALL_INTERFACE_IF_REACHABLE(CurrentMemoryPages, result);
return 1 + imm.length;
}
......
......@@ -5008,6 +5008,16 @@ TEST_P(FunctionBodyDecoderTestOnBothMemoryTypes, 64BitOffset) {
#undef ZERO_FOR_TYPE
}
TEST_P(FunctionBodyDecoderTestOnBothMemoryTypes, MemorySize) {
builder.InitializeMemory(GetParam());
// memory.size returns i32 on memory32.
Validate(!is_memory64(), sigs.v_v(),
{WASM_MEMORY_SIZE, kExprI32Eqz, kExprDrop});
// memory.size returns i64 on memory64.
Validate(is_memory64(), sigs.v_v(),
{WASM_MEMORY_SIZE, kExprI64Eqz, kExprDrop});
}
#undef B1
#undef B2
#undef B3
......
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