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

Support ExecJS in Truffle using Graal.js #3614

Merged
merged 4 commits into from
Jan 26, 2016
Merged

Support ExecJS in Truffle using Graal.js #3614

merged 4 commits into from
Jan 26, 2016

Conversation

chrisseaton
Copy link
Contributor

You use it by requiring truffle/execjs after execjs. It uses Graal.js to run high-performance JavaScript, including with inlining between Ruby and JavaScript and back again, escape analysis between the two languages, etc etc. The same technology we used to do C extensions.

You will need trufflejs.jar from the GraalVM (https://github.com/jruby/jruby/wiki/Downloading-GraalVM)

You will need a recent trufflejs.jar.

For example:

require "execjs"
require "truffle/execjs"

source = File.read('test/truffle/integration/execjs/coffeescript.js')
context = ExecJS.compile(source)
puts context.call("CoffeeScript.compile", "square = (x) -> x * x", bare: true)
bin/jruby -X-T bin/gem install execjs -v 2.6.0
JRUBY_OPTS='-J-cp trufflejs.jar' bin/jruby -X+T -Ilib/ruby/gems/shared/gems/execjs-2.6.0/lib test.rb

@chrisseaton chrisseaton added this to the truffle-dev milestone Jan 25, 2016

require "execjs"
require "truffle/execjs"
#require "open-uri"
Copy link
Contributor

Choose a reason for hiding this comment

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

I was confused by this at first. I'd maybe just add a note above indicating you made changes to prevent a test from accessing a public URL.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I actually did it because we fail at inflating the gzipped response the URL gives us :)

@nirvdrum
Copy link
Contributor

This is awesome.

chrisseaton added a commit that referenced this pull request Jan 26, 2016
Support ExecJS in Truffle using Graal.js
@chrisseaton chrisseaton merged commit 25600ba into master Jan 26, 2016
@chrisseaton chrisseaton deleted the truffle-execjs branch January 26, 2016 17:02
@enebo enebo added this to the Non-Release milestone Dec 7, 2017
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.

None yet

3 participants