lib/bootsnap/compile_cache/iseq.rb in bootsnap-1.16.0 vs lib/bootsnap/compile_cache/iseq.rb in bootsnap-1.17.0

- old
+ new

@@ -10,10 +10,14 @@ attr_reader(:cache_dir) def cache_dir=(cache_dir) @cache_dir = cache_dir.end_with?("/") ? "#{cache_dir}iseq" : "#{cache_dir}-iseq" end + + def supported? + CompileCache.supported? && defined?(RubyVM) + end end has_ruby_bug_18250 = begin # https://bugs.ruby-lang.org/issues/18250 if defined? RubyVM::InstructionSequence RubyVM::InstructionSequence.compile("def foo(*); ->{ super }; end; def foo(**); ->{ super }; end").to_binary @@ -81,12 +85,10 @@ def load_iseq(path) # Having coverage enabled prevents iseq dumping/loading. return nil if defined?(Coverage) && Bootsnap::CompileCache::Native.coverage_running? Bootsnap::CompileCache::ISeq.fetch(path.to_s) - rescue Errno::EACCES - Bootsnap::CompileCache.permission_error(path) rescue RuntimeError => error if error.message =~ /unmatched platform/ puts("unmatched platform for file #{path}") end raise @@ -101,14 +103,18 @@ def self.compile_option_updated option = RubyVM::InstructionSequence.compile_option crc = Zlib.crc32(option.inspect) Bootsnap::CompileCache::Native.compile_option_crc32 = crc end - compile_option_updated + compile_option_updated if supported? 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 end