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)
- COVERAGE_SUPPORTED =
RUBY_VERSION >= "4.0.4"
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.cache_dir ⇒ Object
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_selector ⇒ Object
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_compiler ⇒ Object
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_updated ⇒ Object
197
198
199
200
201
202
|
# File 'lib/bootsnap/compile_cache/iseq.rb', line 197
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? ⇒ Boolean
172
173
174
|
# File 'lib/bootsnap/compile_cache/iseq.rb', line 172
def self.coverage_on?
defined?(Coverage) && Coverage.running?
end
|
.fetch(path, cache_dir: ISeq.cache_dir) ⇒ Object
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
# File 'lib/bootsnap/compile_cache/iseq.rb', line 132
def self.fetch(path, cache_dir: ISeq.cache_dir)
compiler = compiler_selector&.call(path) || default_compiler
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
|
.precompile ⇒ Object
161
162
163
164
165
166
167
168
169
|
# File 'lib/bootsnap/compile_cache/iseq.rb', line 161
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
17
18
19
|
# File 'lib/bootsnap/compile_cache/iseq.rb', line 17
def supported?
CompileCache.supported? && defined?(RubyVM)
end
|