Skip to content

Conversation

@balajirrao
Copy link
Contributor

@balajirrao balajirrao commented Dec 4, 2025

This has 2 changes

  • Remove the use of activations to keep track of strictness
  • Remove isTopLevelStrict from Context. 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.

private boolean sharedWithActivation(int index) {
Context cx = Context.getContext();
if (cx.isStrictMode()) {
if (activation.isStrict) {
Copy link
Contributor

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.

Copy link
Contributor

@aardvark179 aardvark179 Dec 9, 2025

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;
Copy link
Contributor

@andreabergia andreabergia Dec 9, 2025

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) {
Copy link
Contributor

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);
Copy link
Contributor

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

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.

4 participants