Boa has reached a new release. v0.11, our biggest one yet!
Since v0.10 we've closed 77 issues and merged 129 pull requests. The engine has been faster and more compliant to the spec. Below are some of the highlights but please see the changelog for more information.
What is Boa? See the About page for more info.
Test262 is the implementation conformance test suite maintained by TC39. It's used by nearly all engines to measure how conformant they are to the specification. Boa pulls the tests in-tree and runs them against all PRs. You can find more about Test262 here.
Since v0.10 we have almost doubled on spec conformance, and reduced panics. A year ago Boa didn't even track itself against Test262 so it was difficult to know how compliant we were to the spec, today not only do we track all changes against Test262 but we can see progress on a PR to PR basis.
Previously many tests failed to run as the test-runner was still being worked on. Those issues have been fixed and our tests jumped from 38k to 78K which is why the graph flips up above. Boa should never panic, however we've had many tests reveal areas where panics happen, this has helped us identify and apply correct fixes, to the point where our panics have gone from hundreds to under 50 (the graph above shows the dark red diminishing).
For live tracking of conformance tests you can check here. Below is a snapshot of the previous version and today.
- Total tests: 38,706
- Passed tests: 6,960
- Ignored tests: 5,748
- Failed tests: 25,998
- Conformance: 17.98%
- Total tests: 78,497
- Passed tests: 24,550
- Ignored tests: 15,585
- Failed tests: 38,362 (24 ⚠)
- Conformance: 31.28%
In this release Boa switched from its own implementation (wrapping
regex) to the
regress engine for regular expressions. Regress is a crate aiming to implement ECMAScript compliant regular expressions and Boa makes use of (and contributes back to) that.
While Regress is not 100% spec compliant this is something which is being worked on, also the switch gave us quite a performance boost in our benchmarks we're seeing almost 6X faster execution.
The above image shows a big drop in the middle of the graph, above
fb1b8d5 is where we switched over. Conformance went from 19.01% to 18.99% and introduced some panics, however many of those have since been fixed.
Iterating over bytes
Previously the lexer iterated over unicode chars (u32 code points), this wasn't strictly neccesary for Boa and we have instead changed the lexer to work over bytes (u8). Iterating over bytes rather than chars is inherently much faster, non-ascii UTF8 bytes are all >=128, and we might only really care about those being correct when parsing idents. This is standard practise amongs lexical analyzers and even browsers read source code byte-by-byte, using the rules of the language's syntax to convert the source text into tokens.
This was worked on by @jevancc and his changes have improved performance overall.
We are still working on what the public API should look like, some of these decisions are driven by feedback and the ever-changing way which Boa works.
Below are some of the more recent functions available from the Context object for you to add your own functionality.
// Rust implementation of a function injected into the environment Context::register_global_function(), // Rust implementation of a class injected into the environment Context::register_global_class(), // Rust implementation of a property injected into the environment Context::register_global_property()
If there are any examples you would like added, please raise an issue on the main repository.
Today Boa walks the tree of the AST, although easy to implement it's not ideal for performance.
We are looking to do code generation which can then be interpreted. This gradual process may happen over many releases until at some point we can switch implementations under the hood. Our steps are:
Experiment with VM Path on isolated branch Experiment with generating more simpler instructions
- Build up parity with current implementation
- Run test suite over VM path including conformance tests
- Switch over once performance is steady
- Optimize code generation and intreperter
Everything in this release has been such a huge effort, we want to thank all the contributors in this release, whether it was features, fixes or raising bugs.