mini_racer 0.4.0 → 0.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +72 -28
- data/.gitignore +1 -0
- data/CHANGELOG +40 -0
- data/README.md +32 -17
- data/Rakefile +16 -4
- data/ext/mini_racer_extension/extconf.rb +34 -13
- data/ext/mini_racer_extension/mini_racer_extension.cc +404 -221
- data/ext/mini_racer_loader/extconf.rb +6 -1
- data/lib/mini_racer/truffleruby.rb +353 -0
- data/lib/mini_racer/version.rb +2 -2
- data/lib/mini_racer.rb +34 -23
- data/mini_racer.gemspec +1 -3
- metadata +11 -11
- data/.travis.yml +0 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4290b52d3d19c196567892c0d3eda0b47f07047afe059e63d4ac976258cb52a0
|
4
|
+
data.tar.gz: 55e41b4e8ab93cdfe45446ff08a5b3c42323356e36b79d91f2e564c43a7715fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c0e0cca11803ffa6ba38998810ccb82413257145947a637f3800252f4a0d47bd47fde425786c09f1eedf6c28b1bb584d34914b111effffef908ff182e79c5329
|
7
|
+
data.tar.gz: 05dbfe34c140fedf6fbd33f5eee62f6cc6880579d238039f2e351a0279fa9267575b46ae7890f9c7d19ebd43bf1020e9bb57d445ad4e6ac8f89440ac3e2744d3
|
data/.github/workflows/ci.yml
CHANGED
@@ -1,50 +1,92 @@
|
|
1
|
-
name:
|
1
|
+
name: Tests
|
2
|
+
|
2
3
|
on:
|
3
|
-
|
4
|
+
pull_request:
|
5
|
+
push:
|
6
|
+
branches:
|
7
|
+
- master
|
4
8
|
|
5
9
|
jobs:
|
10
|
+
test-truffleruby:
|
11
|
+
strategy:
|
12
|
+
fail-fast: false
|
13
|
+
matrix:
|
14
|
+
os:
|
15
|
+
- "macos-11"
|
16
|
+
- "macos-12"
|
17
|
+
- "ubuntu-20.04"
|
18
|
+
ruby:
|
19
|
+
- "truffleruby+graalvm-head"
|
20
|
+
|
21
|
+
name: ${{ matrix.os }} - ${{ matrix.ruby }}
|
22
|
+
runs-on: ${{ matrix.os }}
|
23
|
+
|
24
|
+
env:
|
25
|
+
TRUFFLERUBYOPT: "--jvm --polyglot"
|
26
|
+
|
27
|
+
steps:
|
28
|
+
- uses: actions/checkout@v3
|
29
|
+
- uses: ruby/setup-ruby@v1
|
30
|
+
with:
|
31
|
+
ruby-version: ${{ matrix.ruby }}
|
32
|
+
bundler-cache: true
|
33
|
+
- name: Install GraalVM JS component
|
34
|
+
run: gu install js
|
35
|
+
- name: Compile
|
36
|
+
run: bundle exec rake compile
|
37
|
+
- name: Test
|
38
|
+
run: bundle exec rake test
|
39
|
+
|
6
40
|
test-darwin:
|
7
41
|
strategy:
|
8
42
|
fail-fast: false
|
9
43
|
matrix:
|
10
44
|
os:
|
11
|
-
-
|
12
|
-
-
|
13
|
-
|
14
|
-
-
|
15
|
-
|
16
|
-
|
17
|
-
|
45
|
+
- "macos-11"
|
46
|
+
- "macos-12"
|
47
|
+
ruby:
|
48
|
+
- "ruby-2.6"
|
49
|
+
- "ruby-2.7"
|
50
|
+
- "ruby-3.0"
|
51
|
+
- "ruby-3.1"
|
52
|
+
|
53
|
+
name: ${{ matrix.os }} - ${{ matrix.ruby }}
|
54
|
+
runs-on: ${{ matrix.os }}
|
55
|
+
|
18
56
|
steps:
|
19
|
-
-
|
20
|
-
|
21
|
-
|
22
|
-
|
57
|
+
- uses: actions/checkout@v3
|
58
|
+
- uses: ruby/setup-ruby@v1
|
59
|
+
with:
|
60
|
+
ruby-version: ${{ matrix.ruby }}
|
61
|
+
bundler-cache: true
|
23
62
|
- name: Compile
|
24
63
|
run: bundle exec rake compile
|
25
64
|
- name: Test
|
26
65
|
run: bundle exec rake test
|
66
|
+
|
27
67
|
test-linux:
|
28
68
|
strategy:
|
29
69
|
fail-fast: false
|
30
70
|
matrix:
|
31
71
|
ruby:
|
32
|
-
-
|
33
|
-
-
|
34
|
-
-
|
35
|
-
-
|
36
|
-
- '3.0'
|
72
|
+
- "2.6"
|
73
|
+
- "2.7"
|
74
|
+
- "3.0"
|
75
|
+
- "3.1"
|
37
76
|
platform:
|
38
|
-
- amd64
|
39
|
-
- arm64
|
40
|
-
# arm
|
41
|
-
# ppc64le
|
42
|
-
# s390x
|
77
|
+
- "amd64"
|
78
|
+
- "arm64"
|
43
79
|
libc:
|
44
|
-
- gnu
|
45
|
-
- musl
|
46
|
-
|
80
|
+
- "gnu"
|
81
|
+
- "musl"
|
82
|
+
exclude:
|
83
|
+
# there's no libv8-node (v16) for aarch64-linux-musl at the moment
|
84
|
+
- platform: "arm64"
|
85
|
+
libc: "musl"
|
86
|
+
|
87
|
+
name: linux-${{ matrix.platform }} - ruby-${{ matrix.ruby }} - ${{ matrix.libc }}
|
47
88
|
runs-on: ubuntu-20.04
|
89
|
+
|
48
90
|
steps:
|
49
91
|
- name: Enable ${{ matrix.platform }} platform
|
50
92
|
id: qemu
|
@@ -69,9 +111,11 @@ jobs:
|
|
69
111
|
echo "::set-output name=id::$(cat container_id)"
|
70
112
|
- name: Install Alpine system dependencies
|
71
113
|
if: ${{ matrix.libc == 'musl' }}
|
72
|
-
run: docker exec -w "${PWD}" ${{ steps.container.outputs.id }} apk add --no-cache build-base
|
114
|
+
run: docker exec -w "${PWD}" ${{ steps.container.outputs.id }} apk add --no-cache build-base bash git
|
73
115
|
- name: Checkout
|
74
|
-
uses: actions/checkout@
|
116
|
+
uses: actions/checkout@v3
|
117
|
+
- name: Update Rubygems
|
118
|
+
run: docker exec -w "${PWD}" ${{ steps.container.outputs.id }} gem update --system
|
75
119
|
- name: Bundle
|
76
120
|
run: docker exec -w "${PWD}" ${{ steps.container.outputs.id }} bundle install
|
77
121
|
- name: Compile
|
data/.gitignore
CHANGED
data/CHANGELOG
CHANGED
@@ -1,5 +1,45 @@
|
|
1
|
+
- 16-08-2022
|
2
|
+
|
3
|
+
- 0.6.3
|
4
|
+
|
5
|
+
- Truffle ruby support! Thanks to Brandon Fish and the truffle team
|
6
|
+
- Hide libv8 symbols on ELF targets
|
7
|
+
- Slightly shrunk binary size
|
8
|
+
- Simplified timeout implementation
|
9
|
+
- Some stability fixes
|
10
|
+
|
11
|
+
- 17-01-2022
|
12
|
+
|
13
|
+
- 0.6.2
|
14
|
+
|
15
|
+
- Fix support for compilation on 2.6, llvm compiles
|
16
|
+
- Stability patches to handle rare memory leaks
|
17
|
+
- Corrected re-raising of exceptions to support strings
|
18
|
+
- During early termination of context under certain conditions MiniRacer could crash
|
19
|
+
|
20
|
+
|
21
|
+
- 31-12-2021
|
22
|
+
|
23
|
+
- 0.6.1
|
24
|
+
|
25
|
+
- Added support for single threaded platform: `MiniRacer::Platform.set_flags! :single_threaded`
|
26
|
+
must be called prior to booting ANY MiniRacer::Context
|
27
|
+
|
28
|
+
- 0.6.0
|
29
|
+
|
30
|
+
- Ruby 3.1 support
|
31
|
+
- Fixes memory leak in heap snapshotting
|
32
|
+
- Improved compilation ergonomics in clang
|
33
|
+
- Migrated internal storage in c extension to TypedData
|
34
|
+
|
1
35
|
- 11-04-2021
|
2
36
|
|
37
|
+
- 0.5.0
|
38
|
+
- Fixes issues on aarch (Apple M1)
|
39
|
+
- Update to use libv8-node 16.x (#210) [Loic Nageleisen]
|
40
|
+
- FEATURE: Configurable max marshal stack depth (#202) [seanmakesgames]
|
41
|
+
- Ruby 2.3 and 2.4 are EOL, we no longer support them
|
42
|
+
|
3
43
|
- 0.4.0
|
4
44
|
|
5
45
|
- FEATURE: upgrade to libv8 node 15.14.0 (v8 8.6.395.17)
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# MiniRacer
|
2
2
|
|
3
|
-
[![
|
3
|
+
[![Test](https://github.com/rubyjs/mini_racer/actions/workflows/ci.yml/badge.svg)](https://github.com/rubyjs/mini_racer/actions/workflows/ci.yml)
|
4
4
|
|
5
5
|
Minimal, modern embedded V8 for Ruby.
|
6
6
|
|
@@ -12,7 +12,7 @@ MiniRacer has an adapter for [execjs](https://github.com/rails/execjs) so it can
|
|
12
12
|
|
13
13
|
### A note about Ruby version Support
|
14
14
|
|
15
|
-
MiniRacer only supports non-EOL versions of Ruby. See [Ruby](https://www.ruby-lang.org/en/downloads)
|
15
|
+
MiniRacer only supports non-EOL versions of Ruby. See [Ruby Maintenance Branches](https://www.ruby-lang.org/en/downloads/branches/) for the list of non-EOL Rubies.
|
16
16
|
|
17
17
|
If you require support for older versions of Ruby install an older version of the gem.
|
18
18
|
|
@@ -85,6 +85,19 @@ context.eval 'var a = new Array(10000); while(true) {a = a.concat(new Array(1000
|
|
85
85
|
# => V8OutOfMemoryError is raised
|
86
86
|
```
|
87
87
|
|
88
|
+
### Object marshal max stackdepth support
|
89
|
+
|
90
|
+
Contexts can specify a stack depth limit for object marshalling. Max depth is unbounded by default.
|
91
|
+
|
92
|
+
```ruby
|
93
|
+
# terminates script if stack depth exceeds max during marshal
|
94
|
+
context = MiniRacer::Context.new(marshal_stack_depth: 500)
|
95
|
+
context.attach("a", proc{|a| a})
|
96
|
+
|
97
|
+
context.eval("let arr = []; arr.push(arr); a(arr)")
|
98
|
+
# => RuntimeError is raised
|
99
|
+
```
|
100
|
+
|
88
101
|
### Rich debugging with "filename" support
|
89
102
|
|
90
103
|
```ruby
|
@@ -99,16 +112,21 @@ context.eval('bar()', filename: 'a/bar.js')
|
|
99
112
|
|
100
113
|
### Fork safety
|
101
114
|
|
102
|
-
Some Ruby web servers employ forking (for example unicorn or puma in clustered mode). V8 is not fork safe.
|
103
|
-
|
115
|
+
Some Ruby web servers employ forking (for example unicorn or puma in clustered mode). V8 is not fork safe by default and sadly Ruby does not have support for fork notifications per [#5446](https://bugs.ruby-lang.org/issues/5446).
|
116
|
+
|
117
|
+
Since 0.6.1 mini_racer does support V8 single threaded platform mode which should remove most forking related issues. To enable run this before using `MiniRacer::Context`:
|
118
|
+
|
119
|
+
```ruby
|
120
|
+
MiniRacer::Platform.set_flags!(:single_threaded)
|
121
|
+
```
|
104
122
|
|
105
123
|
If you want to ensure your application does not leak memory after fork either:
|
106
124
|
|
107
|
-
1. Ensure no MiniRacer::Context objects are created in the master process
|
125
|
+
1. Ensure no `MiniRacer::Context` objects are created in the master process
|
108
126
|
|
109
127
|
Or
|
110
128
|
|
111
|
-
2. Dispose manually of all MiniRacer::Context objects prior to forking
|
129
|
+
2. Dispose manually of all `MiniRacer::Context` objects prior to forking
|
112
130
|
|
113
131
|
```ruby
|
114
132
|
# before fork
|
@@ -403,21 +421,18 @@ Or install it yourself as:
|
|
403
421
|
$ gem install mini_racer
|
404
422
|
|
405
423
|
|
406
|
-
**Note** using v8.h and compiling MiniRacer requires a C++11 standard compiler, more specifically clang 3.5 (or later) or
|
407
|
-
|
424
|
+
**Note** using v8.h and compiling MiniRacer requires a C++11 standard compiler, more specifically clang 3.5 (or later) or GCC 6.3 (or later).
|
408
425
|
|
409
|
-
## Travis-ci
|
410
426
|
|
411
|
-
|
427
|
+
### Troubleshooting
|
412
428
|
|
413
|
-
|
429
|
+
If you have a problem installing mini_racer, please consider the following steps:
|
414
430
|
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
-
|
419
|
-
|
420
|
-
```
|
431
|
+
* make sure you try the latest released version of mini_racer
|
432
|
+
* make sure you have Rubygems >= 3.2.13 and bundler >= 2.2.13 installed via `gem update --system`
|
433
|
+
* if you are using bundler, make sure to have `PLATFORMS` set correctly in `Gemfile.lock` via `bundle lock --add-platform`
|
434
|
+
* make sure to recompile/reinstall `mini_racer` and `libv8-node` after system upgrades (for example via `gem uninstall --all mini_racer libv8-node`)
|
435
|
+
* make sure you are on the latest patch/teeny version of a supported Ruby branch
|
421
436
|
|
422
437
|
## Similar Projects
|
423
438
|
|
data/Rakefile
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
2
|
require "rake/testtask"
|
3
|
-
require "rake/extensiontask"
|
4
3
|
|
5
4
|
Rake::TestTask.new(:test) do |t|
|
6
5
|
t.libs << "test"
|
@@ -11,8 +10,21 @@ end
|
|
11
10
|
task :default => [:compile, :test]
|
12
11
|
|
13
12
|
gem = Gem::Specification.load( File.dirname(__FILE__) + '/mini_racer.gemspec' )
|
14
|
-
|
15
|
-
|
13
|
+
|
14
|
+
if RUBY_ENGINE == "truffleruby"
|
15
|
+
task :compile do
|
16
|
+
# noop
|
17
|
+
end
|
18
|
+
|
19
|
+
task :clean do
|
20
|
+
# noop
|
21
|
+
end
|
22
|
+
else
|
23
|
+
require 'rake/extensiontask'
|
24
|
+
Rake::ExtensionTask.new( 'mini_racer_loader', gem )
|
25
|
+
Rake::ExtensionTask.new( 'mini_racer_extension', gem )
|
26
|
+
end
|
27
|
+
|
16
28
|
|
17
29
|
|
18
30
|
# via http://blog.flavorjon.es/2009/06/easily-valgrind-gdb-your-ruby-c.html
|
@@ -92,5 +104,5 @@ task :lint do
|
|
92
104
|
portability-*
|
93
105
|
readability-*).join(',')
|
94
106
|
|
95
|
-
sh RbConfig::expand("clang-tidy -checks='#{checks}' ext/mini_racer_extension/mini_racer_extension.cc -- #$INCFLAGS #$
|
107
|
+
sh RbConfig::expand("clang-tidy -checks='#{checks}' ext/mini_racer_extension/mini_racer_extension.cc -- #$INCFLAGS #$CXXFLAGS", conf)
|
96
108
|
end
|
@@ -1,4 +1,10 @@
|
|
1
1
|
require 'mkmf'
|
2
|
+
|
3
|
+
if RUBY_ENGINE == "truffleruby"
|
4
|
+
File.write("Makefile", dummy_makefile($srcdir).join(""))
|
5
|
+
return
|
6
|
+
end
|
7
|
+
|
2
8
|
require_relative '../../lib/mini_racer/version'
|
3
9
|
gem 'libv8-node', MiniRacer::LIBV8_NODE_VERSION
|
4
10
|
require 'libv8-node'
|
@@ -7,18 +13,25 @@ IS_DARWIN = RUBY_PLATFORM =~ /darwin/
|
|
7
13
|
|
8
14
|
have_library('pthread')
|
9
15
|
have_library('objc') if IS_DARWIN
|
10
|
-
$
|
11
|
-
$
|
12
|
-
$
|
13
|
-
$
|
14
|
-
$
|
15
|
-
$
|
16
|
-
|
17
|
-
$
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
16
|
+
$CXXFLAGS += " -Wall" unless $CXXFLAGS.split.include? "-Wall"
|
17
|
+
$CXXFLAGS += " -g" unless $CXXFLAGS.split.include? "-g"
|
18
|
+
$CXXFLAGS += " -rdynamic" unless $CXXFLAGS.split.include? "-rdynamic"
|
19
|
+
$CXXFLAGS += " -fPIC" unless $CXXFLAGS.split.include? "-rdynamic" or IS_DARWIN
|
20
|
+
$CXXFLAGS += " -std=c++14"
|
21
|
+
$CXXFLAGS += " -fpermissive"
|
22
|
+
#$CXXFLAGS += " -DV8_COMPRESS_POINTERS"
|
23
|
+
$CXXFLAGS += " -fvisibility=hidden "
|
24
|
+
|
25
|
+
# __declspec gets used by clang via ruby 3.x headers...
|
26
|
+
$CXXFLAGS += " -fms-extensions"
|
27
|
+
|
28
|
+
$CXXFLAGS += " -Wno-reserved-user-defined-literal" if IS_DARWIN
|
29
|
+
|
30
|
+
if IS_DARWIN
|
31
|
+
$LDFLAGS.insert(0, " -stdlib=libc++ ")
|
32
|
+
else
|
33
|
+
$LDFLAGS.insert(0, " -lstdc++ ")
|
34
|
+
end
|
22
35
|
|
23
36
|
# check for missing symbols at link time
|
24
37
|
# $LDFLAGS += " -Wl,--no-undefined " unless IS_DARWIN
|
@@ -63,9 +76,17 @@ end
|
|
63
76
|
|
64
77
|
Libv8::Node.configure_makefile
|
65
78
|
|
79
|
+
# --exclude-libs is only for i386 PE and ELF targeted ports
|
80
|
+
append_ldflags("-Wl,--exclude-libs=ALL ")
|
81
|
+
|
66
82
|
if enable_config('asan')
|
67
|
-
$
|
83
|
+
$CXXFLAGS.insert(0, " -fsanitize=address ")
|
68
84
|
$LDFLAGS.insert(0, " -fsanitize=address ")
|
69
85
|
end
|
70
86
|
|
87
|
+
# there doesn't seem to be a CPP macro for this in Ruby 2.6:
|
88
|
+
if RUBY_ENGINE == 'ruby'
|
89
|
+
$CPPFLAGS += ' -DENGINE_IS_CRUBY '
|
90
|
+
end
|
91
|
+
|
71
92
|
create_makefile 'mini_racer_extension'
|