Readit News logoReadit News
canadahonk commented on Porffor: A from-scratch experimental ahead-of-time JS engine   porffor.dev/... · Posted by u/bpierre
frutiger · 2 years ago
Not sure where you mean by synchronously but if you mean what I think you mean then that is not correct behaviour. This is important to ensure predicatibility.

Eg.

    Promise.then(() => console.log(“a”));
    console.log(“b”)
must log [“b”, “a”] and not [“a”, “b”].

canadahonk · 2 years ago
This type of test does work as expected. The "sync" means that it does not feature a full event loop (yet) so cannot easily support async I/O or some more "advanced" use cases.
canadahonk commented on Porffor: A from-scratch experimental ahead-of-time JS engine   porffor.dev/... · Posted by u/bpierre
chillfox · 2 years ago
There are already projects that does JS-to-WASM by bundling a JS interpreter. So, it's likely to make the difference to those clearer.
canadahonk · 2 years ago
Yep! Also as it is technically more of an engine/runtime (sometimes) than "just" a compiler, folks in the JS space are more familiar with engine as a term :)
canadahonk commented on Porffor: A from-scratch experimental ahead-of-time JS engine   porffor.dev/... · Posted by u/bpierre
derdi · 2 years ago
Presumably the idea is that any work that causes Test262 regressions is temporary, takes place in a separate branch, and is only merged to main once the branch also contains all the necessary fixes to make the regressions go away again. A new version number would only be used once that merge happens.
canadahonk · 2 years ago
Exactly. The versioning system is definitely unique and controversial, but I think it fits for a fast moving project like this, so I don't have to really consider versioning which could slow development. When it becomes more stable, I'll likely move to a more traditional semver scheme from 1.0.
canadahonk commented on Porffor: A from-scratch experimental ahead-of-time JS engine   porffor.dev/... · Posted by u/bpierre
rubenfiszel · 2 years ago
At windmill.dev, when users deploy their code, we use Bun build (which is similar to esbuild) to bundle their scripts and all their dependencies into a single js file to load which improve cold start and memory usage. We store the bundle on s3 because of the size of the bundles.

If we could bundle everything to native that would completely change the game since as good as bun's cold start is, you can't beat running straight native with a small binary.

canadahonk · 2 years ago
Hey, dev here, I agree that is an interesting application which Porffor could potentially help with! Happy to chat sometime :)
canadahonk commented on Porffor: A from-scratch experimental ahead-of-time JS engine   porffor.dev/... · Posted by u/bpierre
syrusakbary · 2 years ago
It's awesome to see how more JS runtimes try to approach Wasm. This project reminds me to Static Hermes (the JS engine from Facebook to improve the speed of React Native projects on iOS and Android).

I've spent a bit of time trying to review each, so hopefully this analysis will be useful for some readers. What are the main commonalities and differences between Static Hermes and Porffor?

  * They both aim for JS test262 conformance [1]
  * Porffor supports both Native and Wasm outputs while Static Hermes is mainly focused on Native outputs for now
  * Porffor is self-hosted (Porffor is written in pure JS and can compile itself), while Static Hermes relies on LLVM
  * Porffor currently doesn't support async/promise/await while Static Hermes does (with some limitations)
  * Static Hermes is written in C++ while Porffor is mainly JS
  * They both support TypeScript (although Static Hermes does it through transpiling the TS AST to Flow, while Porffor supports it natively)
  * Static Hermes has a fallback interpreter (to support `eval` and other hard-to-compile JS scenarios), while Porffor only supports AOT compiling (although, as I commented in other thread here, it maybe be possible to support `eval` in Porffor as well)
In general, I'm excited to see if this project can gain some traction so we can speed-up Javascript engines one the Edge! Context: I'm Syrus, from Wasmer [3]

[1] https://github.com/facebook/hermes/discussions/1137

[2] https://github.com/tc39/test262

[3] https://wasmer.io

canadahonk · 2 years ago
Good comparison and thanks! A few minor clarifications: - Porffor isn't fully self-hosted yet but should be possible hopefully! It does partially compile itself for builtins (eg Array.prototype.filter, Math.sin, atob, ...) though. - As of late, Porffor does now support basic async/promise/await! Not very well yet though.
canadahonk commented on Porffor: A from-scratch experimental ahead-of-time JS engine   porffor.dev/... · Posted by u/bpierre
saagarjha · 2 years ago
What happens when someone calls eval?
canadahonk · 2 years ago
For now, unless it is given a literal string (eg `eval('42')`) eval just won't work.
canadahonk commented on Using TS type annotations for JavaScript engine optimization   goose.icu/porffor-types/... · Posted by u/canadahonk
rezonant · 2 years ago
> But since we are compiling AOT and not JIT, we cannot de-opt/undo that guess if it becomes wrong - instead we would just crash. > > But we could define the type using type annotations (TS)! > > Now we have to do 0 checks of the type of a, since we already know it at compile-time. This can allow for some big speedups :)

This comes with a big caveat that if the type assertion is wrong at runtime that the AOT'ed app will crash. Also I get the sense that the author assumes type "string" always means non-null and non-undefined but this is only true if the strictNullChecks compiler option is enabled.

Nonetheless, cool to see folks experimenting in the JS engine arena, especially around AOT!

canadahonk · 2 years ago
Agreed, I have it behind a flag because of this, in the (far) future I could enable by default if I write a type checker built-in or something. Thank you!
canadahonk commented on Using TS type annotations for JavaScript engine optimization   goose.icu/porffor-types/... · Posted by u/canadahonk
h4ch1 · 2 years ago
Just a hitch found on https://porffor.goose.icu/

On running the example 'Array Reading' with an optimization level of 3 I get the following error

CompileError: WebAssembly.instantiate(): Compiling function #2 failed: local.set[0] expected type f64, found global.get of type i32 @+207

Is this expected?

canadahonk · 2 years ago
Unfortunately yes, optimizer at high levels is very unstable/aggressive at the moment. Currently working on refactoring things for perf generally instead of just an optimizer, but definitely will fix in the future!

u/canadahonk

KarmaCake day40October 27, 2023View Original