Skip to content

Conversation

@wenyongh
Copy link
Collaborator

@wenyongh wenyongh commented Jul 1, 2022

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.

@wenyongh wenyongh changed the base branch from main to dev/fast_jit July 1, 2022 08:30
bh_list_insert(jmp_info_list, node);

imm.setValue(INT32_MAX);
a.je(imm);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in another PR, after je to INT32_MAX, there is an error checking. Do we need it here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is because that I don't want to write offset to the invalid place when asmjit error occurs. Normally we check the asm error in jit_codegen_gen_native, after generating machine code for each INSN, in other place, we can skip the check to reduce the footprint.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but if the error was raised,

will be triggered?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it will be triggered, in the beginning of jit_codegen_gen_native, we set the error handler of code buffer:

code.init(env);
code.setErrorHandler(&err_handler);
x86::Assembler a(&code);

And the JitErrorHandler is defined here:

class JitErrorHandler : public ErrorHandler
{
public:
Error err;
JitErrorHandler()
: err(kErrorOk)
{}
void handleError(Error e, const char *msg, BaseEmitter *base) override
{
(void)msg;
(void)base;
this->err = e;

Merge bytecodealliance:dev/fast_jit into wenyongh:opt_fast_jit_br_table_cg
@wenyongh wenyongh merged commit bb9c9a6 into bytecodealliance:dev/fast_jit Jul 8, 2022
wenyongh added a commit to wenyongh/wasm-micro-runtime that referenced this pull request Jul 8, 2022
Refine fast jit backend translation of IR lookupswitch (bytecodealliance#1264)
@wenyongh wenyongh deleted the opt_fast_jit_br_table_cg branch July 11, 2022 03:50
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.

2 participants