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

Switch to rquickjs #618

Merged
merged 23 commits into from
May 2, 2024
Merged

Conversation

saulecabrera
Copy link
Member

@saulecabrera saulecabrera commented Mar 19, 2024

Description of the change

Historically, the Javy project has relied on its own QuickJS bindings in order to consume QuickJS' functionality. When the project started, there were very limited options for bindings that could work for our use-case and more importantly, bindings that would compile to wasm32-wasi. That said, bindings under this project are "good enough" for Javy, but they are probably not the most ergonomic for use-cases that require more complex interactions with QuickJS.

The Rust <> QuickJS landscape has changed in the past few years, which means that it's probably a good time to reconsider our initial decisions.

This PR proposes migrating to rquickjs and dropping support for quickjs-wasm-rs and quickjs-wasm-sys. The rquickjs bindings are more ergonomic and enable more natural interactions between Rust and QuickJS' API.

With the adoption of rquickjs, we'd be able to address issues like: #605, #608, #617 and #611.

This change is divided in a series of commits, but it's better reviewed as a whole, given that I didn't put enough thought to make each commit self-contained.

In general, this change doesn't introduce any functional changes, dropping support for quickjs-wasm-rs is the only breaking change introduced by this PR. The only exception is that I fixed a bug in our number deserialization process, in which the implementation was not respecting the MIN_SAFE_INTEGER..=MAX_SAFE_INTEGER range.

This change is already big as-is; I'm planning on creating follow-up PRs for:

  • Updating the documentation under docs
  • Update the READMEs for quickjs-wasm-rs and quickjs-wasm-sys with a deprecation notice.

Checklist

  • I've updated the relevant CHANGELOG files if necessary. Changes to javy-cli and javy-core do not require updating CHANGELOG files.
  • I've updated the relevant crate versions if necessary. Versioning policy for library crates
  • I've updated documentation including crate documentation if necessary.

Migrated the `Console` and `Random` APIs; got to the `StreamIO` API.
@saulecabrera saulecabrera mentioned this pull request Mar 19, 2024
3 tasks
This commit migrates the `console`, `stream_io`, `random` and `text_encoding`  APIs to use rquickjs. 

One notable change in this commit is the introduction of the `Args` struct to tie the lifetime of `Ctx<'js>` and `Rest<Value<'js>>` arguments, given that explicit lifetime binding is not possible in Rust closures at the moment.
@saulecabrera saulecabrera marked this pull request as ready for review April 11, 2024 01:38
@saulecabrera
Copy link
Member Author

Not quite ready for review, but almost. I want to see what CI says.

Copy link
Collaborator

@surma surma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know you didn’t solicit a review and I didn’t really do a full review, but I wanted to take a look where you are at and left 2 comments :3

crates/apis/src/console/mod.rs Outdated Show resolved Hide resolved
crates/javy/src/lib.rs Show resolved Hide resolved
@saulecabrera
Copy link
Member Author

Ok, so all tests are passing here. I'm working on migrating our json/msgpack ser/de and that should be the last step (aside from vetting the new dependencies) to get this in a review-ready state.

@saulecabrera saulecabrera requested review from surma, makrisoft and jeffcharles and removed request for makrisoft April 16, 2024 01:14
I wanted to avoid as much as possible using the underlying QuickJS unsafe APIs, but that introduced behavioral changes and bugs. So for now, I'm sticking to the previous implementation.
This commit introduces rquickjs 0.6.0 through a fork that contains Wasm specific performance improvements. We intend to upstream these improvements.
Adds special policy for rquickjs given that we're currently in a fork.
@saulecabrera saulecabrera merged commit 235b5a6 into bytecodealliance:main May 2, 2024
14 checks passed
@saulecabrera saulecabrera deleted the javy-rquickjs branch May 2, 2024 11:17
@jbourassa jbourassa mentioned this pull request May 3, 2024
3 tasks
saulecabrera added a commit to saulecabrera/javy that referenced this pull request May 6, 2024
This commit is a follow-up to bytecodealliance#618, to formally mark `quckjs-wasm-{sys, rs}` crates as deprecated.

The rollout strategy is to:

* Merge this PR
* Publish the a new version of each of the crates, containing the last unreleased change in each and the deprecation notice.
saulecabrera added a commit that referenced this pull request May 7, 2024
This commit is a follow-up to #618, to formally mark `quckjs-wasm-{sys, rs}` crates as deprecated.

The rollout strategy is to:

* Merge this PR
* Publish the a new version of each of the crates, containing the last unreleased change in each and the deprecation notice.
@redoC-A2k
Copy link

redoC-A2k commented May 18, 2024

Thanks a lot for doing rquickjs switch work .Till when can I expect the new release on github roughly ?

@saulecabrera
Copy link
Member Author

Mid June is my estimate: we're doing more extensive testing and working on other improvements before releasing the next version.

saulecabrera added a commit to saulecabrera/javy that referenced this pull request Aug 13, 2024
This commit removes the following deprecated crates from the tree:

* `quickjs-wasm-sys`
* `quickjs-wasm-rs`
* `javy-apis`

These crates were marked as deprecated as part of the migration to
rquickjs: bytecodealliance#618 and they
have also been removed from our `cargo vet` configuration in
bytecodealliance#715
@saulecabrera saulecabrera mentioned this pull request Aug 13, 2024
3 tasks
saulecabrera added a commit that referenced this pull request Aug 14, 2024
* Remove deprecated crates from tree

This commit removes the following deprecated crates from the tree:

* `quickjs-wasm-sys`
* `quickjs-wasm-rs`
* `javy-apis`

These crates were marked as deprecated as part of the migration to
rquickjs: #618 and they
have also been removed from our `cargo vet` configuration in
#715

* Remove `javy-apis` from cargo vet config
@sandstrom
Copy link
Contributor

I'm trying to figure out which version of QuickJS that the Javy's master branch is using.

Is it 2024-01-13 or 2023-12-09?

https://bellard.org/quickjs/

@saulecabrera
Copy link
Member Author

https://github.com/bellard/quickjs/blob/3b45d155c77bbdfe9177b1e03db830d2aff0b2a8/VERSION -- we currently rely on rquickjs version 0.6.1, which points to the link above, which defines version 2024-02-14

@sandstrom
Copy link
Contributor

Thanks @saulecabrera!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants