rusty_racer 0.1.1 → 0.1.3
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/README.md +73 -0
- data/ext/rusty_racer/Cargo.toml +1 -1
- data/ext/rusty_racer/src/lib.rs +137 -2232
- data/ext/rusty_racer/src/marshal.rs +798 -0
- data/ext/rusty_racer/src/ops.rs +1061 -0
- data/ext/rusty_racer/src/stack.rs +292 -0
- data/ext/rusty_racer/src/watchdog.rs +236 -0
- data/lib/rusty_racer/execjs.rb +118 -0
- data/lib/rusty_racer/version.rb +1 -1
- data/lib/rusty_racer.rb +13 -3
- metadata +13 -4
data/lib/rusty_racer.rb
CHANGED
|
@@ -27,6 +27,10 @@ module RustyRacer
|
|
|
27
27
|
class ParseError < EvalError; end
|
|
28
28
|
class RuntimeError < EvalError; end
|
|
29
29
|
class ScriptTerminatedError < EvalError; end
|
|
30
|
+
# Raised when JS allocation exceeds the isolate's memory_limit. Catchable like
|
|
31
|
+
# any eval error — a runaway script fails its own eval instead of aborting the
|
|
32
|
+
# process. The space-axis twin of ScriptTerminatedError (the time axis).
|
|
33
|
+
class V8OutOfMemoryError < EvalError; end
|
|
30
34
|
class SnapshotError < Error; end
|
|
31
35
|
class PlatformAlreadyInitialized < Error; end
|
|
32
36
|
|
|
@@ -41,16 +45,22 @@ module RustyRacer
|
|
|
41
45
|
# Keyword-arg constructor over the positional Rust primitive. A snapshot
|
|
42
46
|
# (RustyRacer::Snapshot) boots the isolate with its baked-in state;
|
|
43
47
|
# timeout_ms caps each eval/call (0 = no limit) against in-V8 infinite
|
|
44
|
-
# loops.
|
|
48
|
+
# loops. memory_limit caps the V8 heap in bytes (0 = no limit): a script
|
|
49
|
+
# that exceeds it is terminated and raises V8OutOfMemoryError rather than
|
|
50
|
+
# aborting the process, and the isolate stays usable afterward. It is a soft
|
|
51
|
+
# limit — V8 enforces it at GC granularity, so usage may briefly overshoot,
|
|
52
|
+
# and it must comfortably exceed the isolate's baseline (and any snapshot's
|
|
53
|
+
# baked-in heap), since the limit is only armed once the isolate has booted.
|
|
54
|
+
# microtasks mirrors V8's kAuto/kExplicit: :auto (default) drains
|
|
45
55
|
# the microtask queue when the outermost eval/call/run/evaluate completes
|
|
46
56
|
# (the standard embedder contract); :explicit drains only on
|
|
47
57
|
# #perform_microtask_checkpoint.
|
|
48
|
-
def self.new(host_namespace: nil, snapshot: nil, timeout_ms: 0, microtasks: :auto)
|
|
58
|
+
def self.new(host_namespace: nil, snapshot: nil, timeout_ms: 0, memory_limit: 0, microtasks: :auto)
|
|
49
59
|
unless %i[auto explicit].include?(microtasks)
|
|
50
60
|
raise ArgumentError, "microtasks must be :auto or :explicit, got #{microtasks.inspect}"
|
|
51
61
|
end
|
|
52
62
|
|
|
53
|
-
_new(host_namespace, snapshot, timeout_ms, microtasks == :explicit)
|
|
63
|
+
_new(host_namespace, snapshot, timeout_ms, memory_limit, microtasks == :explicit)
|
|
54
64
|
end
|
|
55
65
|
|
|
56
66
|
# ->(specifier, referrer_url, context) { Module } for JS import(). |context|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rusty_racer
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Keita Urashima
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-06-
|
|
11
|
+
date: 2026-06-14 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rb_sys
|
|
@@ -25,7 +25,8 @@ dependencies:
|
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
26
|
version: '0.9'
|
|
27
27
|
description: 'A V8 engine for Ruby built on rusty_v8 and Magnus: eval, host functions,
|
|
28
|
-
ES modules, snapshots, realms, bytecode cache,
|
|
28
|
+
ES modules, snapshots, realms, bytecode cache, faithful value marshalling, and an
|
|
29
|
+
ExecJS adapter.'
|
|
29
30
|
email:
|
|
30
31
|
- ursm@ursm.jp
|
|
31
32
|
executables: []
|
|
@@ -39,12 +40,20 @@ files:
|
|
|
39
40
|
- ext/rusty_racer/Cargo.toml
|
|
40
41
|
- ext/rusty_racer/extconf.rb
|
|
41
42
|
- ext/rusty_racer/src/lib.rs
|
|
43
|
+
- ext/rusty_racer/src/marshal.rs
|
|
44
|
+
- ext/rusty_racer/src/ops.rs
|
|
45
|
+
- ext/rusty_racer/src/stack.rs
|
|
46
|
+
- ext/rusty_racer/src/watchdog.rs
|
|
42
47
|
- lib/rusty_racer.rb
|
|
48
|
+
- lib/rusty_racer/execjs.rb
|
|
43
49
|
- lib/rusty_racer/version.rb
|
|
44
50
|
homepage: https://github.com/ursm/rusty_racer
|
|
45
51
|
licenses:
|
|
46
52
|
- MIT
|
|
47
|
-
metadata:
|
|
53
|
+
metadata:
|
|
54
|
+
source_code_uri: https://github.com/ursm/rusty_racer
|
|
55
|
+
bug_tracker_uri: https://github.com/ursm/rusty_racer/issues
|
|
56
|
+
rubygems_mfa_required: 'true'
|
|
48
57
|
post_install_message:
|
|
49
58
|
rdoc_options: []
|
|
50
59
|
require_paths:
|