Fix fast jit several issues (#1163)

This commit is contained in:
Wenyong Huang 2022-05-10 15:22:43 +08:00 committed by GitHub
parent d40eb1d3ff
commit 4135622008
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 7 deletions

View File

@ -696,8 +696,15 @@ mov_r_to_m(x86::Assembler &a, uint32 bytes_dst, uint32 kind_dst,
* @return new stream
*/
static bool
mov_imm_to_m(x86::Assembler &a, x86::Mem &m_dst, Imm imm_src)
mov_imm_to_m(x86::Assembler &a, x86::Mem &m_dst, Imm imm_src, uint32 bytes_dst)
{
if (bytes_dst == 8) {
/* As there is no instruction `MOV m64, imm64`, we use
two instructions to implement it */
a.mov(regs_i64[REG_I64_FREE_IDX], imm_src);
a.mov(m_dst, regs_i64[REG_I64_FREE_IDX]);
}
else
a.mov(m_dst, imm_src);
return true;
}
@ -931,7 +938,7 @@ st_imm_to_base_imm_offset_imm(x86::Assembler &a, uint32 bytes_dst,
x86::Mem m((uintptr_t)(base + offset), bytes_dst);
Imm imm;
imm_set_value(imm, data_src, bytes_dst);
return mov_imm_to_m(a, m, imm);
return mov_imm_to_m(a, m, imm, bytes_dst);
}
/**
@ -954,7 +961,7 @@ st_imm_to_base_imm_offset_r(x86::Assembler &a, uint32 bytes_dst, void *data_src,
x86::Mem m(regs_i64[reg_no_offset], base, bytes_dst);
Imm imm;
imm_set_value(imm, data_src, bytes_dst);
return mov_imm_to_m(a, m, imm);
return mov_imm_to_m(a, m, imm, bytes_dst);
}
/**
@ -977,7 +984,7 @@ st_imm_to_base_r_offset_imm(x86::Assembler &a, uint32 bytes_dst, void *data_src,
x86::Mem m(regs_i64[reg_no_base], offset, bytes_dst);
Imm imm;
imm_set_value(imm, data_src, bytes_dst);
return mov_imm_to_m(a, m, imm);
return mov_imm_to_m(a, m, imm, bytes_dst);
}
/**
@ -1001,7 +1008,7 @@ st_imm_to_base_r_offset_r(x86::Assembler &a, uint32 bytes_dst, void *data_src,
x86::Mem m(regs_i64[reg_no_base], regs_i64[reg_no_offset], 0, 0, bytes_dst);
Imm imm;
imm_set_value(imm, data_src, bytes_dst);
return mov_imm_to_m(a, m, imm);
return mov_imm_to_m(a, m, imm, bytes_dst);
}
/**

View File

@ -454,7 +454,7 @@ handle_op_end(JitCompContext *cc, uint8 **p_frame_ip, bool is_block_polymorphic)
jit_basic_block_label(block->basic_block_end);
}
else if (insn->opcode == JIT_OP_BNE) {
*(jit_insn_opnd(insn, 1)) =
*(jit_insn_opnd(insn, 2)) =
jit_basic_block_label(block->basic_block_end);
}
else {

View File

@ -837,8 +837,14 @@ jit_invoke_native(WASMExecEnv *exec_env, uint32 func_idx,
WASMModuleInstance *module_inst =
(WASMModuleInstance *)exec_env->module_inst;
WASMFunctionInstance *cur_func = module_inst->functions + func_idx;
uint32 *sp_org;
sp_org = prev_frame->sp;
wasm_interp_call_func_native(module_inst, exec_env, cur_func, prev_frame);
/* Restore the stack pointer of previous frame as the caller in
jitted code will just read the return value and won't decrease
the stack pointer */
prev_frame->sp = sp_org;
return wasm_get_exception(module_inst) ? false : true;
}