Skip to content

Conversation

@wenyongh
Copy link
Collaborator

No description provided.

wenyongh and others added 30 commits March 9, 2022 09:40
Import Fast JIT framework and translate some opcodes in the frontend.
Add more return value checks and set lass error
Implement exception throw and add operand stack overflow check
Remove lower_fe pass
Use cc->cmp_reg for cmp/branch IRs
Fix jit dump issues
Fix some compile warnings
Add part of codegen framework
Remove some unused JIT IRs
After `jit_value_stack_destory()`, the `JitValue` pointed
by `value_list_head` and `value_list_end` are freed and
still keep the value.

So, when `jit_value_stack_push()` is called, for example,
`load_block_params()` after `jit_value_stack_destroy()` in
`handle_op_else()`, `value_stack` will not be treated like
an empty one, and new `JitValue` will be appended to `value_list_end`,
which is a dangling pointer(pointer to the freed `JitValue`).
Since `basic_block_else` is NULL, it meets a crash if there is a
IF block without a else branch. Like:

``` wat
(func (export "params-id") (param i32) (result i32)
  (i32.const 1)
  (if (param i32) (result i32) (local.get 0)
    (then)
  )
)
```

Consider the ELSE block will be created lazily, focus on
`basic_block_entry" here.
Implement part of codegen and fix some frontend issues
Add asmjit to emit native code and add zydis to disassemble native code
Can successfully run some simple cases
Or else, all secondary IRs and machine code will be appended into
the content of first function
And refine IR translation of BR_IF
Translate WASM_OP_CALL into JIT IR in the frontend, and translate
JIT_OP_CALLBC and JIT_OP_CALLNATIVE in the backend.
For calling wasm native API, simply call wasm_interp_call_func_native
to reduce the complexity.
And fix some issues, including wasm loader, frontend, register allocator,
and code gen.
And define the fixed virtual registers, create them at the beginning.
Directly patch the offset in condition jmp instructions as
the offset generated by asmjit is always 0.
WASM_OP_SET_GLOBAL_AUX_STACK is unsupported currently
Since locals and operands are stored in stack on a 64-bit platform
`DEF_UNI_INT_CONST_OPS` handle the case of both consts
wenyongh and others added 27 commits June 28, 2022 23:58
Refine fast jit frontend translation of opcode br_if and br_table:

for br_if, no need to clear jit frame after handling new basic block,
so as to re-use registers of current basic block,
for br_table, no need to create a new basic block to jump if there is
no parameters/results to copy to new block, just jumping to current
existing basic block.
Merge below INSNs translated by wasm opcodes cmp + if or cmp + br_if:
  CMP, SELECTcc, CMP, Bcc
into
  CMP, Bcc
So as to reduce the instructions
If the branches of lookupswitch is relatively big, lookup the dst
label address to jump from the address table but not compare
the value of branch one by one.
Use register edx/rdx/xmm0 to pass i32/i64/f32/f64 return value
in function return/call, but not store and load the register into
stack frame, so as to improve performance.
Fix fast jit sanitizer complaint in fe/jit_emit_number.c:
i32/i64 multiply integer overflow was detected
Merge two JIT IRs:
ADD maddr, memory_data, offset1
LOAD/STORE value, maddr, 0
into one JIT IR:
LOAD/STORE value, memory_data, offset1
Copy fast jit function pointers array from wasm module into wasm
module instance, and load fast jit func pointer from module instance
instead of wasm module, so as to reduce one load operation when callbc.
Fix compilation issues
Update build scripts
Update documents
Fix interp hw bound check issues (#1322)
Translate call_indirect opcode by calling wasm functions with JIT IRs instead of
calling jit_call_indirect runtime API, so as to improve the performance.
Translate call native function process with JIT IRs to validate each pointer argument
and convert it into native address, and then call the native function directly instead
of calling jit_invoke_native runtime API, so as to improve the performance.
@wenyongh wenyongh merged commit 1d4cbfc into main Oct 19, 2022
@wenyongh wenyongh deleted the dev/fast_jit branch December 19, 2022 03:54
vickiegpt pushed a commit to vickiegpt/wamr-aot-gc-checkpoint-restore that referenced this pull request May 27, 2024
…ce#1620)

Translate call_indirect opcode by calling wasm functions with Fast JIT IRs instead of
calling jit_call_indirect runtime API, so as to improve the performance.

Translate call native function process with Fast JIT IRs to validate each pointer argument
and convert it into native address, and then call the native function directly instead
of calling jit_invoke_native runtime API, so as to improve the performance.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants