Skip to content

Const and loop fixes. - #2500

Open
aardvark179 wants to merge 13 commits into
mozilla:masterfrom
aardvark179:aardvark179-scope-loop-improvements
Open

aardvark179 wants to merge 13 commits into
mozilla:masterfrom
aardvark179:aardvark179-scope-loop-improvements

Conversation

@aardvark179

Copy link
Copy Markdown
Contributor

This is in draft because there are still a couple of legacy kinks I need to work out, and I need to reorder and tidy up the commits, but I almost have something that maintains legacy behaviour and doesn't cause test regressions.

@gbrail

gbrail commented Sep 23, 2026

Copy link
Copy Markdown
Collaborator

Do you think this will fix the problems we have with "threejs" in the other two big PRs you have? If so I'll take a look as soon as it's ready. That one benchmark is a doozy, I'm OK with moving forward but my preference would be to keep it working while we work on other new things.

@aardvark179

Copy link
Copy Markdown
Contributor Author

I've tried stacking up all the changes, and I still see a failure with three JS. As far as I can tell it used to fall back silently to the interpreter because it overflowed the constant pool. Fixing a bug in the constant pool code stopped it over flowing, so now we try to run the compiled class file and it crashes. I've tried chopping down three.js a bit, and that makes it work, and the boundary is suspiciously close to 65K invoke dynamic instructions.

I will see about putting together some to split large class files at compilation time to avoid this.

@gbrail

gbrail commented Sep 24, 2026 via email

Copy link
Copy Markdown
Collaborator

@aardvark179

Copy link
Copy Markdown
Contributor Author

I'm not sure classfile splitting is quite as hard as you think, I think I have enough of a plan to knock up a prototype. Also I might see if I can try reproducing the failure on debug build. It might be quite slow to run the compilation on a debug build, so I'll see if I can provoke the crash with a jack built version.

@aardvark179

Copy link
Copy Markdown
Contributor Author

I have a working class splitter, and can now load three.js as compiled code without issue. I'll try and package that up with the other constant pool fixes and tidy it up a bit (it's a little brute force at the moment).

@aardvark179
aardvark179 force-pushed the aardvark179-scope-loop-improvements branch from a80f7c7 to 19f0e08 Compare September 29, 2026 09:45
@aardvark179
aardvark179 force-pushed the aardvark179-scope-loop-improvements branch from 19f0e08 to 51359cd Compare September 29, 2026 10:23
@aardvark179

Copy link
Copy Markdown
Contributor Author

Okay, this is now in a state where it's at least worth an initial review. The tests around global function declaration that are now failing are doing so because we don't correctly distinguish between the declaration of functions and variables. According to the spec in non-strict mode a script like this function NaN() {} should throw a type error, but NaN = 1.2; should not throw an error (because NaN is a read only non-configurable property on globalThis not a const). Now we do the correct thing for consts we do the wrong thing for functions. For extra fun (function NaN() {} ) should not throw a an error.

I think this is okay for now, because sorting out the horrors of global function declaration is probably a PR in itself.

@aardvark179
aardvark179 force-pushed the aardvark179-scope-loop-improvements branch from 51359cd to a752db6 Compare September 29, 2026 10:49
@aardvark179
aardvark179 marked this pull request as ready for review September 29, 2026 10:50

This branch has not been deployed

No deployments
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.

2 participants