-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
De-Module[]-arize print and printErr (#6756)
This JS change replaces calls to Module['print'] (to print to stdout) and Module['printErr'] (to print to stderr) with calls to out() and err() respectively, which are defined in the main scope directly. This allows the optimizer to dce things more effectively, and shrinks our hello world JS by over 1% (with and without closure). More generally, we have too many things that we use on Module when we don't need to. It makes sense to allow users to define Module['print'] (as how we emit to stdout), and to optionally be where we export that function if the user requested it, but it is silly to constantly looking up Module['print'] everywhere - it increases size and adds overhead. In other words, Module makes sense as an interface to receiving stuff or sending stuff, but not internal work. Also, using Module everywhere makes it harder to do some bigger refactorings for code size that I have some ideas about, so removing this unhelpful complexity is a step in the right direction. There are two possible changes people might see here: * If you change Module['print'] during program execution, we don't notice that. This was never documented as intended to work, but probably worked in most cases. We did have a test or two that depended on this. The docs have been updated to mention this. * If you expect Module['print'] to always exist, it won't unless it is explicitly exported. That is in line with the other exporting changes we've been making. As with those changes, we will show a clear error in an assertions builds in that case, with instructions for how to fix it. Almost all of this patch is autogenerated (using tools/update_js.py). For the main non-autogenerated portion, see src/shell.js. Note that we can't use print(), printErr() as the names since those are used in some shell environments (we use those as stdout and stderr if they are defined, in fact).
- Loading branch information
Showing
113 changed files
with
904 additions
and
832 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.