mini_racer 0.17.0.pre5 → 0.17.0.pre7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +9 -0
- data/README.md +7 -38
- data/ext/mini_racer_extension/extconf.rb +2 -0
- data/ext/mini_racer_extension/mini_racer_extension.c +1564 -0
- data/ext/mini_racer_extension/mini_racer_v8.cc +822 -0
- data/ext/mini_racer_extension/mini_racer_v8.h +56 -0
- data/ext/mini_racer_extension/serde.c +747 -0
- data/lib/mini_racer/shared.rb +380 -0
- data/lib/mini_racer/truffleruby.rb +32 -9
- data/lib/mini_racer/version.rb +1 -1
- data/lib/mini_racer.rb +14 -389
- metadata +11 -7
- data/ext/mini_racer_extension/mini_racer_extension.cc +0 -1942
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d058a397309a0e5354576fa25b299f26e9ca9576b23333063dbcd46fcf9f775
|
4
|
+
data.tar.gz: 3dde7c0c2e713ebb419593eb6fb0d7634f07ee4d91e35549aa9fb57987a255e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8cf3e4c85acafb8161ff8a88d193b7bfde7e2b1ab241366364306a72416f462cbd31b4886a3b1f01402557a6045fd6ad40b1837849f307df9d3ac3fafdd7c6d0
|
7
|
+
data.tar.gz: a08db269e750b147daa7501cdf38dccdee8de7d07530b0112aecd1da3949b8daab704c778f1b3657d0dea328b087db9173f30e9aeb43f9d755d4a95dd1e51bac
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
- 0.17.0.pre7 - 10-01-2025
|
2
|
+
|
3
|
+
- Objects containing non serializable properties will return an Error object vs raising an exception. Ben Noordhuis
|
4
|
+
- Truffle support was added back Eregon
|
5
|
+
|
6
|
+
- 0.17.0.pre6 - 08-01-2025
|
7
|
+
|
8
|
+
- Moved all mini_racer interaction with v8 to a dedicated native thread to avoid cross VM stack contamination. Ben Noordhuis
|
9
|
+
|
1
10
|
- 0.17.0.pre5 - 30-09-2024
|
2
11
|
|
3
12
|
- Handle segfault from JSON.stringify
|
data/README.md
CHANGED
@@ -206,58 +206,27 @@ context.eval("counter")
|
|
206
206
|
# => 1
|
207
207
|
```
|
208
208
|
|
209
|
-
###
|
209
|
+
### Garbage collection
|
210
210
|
|
211
|
-
|
211
|
+
Re-using the same context over and over again means V8's garbage collector will have to run to clean it up every now and then; it's possible to trigger a _blocking_ V8 GC run inside your context by running the `idle_notification` method on it, which takes a single argument: the amount of time (in milliseconds) that V8 should use at most for garbage collecting:
|
212
212
|
|
213
213
|
```ruby
|
214
|
-
|
215
|
-
|
216
|
-
context1 = MiniRacer::Context.new(isolate: isolate)
|
217
|
-
context2 = MiniRacer::Context.new(isolate: isolate)
|
218
|
-
|
219
|
-
context1.isolate == context2.isolate
|
220
|
-
# => true
|
221
|
-
```
|
222
|
-
|
223
|
-
The main benefit of this is avoiding creating/destroying isolates when not needed (for example if you use a lot of contexts).
|
224
|
-
|
225
|
-
The caveat with this is that a given isolate can only execute one context at a time, so don't share isolates across contexts that you want to run concurrently.
|
226
|
-
|
227
|
-
Also, note that if you want to use shared isolates together with snapshots, you need to first create an isolate with that snapshot, and then create contexts from that isolate:
|
228
|
-
|
229
|
-
```ruby
|
230
|
-
snapshot = MiniRacer::Snapshot.new("function hello() { return 'world!'; }")
|
231
|
-
|
232
|
-
isolate = MiniRacer::Isolate.new(snapshot)
|
233
|
-
|
234
|
-
context = MiniRacer::Context.new(isolate: isolate)
|
235
|
-
|
236
|
-
context.eval("hello()")
|
237
|
-
# => "world!"
|
238
|
-
```
|
239
|
-
|
240
|
-
Re-using the same isolate over and over again means V8's garbage collector will have to run to clean it up every now and then; it's possible to trigger a _blocking_ V8 GC run inside your isolate by running the `idle_notification` method on it, which takes a single argument: the amount of time (in milliseconds) that V8 should use at most for garbage collecting:
|
241
|
-
|
242
|
-
```ruby
|
243
|
-
isolate = MiniRacer::Isolate.new
|
244
|
-
|
245
|
-
context = MiniRacer::Context.new(isolate: isolate)
|
214
|
+
context = MiniRacer::Context.new
|
246
215
|
|
247
216
|
# do stuff with that context...
|
248
217
|
|
249
218
|
# give up to 100ms for V8 garbage collection
|
250
|
-
|
219
|
+
context.idle_notification(100)
|
251
220
|
|
252
221
|
# force V8 to perform a full GC
|
253
|
-
|
222
|
+
context.low_memory_notification
|
254
223
|
```
|
255
224
|
|
256
225
|
This can come in handy to force V8 GC runs for example in between requests if you use MiniRacer on a web application.
|
257
226
|
|
258
227
|
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.`
|
259
228
|
|
260
|
-
Additionally you may automate this process on a context by defining it with `MiniRacer::
|
229
|
+
Additionally you may automate this process on a context by defining it with `MiniRacer::Context.new(ensure_gc_after_idle: 1000)`. Using this will ensure V8 will run a full GC using `context.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 contexts use minimal amounts of memory.
|
261
230
|
|
262
231
|
### V8 Runtime flags
|
263
232
|
|
@@ -301,7 +270,7 @@ Please refer to http://node.green/ as a reference on other harmony features.
|
|
301
270
|
|
302
271
|
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).
|
303
272
|
|
304
|
-
Note that runtime flags must be set before any other operation (e.g. creating a context
|
273
|
+
Note that runtime flags must be set before any other operation (e.g. creating a context or a snapshot), otherwise an exception will be thrown.
|
305
274
|
|
306
275
|
Flags:
|
307
276
|
|