sq_mini_racer 0.2.5.0.1.beta1 → 0.3.1.0.2

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: a4deece72e6d02478b4381a59ab9b1988a2fbff6a30e811596183240699fd018
4
- data.tar.gz: ac83f077c9b56423cd8b8e716d8102bec73050c8a4ae0e525fda931f43ec6762
3
+ metadata.gz: e68f36f6b57f07077c1f7914e2e902c6e824ee2de5d00008a5f5df50acee72b7
4
+ data.tar.gz: f7cf237de4ca9714d8588d3d8fc88afdc3a5eaf561b5ba96e78f7f2acfd10e3f
5
5
  SHA512:
6
- metadata.gz: cad6011c1066ccc51e1c3bfe3064c50e7dbdc6dd04127ce24f855a97f9ba8fd492a5de3b1af54b810b4a112d74f03bcd746c8d95af822a5f9d59e8cd9cdce8a2
7
- data.tar.gz: f985a398202455acfadd914606306d5469928bfbf69394fd39b5a79b097f81a6994bf4875bb7765d01b4fd2797b00378a5e3d23de4a05b4d3588216e3ac59cc9
6
+ metadata.gz: 63227b1b45f9d20020553c96b3dda2e8e5d679ad92720131e7f5feea1055a08093270c1f8eef8cd6e1b0860fb2bdb17e004aac33c5a1000cdc0f3bbca0b66563
7
+ data.tar.gz: ec0c9d009c94031a1a1dd3857bede44239fe657ea4999a167ee75e2f57873107870d7c8db77721ef088cc7fe6c9b8e88aacca3c32a127aafc692e886b4c86155
@@ -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/sq_mini_racer_extension.so
11
+ lib/sq_mini_racer_loader.so
12
+ *.bundle
data/.gitignore CHANGED
@@ -11,3 +11,12 @@ lib/*.so
11
11
  /lib/sq_mini_racer/
12
12
  /ext/mini_racer_extension/mini_racer.creator.*
13
13
  *.bundle
14
+ /mini_racer.config
15
+ /mini_racer.creator
16
+ /mini_racer.creator.user
17
+ /mini_racer.files
18
+ /mini_racer.includes
19
+ /compile_commands.json
20
+ /.vscode/
21
+ /.clangd/
22
+ /.idea/
data/CHANGELOG CHANGED
@@ -1,3 +1,76 @@
1
+ - Unreleased
2
+
3
+ - FIX: on downgrade mkmf was picking the wrong version of libv8, this fix will correct future issues
4
+
5
+ - 23-07-2020
6
+
7
+ - 0.3.1
8
+
9
+ - FIX: specify that libv8 must be larger than 8.4.255 but smaller than 8.5, this avoids issues going forward
10
+
11
+ - 22-07-2020
12
+
13
+ - 0.3.0
14
+
15
+ - FEATURE: upgraded to libv8 version 8.4.255.0
16
+
17
+ - 29-06-2020
18
+
19
+ - 0.2.15
20
+
21
+ - FEATURE: basic wasm support via pump_message_loop
22
+
23
+ - 15-05-2020
24
+
25
+ - 0.2.14
26
+
27
+ - FIX: ensure_gc_after_idle should take in milliseconds like the rest of the APIs not seconds
28
+ - FEATURE: strict params on MiniRacer::Context.new
29
+
30
+ - 15-05-2020
31
+
32
+ - 0.2.13
33
+
34
+ - FIX: edge case around ensure_gc_after_idle possibly firing when context is not idle
35
+
36
+ - 15-05-2020
37
+
38
+ - 0.2.12
39
+
40
+ - FEATURE: isolate.low_memory_notification which can force a full GC
41
+ - 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
42
+
43
+ - 14-05-2020
44
+
45
+ - 0.2.11
46
+
47
+ - FIX: dumping heap snapshots was not flushing the file leading to corrupt snapshots
48
+ - FIX: a use-after-free shutdown crash
49
+
50
+ - 0.2.10
51
+
52
+ - 22-04-2020
53
+
54
+ - FEATURE: memory softlimit support for nogvl_context_call
55
+
56
+ - 0.2.9
57
+
58
+ - 09-01-2020
59
+
60
+ - FIX: correct segfault when JS returns a Symbol and properly cast to ruby symbol
61
+
62
+ - 0.2.8
63
+
64
+ - 11-11-2019
65
+
66
+ - FIX: ensure thread live cycle is properly accounter for following file descriptor fix
67
+
68
+ - 0.2.7
69
+
70
+ - 11-11-2019
71
+
72
+ - FIX: release the file descriptor for timeout pipe earlier (this avoids holding too many files open in Ruby 2.7)
73
+
1
74
  - 14-05-2019
2
75
 
3
76
  - 0.2.6
@@ -0,0 +1,22 @@
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
+
12
+ COPY Gemfile mini_racer.gemspec /code/
13
+ COPY lib/sqreen/mini_racer/version.rb /code/lib/sqreen/mini_racer/version.rb
14
+ WORKDIR /code
15
+ RUN bundle install
16
+
17
+ COPY Rakefile /code/
18
+ COPY ext /code/ext/
19
+ RUN bundle exec rake compile
20
+
21
+ COPY . /code/
22
+ CMD bundle exec irb -rmini_racer
data/README.md CHANGED
@@ -234,12 +234,17 @@ context = MiniRacer::Context.new(isolate: isolate)
234
234
  # give up to 100ms for V8 garbage collection
235
235
  isolate.idle_notification(100)
236
236
 
237
+ # force V8 to perform a full GC
238
+ isolate.low_memory_notification
239
+
237
240
  ```
238
241
 
239
242
  This can come in handy to force V8 GC runs for example in between requests if you use MiniRacer on a web application.
240
243
 
241
244
  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.`
242
245
 
246
+ 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.
247
+
243
248
  ### V8 Runtime flags
244
249
 
245
250
  It is possible to set V8 Runtime flags:
@@ -277,7 +282,7 @@ context.eval js
277
282
  The same code without the harmony runtime flag results in a `MiniRacer::RuntimeError: RangeError: Maximum call stack size exceeded` exception.
278
283
  Please refer to http://node.green/ as a reference on other harmony features.
279
284
 
280
- 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).
285
+ 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).
281
286
 
282
287
  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.
283
288
 
@@ -314,6 +319,16 @@ context.eval("a = 2")
314
319
  # nothing works on the context from now on, its a shell waiting to be disposed
315
320
  ```
316
321
 
322
+ A MiniRacer context can also be dumped in a heapsnapshot file using `#write_heap_snapshot(file_or_io)`
323
+
324
+ ```ruby
325
+ context = MiniRacer::Context.new(timeout: 5)
326
+ context.eval("let a='testing';")
327
+ context.write_heap_snapshot("test.heapsnapshot")
328
+ ```
329
+
330
+ This file can then be loaded in the memory tab of the chrome dev console.
331
+
317
332
  ### Function call
318
333
 
319
334
  This calls the function passed as first argument:
@@ -451,7 +466,7 @@ Add this to your .travis.yml file:
451
466
 
452
467
  ## Contributing
453
468
 
454
- 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.
469
+ 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.
455
470
 
456
471
 
457
472
  ## License
data/Rakefile CHANGED
@@ -1,75 +1,57 @@
1
1
  require "bundler/gem_tasks"
2
2
  require "rake/testtask"
3
3
  require "rake/extensiontask"
4
+ require "shellwords"
5
+
6
+ class ValgrindTestTask < Rake::TestTask
7
+ VALGRIND_EXEC = 'valgrind'
8
+ DEFAULT_VALGRIND_OPTS = %w{
9
+ --trace-children=yes
10
+ --partial-loads-ok=yes
11
+ --error-limit=no
12
+ --error-exitcode=33
13
+ --num-callers=100
14
+ --suppressions=valgrind.supp
15
+ --gen-suppressions=all
16
+ }
17
+
18
+ attr_accessor :valgrind_args
19
+
20
+ def initialize(name=:valgrind_test)
21
+ @valgrind_args = DEFAULT_VALGRIND_OPTS
22
+ super
23
+ end
4
24
 
5
- Rake::TestTask.new(:test) do |t|
6
- t.libs << "test"
7
- t.libs << "lib"
8
- t.test_files = FileList['test/**/*_test.rb']
9
- end
10
-
11
- task :default => [:compile, :test]
12
-
13
- gem = Gem::Specification.load( File.dirname(__FILE__) + '/sq_mini_racer.gemspec' )
14
- Rake::ExtensionTask.new( 'mini_racer_extension', gem ) do |ext|
15
- ext.name = 'sq_mini_racer_extension'
16
- end
17
- Rake::ExtensionTask.new('prv_ext_loader', gem)
18
-
19
-
20
- # via http://blog.flavorjon.es/2009/06/easily-valgrind-gdb-your-ruby-c.html
21
- namespace :test do
22
- desc "run test suite with Address Sanitizer"
23
- task :asan do
24
- ENV["CONFIGURE_ARGS"] = [ENV["CONFIGURE_ARGS"], '--enable-asan'].compact.join(' ')
25
- Rake::Task['compile'].invoke
26
-
27
- asan_path = `ldconfig -N -p |grep libasan | grep -v 32 | sed 's/.* => \\(.*\\)$/\\1/'`.chomp.split("\n")[-1]
28
-
29
-
30
- cmdline = "env LD_PRELOAD=\"#{asan_path}\" ruby test/test_leak.rb"
31
- puts cmdline
32
- system cmdline
33
-
34
- cmdline = "env LD_PRELOAD=\"#{asan_path}\" rake test"
35
- puts cmdline
36
- system cmdline
25
+ # see original def in fileutils.rb
26
+ def ruby(*args, &block)
27
+ options = (Hash === args.last) ? args.pop : {}
28
+ if args.length > 1
29
+ sh(*([VALGRIND_EXEC] + valgrind_args + [RUBY] + args + [options]), &block)
30
+ else
31
+ # if the size is 1 it's assumed the arguments are already escaped
32
+ non_escaped_args = [VALGRIND_EXEC] + valgrind_args + [RUBY]
33
+ sh("#{non_escaped_args.map { |s| Shellwords.escape(s) }.join(' ')} #{args.first}", options, &block)
37
34
  end
38
- # partial-loads-ok and undef-value-errors necessary to ignore
39
- # spurious (and eminently ignorable) warnings from the ruby
40
- # interpreter
41
- VALGRIND_BASIC_OPTS = "--num-callers=50 --error-limit=no \
42
- --partial-loads-ok=yes --undef-value-errors=no"
35
+ end
36
+ end
43
37
 
44
- desc "run test suite under valgrind with basic ruby options"
45
- task :valgrind => :compile do
46
- cmdline = "valgrind #{VALGRIND_BASIC_OPTS} ruby test/test_leak.rb"
47
- puts cmdline
48
- system cmdline
38
+ test_task_cfg = Proc.new do |t|
39
+ t.libs << 'test'
40
+ t.libs << 'lib'
41
+ t.test_files = FileList['test/**/*_test.rb']
49
42
  end
50
43
 
51
- desc "run test suite under valgrind with leak-check=full"
52
- task :valgrind_leak_check => :compile do
53
- cmdline = "valgrind #{VALGRIND_BASIC_OPTS} --leak-check=full ruby test/test_leak.rb"
54
- puts cmdline
55
- require 'open3'
56
- _, stderr = Open3.capture3(cmdline)
44
+ Rake::TestTask.new(:test, &test_task_cfg)
45
+ ValgrindTestTask.new(:'test:valgrind', &test_task_cfg)
57
46
 
58
- section = ""
59
- stderr.split("\n").each do |line|
47
+ task :default => [:compile, :test]
60
48
 
61
- if line =~ /==.*==\s*$/
62
- if (section =~ /mini_racer|SUMMARY/)
63
- puts
64
- puts section
65
- puts
66
- end
67
- section = ""
68
- else
69
- section << line << "\n"
70
- end
71
- end
72
- end
49
+ gem = Gem::Specification.load( File.dirname(__FILE__) + '/mini_racer.gemspec' )
50
+ Rake::ExtensionTask.new( 'mini_racer_loader', gem ) do |ext|
51
+ ext.name = 'sq_mini_racer_loader'
52
+ end
53
+ Rake::ExtensionTask.new( 'mini_racer_extension', gem ) do |ext|
54
+ ext.name = 'sq_mini_racer_extension'
73
55
  end
74
56
 
75
57
  desc 'run clang-tidy linter on mini_racer_extension.cc'
@@ -0,0 +1,69 @@
1
+ jobs:
2
+ - template: azure-template.yml
3
+ parameters:
4
+ name: linux_2_0
5
+ displayName: Linux Ruby 2.0
6
+ rubyVersion: '2.0'
7
+ publishCoverage: true
8
+
9
+ - template: azure-template.yml
10
+ parameters:
11
+ name: linux_2_1
12
+ displayName: Linux Ruby 2.1
13
+ rubyVersion: '2.1'
14
+
15
+ - template: azure-template.yml
16
+ parameters:
17
+ name: linux_2_2
18
+ displayName: Linux Ruby 2.2
19
+ rubyVersion: '2.2'
20
+
21
+ - template: azure-template.yml
22
+ parameters:
23
+ name: linux_2_3
24
+ displayName: Linux Ruby 2.3
25
+ rubyVersion: '2.3'
26
+
27
+ - template: azure-template.yml
28
+ parameters:
29
+ name: linux_2_4
30
+ displayName: Linux Ruby 2.4
31
+ rubyVersion: '2.4'
32
+
33
+ - template: azure-template.yml
34
+ parameters:
35
+ name: linux_2_5
36
+ displayName: Linux Ruby 2.5
37
+ rubyVersion: '2.5'
38
+
39
+ - template: azure-template.yml
40
+ parameters:
41
+ name: linux_2_6
42
+ displayName: Linux Ruby 2.6
43
+ rubyVersion: '2.6'
44
+
45
+ - template: azure-template.yml
46
+ parameters:
47
+ name: linux_2_7
48
+ displayName: Linux Ruby 2.7
49
+ rubyVersion: '2.7'
50
+
51
+ - template: azure-template.yml
52
+ parameters:
53
+ name: linux_2_7_mini_racer
54
+ displayName: Linux Ruby 2.7 (with mini_racer)
55
+ rubyVersion: '2.7'
56
+ with_mini_racer: true
57
+
58
+ - template: azure-template.yml
59
+ parameters:
60
+ name: linux_2_7_therubyracer
61
+ displayName: Linux Ruby 2.7 (with therubyracer)
62
+ rubyVersion: '2.7'
63
+ with_therubyracer: true
64
+
65
+ - template: azure-template.yml
66
+ parameters:
67
+ name: macos_10_15
68
+ displayName: MacOS 10.15
69
+ imageName: 'macos-10.15'
@@ -0,0 +1,101 @@
1
+ parameters:
2
+ name: ~
3
+ displayName: ~
4
+ rubyVersion: bundled
5
+ imageName: ubuntu-18.04
6
+ publishCoverage: false
7
+ with_mini_racer: false
8
+ with_therubyracer: false
9
+
10
+ jobs:
11
+ - job: ${{ parameters.name }}
12
+ displayName: ${{ parameters.displayName }}
13
+ pool:
14
+ vmImage: ${{ parameters.imageName }}
15
+
16
+ variables:
17
+ TESTOPTS: -v
18
+ ${{ if eq(parameters.publishCoverage, true) }}:
19
+ CPPFLAGS: --coverage
20
+ LDFLAGS: --coverage
21
+ ${{ if eq(parameters.rubyVersion, 'bundled') }}:
22
+ gem: gem
23
+ bundle: bundle
24
+ ${{ if ne(parameters.rubyVersion, 'bundled') }}:
25
+ gem: /opt/ruby/${{ parameters.rubyVersion }}/bin/gem
26
+ bundle: /opt/ruby/${{ parameters.rubyVersion }}/bin/bundle
27
+ GEM_HOME: /opt/ruby/${{ parameters.rubyVersion }}/lib/ruby/gems/${{ parameters.rubyVersion }}.0
28
+
29
+ steps:
30
+ - checkout: self
31
+ displayName: Checkout
32
+ clean: true
33
+ submodules: recursive
34
+
35
+ - ${{ if ne(parameters.rubyVersion, 'bundled') }}:
36
+ - script: |
37
+ sudo apt-get install -y gnupg
38
+ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 5D98E7264E3F3D89463B314B12229434A9F003C9
39
+ echo deb [arch=amd64] http://sqreen-download-private.s3.amazonaws.com/deb bionic main | sudo tee -a /etc/apt/sources.list
40
+ sudo apt-get update
41
+ sudo apt-get install -y sq-ruby${{ parameters.rubyVersion }} ruby-
42
+ displayName: Install Ruby
43
+
44
+ - ${{ if eq(parameters.rubyVersion, 'bundled') }}:
45
+ - script: sudo $(gem) install bundler --version '< 2.0' --no-document
46
+ displayName: Install bundler
47
+
48
+ - ${{ if eq(parameters.imageName, 'ubuntu-18.04') }}:
49
+ - script: |
50
+ sudo apt-get install -y build-essential git curl valgrind g++ make
51
+ displayName: Install Linux packages
52
+
53
+ - script: $(bundle) install --path vendor/bundle
54
+ displayName: Install gem dependencies
55
+ env:
56
+ ${{ if eq(parameters.with_mini_racer, true) }}:
57
+ LOAD_MINI_RACER: 1
58
+ ${{ if eq(parameters.with_therubyracer, true) }}:
59
+ LOAD_THERUBYRACER: 1
60
+
61
+ - script: PATH=`dirname $(bundle)`:$PATH CPPFLAGS=$(CPPFLAGS) LDFLAGS=$(LDFLAGS) $(bundle) exec rake compile
62
+ displayName: Compile extension
63
+
64
+ - script: |
65
+ find . -name '*.log' -exec cat '{}' \;
66
+ displayName: Print logs
67
+ condition: failed()
68
+
69
+ - script: TESTOPTS=--junit $(bundle) exec rake test
70
+ displayName: Run tests
71
+ env:
72
+ ${{ if eq(parameters.with_mini_racer, true) }}:
73
+ LOAD_MINI_RACER: 1
74
+ ${{ if eq(parameters.with_therubyracer, true) }}:
75
+ LOAD_THERUBYRACER: 1
76
+
77
+ - task: PublishTestResults@2
78
+ displayName: Publish test results
79
+ condition: succeededOrFailed()
80
+ inputs:
81
+ testResultsFormat: 'JUnit'
82
+ testResultsFiles: '**/report.xml'
83
+ searchFolder: '$(System.DefaultWorkingDirectory)'
84
+ mergeTestResults: true
85
+
86
+ - ${{ if and(eq(parameters.imageName, 'ubuntu-18.04'), eq(parameters.with_mini_racer, false), eq(parameters.with_therubyracer, false)) }}:
87
+ - script: $(bundle) exec rake test:valgrind
88
+ displayName: Run tests w/ valgrind
89
+
90
+ - script: |
91
+ PATH=$PATH:$(dirname $(which $(gem)))
92
+ $(bundle) exec rake build
93
+ sudo PATH=$PATH $(gem) install pkg/*.gem
94
+ displayName: Check that the gem is installable
95
+
96
+ - ${{ if eq(parameters.publishCoverage, true) }}:
97
+ - bash: >
98
+ test -z "$CODECOV_TOKEN" || bash <(curl -s https://codecov.io/bash)
99
+ displayName: "Publish coverage (Codecov)"
100
+ env:
101
+ CODECOV_TOKEN: $(CODECOV_TOKEN)