diff options
| author | Maxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com> | 2024-04-30 13:57:18 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-30 17:57:18 +0000 |
| commit | ade22339e3056710dbe27eaa624c2e76fa15567b (patch) | |
| tree | 5e06e58448e120719afe4b92742e7740f6e06136 | |
| parent | bd419a6578e89c8d853937de686617afe13227b3 (diff) | |
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>
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | yjit.rb | 26 |
2 files changed, 21 insertions, 6 deletions
diff --git a/.gitignore b/.gitignore index d7a8b978c9..b6beba3b3e 100644 --- a/.gitignore +++ b/.gitignore @@ -167,6 +167,7 @@ lcov*.info # /coroutine/ !/coroutine/**/*.s +!/coroutine/**/*.S # /enc/trans/ /enc/trans/*.c @@ -201,13 +201,27 @@ module RubyVM::YJIT # If a method or proc is passed in, get its iseq iseq = RubyVM::InstructionSequence.of(iseq) - if self.enabled? - # Produce the disassembly string - # Include the YARV iseq disasm in the string for additional context - iseq.disasm + "\n" + Primitive.rb_yjit_disasm_iseq(iseq) - else - iseq.disasm + if !self.enabled? + warn( + "YJIT needs to be enabled to produce disasm output, e.g.\n" + + "ruby --yjit-call-threshold=1 my_script.rb (see doc/yjit/yjit.md)" + ) + return nil 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 # Produce a list of instructions compiled by YJIT for an iseq |
