-
Notifications
You must be signed in to change notification settings - Fork 749
Implement part of codegen #1050
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement part of codegen #1050
Conversation
Merge bytecodealliance:dev/fast_jit into wenyongh:dev/fast_jit
|
|
||
| /* Pop block and load block results */ | ||
| block = jit_block_stack_pop(&cc->block_stack); | ||
| if (!load_block_results(cc, block)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
L414 if(!block->incoming_insn_for_end_bb) also needs to transfer return values from the if block or else block to the outer block.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems no need to change the jit_frame, just move result values from popped block's value stack into previous block's value stack?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, only return values . No basic_block, No modification of jit_frame.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But still, need to handle the special case of LABE_TYPE_FUNCTION
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if (!load_block_results(cc, block)) { | |
| if (block->label_type == LABEL_TYPE_FUNCTION) { | |
| handle_func_return(cc, block); | |
| SET_BB_END_BCIP(cc->cur_basic_block, *p_frame_ip - 1); | |
| } | |
| else { | |
| if (!load_block_result(cc, block) { | |
| } |
| INSN(RETURNBC, Reg, 1, 0) | ||
| INSN(CALLBC, Reg, 3, 2) | ||
| INSN(RETURNBC, Reg, 3, 0) | ||
| INSN(RETURN, Reg, 1, 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is the difference between CALLNATIVE and CALLBC? and between RETURNBC and RETURN ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CALLNATIVE is to call a native function, including runtime APIs (e.g., jit_set_exception_with_id) and native APIs (e.g., libc-builtin, libc-wasi, etc.), we must use call instruction to call that native function, and pass the arguments/results according the calling convention of host, e.g., ABI of Linux/Windows.
CALLBC means call bytecode, it is to call the wasm function, currently we only call the jited code of wasm function, in the future, we might return back to interpreter to call the wasm function, if it hasn't been compiled into jited code. Note that we use jmp instruction but not call instruction to jump to the jited code, and the arguments/results are passed by interpreter stack frame.
RETURNBC is to return to the caller from current jited code, if the caller is a wasm function, we jump to the next instruction of caller's jmp instruction (used by CALLBC) to let caller continue to run. If the caller is interpreter, we jump to the global code block jit_globals->return_to_interp_from_jitted to return to interpreter.
RETURN is used when exception was thrown, and we want to return to interpreter directly.
Implement part of codegen, add asmjit and zydis (bytecodealliance#1050)
No description provided.