mini_racer 0.2.9 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 97112de9fedf9f005d85b2325d129a6689ac7b878da020db8caf13c4921e0a92
4
- data.tar.gz: 20cdb63b3661c0626ff4edcf033380a6f59317265d84ecaa24df279d1a7acc39
3
+ metadata.gz: f868c575c8ed41f4080580b2d09d0d42522d337390f425b3110e38298952a6f4
4
+ data.tar.gz: 9c2df1f0171dd3ed4bba7a59faa3ea7d87a1976087395da3ec56966aeedd23d8
5
5
  SHA512:
6
- metadata.gz: e2db9f72fa5869a7e9c31ee1b9ef8215e07afb672f6142bf67fc3b509627c594f0e7282fd71bf62b64efb2cbe560a9bdf54615a0e522bc8d57e919746861dc02
7
- data.tar.gz: dc844371d224fbbb7eebdc638282f5c9ee0250d3a09fd4a1fc1de1a7f0ef741bfb87e485f17048017ab7d1c4e34bed0a582d367ac0c603cb0ee738ea108e3d26
6
+ metadata.gz: 7c51ea3a8f4abc4ae458090ce2f37760110ac240f7600e3fd249f07df97725e0b7903884fb90063b3d3140c0337eeae132a6e395b1f74777c85dfddc03b6ad96
7
+ data.tar.gz: '0948c498cdb9a0767dbe0de9d4b233d2561eb6b72f6603170c3f4d9304083487a03fc395f8803f1d1690ef6f9d06e0faddc86ef694b950c0e95ea4047943c96e'
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.3
4
- - 2.4
5
- - 2.5
6
4
  - 2.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,68 @@
1
+ - 11-04-2021
2
+
3
+ - 0.4.0
4
+
5
+ - FEATURE: upgrade to libv8 node 15.14.0 (v8 8.6.395.17)
6
+ - Promote 0.4.0.beta1 to release, using libv8-node release path
7
+
8
+ - 08-04-2021
9
+
10
+ - 0.4.0.beta1
11
+
12
+ - FIX: on downgrade mkmf was picking the wrong version of libv8, this fix will correct future issues
13
+ - FEATURE: upgraded libv8 to use node libv8 build which supports M1 and various ARM builds v8 moved to (8.6.395.17)
14
+
15
+ - 23-07-2020
16
+
17
+ - 0.3.1
18
+
19
+ - FIX: specify that libv8 must be larger than 8.4.255 but smaller than 8.5, this avoids issues going forward
20
+
21
+ - 22-07-2020
22
+
23
+ - 0.3.0
24
+
25
+ - FEATURE: upgraded to libv8 version 8.4.255.0
26
+
27
+ - 29-06-2020
28
+
29
+ - 0.2.15
30
+
31
+ - FEATURE: basic wasm support via pump_message_loop
32
+
33
+ - 15-05-2020
34
+
35
+ - 0.2.14
36
+
37
+ - FIX: ensure_gc_after_idle should take in milliseconds like the rest of the APIs not seconds
38
+ - FEATURE: strict params on MiniRacer::Context.new
39
+
40
+ - 15-05-2020
41
+
42
+ - 0.2.13
43
+
44
+ - FIX: edge case around ensure_gc_after_idle possibly firing when context is not idle
45
+
46
+ - 15-05-2020
47
+
48
+ - 0.2.12
49
+
50
+ - FEATURE: isolate.low_memory_notification which can force a full GC
51
+ - 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
52
+
53
+ - 14-05-2020
54
+
55
+ - 0.2.11
56
+
57
+ - FIX: dumping heap snapshots was not flushing the file leading to corrupt snapshots
58
+ - FIX: a use-after-free shutdown crash
59
+
60
+ - 0.2.10
61
+
62
+ - 22-04-2020
63
+
64
+ - FEATURE: memory softlimit support for nogvl_context_call
65
+
1
66
  - 0.2.9
2
67
 
3
68
  - 09-01-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
@@ -1,6 +1,6 @@
1
1
  # MiniRacer
2
2
 
3
- [![Build Status](https://travis-ci.org/discourse/mini_racer.svg?branch=master)](https://travis-ci.org/discourse/mini_racer)
3
+ [![Build Status](https://travis-ci.org/rubyjs/mini_racer.svg?branch=master)](https://travis-ci.org/rubyjs/mini_racer)
4
4
 
5
5
  Minimal, modern embedded V8 for Ruby.
6
6
 
@@ -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
  ```
@@ -273,7 +291,7 @@ context.eval js
273
291
  The same code without the harmony runtime flag results in a `MiniRacer::RuntimeError: RangeError: Maximum call stack size exceeded` exception.
274
292
  Please refer to http://node.green/ as a reference on other harmony features.
275
293
 
276
- A list of all V8 runtime flags can be found using `node --v8-options`, or else by perusing [the V8 source code for flags (make sure to use the right version of V8)](https://github.com/v8/v8/blob/master/src/flag-definitions.h).
294
+ A list of all V8 runtime flags can be found using `node --v8-options`, or else by perusing [the V8 source code for flags (make sure to use the right version of V8)](https://github.com/v8/v8/blob/master/src/flags/flag-definitions.h).
277
295
 
278
296
  Note that runtime flags must be set before any other operation (e.g. creating a context, a snapshot or an isolate), otherwise an exception will be thrown.
279
297
 
@@ -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
 
@@ -447,7 +475,7 @@ Add this to your .travis.yml file:
447
475
 
448
476
  ## Contributing
449
477
 
450
- Bug reports and pull requests are welcome on GitHub at https://github.com/discourse/mini_racer. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
478
+ Bug reports and pull requests are welcome on GitHub at https://github.com/rubyjs/mini_racer. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
451
479
 
452
480
 
453
481
  ## License
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
 
@@ -1,5 +1,7 @@
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
 
@@ -9,13 +11,19 @@ $CPPFLAGS += " -Wall" unless $CPPFLAGS.split.include? "-Wall"
9
11
  $CPPFLAGS += " -g" unless $CPPFLAGS.split.include? "-g"
10
12
  $CPPFLAGS += " -rdynamic" unless $CPPFLAGS.split.include? "-rdynamic"
11
13
  $CPPFLAGS += " -fPIC" unless $CPPFLAGS.split.include? "-rdynamic" or IS_DARWIN
12
- $CPPFLAGS += " -std=c++0x"
14
+ $CPPFLAGS += " -std=c++14"
13
15
  $CPPFLAGS += " -fpermissive"
16
+ #$CPPFLAGS += " -DV8_COMPRESS_POINTERS"
17
+ $CPPFLAGS += " -fvisibility=hidden "
14
18
 
15
19
  $CPPFLAGS += " -Wno-reserved-user-defined-literal" if IS_DARWIN
16
20
 
17
21
  $LDFLAGS.insert(0, " -stdlib=libc++ ") if IS_DARWIN
18
22
 
23
+ # check for missing symbols at link time
24
+ # $LDFLAGS += " -Wl,--no-undefined " unless IS_DARWIN
25
+ # $LDFLAGS += " -Wl,-undefined,error " if IS_DARWIN
26
+
19
27
  if ENV['CXX']
20
28
  puts "SETTING CXX"
21
29
  CONFIG['CXX'] = ENV['CXX']
@@ -53,7 +61,7 @@ if enable_config('debug') || enable_config('asan')
53
61
  CONFIG['debugflags'] << ' -ggdb3 -O0'
54
62
  end
55
63
 
56
- Libv8.configure_makefile
64
+ Libv8::Node.configure_makefile
57
65
 
58
66
  if enable_config('asan')
59
67
  $CPPFLAGS.insert(0, " -fsanitize=address ")