module Bootsnap::CompileCache::ISeq

Attributes

cache_dir[RW]

Public Class Methods

compile_option_updated() click to toggle source
# File lib/bootsnap/compile_cache/iseq.rb, line 55
def self.compile_option_updated
  option = RubyVM::InstructionSequence.compile_option
  crc = Zlib.crc32(option.inspect)
  Bootsnap::CompileCache::Native.compile_option_crc32 = crc
end
input_to_output(_) click to toggle source
# File lib/bootsnap/compile_cache/iseq.rb, line 28
def self.input_to_output(_)
  nil # ruby handles this
end
input_to_storage(_, path) click to toggle source
# File lib/bootsnap/compile_cache/iseq.rb, line 11
def self.input_to_storage(_, path)
  RubyVM::InstructionSequence.compile_file(path).to_binary
rescue SyntaxError
  raise Uncompilable, 'syntax error'
end
install!(cache_dir) click to toggle source
# File lib/bootsnap/compile_cache/iseq.rb, line 61
def self.install!(cache_dir)
  Bootsnap::CompileCache::ISeq.cache_dir = cache_dir
  Bootsnap::CompileCache::ISeq.compile_option_updated
  class << RubyVM::InstructionSequence
    prepend InstructionSequenceMixin
  end
end
storage_to_output(binary) click to toggle source
# File lib/bootsnap/compile_cache/iseq.rb, line 17
def self.storage_to_output(binary)
  RubyVM::InstructionSequence.load_from_binary(binary)
rescue RuntimeError => e
  if e.message == 'broken binary format'
    STDERR.puts "[Bootsnap::CompileCache] warning: rejecting broken binary"
    return nil
  else
    raise
  end
end