Skip to content

De-runtime-ification#5954

Merged
kripken merged 22 commits intoincomingfrom
de-runtime-ification
Dec 20, 2017
Merged

De-runtime-ification#5954
kripken merged 22 commits intoincomingfrom
de-runtime-ification

Conversation

@kripken
Copy link
Copy Markdown
Member

@kripken kripken commented Dec 19, 2017

This removes the Runtime object from the generated code. Much of it was not needed at all, the rest is moved into plain JS functions in a new support.js file (which is easier for DCE to remove). This is something @juj suggested we do, and it helps with the goal of shrinking JS - this reduces code from a few % in something like libc++ to 15% in small hello world type things.

The history here is that in the early days I thought we'd have a coherent Runtime object, and it would be used at both compile time and execution time, sharing code between them. But with asm.js and wasm, we've been doing less and less in JS anyhow, so Runtime has made less and less sense. Also it turns out there are just a handful of methods we need both at compile time and execution time, at this point.

Another old idea was that we need to generate the runtime support dynamically, since we supported weird things like QUANTUM=1 (ints and pointers take one memory address location). That's why we had RuntimeGenerator and all that. But again, with asm.js and wasm, we really just support one type of memory, the plain C style. So it's easier to just write out those methods in support.js instead of generating them from a flexible template. This simplification may also help us in the future with more modularization of our runtime code (ES6 modules, etc.).

Breakage-wise, this does affect anyone that used anything on Runtime in a manual way: Runtime.X needs to change to just X. The Runtime object is sort of an internal implementation detail, so hopefully few people ever used it, but still, there's a risk. There are helper messages in assertions mode with some of the more likely candidates, hopefully that will help. Overall, I think this is unavoidable refactoring, and hopefully any inconvenience will be minor.

@juj
Copy link
Copy Markdown
Collaborator

juj commented Dec 20, 2017

This looks great!

@juj
Copy link
Copy Markdown
Collaborator

juj commented Dec 20, 2017

Breakage-wise, this does affect anyone that used anything on Runtime in a manual way: Runtime.X needs to change to just X.

I think if Runtime goes away altogether, people should get a clear exception about Runtime.x since Runtime doesn't exist? So even if there's a breakage involved, the breakage should be clear and we can directly document a mechanical s/Runtime.x/x transformation to users to do to fix, so there's no risk of getting insidious silent failures or things suddenly stopping from working or similar.

@kripken
Copy link
Copy Markdown
Member Author

kripken commented Dec 20, 2017

Thanks!

Yeah, breakage will not be subtle, it will be looking for an object or function that no longer exists, and throw. Good idea to document the necessary s/Runtime.*/* fix directly, I'll add it to the Changelog.

I'll merge this later today if no one else has any concerns. I'll tag a new minor version before, so it's in a different version than the last breaking change (NO_EXIT_RUNTIME).

@kripken kripken merged commit c5a4558 into incoming Dec 20, 2017
@kripken kripken deleted the de-runtime-ification branch December 20, 2017 23:36
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