Skip to content

Gracefully handle function body maximum size limit #5746

Closed

Description

@dschuff

As discussed in WebAssembly/design#1138 browsers currently have a (fairly small) limitation on the maximum size of a wasm function body; small enough that (at least until another round of browser updates goes out) it is likely to affect some projects. So we should try to help those users out in emscripten.

At minimum, we should check all the body sizes after encoding, and warn the user if they are over the limit. That should be straightforward (it could be implemented in emscripten or binaryen).

Ideally we would also have some way to help them fix it, or just fix it for them. Presumably this would be some sort of outlining or function-splitting transformation. My understanding from previous discussion with @kripken is that the JS optimizer had such a transform for asm.js but that it was fragile and/or buggy. LLVM currently has MachineOutliner which operates on the MIR level and there was a recent proposal for a similar pass on LLVM IR although it's unclear how helpful those would be off-the-shelf, since their goal is somewhat different. LLVM does have a lower-level utility, CodeExtractor which might be used in a custom pass for function splitting.

Activity

  1. kripken commented on Nov 7, 2017

    @kripken
    Member

    There is a PR for warning about this in binaryen, WebAssembly/binaryen#1246

    I have a good idea of how to do function splitting in binaryen, so I can do that if we want, but from the design issue I wasn't sure there was much interest? Was there more concern about this from browser vendors recently?

  2. kripken commented on Nov 7, 2017

    @kripken
    Member

    (If we do want to provide a function splitting option, then I think binaryen is the best place to do it, e.g. because of use cases like Go which can generate large functions and not use llvm, so a wasm2wasm splitter would be the most applicable.)

  3. dschuff commented on Nov 7, 2017

    @dschuff
    MemberAuthor

    I wouldn't say there has been any new concern; we discussed it at the in-person CG meeting, although most of the discussion (other than what is already in WebAssembly/design#1138) was about how to avoid the mismatch problem in the future. The plan of record is still to bump the limit up, but it will be a while before the next Edge update. I just have an AI from the meeting to follow up on this (and I had forgotten than you already did the warning in Binaryen), so I just filed this so I wouldn't forget.

  4. kripken commented on Nov 7, 2017

    @kripken
    Member

    Ok. Well, I think function splitting would be a few days of work in binaryen - happy to do that, if we think it makes sense. I wasn't sure based on the discussion I've heard so far, although the Go use case does seem like it raises the importance, but I'm unsure how much. My gut says to do it so we don't get stuck later.

  5. stale commented on Sep 19, 2019

    @stale

    This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 7 days. Feel free to re-open at any time if this issue is still relevant.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions