Skip to content

gen-host-js: --valid-lifting-optimization#415

Merged
guybedford merged 4 commits intobytecodealliance:mainfrom
guybedford:no-verify
Nov 8, 2022
Merged

gen-host-js: --valid-lifting-optimization#415
guybedford merged 4 commits intobytecodealliance:mainfrom
guybedford:no-verify

Conversation

@guybedford
Copy link
Copy Markdown
Contributor

@guybedford guybedford commented Nov 5, 2022

This adds a new --valid-lifting-optimization flag to the JS generator to disable the runtime checks of the Wasm data structures. The assumption being that when the interfaces have been fully tested, this can be enabled in production for a significant reduction in output JS file size.

We could could possibly treat this as an explicit optimization or production option. Checks of user inputs should still remain though.

I've based this branch to the --tla-compat PR at #414 so it should land after that.

I've also started to unify on the uwriteln! / uwrite! patterns that feel a bit cleaner than the source functions, so am refactoring those as I go, let me know if you agree that these look better or have further suggestions on the refactoring. Would be nice to converge on code style with the formatting.

@alexcrichton
Copy link
Copy Markdown
Member

One area I think it's fine to relax checks on is incoming JS values in the sense that those are embedder-specific and in theory already correct. I believe this PR is also relaxing checks for values coming out of the component itself, though, and I don't believe that's something that we can compromise on. The purpose of wit-bindgen is to be a component runtime polyfill and to implement that correctly many of these checks are required (e.g. variant discriminants all valid)

@guybedford
Copy link
Copy Markdown
Contributor Author

I've rebased this PR and changed the flag name to --valid-component-optimization where these optimizations are based on the assumption that the component being consumed is a safe trusted component binary that is known to produce valid outputs.

@guybedford guybedford changed the title gen-host-js: --no-checks flag gen-host-js: --valid-component-optimization Nov 7, 2022
@guybedford guybedford force-pushed the no-verify branch 2 times, most recently from 99b26be to 448a8a7 Compare November 7, 2022 20:59
@guybedford guybedford changed the title gen-host-js: --valid-component-optimization gen-host-js: --valid-lifting-optimization Nov 7, 2022
@guybedford
Copy link
Copy Markdown
Contributor Author

To be completely clear about when this applies I've updated the flag name to --valid-lifting-optimization and removed all branches which did not apply to this case.

@guybedford guybedford merged commit b0a34f0 into bytecodealliance:main Nov 8, 2022
@guybedford guybedford deleted the no-verify branch November 8, 2022 00:48
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