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

how to disable generation "trampoline" code? #102

Closed
blooddy opened this issue May 8, 2018 · 3 comments
Closed

how to disable generation "trampoline" code? #102

blooddy opened this issue May 8, 2018 · 3 comments
Labels

Comments

@blooddy
Copy link

blooddy commented May 8, 2018

  (func $main/test (type $t1) (param $p0 i32) (param $p1 i32)
  ...)
  (func $main/test|trampoline (export "test") (type $t1) (param $p0 i32) (param $p1 i32)
    block $B0
      block $B1
        block $B2
          get_global $g25
          i32.const 1
          i32.sub
          br_table $B1 $B0 $B2
        end
        unreachable
      end
      i32.const 0
      set_local $p1
    end
    get_local $p0
    get_local $p1
    call $main/test)
  (func $~setargc (export "_setargc") (type $t2) (param $p0 i32)
    get_local $p0
    set_global $g25)
@blooddy blooddy changed the title how to disable generation "trampoline" generated code? how to disable generation "trampoline" code? May 8, 2018
@dcodeIO
Copy link
Member

dcodeIO commented May 9, 2018

The trampoline is generated if a function with optional arguments is called with omitted arguments. It basically wraps up the initializers of optional arguments in a proper context and calls the original function with them. If you always call functions with optional arguments with all arguments provided, no trampolines must be generated.

@dcodeIO
Copy link
Member

dcodeIO commented May 9, 2018

This reminds me that a few optimizations could be performed there. One is that if default values of omitted arguments are zero anyway, another one is if default values are constants that can be inlined into the call.

dcodeIO added a commit that referenced this issue May 11, 2018
…102; Fix temporary local flags not being cleared; Fix inlined temporary locals not being free'd; Fix inlined flows not breaking after returns; Allow changetype of u32s, i.e. function pointers
@dcodeIO
Copy link
Member

dcodeIO commented Jul 10, 2018

Closing this issue for now as it hasn't received any replies recently, so I assume that the optimizations implemented above address it sufficiently. Feel free to reopen if necessary!

@dcodeIO dcodeIO closed this as completed Jul 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants