Class: MiniRacer::Snapshot
- Inherits:
-
Object
- Object
- MiniRacer::Snapshot
- Defined in:
- lib/mini_racer/shared.rb,
lib/mini_racer/truffleruby.rb,
ext/mini_racer_extension/mini_racer_extension.c
Overview
size and warmup! public methods are defined in the C class
Instance Method Summary collapse
-
#initialize(str = "") ⇒ Snapshot
constructor
A new instance of Snapshot.
- #load(str) ⇒ Object
- #warmup!(src) ⇒ Object
- #warmup_unsafe!(src) ⇒ Object
Constructor Details
#initialize(str = "") ⇒ Snapshot
Returns a new instance of Snapshot.
390 391 392 393 394 395 396 397 398 399 400 401 402 403 |
# File 'lib/mini_racer/shared.rb', line 390 def initialize(str = "") # ensure it first can load begin ctx = MiniRacer::Context.new ctx.eval(str) rescue MiniRacer::RuntimeError => e raise MiniRacer::SnapshotError, e., e.backtrace end @source = str # defined in the C class load(str) end |
Instance Method Details
#load(str) ⇒ Object
423 424 425 426 427 428 |
# File 'lib/mini_racer/truffleruby.rb', line 423 def load(str) unless str.is_a?(String) raise TypeError, "wrong type argument #{str.class} (should be a string)" end # Intentionally noop since TruffleRuby mocks the snapshot API end |
#warmup!(src) ⇒ Object
405 406 407 408 409 410 411 412 413 414 415 416 417 418 |
# File 'lib/mini_racer/shared.rb', line 405 def warmup!(src) # we have to do something here # we are bloating memory a bit but it is more correct # than hitting an exception when attempty to compile invalid source begin ctx = MiniRacer::Context.new ctx.eval(@source) ctx.eval(src) rescue MiniRacer::RuntimeError => e raise MiniRacer::SnapshotError, e., e.backtrace end warmup_unsafe!(src) end |
#warmup_unsafe!(src) ⇒ Object
430 431 432 433 434 435 436 437 |
# File 'lib/mini_racer/truffleruby.rb', line 430 def warmup_unsafe!(src) unless src.is_a?(String) raise TypeError, "wrong type argument #{src.class} (should be a string)" end # Intentionally noop since TruffleRuby mocks the snapshot API # by replaying snapshot source before the first eval/call self end |