sqreen 1.10.1-java → 1.10.2-java

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: 2769174da57177a2fb014d06f5c810f35d1b011e0b84640b935079f83bc01153
4
- data.tar.gz: 06be029bc2497b2e1f5eb2f6993f09c4f0ad0dae8597ecd62e1d7ec6b3470f54
3
+ metadata.gz: 2277eaa2d49d4308c33a920b5faf831445067e4bce6e46a745211c511f59e318
4
+ data.tar.gz: 510b43dd0c0b70cec0c6423bb7090321e7f64ffdd8189d7fc799d6f0ed6d0ad3
5
5
  SHA512:
6
- metadata.gz: 19804e889ab4f9aadacaac5d87805c2bb7873f62f95b30829367752a224a7ec9f12d4a31ebccde3ffda21584c6483473c17dfe18c573ec4f393f9e3f1e17fead
7
- data.tar.gz: c85dea9e1a61cfb25dcb278213fbb344344f4a5932425b49b80d8375d75a68a7c4042af88d5d700ec65945246014fe14e48f1ceee9eb125d4e3472d3e3ad9909
6
+ metadata.gz: 344b5bb85b8d5c5b1d42c46bb853e2b3163450a513c0c05c27dac4141c0c621678a550722e20528d8e40de4a1e76b97e378ca426cfd7dd655e102c57fddeb200
7
+ data.tar.gz: 1f1de62a20ce2e3afc39969ef53459b9b5b8a25ef9ceb4fc7d88c947bc424693d1d75dea9ed4c02fbf234afe7dde54639a850f2b8bdb91df2f0eb3bc0f17a9ca
@@ -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: java
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