The Wayback Machine - https://web.archive.org/web/20200908100256/https://github.com/scala-js/scala-js/issues/1593/
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

Analyze for elidable LoadModules in JS desugaring #1593

Open
colinrgodsey opened this issue Apr 13, 2015 · 5 comments
Open

Analyze for elidable LoadModules in JS desugaring #1593

colinrgodsey opened this issue Apr 13, 2015 · 5 comments
Labels

Comments

@colinrgodsey
Copy link

@colinrgodsey colinrgodsey commented Apr 13, 2015

Branching from discussion in #1588

WIP - master...colinrgodsey:wip-loadmodule-2

Intent

Alter the behavior of JSDesugring to omit unnecessary module load calls in emitted js.

Goals

  • Elidable module inits in desugared JS trees based on guarantee of construction
  • Elidable inits for modules that have no potential constructor side-effects
  • Faster and more dense JS!

Actions

  1. Add initializedModules set to JSDesugar#Env
  2. Update initializedModules(m) via env for the following trees:
    • Block(...[0], LoadModule(m), ...[1], last)
    • Block(...[0], Apply(LoadModule(m), ...[1]), ...[1], last)
    • More to come....
  3. Update genLoadModule with hasInitialized boolean arg. This will refer to either the constructor function or the static reference accordingly. This value should come from Env#initializedModules when possible.
  4. Update desugaring to omit side-effect only module inits if initializedModules(m)
  5. Analyse LinkedClass for static init expressions (LinkedClass#isPure).
  6. Modify module definition to run its init during 'link-time' for pure modules.
  7. Modify desugaring to pre-populate initializedModules with the types for pure modules.
@colinrgodsey
Copy link
Author

@colinrgodsey colinrgodsey commented Apr 15, 2015

@sjrd Is there any good testkit project that will allow me to test both the scjsir compiler and the JS emitters in tools.javascript together? I'm having issues finding a test project that has access to both classpaths

@sjrd
Copy link
Member

@sjrd sjrd commented Apr 15, 2015

The tools are part of the Build itself. Just reload and run the testSuite/test. That will make all the tests you want.

@gzm0
Copy link
Contributor

@gzm0 gzm0 commented Apr 15, 2015

@colinrgodsey We currently do not have unit tests for the tools. You could start adding unit tests in tools/jvm/src/test. (There is currently no test framework we could use that cross compiles JS / JVM)

If you feel fancy you can also write a little shim for JUnit and Jasmine so that you can run the tools unit tests in both environments...

@colinrgodsey
Copy link
Author

@colinrgodsey colinrgodsey commented Apr 16, 2015

@gzm0 cool, just wanted to make sure i wasnt missing any components. I m probably going to see if i can make something similar to the JSASTTest, as I'm mostly going to be fiddling with the desugaring and want to verify the javascript.Trees

@colinrgodsey
Copy link
Author

@colinrgodsey colinrgodsey commented May 28, 2015

note- I have a PR done, just need to clean it up before i submit it

@sjrd sjrd added optimization and removed enhancement labels Feb 16, 2016
@sjrd sjrd added this to the Post-v1.0.0 milestone Oct 11, 2017
@gzm0 gzm0 removed this from the Post-v1.0.0 milestone Apr 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.