wasm-micro-runtime/core
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
..
app-framework Fix return value not checked issue reported by Coverity (#1156) 2022-05-07 19:22:00 +08:00
app-mgr Fix some issues reported by Coverity (#1150) 2022-05-07 16:51:43 +08:00
deps Fix littlevgl link error issues (#1006) 2022-02-15 08:41:36 +08:00
iwasm Lock register to avoid spilling it out by register allocator (#1188) 2022-05-31 11:58:02 +08:00
shared Add check for stack_min_addr in bound check with hardware trap (#1166) 2022-05-12 12:23:35 +08:00
config.h Merge pull request #1084 from bytecodealliance/main 2022-04-12 20:09:28 +08:00