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

[TheOneric] Enable strict mode in js #46

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

dmitrylyzo
Copy link
Collaborator

Pulling from the upstream.
Original author: TheOneric

libass#143

@dmitrylyzo dmitrylyzo marked this pull request as draft January 9, 2023 22:01
@dmitrylyzo
Copy link
Collaborator Author

dmitrylyzo commented Jan 10, 2023

This doesn't seem to add "use strict;" to workers - null; has been added instead.
Emscripten 3.1.24 adds "use strict;" to the normal worker, but not to the legacy one.

UPD:
Emscripten 3.1.25 adds "use strict;" to both workers. So this the minimum version for the STRICT_JS feature.

@TheOneric
Copy link

Emscripten 3.1.25 adds "use strict;" to both workers. So this the minimum version for the STRICT_JS feature.

STRICT_JS existed since emscripten 1.38.43 (also see introducing commit). So it was supposed to work for much longer, however as you noticed on some versions it didn't, good catch.
It turns out an optimiser pass of emscripten turned "use strict"; int null;, which was fixed with emscripten 3.1.24 (not sure what changed with 3.1.25 or when this bug was first introduced).

TheOneric and others added 5 commits July 23, 2024 16:16
This will make some types of bugs easier to detect
and avoid accidental additions of code not working
inside Modules, which always use strict mode.

Performance measurements show no relevant performance
difference between strict and non-strict mode, so this
won't cause regressions in this regard.

Cherry-picked from: libass@c8f02d6
It turns out an optimizer pass of emscripten turned `"use strict";`
into `null;`, which was fixed with emscripten 3.1.24
EVAL_CTORS now errors when used without WASM,
previosuly it was likely just silently disabled.
Thus, only set it when linking with WASM.

Cherry-picked from: libass@45a05db
There's now a new warning when closure isn't set explicitly
for non-WASM builds. Currently, there are errors concerning
redeclaration of the variable screen with closure enabled,
so explicitly disable it.
For the future, we probably want to remove the redeclaration
and enable closure.

Cherry-picked from: libass@45a05db
`calledMain` global variable was removed from the JS runtime
in emscripten 3.1.17
@dmitrylyzo dmitrylyzo force-pushed the TheOneric/strict_js branch from 5ba02cb to baa99fa Compare July 23, 2024 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants