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

polyfill: don't compile js on each env start #319

Open
krichprollsch opened this issue Dec 3, 2024 · 0 comments
Open

polyfill: don't compile js on each env start #319

krichprollsch opened this issue Dec 3, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@krichprollsch
Copy link
Member

Currently, when we load polyfills, we always compile and run javascript scripts.
It would be better to compile once and run multiple times.

An idea would be:

  1. create a ScriptCompiler::Source [0]

  2. replace the usage of ScriptCompiler::Compile [1] with ScriptCompiler::CompileUnboundScript [2]. Use the created ScriptCompiler::Source.
    ⚠️ The doc is wrong, the func needs a context (see https://chromium.googlesource.com/v8/v8.git/+/refs/heads/main/src/api/api.cc#2582 and https://groups.google.com/u/1/g/v8-users/c/btTLjLN9uZg/m/v6cZ64RKBQAJ

  3. call ScriptCompiler::CreateCodeCache [3] to save a CachedDate.

  4. call UnboundScript::BindToCurrentContext [4] to bind with the current context an retrieve a Script.

  5. run the script [5]

  6. The next start, pass the saved CachedData when creating the ScriptCompiler::Source [0]

  7. repeat the following steps.


lightpanda-io/zig-js-runtime#263 and lightpanda-io/zig-v8-fork#32 expose the UnboundScript functions but CachedData funcs are missing. A question is: how to encapsulate and expose v8 CachedData logic in zig-js-runtime?

@krichprollsch krichprollsch added the enhancement New feature or request label Dec 3, 2024
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

No branches or pull requests

1 participant