-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Conversation
… check everywhere, and console.log is guaranteed pretty everywhere now
// Callbacks | ||
Module['preRun'] = []; | ||
Module['postRun'] = []; | ||
|
||
// Merge back in the overrides | ||
for (key in moduleOverrides) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
,
src/shell.js
Outdated
Module['printErr'] = console.warn || console.log; | ||
} else { | ||
Module['print'] = Module['printErr'] = function(){}; | ||
#if LEGACY_VM_SUPPORT |
There was a problem hiding this comment.
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
?)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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:
-
SpiderMonkey documented
console.log
for SpiderMonkey 53, (which was released on 2017-04-19): https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/Shell_global_objects$compare?locale=en-US&to=1151230&from=1004343 -
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?)
-
From https://stackoverflow.com/questions/34914397/why-doesnt-console-log-work-in-the-jsc-environment-but-it-works-in-safaris-deb/34914888 and https://stackoverflow.com/questions/19649932/javascriptcore-console-log?noredirect=1&lq=1, it looks like
jsc
did not have console.log at least in May 2017.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
Does jsc have console.log? |
@jfbastien, does the jsc shell have console.log and console.warn? |
In my build it looks like the answer is no. |
We have |
Ok, thanks, I restored print/printErr support for jsc. Also added a few more minor cleanups in that file. |
Any concerns here? |
LEGACY_VM_SUPPORT
to use older methods for really old shells).moduleOverrides
).