extensions
Volodymyr Shymanskyy 3 years ago
parent 33b501fe26
commit a0f4f69d12

@ -499,15 +499,15 @@ M3Result Pop (IM3Compilation o)
M3Result PopType (IM3Compilation o, u8 i_type)
{
M3Result result = m3Err_none;
u8 topType = GetStackTopType (o);
if (i_type == topType or o->block.isPolymorphic)
{
result = Pop (o);
}
else result = m3Err_typeMismatch;
return result;
}
@ -1011,7 +1011,7 @@ M3Result Compile_Return (IM3Compilation o, m3opcode_t i_opcode)
if (GetFunctionNumReturns (o->function))
{
u8 type = GetFunctionReturnType (o->function, 0);
_ (ReturnStackTop (o));
_ (PopType (o, type));
}
@ -1037,7 +1037,7 @@ M3Result Compile_End (IM3Compilation o, m3opcode_t i_opcode)
{
if (not o->block.isPolymorphic and type != GetStackTopType (o))
_throw (m3Err_typeMismatch);
// if there are branches to the function end, then their values are in a register
// if the block happens to have its top in a register too, then we can patch the branch
// to here. Otherwise, an ReturnStackTop is appended to the end of the function (at B) and
@ -1486,13 +1486,15 @@ _ (EmitOp (o, op_CallIndirect));
}
M3Result Compile_Memory_Current (IM3Compilation o, m3opcode_t i_opcode)
M3Result Compile_Memory_Size (IM3Compilation o, m3opcode_t i_opcode)
{
M3Result result;
i8 reserved;
_ (ReadLEB_i7 (& reserved, & o->wasm, o->wasmEnd));
_ (PreserveRegisterIfOccupied (o, c_m3Type_i32));
_ (EmitOp (o, op_MemCurrent));
_ (PushRegister (o, c_m3Type_i32));
@ -1971,8 +1973,8 @@ const M3OpInfo c_operations [] =
M3OP( "i64.store16", -2, none, d_binOpList (i64, Store_i16), Compile_Load_Store ), // 0x3d
M3OP( "i64.store32", -2, none, d_binOpList (i64, Store_i32), Compile_Load_Store ), // 0x3e
M3OP( "memory.current", 1, i_32, d_logOp (MemCurrent), Compile_Memory_Current ), // 0x3f
M3OP( "memory.grow", 1, i_32, d_logOp (MemGrow), Compile_Memory_Grow ), // 0x40
M3OP( "memory.size", 1, i_32, d_logOp (MemCurrent), Compile_Memory_Size ), // 0x3f
M3OP( "memory.grow", 1, i_32, d_logOp (MemGrow), Compile_Memory_Grow ), // 0x40
M3OP( "i32.const", 1, i_32, d_logOp (Const32), Compile_Const_i32 ), // 0x41
M3OP( "i64.const", 1, i_64, d_logOp (Const64), Compile_Const_i64 ), // 0x42
@ -2379,7 +2381,7 @@ _try {
// skip over code size. the end was already calculated during parse phase
u32 size;
_ (ReadLEB_u32 (& size, & o->wasm, o->wasmEnd)); d_m3Assert (size == (o->wasmEnd - o->wasm))
_ (AcquireCompilationCodePage (o, & o->page));
pc_t pc = GetPagePC (o->page);

Loading…
Cancel
Save