Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shell.js environment cleanup #5990

Merged
merged 5 commits into from
Jan 17, 2018
Merged

shell.js environment cleanup #5990

merged 5 commits into from
Jan 17, 2018

Conversation

kripken
Copy link
Member

@kripken kripken commented Dec 26, 2017

  • Use console.log, it is present in all modern environments (use LEGACY_VM_SUPPORT to use older methods for really old shells).
  • No need to check if a property exists on Module already, we handle that in a general way, user-provided things will not be overridden (see moduleOverrides).

// Callbacks
Module['preRun'] = [];
Module['postRun'] = [];

// Merge back in the overrides
for (key in moduleOverrides) {
Copy link
Contributor

Choose a reason for hiding this comment

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

While you are at it, can you add a var here?

Copy link
Member Author

Choose a reason for hiding this comment

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

There's already a var key; in the top scope, before the first loop on key in moduleOverrides,

https://github.com/kripken/emscripten/blob/2c5e89c662621e68d2cf4f3a7e237ad3a1c6b358/src/shell.js#L34

src/shell.js Outdated
Module['printErr'] = console.warn || console.log;
} else {
Module['print'] = Module['printErr'] = function(){};
#if LEGACY_VM_SUPPORT
Copy link
Collaborator

Choose a reason for hiding this comment

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

LEGACY_VM_SUPPORT is a bit vague - what is considered a legacy VM, and what does it enable? Can we directly name the feature something like SUPPORT_OLD_SPIDERMONKEY_CONSOLE_PRINT or similar? (I presume this is for old SpiderMonkey that did not have console.log but had print?)

Copy link
Member Author

Choose a reason for hiding this comment

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

Not just spidermonkey, d8 also had print and printErr early on, and I think webkit had print but not printErr (but less sure about that, I tested less on it).

Honestly I think we can just drop this section, but I figured since LEGACY_VM_SUPPORT already exists, why not let it cover this as well? Basically anyone using a non up-to-date VM can use that and get backwards compatibility, but most people don't need to think about it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh now I see indeed we have a LEGACY_VM_SUPPORT feature already, missed that it already existed. I feel that's not the kind of way we'd want to feature test for compatibility features, since it's either "all legacy" or "no legacy", without documenting what the actual legacy feature(s) are and which versions of software need which legacy features. I think we'd rather remove LEGACY_VM_SUPPORT and replace it with feature-specific or client-specific #ifdefs (whichever is easier?) Something like that was the idea with #5554. Perhaps we could have #ifdef SUPPORT_JS_VM_CONSOLE_PRINT and #ifdef POLYFILL_PRIMITIVE_MATH_OPS or similar, so that we would not put multiple features behind the same flag, but have one define per feature? Then the name will illustrate what the actual features are.

For related reference:

Copy link
Member Author

Choose a reason for hiding this comment

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

On the one hand, I agree that for commonly useful features we should have specific flags. But I see legacy support as different, it's rarely used, and it's code we are very close to just removing entirely.

For those reasons, a single flag for all legacy stuff seems ok to me. But if I'm in the minority here I don't feel strongly.

Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like d8 does not yet have console.log, from https://bugs.chromium.org/p/v8/issues/detail?id=4986 . (or could be that bug report is out of date?)

The bug is out-dated. d8 does have console.log, along with other console methods. See https://cs.chromium.org/chromium/src/v8/src/d8-console.cc?l=59

@dschuff
Copy link
Member

dschuff commented Jan 4, 2018

Does jsc have console.log?

@kripken
Copy link
Member Author

kripken commented Jan 12, 2018

@jfbastien, does the jsc shell have console.log and console.warn?

@dschuff
Copy link
Member

dschuff commented Jan 12, 2018

In my build it looks like the answer is no.

@jfbastien
Copy link
Contributor

We have print and printErr.

@kripken
Copy link
Member Author

kripken commented Jan 12, 2018

Ok, thanks, I restored print/printErr support for jsc. Also added a few more minor cleanups in that file.

@kripken
Copy link
Member Author

kripken commented Jan 17, 2018

Any concerns here?

@kripken kripken merged commit b29b9a8 into incoming Jan 17, 2018
@kripken kripken deleted the shell branch January 17, 2018 21:16
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.

None yet

5 participants