YJIT: print msg to stderr when RubyVM::YJIT.disasm not available (#10688)
* YJIT: print msg to stderr when RubyVM::YJIT.disasm not available Print a more useful error message when people try to use this feature without YJIT dev. Also fix an issue with .gitignore file on macOS * Update yjit.rb Co-authored-by: Randy Stauner <randy@r4s6.net> * Use warn and always return nil if YJIT disasm not available. --------- Co-authored-by: Randy Stauner <randy@r4s6.net>
This commit is contained in:
parent
bd419a6578
commit
ade22339e3
1
.gitignore
vendored
1
.gitignore
vendored
@ -167,6 +167,7 @@ lcov*.info
|
|||||||
|
|
||||||
# /coroutine/
|
# /coroutine/
|
||||||
!/coroutine/**/*.s
|
!/coroutine/**/*.s
|
||||||
|
!/coroutine/**/*.S
|
||||||
|
|
||||||
# /enc/trans/
|
# /enc/trans/
|
||||||
/enc/trans/*.c
|
/enc/trans/*.c
|
||||||
|
26
yjit.rb
26
yjit.rb
@ -201,13 +201,27 @@ module RubyVM::YJIT
|
|||||||
# If a method or proc is passed in, get its iseq
|
# If a method or proc is passed in, get its iseq
|
||||||
iseq = RubyVM::InstructionSequence.of(iseq)
|
iseq = RubyVM::InstructionSequence.of(iseq)
|
||||||
|
|
||||||
if self.enabled?
|
if !self.enabled?
|
||||||
# Produce the disassembly string
|
warn(
|
||||||
# Include the YARV iseq disasm in the string for additional context
|
"YJIT needs to be enabled to produce disasm output, e.g.\n" +
|
||||||
iseq.disasm + "\n" + Primitive.rb_yjit_disasm_iseq(iseq)
|
"ruby --yjit-call-threshold=1 my_script.rb (see doc/yjit/yjit.md)"
|
||||||
else
|
)
|
||||||
iseq.disasm
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
disasm_str = Primitive.rb_yjit_disasm_iseq(iseq)
|
||||||
|
|
||||||
|
if !disasm_str
|
||||||
|
warn(
|
||||||
|
"YJIT disasm is only available when YJIT is built in dev mode, i.e.\n" +
|
||||||
|
"./configure --enable-yjit=dev (see doc/yjit/yjit.md)\n"
|
||||||
|
)
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
# Produce the disassembly string
|
||||||
|
# Include the YARV iseq disasm in the string for additional context
|
||||||
|
iseq.disasm + "\n" + disasm_str
|
||||||
end
|
end
|
||||||
|
|
||||||
# Produce a list of instructions compiled by YJIT for an iseq
|
# Produce a list of instructions compiled by YJIT for an iseq
|
||||||
|
Loading…
x
Reference in New Issue
Block a user