All Projects → binast → Binjs Ref

binast / Binjs Ref

Licence: other
Reference implementation for the JavaScript Binary AST format

Programming Languages

javascript
184084 projects - #8 most used programming language
rust
11053 projects
ecmascript
72 projects

Projects that are alternatives of or similar to Binjs Ref

Escaya
An blazing fast 100% spec compliant, incremental javascript parser written in Typescript
Stars: ✭ 217 (-45.61%)
Mutual labels:  parsing, performance
Bssom.net
A small, high performance, powerful serializer using bssom binary protocol
Stars: ✭ 117 (-70.68%)
Mutual labels:  binary, performance
Fastbinaryencoding
Fast Binary Encoding is ultra fast and universal serialization solution for C++, C#, Go, Java, JavaScript, Kotlin, Python, Ruby, Swift
Stars: ✭ 421 (+5.51%)
Mutual labels:  binary, performance
Buntis
A 100% compliant, self-hosted typescript parser that emits an ESTree-compatible AST
Stars: ✭ 90 (-77.44%)
Mutual labels:  parsing, performance
Formatfuzzer
FormatFuzzer is a framework for high-efficiency, high-quality generation and parsing of binary inputs.
Stars: ✭ 117 (-70.68%)
Mutual labels:  parsing, binary
Corrode
A batteries-included library for reading binary data.
Stars: ✭ 116 (-70.93%)
Mutual labels:  parsing, binary
Meriyah
A 100% compliant, self-hosted javascript parser - https://meriyah.github.io/meriyah
Stars: ✭ 690 (+72.93%)
Mutual labels:  parsing, performance
Cherow
Very fast and lightweight, standards-compliant, self-hosted javascript parser with high focus on both performance and stability
Stars: ✭ 1,539 (+285.71%)
Mutual labels:  parsing, performance
structures
Declarative binary data builder and parser: simple, fast, extensible
Stars: ✭ 29 (-92.73%)
Mutual labels:  parsing, binary
Sharp
High performance Node.js image processing, the fastest module to resize JPEG, PNG, WebP, AVIF and TIFF images. Uses the libvips library.
Stars: ✭ 21,131 (+5195.99%)
Mutual labels:  performance
Json.h
🗄️ single header json parser for C and C++
Stars: ✭ 387 (-3.01%)
Mutual labels:  parsing
Awesome Wp Speed Up
Plugins and resources to speed up and optimize your WordPress site.
Stars: ✭ 375 (-6.02%)
Mutual labels:  performance
Nlpnet
A neural network architecture for NLP tasks, using cython for fast performance. Currently, it can perform POS tagging, SRL and dependency parsing.
Stars: ✭ 379 (-5.01%)
Mutual labels:  parsing
Laravel Model Cleanup
Clean up unneeded records
Stars: ✭ 388 (-2.76%)
Mutual labels:  performance
Ava
Node.js test runner that lets you develop with confidence 🚀
Stars: ✭ 19,458 (+4776.69%)
Mutual labels:  performance
Guider
Performance Analyzer
Stars: ✭ 393 (-1.5%)
Mutual labels:  performance
Ceras
Universal binary serializer for a wide variety of scenarios https://discord.gg/FGaCX4c
Stars: ✭ 374 (-6.27%)
Mutual labels:  binary
See Phit
A C++ HTML template engine that uses compile time HTML parsing
Stars: ✭ 370 (-7.27%)
Mutual labels:  parsing
Csv
CSV Decoding and Encoding for Elixir
Stars: ✭ 398 (-0.25%)
Mutual labels:  parsing
0day Security Software Vulnerability Analysis Technology
0day安全_软件漏洞分析技术
Stars: ✭ 393 (-1.5%)
Mutual labels:  binary

Travis Status

About the JavaScript Binary AST

As websites become more sophisticated, the amount of JavaScript source code keeps increasing. While depending upon a large JavaScript codebase won't prevent a website from working, it will cause websites to start slowly – often unacceptably slow. This is due to two bottlenecks: parsing and bytecode compiling JavaScript. Unfortunately, browsers have pretty much reached efficiency peak for both operations.

We (Mozilla, Bloomberg, Facebook, CloudFlare) are currently working on a domain-specific encoding for JavaScript, called "BinAST" (short for "JavaScript Binary AST"). The JavaScript Binary AST is designed to break the bottleneck. Current advanced prototypes already show JS parsing improvements of 30%-50% on all the most common frameworks, just by changing the format, and we believe that we can increase this improvement much further. The encoding can be built as part of a webdev toolchain, or injected by a proxy or CDN, hence automatically improving the performance of end users without change to the original website.

This encoding is currently in the JavaScript TC39 standardization process [3]. It can be used alongside existing compression techniques (gzip, brotli, etc.)

Testing it

  1. Install dependencies (you will need npm, rustup)
npm install
rustup install nightly
rustup default nightly
  1. Pull the code.
git clone https://github.com/binast/binjs-ref
  1. Compress/decompress.
cargo run --bin binjs_encode -- --help
cargo run --bin binjs_decode -- --help

Note The JS parser may choke on very large JS source files. If so, you'll need to set the environment variable NODE_MAX_OLD_SPACE_SIZE=xxxx. This will instruct the Node-based parser to allocate more memory. The default value is 2048 (Mb). This is equivalent to passing --max_old_space_size to the Node process.

  1. Dump tree structure.
cargo run --bin binjs_dump -- --help

Note binjs_dump supports only multipart format.

Compatibility with JavaScript source code

Preserved:

  • semantics of well-formed programs;
  • variable and function names.

Not preserved:

  • actual semantics of syntax errors;
  • source code positions;
  • formatting (including whitespaces and semicolumns);
  • comments (including source maps).

Expected benefits

The Binary AST format is designed to be generally faster to parse than JS source, thanks to a syntax that requires no backtracking, strings that do not need interning more than once, etc.

The Binary AST format is designed so that the VM can start parsing the file as soon as the first few bytes are received (streaming parsing) and can start compiling the file to bytecode soon after that (streaming bytecode compilation).

Furthermore, parsing a JS source is specified for a specific encoding, which means that many encodings need to be transcoded before they can be parsed (or, at best, while parsing), which slows down parsing. As BinAST is a binary format, it does not need any form of transcoding.

Finally, most modern JavaScript VMs support a form of lazy parsing, which performs faster parsing without most memory allocations. The BinAST format is designed to make lazy parsing more efficient, if required, by letting parsers jump over (functions) in a single operation.

Specifications

  • The semantics are specified here.
  • The binary format is specified here.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].