mini_racer 0.2.10 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a50c6aea93635efc351ce95def252df6edb3fbede6a0372272f8c9cd58f9aaed
4
- data.tar.gz: b01cd6a98eca13db18d539ed259e4acd968eb073582979ff06f78a5df54a4207
3
+ metadata.gz: e832863760637f983976194ebef263d8815c149d48ff26c7200367ab33640dda
4
+ data.tar.gz: 7c1c393ae6403a75d2a413395d56e7d5f3affe706b81c121273b4c6b5d471bf4
5
5
  SHA512:
6
- metadata.gz: cac0258ac9f1f93245b00b313d004504d770e9dce3eb5ac9a8d547a1b24cd3649ec9039d9c7429ff7871f9f8d3c07e260997d86647905ba433688f361bd72611
7
- data.tar.gz: b054a38013e7bcffe689c3732d7d95abbaf61c350dab275ff7e04e667bc5f15ae9863a706beb2848681b8d69cc1194c0bb87014a4c49e2f49d14a4289b1f6436
6
+ metadata.gz: 4504cb3a564e5b311b65de74bac321b058995af17df47f9f3dc01fcb589a87eebfda55497e0ddb135a2ab15ef1818760652561d434d3f497c0dbd036451934c6
7
+ data.tar.gz: b83df123a61092ab4041212bb6e4f15b276d5e32e8be8d2b5cbc014988b8cf20ed0e0b3b30595de53ca4c0d599a86112d695009cda13891fe177742aff7d911e
data/.dockerignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ lib/mini_racer_extension.so
11
+ lib/mini_racer_loader.so
12
+ *.bundle
@@ -0,0 +1,78 @@
1
+ name: Test
2
+ on:
3
+ - push
4
+
5
+ jobs:
6
+ test-darwin:
7
+ strategy:
8
+ fail-fast: false
9
+ matrix:
10
+ os:
11
+ - '10.15'
12
+ - '11.0'
13
+ platform:
14
+ - x86_64
15
+ # arm64
16
+ name: Test (darwin)
17
+ runs-on: macos-${{ matrix.os }}
18
+ steps:
19
+ - name: Checkout
20
+ uses: actions/checkout@v2
21
+ - name: Bundle
22
+ run: bundle install
23
+ - name: Compile
24
+ run: bundle exec rake compile
25
+ - name: Test
26
+ run: bundle exec rake test
27
+ test-linux:
28
+ strategy:
29
+ fail-fast: false
30
+ matrix:
31
+ ruby:
32
+ - '2.6'
33
+ - '2.7'
34
+ - '3.0'
35
+ platform:
36
+ - amd64
37
+ - arm64
38
+ # arm
39
+ # ppc64le
40
+ # s390x
41
+ libc:
42
+ - gnu
43
+ - musl
44
+ name: Test (linux)
45
+ runs-on: ubuntu-20.04
46
+ steps:
47
+ - name: Enable ${{ matrix.platform }} platform
48
+ id: qemu
49
+ if: ${{ matrix.platform != 'amd64' }}
50
+ run: |
51
+ docker run --privileged --rm tonistiigi/binfmt:latest --install ${{ matrix.platform }} | tee platforms.json
52
+ echo "::set-output name=platforms::$(cat platforms.json)"
53
+ - name: Start container
54
+ id: container
55
+ run: |
56
+ case ${{ matrix.libc }} in
57
+ gnu)
58
+ echo 'ruby:${{ matrix.ruby }}'
59
+ ;;
60
+ musl)
61
+ echo 'ruby:${{ matrix.ruby }}-alpine'
62
+ ;;
63
+ esac > container_image
64
+ echo "::set-output name=image::$(cat container_image)"
65
+ docker run --rm -d -v "${PWD}":"${PWD}" -w "${PWD}" --platform linux/${{ matrix.platform }} $(cat container_image) /bin/sleep 64d | tee container_id
66
+ docker exec -w "${PWD}" $(cat container_id) uname -a
67
+ echo "::set-output name=id::$(cat container_id)"
68
+ - name: Install Alpine system dependencies
69
+ if: ${{ matrix.libc == 'musl' }}
70
+ run: docker exec -w "${PWD}" ${{ steps.container.outputs.id }} apk add --no-cache build-base linux-headers bash python2 python3 git curl tar clang binutils-gold
71
+ - name: Checkout
72
+ uses: actions/checkout@v2
73
+ - name: Bundle
74
+ run: docker exec -w "${PWD}" ${{ steps.container.outputs.id }} bundle install
75
+ - name: Compile
76
+ run: docker exec -w "${PWD}" ${{ steps.container.outputs.id }} bundle exec rake compile
77
+ - name: Test
78
+ run: docker exec -w "${PWD}" ${{ steps.container.outputs.id }} bundle exec rake test
data/.gitignore CHANGED
@@ -8,4 +8,6 @@ Gemfile.lock
8
8
  /spec/reports/
9
9
  /tmp/
10
10
  lib/mini_racer_extension.so
11
+ lib/mini_racer_loader.so
11
12
  *.bundle
13
+ .vscode/
data/.travis.yml CHANGED
@@ -1,24 +1,23 @@
1
1
  language: ruby
2
+ os: linux
2
3
  rvm:
3
- - 2.4
4
- - 2.5
5
4
  - 2.6
6
5
  - 2.7
6
+ - 3.0
7
7
  - ruby-head
8
- matrix:
8
+ arch:
9
+ - amd64
10
+ - arm64
11
+ jobs:
9
12
  include:
10
- - rvm: 2.5.1
13
+ - rvm: 2.6
11
14
  os: osx
12
- osx_image: xcode9.4
13
- - rvm: 2.4.0
15
+ osx_image: xcode11.3
16
+ - rvm: 2.6
14
17
  os: osx
15
- osx_image: xcode8.3
16
- - rvm: 2.4.0
18
+ osx_image: xcode12.2
19
+ - rvm: 2.7
17
20
  os: osx
18
- osx_image: xcode7.3
19
- dist: trusty
20
- sudo: true
21
- before_install:
22
- - gem update --system
23
- - gem install bundler -v 1.16.2
21
+ osx_image: xcode12.2
22
+ dist: xenial
24
23
  cache: bundler
data/CHANGELOG CHANGED
@@ -1,3 +1,92 @@
1
+ - 17-01-2021
2
+
3
+ - 0.6.2
4
+
5
+ - Fix support for compilation on 2.6, llvm compiles
6
+ - Stability patches to handle rare memory leaks
7
+ - Corrected re-raising of exceptions to support strings
8
+ - During early termination of context under certain conditions MiniRacer could crash
9
+
10
+
11
+ - 31-12-2021
12
+
13
+ - 0.6.1
14
+
15
+ - Added support for single threaded platform: `MiniRacer::Platform.set_flags! :single_threaded`
16
+ must be called prior to booting ANY MiniRacer::Context
17
+
18
+ - 0.6.0
19
+
20
+ - Ruby 3.1 support
21
+ - Fixes memory leak in heap snapshotting
22
+ - Improved compilation ergonomics in clang
23
+ - Migrated internal storage in c extension to TypedData
24
+
25
+ - 11-04-2021
26
+
27
+ - 0.5.0
28
+ - Fixes issues on aarch (Apple M1)
29
+ - Update to use libv8-node 16.x (#210) [Loic Nageleisen]
30
+ - FEATURE: Configurable max marshal stack depth (#202) [seanmakesgames]
31
+ - Ruby 2.3 and 2.4 are EOL, we no longer support them
32
+
33
+ - 0.4.0
34
+
35
+ - FEATURE: upgrade to libv8 node 15.14.0 (v8 8.6.395.17)
36
+ - Promote 0.4.0.beta1 to release, using libv8-node release path
37
+
38
+ - 08-04-2021
39
+
40
+ - 0.4.0.beta1
41
+
42
+ - FIX: on downgrade mkmf was picking the wrong version of libv8, this fix will correct future issues
43
+ - FEATURE: upgraded libv8 to use node libv8 build which supports M1 and various ARM builds v8 moved to (8.6.395.17)
44
+
45
+ - 23-07-2020
46
+
47
+ - 0.3.1
48
+
49
+ - FIX: specify that libv8 must be larger than 8.4.255 but smaller than 8.5, this avoids issues going forward
50
+
51
+ - 22-07-2020
52
+
53
+ - 0.3.0
54
+
55
+ - FEATURE: upgraded to libv8 version 8.4.255.0
56
+
57
+ - 29-06-2020
58
+
59
+ - 0.2.15
60
+
61
+ - FEATURE: basic wasm support via pump_message_loop
62
+
63
+ - 15-05-2020
64
+
65
+ - 0.2.14
66
+
67
+ - FIX: ensure_gc_after_idle should take in milliseconds like the rest of the APIs not seconds
68
+ - FEATURE: strict params on MiniRacer::Context.new
69
+
70
+ - 15-05-2020
71
+
72
+ - 0.2.13
73
+
74
+ - FIX: edge case around ensure_gc_after_idle possibly firing when context is not idle
75
+
76
+ - 15-05-2020
77
+
78
+ - 0.2.12
79
+
80
+ - FEATURE: isolate.low_memory_notification which can force a full GC
81
+ - FEATURE: MiniRacer::Context.new(ensure_gc_after_idle: 2) - to force full GC 2 seconds after context is idle, this allows you to conserve memory on isolates
82
+
83
+ - 14-05-2020
84
+
85
+ - 0.2.11
86
+
87
+ - FIX: dumping heap snapshots was not flushing the file leading to corrupt snapshots
88
+ - FIX: a use-after-free shutdown crash
89
+
1
90
  - 0.2.10
2
91
 
3
92
  - 22-04-2020
data/Dockerfile ADDED
@@ -0,0 +1,21 @@
1
+ ARG RUBY_VERSION=2.7
2
+ FROM ruby:${RUBY_VERSION}
3
+
4
+ RUN test ! -f /etc/alpine-release || apk add --no-cache build-base git
5
+
6
+ # without this `COPY .git`, we get the following error:
7
+ # fatal: not a git repository (or any of the parent directories): .git
8
+ # but with it we need the full gem just to compile the extension because
9
+ # of gemspec's `git --ls-files`
10
+ # COPY .git /code/.git
11
+ COPY Gemfile mini_racer.gemspec /code/
12
+ COPY lib/mini_racer/version.rb /code/lib/mini_racer/version.rb
13
+ WORKDIR /code
14
+ RUN bundle install
15
+
16
+ COPY Rakefile /code/
17
+ COPY ext /code/ext/
18
+ RUN bundle exec rake compile
19
+
20
+ COPY . /code/
21
+ CMD bundle exec irb -rmini_racer
data/README.md CHANGED
@@ -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
@@ -230,12 +243,17 @@ context = MiniRacer::Context.new(isolate: isolate)
230
243
  # give up to 100ms for V8 garbage collection
231
244
  isolate.idle_notification(100)
232
245
 
246
+ # force V8 to perform a full GC
247
+ isolate.low_memory_notification
248
+
233
249
  ```
234
250
 
235
251
  This can come in handy to force V8 GC runs for example in between requests if you use MiniRacer on a web application.
236
252
 
237
253
  Note that this method maps directly to [`v8::Isolate::IdleNotification`](http://bespin.cz/~ondras/html/classv8_1_1Isolate.html#aea16cbb2e351de9a3ae7be2b7cb48297), and that in particular its return value is the same (true if there is no further garbage to collect, false otherwise) and the same caveats apply, in particular that `there is no guarantee that the [call will return] within the time limit.`
238
254
 
255
+ Additionally you may automate this process on a context by defining it with `MiniRacer::Content.new(ensure_gc_after_idle: 1000)`. Using this will ensure V8 will run a full GC using `context.isolate.low_memory_notification` 1 second after the last eval on the context. Low memory notification is both slower and more aggressive than an idle_notification and will ensure long living isolates use minimal amounts of memory.
256
+
239
257
  ### V8 Runtime flags
240
258
 
241
259
  It is possible to set V8 Runtime flags:
@@ -244,7 +262,7 @@ It is possible to set V8 Runtime flags:
244
262
  MiniRacer::Platform.set_flags! :noconcurrent_recompilation, max_inlining_levels: 10
245
263
  ```
246
264
 
247
- This can come in handy if you want to use MiniRacer with Unicorn, which doesn't seem to alwatys appreciate V8's liberal use of threading:
265
+ This can come in handy if you want to use MiniRacer with Unicorn, which doesn't seem to always appreciate V8's liberal use of threading:
248
266
  ```ruby
249
267
  MiniRacer::Platform.set_flags! :noconcurrent_recompilation, :noconcurrent_sweeping
250
268
  ```
@@ -310,6 +328,16 @@ context.eval("a = 2")
310
328
  # nothing works on the context from now on, its a shell waiting to be disposed
311
329
  ```
312
330
 
331
+ A MiniRacer context can also be dumped in a heapsnapshot file using `#write_heap_snapshot(file_or_io)`
332
+
333
+ ```ruby
334
+ context = MiniRacer::Context.new(timeout: 5)
335
+ context.eval("let a='testing';")
336
+ context.write_heap_snapshot("test.heapsnapshot")
337
+ ```
338
+
339
+ This file can then be loaded in the memory tab of the chrome dev console.
340
+
313
341
  ### Function call
314
342
 
315
343
  This calls the function passed as first argument:
@@ -388,14 +416,14 @@ Or install it yourself as:
388
416
  $ gem install mini_racer
389
417
 
390
418
 
391
- **Note** using v8.h and compiling MiniRacer requires a C++11 standard compiler, more specifically clang 3.5 (or later) or gcc 4.8 (or later).
419
+ **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).
392
420
 
393
421
 
394
422
  ## Travis-ci
395
423
 
396
- To install `mini-racer` you will need a version of gcc that supports C++11 (gcc 4.8) this is included by default in ubuntu trusty based images.
424
+ To install `mini-racer` you will need a version of GCC that supports C++11 (GCC 6.3) this is included by default in ubuntu trusty based images.
397
425
 
398
- Travis today ships by default with a precise based image. Precise Pangolin (12.04 LTS) was first released in August 2012. Even though you can install GCC 4.8 on precise the simpler approach is to opt for the trusty based image.
426
+ Travis today ships by default with a precise based image. Precise Pangolin (12.04 LTS) was first released in August 2012. Even though you can install GCC 6.3 on precise the simpler approach is to opt for the trusty based image.
399
427
 
400
428
  Add this to your .travis.yml file:
401
429
 
data/Rakefile CHANGED
@@ -11,6 +11,7 @@ end
11
11
  task :default => [:compile, :test]
12
12
 
13
13
  gem = Gem::Specification.load( File.dirname(__FILE__) + '/mini_racer.gemspec' )
14
+ Rake::ExtensionTask.new( 'mini_racer_loader', gem )
14
15
  Rake::ExtensionTask.new( 'mini_racer_extension', gem )
15
16
 
16
17
 
@@ -91,5 +92,5 @@ task :lint do
91
92
  portability-*
92
93
  readability-*).join(',')
93
94
 
94
- sh RbConfig::expand("clang-tidy -checks='#{checks}' ext/mini_racer_extension/mini_racer_extension.cc -- #$INCFLAGS #$CPPFLAGS", conf)
95
+ sh RbConfig::expand("clang-tidy -checks='#{checks}' ext/mini_racer_extension/mini_racer_extension.cc -- #$INCFLAGS #$CXXFLAGS", conf)
95
96
  end
@@ -1,20 +1,35 @@
1
1
  require 'mkmf'
2
- require 'libv8'
2
+ require_relative '../../lib/mini_racer/version'
3
+ gem 'libv8-node', MiniRacer::LIBV8_NODE_VERSION
4
+ require 'libv8-node'
3
5
 
4
6
  IS_DARWIN = RUBY_PLATFORM =~ /darwin/
5
7
 
6
8
  have_library('pthread')
7
9
  have_library('objc') if IS_DARWIN
8
- $CPPFLAGS += " -Wall" unless $CPPFLAGS.split.include? "-Wall"
9
- $CPPFLAGS += " -g" unless $CPPFLAGS.split.include? "-g"
10
- $CPPFLAGS += " -rdynamic" unless $CPPFLAGS.split.include? "-rdynamic"
11
- $CPPFLAGS += " -fPIC" unless $CPPFLAGS.split.include? "-rdynamic" or IS_DARWIN
12
- $CPPFLAGS += " -std=c++0x"
13
- $CPPFLAGS += " -fpermissive"
14
-
15
- $CPPFLAGS += " -Wno-reserved-user-defined-literal" if IS_DARWIN
10
+ $CXXFLAGS += " -Wall" unless $CXXFLAGS.split.include? "-Wall"
11
+ $CXXFLAGS += " -g" unless $CXXFLAGS.split.include? "-g"
12
+ $CXXFLAGS += " -rdynamic" unless $CXXFLAGS.split.include? "-rdynamic"
13
+ $CXXFLAGS += " -fPIC" unless $CXXFLAGS.split.include? "-rdynamic" or IS_DARWIN
14
+ $CXXFLAGS += " -std=c++14"
15
+ $CXXFLAGS += " -fpermissive"
16
+ #$CXXFLAGS += " -DV8_COMPRESS_POINTERS"
17
+ $CXXFLAGS += " -fvisibility=hidden "
18
+
19
+ # __declspec gets used by clang via ruby 3.x headers...
20
+ $CXXFLAGS += " -fms-extensions"
21
+
22
+ $CXXFLAGS += " -Wno-reserved-user-defined-literal" if IS_DARWIN
23
+
24
+ if IS_DARWIN
25
+ $LDFLAGS.insert(0, " -stdlib=libc++ ")
26
+ else
27
+ $LDFLAGS.insert(0, " -lstdc++ ")
28
+ end
16
29
 
17
- $LDFLAGS.insert(0, " -stdlib=libc++ ") if IS_DARWIN
30
+ # check for missing symbols at link time
31
+ # $LDFLAGS += " -Wl,--no-undefined " unless IS_DARWIN
32
+ # $LDFLAGS += " -Wl,-undefined,error " if IS_DARWIN
18
33
 
19
34
  if ENV['CXX']
20
35
  puts "SETTING CXX"
@@ -53,11 +68,16 @@ if enable_config('debug') || enable_config('asan')
53
68
  CONFIG['debugflags'] << ' -ggdb3 -O0'
54
69
  end
55
70
 
56
- Libv8.configure_makefile
71
+ Libv8::Node.configure_makefile
57
72
 
58
73
  if enable_config('asan')
59
- $CPPFLAGS.insert(0, " -fsanitize=address ")
74
+ $CXXFLAGS.insert(0, " -fsanitize=address ")
60
75
  $LDFLAGS.insert(0, " -fsanitize=address ")
61
76
  end
62
77
 
78
+ # there doesn't seem to be a CPP macro for this in Ruby 2.6:
79
+ if RUBY_ENGINE == 'ruby'
80
+ $CPPFLAGS += ' -DENGINE_IS_CRUBY '
81
+ end
82
+
63
83
  create_makefile 'mini_racer_extension'