-
Notifications
You must be signed in to change notification settings - Fork 903
Don't create activations to track strictness #2197
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
base: master
Are you sure you want to change the base?
Don't create activations to track strictness #2197
Conversation
| private boolean sharedWithActivation(int index) { | ||
| Context cx = Context.getContext(); | ||
| if (cx.isStrictMode()) { | ||
| if (activation.isStrict) { |
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.
Why are you looking at the activation here, and not Context::isStrictMode? I understand that, if we have arguments, we always have an activation, but it feels like we'd like to get rid of the "strict" flag in activations completely given this PR, no?
And I fear this might create problems with the debugger, since we always inject activations when we have the debugger turned on.
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.
And I fear this might create problems with the debugger, since we always inject activations when we have the debugger turned on.
Oh, right. Guess I'd better make a PR from my scratch branch… #2205
Also, if we are interested in whether the function is strict, then the function descriptor carries that information.
| enterAreaStartLabel = -1; | ||
| generatorStateLocal = -1; | ||
| savedHomeObjectLocal = -1; | ||
| parentStrictnessLocal = -1; |
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.
Nit: IMHO this could be a local variable, rather than a field.
| ScriptRuntime.exitActivationFunction(cx); | ||
| } | ||
|
|
||
| if (frame.fnOrScript.getDescriptor().getFunctionType() != 0) { |
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.
Why aren't you exiting for scripts? Imagine (in our ServiceNow codebase) a script include inclusion - we should restore the flag once we are done including it!
| @Test | ||
| public void maxLocals() throws IOException { | ||
| test(339); | ||
| test(338); |
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.
A comment here explaining why you had to lower the number would be nice
This has 2 changes
isTopLevelStrictfromContext. All tests pass, however I'm not a 100% confident on this one would appreciate a careful review.This applies only to functions that have a 'use strict' directive in the body. Functions that are in strict top-levels don't use activations.