mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-05-28 20:47:22 +00:00
Implement opcode memory.size (#1217)
This commit is contained in:
parent
5e84cf8826
commit
50982dd145
|
@ -468,8 +468,20 @@ fail:
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
jit_compile_op_memory_size(JitCompContext *cc)
|
jit_compile_op_memory_size(JitCompContext *cc, uint32 mem_idx)
|
||||||
{
|
{
|
||||||
|
JitReg mem_inst, res;
|
||||||
|
|
||||||
|
mem_inst = get_memory_inst_reg(cc->jit_frame, mem_idx);
|
||||||
|
|
||||||
|
res = jit_cc_new_reg_I32(cc);
|
||||||
|
GEN_INSN(LDI32, res, mem_inst,
|
||||||
|
NEW_CONST(I32, offsetof(WASMMemoryInstance, cur_page_count)));
|
||||||
|
|
||||||
|
PUSH_I32(res);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
fail:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ bool
|
||||||
jit_compile_op_f64_store(JitCompContext *cc, uint32 align, uint32 offset);
|
jit_compile_op_f64_store(JitCompContext *cc, uint32 align, uint32 offset);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
jit_compile_op_memory_size(JitCompContext *cc);
|
jit_compile_op_memory_size(JitCompContext *cc, uint32 mem_idx);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
jit_compile_op_memory_grow(JitCompContext *cc, uint32 mem_idx);
|
jit_compile_op_memory_grow(JitCompContext *cc, uint32 mem_idx);
|
||||||
|
|
|
@ -1423,9 +1423,8 @@ jit_compile_func(JitCompContext *cc)
|
||||||
|
|
||||||
case WASM_OP_MEMORY_SIZE:
|
case WASM_OP_MEMORY_SIZE:
|
||||||
read_leb_uint32(frame_ip, frame_ip_end, mem_idx);
|
read_leb_uint32(frame_ip, frame_ip_end, mem_idx);
|
||||||
if (!jit_compile_op_memory_size(cc))
|
if (!jit_compile_op_memory_size(cc, mem_idx))
|
||||||
return false;
|
return false;
|
||||||
(void)mem_idx;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WASM_OP_MEMORY_GROW:
|
case WASM_OP_MEMORY_GROW:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user