Class: RustyRacer::Context
- Inherits:
-
Object
- Object
- RustyRacer::Context
- Defined in:
- lib/rusty_racer.rb
Overview
A v8::Context (realm) handed out by an Isolate: where JS actually runs.
Instance Method Summary collapse
-
#compile(source, filename: '<compile>', cached_data: nil, produce_cache: false, eager: false) ⇒ Object
Compile a classic
Compile a classic
Compile an ES module; returns a RustyRacer::Module to instantiate/evaluate. cached_data: a binary bytecode cache to consume (skip reparse); the result reports #cache_rejected? if stale. produce_cache: collect a fresh cache, readable via Module#cached_data for cross-process reuse.
eager: (default false) compiles every function up front (CompileOptions::EagerCompile) instead of V8's default lazy top-level-only compile. It roughly doubles compile time and uses more memory, so it's only worth it when producing a cache to reuse. Ignored when cached_data: is given (V8 forbids consuming a cache and eager-compiling at once). NOTE: as of V8-150, create_code_cache at compile time still doesn't serialize the eager inner functions, so eager: alone doesn't change the cache yet — it's a forward-looking, semantically-correct switch. For a cache that DOES carry inner functions, run the script/module and call #create_code_cache.
150 151 152
# File 'lib/rusty_racer.rb', line 150 def compile_module(source, filename: '<compile_module>', cached_data: nil, produce_cache: false, eager: false) _compile_module(source, filename, cached_data, produce_cache, eager) end
#eval(source, timeout_ms: 0, filename: '<eval>') ⇒ Object
timeout_ms(0 = the isolate default) caps this eval;filenamenames the script in stack traces and parse-error locations.114 115 116
# File 'lib/rusty_racer.rb', line 114 def eval(source, timeout_ms: 0, filename: '<eval>') _eval(source, timeout_ms, filename, false) end
#eval_void(source, timeout_ms: 0, filename: '<eval>') ⇒ Object
Run
sourcefor its EFFECT and return nil, without marshalling its completion value — the counterpart of #call_void, and what a