sqreen 1.10.1 → 1.10.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: 04735d805b8ea864d96c46e800a897b8a9721189f0ba85aed0d5d299cb6e7907
4
- data.tar.gz: 283e87804132bdbeac132989113bd352f71b0e359a55dbffdb577748466ab5b2
3
+ metadata.gz: 3129e4afc077e7ca7afbe1704c49e3584fc8677de552575307f28d1a11e2a71e
4
+ data.tar.gz: 6a84e5d01b162c304195e50e13b32d301d9faa5190fcfe7d2ebc657e66f7ed25
5
5
  SHA512:
6
- metadata.gz: 409bea4a589bf468b0a1d28024137d9ff19c2a7b2a967b7a7e8c21f963ab71085085b7cdacb1eecdc84303d4774a7b89ce0476dd9b2dfdc36349127c16f4ccbb
7
- data.tar.gz: e9c396aa040c4c57760e8a27c9ea5caa168da52c4a21c134d565696f801f3c63be4dbbe0888b8cf7ae911f3cb839083dcb85f033d6876a3eb1e3b7f56ee6db0d
6
+ metadata.gz: e5b855e58472a20f7f190b37e6c7dce6dd36ca3117dd80b9ff8b406fb5c24c7e99713ad11d14833f0887c2af8497971ca0d0a5c3d93069987175f95b414a2956
7
+ data.tar.gz: 305d5048bbbe5df8d6c9b21c26fae636a6aa6738a77adf8dcc87ff08575b893e7dacb546d4d695ca36b838e9b69cfa0a54410e4ae90ddc5daa0e3da515726e43
@@ -3,14 +3,15 @@
3
3
 
4
4
  if defined?(::JRUBY_VERSION)
5
5
  require 'rhino'
6
- SQREEN_V8_THREAD = false
6
+ SQREEN_MINI_RACER = false
7
7
  else
8
8
  begin
9
9
  require 'mini_racer'
10
- SQREEN_V8_THREAD = true
10
+ SQREEN_MINI_RACER = true
11
+ GC_MINI_RACER = 10000
11
12
  rescue LoadError
12
13
  require 'therubyracer'
13
- SQREEN_V8_THREAD = false
14
+ SQREEN_MINI_RACER = false
14
15
  end
15
16
  end
16
17
 
@@ -40,9 +41,10 @@ module Sqreen
40
41
  end
41
42
 
42
43
  build_runnable(callbacks)
43
- if !SQREEN_V8_THREAD
44
+ if !SQREEN_MINI_RACER
44
45
  @compiled = ExecJS.compile(@source)
45
46
  else
47
+ @snapshot = MiniRacer::Snapshot.new(@source)
46
48
  @runtimes = []
47
49
  end
48
50
  @restrict_max_depth = 20
@@ -146,11 +148,23 @@ module Sqreen
146
148
  end
147
149
 
148
150
  def call_callback(name, inst, args, rv = nil)
149
- if SQREEN_V8_THREAD
150
- if Thread.current["SQREEN_EXECJS_SOURCE#{self.object_id}"].nil? || !Thread.current["SQREEN_EXECJS_SOURCE#{self.object_id}"].weakref_alive?
151
- runtime = ExecJS.compile(@source)
151
+ if SQREEN_MINI_RACER
152
+ mini_racer_context = Thread.current["SQREEN_MINI_RACER_CONTEXT_#{self.object_id}"]
153
+ if mini_racer_context.nil? || mini_racer_context[:r].nil? || !mini_racer_context[:r].weakref_alive?
154
+ runtime = MiniRacer::Context.new(snapshot: @snapshot)
152
155
  @runtimes.push runtime
153
- Thread.current["SQREEN_EXECJS_SOURCE#{self.object_id}"] = WeakRef.new(runtime)
156
+ Thread.current["SQREEN_MINI_RACER_CONTEXT_#{self.object_id}"] = {:c => 0, :r => WeakRef.new(runtime)}
157
+ elsif mini_racer_context[:c] >= GC_MINI_RACER
158
+ @runtimes.delete(mini_racer_context[:r])
159
+ mini_racer_context[:r].dispose
160
+
161
+ new_runtime = MiniRacer::Context.new(snapshot: @snapshot)
162
+ @runtimes.push new_runtime
163
+
164
+ Thread.current["SQREEN_MINI_RACER_CONTEXT_#{self.object_id}"] = {
165
+ :c => 0,
166
+ :r => WeakRef.new(new_runtime)
167
+ }
154
168
  end
155
169
  end
156
170
  ret = nil
@@ -162,8 +176,10 @@ module Sqreen
162
176
  end
163
177
  arguments = restrict(name, arguments) if @conditions.key?(name)
164
178
  Sqreen.log.debug { [name, arguments].inspect }
165
- if SQREEN_V8_THREAD
166
- ret = Thread.current["SQREEN_EXECJS_SOURCE#{self.object_id}"].call(name, *arguments)
179
+ if SQREEN_MINI_RACER
180
+ mini_racer_context = Thread.current["SQREEN_MINI_RACER_CONTEXT_#{self.object_id}"]
181
+ mini_racer_context[:c] += 1
182
+ ret = mini_racer_context[:r].eval("#{name}.apply(this, #{::JSON.generate(arguments)})")
167
183
  else
168
184
  ret = @compiled.call(name, *arguments)
169
185
  end
@@ -1,5 +1,5 @@
1
1
  # Copyright (c) 2015 Sqreen. All Rights Reserved.
2
2
  # Please refer to our terms for more information: https://www.sqreen.io/terms.html
3
3
  module Sqreen
4
- VERSION = '1.10.1'.freeze
4
+ VERSION = '1.10.2'.freeze
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sqreen
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.10.1
4
+ version: 1.10.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sqreen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-14 00:00:00.000000000 Z
11
+ date: 2018-02-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: execjs