wasm-micro-runtime/core/iwasm/fast-jit
liang.he c93508939a
Lock register to avoid spilling it out by register allocator (#1188)
In one instruction, if one or multiple operands tending to lock some
hardware registers in IR phase, like EAX, EDX for DIV, ECX for SHIFT,
it leads to two known cases.

case 1: allocate VOID

`SHRU i250,i249,i3`. if pr_3 was allocated to vr_249 first, incoming
allocation of vr_3 leads a spill out of `vr_249` and clear the value
of `vr->hreg` of vr_249. When applying allocation result in FOREACH
in L732, a NULL will be assigned to.

case 2: unexpected spill out

`DIV_U i1,i1,i44`.  if allocation of vr_44 needs to spill out one
hardware register, there is a chance that `hr_4` will be selected.
If it happens, codegen will operate EDX and overwrite vr_44 value.

The reason of how `hr_4` will be spilled out is a hidden bug that
both information of `rc->hreg[]` and `rc->vreg` can be transfered
from one block to the next one. It means even there is no vr binds
to a hr in current block, the hr may still be thought as a busy one
becase of the left infroamtion of previous blocks

Workaround for cases:

- Add `MOV LOCKED_hr LOCKED_hr` just after the instruction. It prevents
  case 1
- Add `MOV LOCKED_hr LOCKED_hr` just before the instruction. It prevents
  case 2
2022-05-31 11:58:02 +08:00
..
cg Lock register to avoid spilling it out by register allocator (#1188) 2022-05-31 11:58:02 +08:00
fe Lock register to avoid spilling it out by register allocator (#1188) 2022-05-31 11:58:02 +08:00
iwasm_fast_jit.cmake Implement opcode memory.grow and fix zydis compile error (#1123) 2022-04-27 20:02:38 +08:00
jit_codecache.c Implement op_call for fast-jit (#1075) 2022-04-10 18:41:23 +08:00
jit_codecache.h Import Fast JIT framework (#1016) 2022-03-09 12:34:56 +08:00
jit_codegen.c Implement part of codegen, add asmjit and zydis (#1050) 2022-03-22 12:22:04 +08:00
jit_codegen.h Implement i32/i64 div and rem opcodes translation (#1091) 2022-04-18 11:38:10 +08:00
jit_compiler.c Implement op_call for fast-jit (#1075) 2022-04-10 18:41:23 +08:00
jit_compiler.h Implement part of codegen, add asmjit and zydis (#1050) 2022-03-22 12:22:04 +08:00
jit_dump.c Implement part of codegen, add asmjit and zydis (#1050) 2022-03-22 12:22:04 +08:00
jit_dump.h Import Fast JIT framework (#1016) 2022-03-09 12:34:56 +08:00
jit_frontend.c Implement float comparison, conversion and numeric opcodes (#1170) 2022-05-24 19:03:46 +08:00
jit_frontend.h Implement load fixed virtual regs (#1083) 2022-04-12 14:54:38 +08:00
jit_ir.c Lock register to avoid spilling it out by register allocator (#1188) 2022-05-31 11:58:02 +08:00
jit_ir.def Fix fast jit issues (#1193) 2022-05-30 15:27:22 +08:00
jit_ir.h Lock register to avoid spilling it out by register allocator (#1188) 2022-05-31 11:58:02 +08:00
jit_regalloc.c Lock register to avoid spilling it out by register allocator (#1188) 2022-05-31 11:58:02 +08:00
jit_utils.c Import Fast JIT framework (#1016) 2022-03-09 12:34:56 +08:00
jit_utils.h Import Fast JIT framework (#1016) 2022-03-09 12:34:56 +08:00