Module: Bootsnap::CompileCache::ISeq

Defined in:
lib/bootsnap/compile_cache/iseq.rb

Defined Under Namespace

Modules: InstructionSequenceMixin Classes: Compiler

Constant Summary collapse

DEFAULT =
Compiler.new
FROZEN_STRING_LITERAL =
Compiler.new("-fstr", {frozen_string_literal: true}.freeze)
MUTABLE_STRING_LITERAL =
Compiler.new("-no-fstr", {frozen_string_literal: false}.freeze)

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.cache_dirObject

Returns the value of attribute cache_dir.



10
11
12
# File 'lib/bootsnap/compile_cache/iseq.rb', line 10

def cache_dir
  @cache_dir
end

.compiler_selectorObject

Returns the value of attribute compiler_selector.



11
12
13
# File 'lib/bootsnap/compile_cache/iseq.rb', line 11

def compiler_selector
  @compiler_selector
end

.default_compilerObject

Returns the value of attribute default_compiler.



11
12
13
# File 'lib/bootsnap/compile_cache/iseq.rb', line 11

def default_compiler
  @default_compiler
end

Class Method Details

.compile_option_updatedObject



124
125
126
127
128
# File 'lib/bootsnap/compile_cache/iseq.rb', line 124

def self.compile_option_updated
  option = RubyVM::InstructionSequence.compile_option
  crc = Zlib.crc32(option.inspect)
  Bootsnap::CompileCache::Native.compile_option_crc32 = crc
end

.fetch(path, cache_dir: ISeq.cache_dir) ⇒ Object



84
85
86
87
88
89
90
91
92
93
# File 'lib/bootsnap/compile_cache/iseq.rb', line 84

def self.fetch(path, cache_dir: ISeq.cache_dir)
  compiler = compiler_selector&.call(path) || default_compiler
  Bootsnap::CompileCache::Native.fetch(
    cache_dir,
    compiler.namespace,
    path.to_s,
    compiler,
    nil,
  )
end

.install!(cache_dir) ⇒ Object



131
132
133
134
135
136
137
138
139
140
141
# File 'lib/bootsnap/compile_cache/iseq.rb', line 131

def self.install!(cache_dir)
  Bootsnap::CompileCache::ISeq.cache_dir = cache_dir

  return unless supported?

  Bootsnap::CompileCache::ISeq.compile_option_updated

  class << RubyVM::InstructionSequence
    prepend(InstructionSequenceMixin)
  end
end

.precompile(path) ⇒ Object



95
96
97
98
99
100
101
102
103
# File 'lib/bootsnap/compile_cache/iseq.rb', line 95

def self.precompile(path)
  compiler = compiler_selector&.call(path) || default_compiler
  Bootsnap::CompileCache::Native.precompile(
    cache_dir,
    compiler.namespace,
    path.to_s,
    compiler,
  )
end

.supported?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/bootsnap/compile_cache/iseq.rb', line 17

def supported?
  CompileCache.supported? && defined?(RubyVM)
end