module Bootsnap::CompileCache::ISeq
Constants
- COVERAGE_SUPPORTED
- DEFAULT
- FROZEN_STRING_LITERAL
Attributes
cache_dir[R]
compiler_selector[RW]
default_compiler[RW]
Public Class Methods
cache_dir=(cache_dir)
click to toggle source
# File lib/bootsnap/compile_cache/iseq.rb, line 13 def cache_dir=(cache_dir) @cache_dir = cache_dir.end_with?("/") ? "#{cache_dir}iseq" : "#{cache_dir}-iseq" end
compile_option_updated()
click to toggle source
# File lib/bootsnap/compile_cache/iseq.rb, line 199 def self.compile_option_updated option = RubyVM::InstructionSequence.compile_option crc = Zlib.crc32(option.inspect) Bootsnap::CompileCache::Native.compile_option_crc32 = crc FROZEN_STRING_LITERAL.update_options end
coverage_on?()
click to toggle source
# File lib/bootsnap/compile_cache/iseq.rb, line 174 def self.coverage_on? defined?(Coverage) && Coverage.running? end
fetch(path, cache_dir: ISeq.cache_dir)
click to toggle source
# File lib/bootsnap/compile_cache/iseq.rb, line 134 def self.fetch(path, cache_dir: ISeq.cache_dir) compiler = compiler_selector&.call(path) || default_compiler # Having coverage enabled prevents iseq dumping/loading. if coverage_on? return nil if compiler.equal?(DEFAULT) if COVERAGE_SUPPORTED return compiler.input_to_output(nil, path.to_s, nil) elsif !@coverage_support_warning_emitted @coverage_support_warning_emitted = true warn(<<~MSG) Using `Bootsnap.enable_frozen_string_literal` with code coverage enabled is only supported on Ruby 4.0.4+. Files loaded while coverage is on, will have mutable string literals. MSG end return nil end Bootsnap::CompileCache::Native.fetch( cache_dir, compiler.namespace, path.to_s, compiler, nil, ) end
install!(cache_dir)
click to toggle source
# File lib/bootsnap/compile_cache/iseq.rb, line 207 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)
click to toggle source
# File lib/bootsnap/compile_cache/iseq.rb, line 163 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?()
click to toggle source
# File lib/bootsnap/compile_cache/iseq.rb, line 17 def supported? CompileCache.supported? && defined?(RubyVM) end