Skip to content

Conversation

@wenyongh
Copy link
Collaborator

@wenyongh wenyongh commented Jul 1, 2022

Refine fast jit frontend translation of opcode br_if and br_table:

  1. for br_if, no need to clear jit frame after handling new basic block,
    so as to re-use registers of current basic block
  2. for br_table, no need to create new basic block to jump if there is
    no parameters/results to copy to new block, just jumping to current
    existing basic block

@wenyongh wenyongh changed the title Refine fe translate op br_if and br_table Refine fast jit frontend translation of op br_if and br_table Jul 1, 2022
uint32 total_size;

total_size = (uint32)(offsetof(JitFrame, lp)
+ sizeof(*jit_frame->lp) * (max_locals + max_stacks));
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't have any opinion about the code. But just want to clarify that in a frame, all we actually care about is data in both locals and stack, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, not only locals and stacks, but also other info, e.g. frame_sp, virtual fixed registers, e.g. memory/table related registers. Since when clear_values at L972, most of the frame registers are set 0, we need to backup them firstly and then restore them after translating the dst basic block.

total_size =
(uint32)(offsetof(JitFrame, lp)
+ sizeof(*jit_frame_src->lp) * (max_locals + max_stacks));
bh_memcpy_s(jit_frame_dst, total_size, jit_frame_src, total_size);
Copy link
Contributor

Choose a reason for hiding this comment

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

shall we consider the possibility of the overlap between jit_frame_dst and jit_frame_src?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There should be no overlap, the memory of jit_frame_dst is allocated in jit_frame_clone, it is another memory block different from jit_frame_src.

@lum1n0us
Copy link
Contributor

lum1n0us commented Jul 6, 2022

LGTM

@wenyongh wenyongh merged commit 9c2bdd1 into bytecodealliance:dev/fast_jit Jul 6, 2022
@wenyongh wenyongh deleted the opt_fast_jit_emit_control branch July 11, 2022 04:21
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