Skip to content
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

Optimize OP codes when return single value #243

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

coderzh
Copy link
Contributor

@coderzh coderzh commented Jun 2, 2021

Hi, when I profiling fib(40), the op calls show that:

    496740420  op_SetSlot_i32
    331160281  op_u32_LessThan_ss
    331160280  op_Call
    331160280  op_i32_Subtract_ss
    165580141  op_CopySlot_32     <--- extra op codes in new version
    165580141  op_If_r
    165580140  op_i32_Add_ss

Old wasm3 version, fib(40):

    496740420  op_SetSlot_i32
    331160281  op_u32_LessThan_ss
    331160280  op_Call
    331160280  op_i32_Subtract_ss
    165580141  op_If_r
    165580140  op_i32_Add_ss

I reviewed code then I found that it is because of the Multi-values support(#23)

The new version pushed all Return Values to the stack, then followed other Argnument Values, this cause more op_CopySlot_xx generated in ReturnValues function.

In the real world, most of functions return single value. If the count of return values less or equals than 1, can the stack keeps the same as the old version? The slot of the last return value also be the first argument value's.

Case1:

slot
0 return0 argument0
1 argument1

Case2:

slot
0 return0
1 return1 argument0
2 argument1

BTW: The pywasm3 tests failed, should apply this commit:
coderzh/pywasm3@7ca8225

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant