Skip to content

no_special_abortOnCannotGrowMemory#7911

Merged
juj merged 1 commit intoemscripten-core:incomingfrom
juj:no_special_abortOnCannotGrowMemory
Jan 23, 2019
Merged

no_special_abortOnCannotGrowMemory#7911
juj merged 1 commit intoemscripten-core:incomingfrom
juj:no_special_abortOnCannotGrowMemory

Conversation

@juj
Copy link
Collaborator

@juj juj commented Jan 22, 2019

Remove special handling of function abortOnCannotGrowMemory() but make it a regular JS library function.

@juj juj added the code size label Jan 22, 2019
Copy link
Member

@kripken kripken left a comment

Choose a reason for hiding this comment

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

Nice!

Looks like some tests need updating. lgtm if that's just trivial stuff.

@juj juj force-pushed the no_special_abortOnCannotGrowMemory branch from d9ab0fb to 0734f6b Compare January 23, 2019 13:30
@juj juj force-pushed the no_special_abortOnCannotGrowMemory branch from 0734f6b to e07ec77 Compare January 23, 2019 15:01
@juj juj merged commit be3ad43 into emscripten-core:incoming Jan 23, 2019
@PiotrSikora
Copy link

Note: this changed the signature of abortOnCannotGrowMemory from:

(import "env" "abortOnCannotGrowMemory" (func $abortOnCannotGrowMemory (result i32)))

to:

(import "env" "abortOnCannotGrowMemory" (func $abortOnCannotGrowMemory (param i32) (result i32)))

which is a bit problematic for non-JavaScript host runtimes that verify import/export signatures.

@juj
Copy link
Collaborator Author

juj commented Feb 5, 2019

What causes a problem with the change? The signature did change, but unless I did a mistake, all call sites to the function were updated, so call sites + declaration should match?

@PiotrSikora
Copy link

Non-JavaScript host runtimes have to re-implement exported Emscripten functions, e.g.:

since they cannot import generated JavaScript.

But because the signature changed, WASM modules compiled using Emscripten 1.38.26 are trying to import function with a signature that doesn't match the signature in those runtimes.

While I understand that this is not exactly your problem, it would be great if Emscripten wasn't introducing breaking changes that are hard to detect and/or recover from, i.e. adding and/or renaming functions is perfectly fine and easy to support (e.g. WAVM/WAVM@69d647e), but changing signatures is a bit more problematic.

@juj
Copy link
Collaborator Author

juj commented Feb 5, 2019

Thanks, did not know there was this kind of external use going on. Freezing the signatures of JS functions imported to JS is unfortunately not something that we could make a guarantee about, but I'll keep this use case in mind and go the renaming route whenever possible.

@PiotrSikora
Copy link

Yeah, I didn't mean freezing / providing stable ABI, but keeping in mind the other implementations. Thanks!

@kripken
Copy link
Member

kripken commented Feb 6, 2019

We have an ABI version, added by @rianhunter - I don't think we need to rename things (but we can if there's no reason not to), but we do need to update that metadata version, so that other embedders are not surprised.

@juj, please open a PR with an update to EMSCRIPTEN_METADATA_MINOR in tools/shared.py.

@PiotrSikora - sorry for missing this earlier!

@rianhunter
Copy link
Contributor

rianhunter commented Feb 6, 2019

EMSCRIPTEN_ABI_MINOR / EMSCRIPTEN_ABI_MAJOR specify the minimum version of the ABI the WASM binary requires. Since you changed the signature of abortOnCannotGrowMemory, you'd ordinarily bump EMSCRIPTEN_ABI_MAJOR since newer WASM binaries would not be compatible with older versions of the runtime. Preferably in the future, it would be better to change the function name, like abortOnCannotGrowMemoryV2 so you only need to bump EMSCRIPTEN_ABI_MINOR, and the 3rd party runtime would only need to provide a new function to maintain compatibility with both newer and older WASM binaries.

Since EMSCRIPTEN_ABI_MAJOR is currently zero, it's fine to making breaking ABI changes and only increment EMSCRIPTEN_ABI_MINOR since nothing is stable, but this habit should be tempered.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants