mini_racer 0.19.1 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG +6 -0
- data/README.md +19 -0
- data/ext/mini_racer_extension/mini_racer_extension.c +39 -0
- data/lib/mini_racer/version.rb +2 -2
- metadata +7 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5aa16bf587a6e12df562d7a946ce3a965a8444debd9769b376075cafd10a3b5c
|
|
4
|
+
data.tar.gz: 5aaf6a08ae90f05bc554bae0a06e93efce5318d00aacdfe959f36513533caac4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2b2641ceb0fd1770efd32cfb9e37aee92ca857ad6acbe2129157a58be9ed6bbef4a355c5af133f5749f229d578e10a452ef77a62eadbe436993f005146d242cd
|
|
7
|
+
data.tar.gz: 3264e95d4951aa52ba080a94b847c5080705e1de0e3dd5fefae0786342ccece850b00db4f151220e65068e9e5d62fb0eebae0fda65e79647196903fae70d8012
|
data/CHANGELOG
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
- 0.20.0 - 24-02-2026
|
|
2
|
+
- Add Snapshot.load to restore snapshots from binary data, enabling disk persistence
|
|
3
|
+
|
|
4
|
+
- 0.19.2 - 24-12-2025
|
|
5
|
+
- upgrade to node 24.12.0
|
|
6
|
+
|
|
1
7
|
- 0.19.1 - 20-10-2025
|
|
2
8
|
- JS code can now catch ruby exceptions - Ben Noordhuis
|
|
3
9
|
- Retain string encoding when raising exceptions - Ben Noordhuis
|
data/README.md
CHANGED
|
@@ -193,6 +193,25 @@ context.eval("counter")
|
|
|
193
193
|
# => 1
|
|
194
194
|
```
|
|
195
195
|
|
|
196
|
+
Snapshots can also be persisted to disk for faster startup:
|
|
197
|
+
|
|
198
|
+
```ruby
|
|
199
|
+
# Save a snapshot to disk
|
|
200
|
+
snapshot = MiniRacer::Snapshot.new('var foo = "bar";')
|
|
201
|
+
File.binwrite("snapshot.bin", snapshot.dump)
|
|
202
|
+
|
|
203
|
+
# Load it back in a later process
|
|
204
|
+
blob = File.binread("snapshot.bin")
|
|
205
|
+
snapshot = MiniRacer::Snapshot.load(blob)
|
|
206
|
+
context = MiniRacer::Context.new(snapshot: snapshot)
|
|
207
|
+
context.eval("foo")
|
|
208
|
+
# => "bar"
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
Note that snapshots are architecture and V8-version specific. A snapshot created on one platform (e.g., ARM64 macOS) cannot be loaded on a different platform (e.g., x86_64 Linux). Snapshots are best used for same-machine caching or homogeneous deployment environments.
|
|
212
|
+
|
|
213
|
+
**Security note:** Only load snapshots from trusted sources. V8 snapshots are not designed to be safely loaded from untrusted input—malformed or malicious snapshot data may cause crashes or memory corruption.
|
|
214
|
+
|
|
196
215
|
### Garbage collection
|
|
197
216
|
|
|
198
217
|
You can make the garbage collector more aggressive by defining the context 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 notifications ensure long living contexts use minimal amounts of memory.
|
|
@@ -6,6 +6,30 @@
|
|
|
6
6
|
#include <pthread.h>
|
|
7
7
|
#include <math.h>
|
|
8
8
|
|
|
9
|
+
#if defined(__linux__) && !defined(__GLIBC__)
|
|
10
|
+
// musl compatibility for glibc-linked libraries (e.g. libv8-node)
|
|
11
|
+
// some versions of libv8-node are accidentally linked against glibc symbols
|
|
12
|
+
// or compiled with a toolchain that emits these C23 compatibility symbols
|
|
13
|
+
unsigned long long __isoc23_strtoull(const char *nptr, char **endptr, int base) {
|
|
14
|
+
return strtoull(nptr, endptr, base);
|
|
15
|
+
}
|
|
16
|
+
unsigned long __isoc23_strtoul(const char *nptr, char **endptr, int base) {
|
|
17
|
+
return strtoul(nptr, endptr, base);
|
|
18
|
+
}
|
|
19
|
+
long long __isoc23_strtoll(const char *nptr, char **endptr, int base) {
|
|
20
|
+
return strtoll(nptr, endptr, base);
|
|
21
|
+
}
|
|
22
|
+
long __isoc23_strtol(const char *nptr, char **endptr, int base) {
|
|
23
|
+
return strtol(nptr, endptr, base);
|
|
24
|
+
}
|
|
25
|
+
double __isoc23_strtod(const char *nptr, char **endptr) {
|
|
26
|
+
return strtod(nptr, endptr);
|
|
27
|
+
}
|
|
28
|
+
float __isoc23_strtof(const char *nptr, char **endptr) {
|
|
29
|
+
return strtof(nptr, endptr);
|
|
30
|
+
}
|
|
31
|
+
#endif
|
|
32
|
+
|
|
9
33
|
#include "ruby.h"
|
|
10
34
|
#include "ruby/encoding.h"
|
|
11
35
|
#include "ruby/version.h"
|
|
@@ -1666,6 +1690,20 @@ static VALUE snapshot_dump(VALUE self)
|
|
|
1666
1690
|
return ss->blob;
|
|
1667
1691
|
}
|
|
1668
1692
|
|
|
1693
|
+
static VALUE snapshot_load(VALUE klass, VALUE blob)
|
|
1694
|
+
{
|
|
1695
|
+
Snapshot *ss;
|
|
1696
|
+
VALUE self;
|
|
1697
|
+
|
|
1698
|
+
Check_Type(blob, T_STRING);
|
|
1699
|
+
self = snapshot_alloc(klass);
|
|
1700
|
+
TypedData_Get_Struct(self, Snapshot, &snapshot_type, ss);
|
|
1701
|
+
ss->blob = rb_str_dup(blob);
|
|
1702
|
+
rb_enc_associate(ss->blob, rb_ascii8bit_encoding());
|
|
1703
|
+
ENC_CODERANGE_SET(ss->blob, ENC_CODERANGE_VALID);
|
|
1704
|
+
return self;
|
|
1705
|
+
}
|
|
1706
|
+
|
|
1669
1707
|
static VALUE snapshot_size0(VALUE self)
|
|
1670
1708
|
{
|
|
1671
1709
|
Snapshot *ss;
|
|
@@ -1718,6 +1756,7 @@ void Init_mini_racer_extension(void)
|
|
|
1718
1756
|
rb_define_method(c, "warmup!", snapshot_warmup, 1);
|
|
1719
1757
|
rb_define_method(c, "dump", snapshot_dump, 0);
|
|
1720
1758
|
rb_define_method(c, "size", snapshot_size0, 0);
|
|
1759
|
+
rb_define_singleton_method(c, "load", snapshot_load, 1);
|
|
1721
1760
|
rb_define_alloc_func(c, snapshot_alloc);
|
|
1722
1761
|
|
|
1723
1762
|
c = rb_define_class_under(m, "Platform", rb_cObject);
|
data/lib/mini_racer/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mini_racer
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.20.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sam Saffron
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-02-24 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -100,14 +100,14 @@ dependencies:
|
|
|
100
100
|
requirements:
|
|
101
101
|
- - "~>"
|
|
102
102
|
- !ruby/object:Gem::Version
|
|
103
|
-
version: 24.
|
|
103
|
+
version: 24.12.0.1
|
|
104
104
|
type: :runtime
|
|
105
105
|
prerelease: false
|
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
|
107
107
|
requirements:
|
|
108
108
|
- - "~>"
|
|
109
109
|
- !ruby/object:Gem::Version
|
|
110
|
-
version: 24.
|
|
110
|
+
version: 24.12.0.1
|
|
111
111
|
description: Minimal embedded v8 engine for Ruby
|
|
112
112
|
email:
|
|
113
113
|
- sam.saffron@gmail.com
|
|
@@ -137,9 +137,9 @@ licenses:
|
|
|
137
137
|
- MIT
|
|
138
138
|
metadata:
|
|
139
139
|
bug_tracker_uri: https://github.com/discourse/mini_racer/issues
|
|
140
|
-
changelog_uri: https://github.com/discourse/mini_racer/blob/v0.
|
|
141
|
-
documentation_uri: https://www.rubydoc.info/gems/mini_racer/0.
|
|
142
|
-
source_code_uri: https://github.com/discourse/mini_racer/tree/v0.
|
|
140
|
+
changelog_uri: https://github.com/discourse/mini_racer/blob/v0.20.0/CHANGELOG
|
|
141
|
+
documentation_uri: https://www.rubydoc.info/gems/mini_racer/0.20.0
|
|
142
|
+
source_code_uri: https://github.com/discourse/mini_racer/tree/v0.20.0
|
|
143
143
|
post_install_message:
|
|
144
144
|
rdoc_options: []
|
|
145
145
|
require_paths:
|