diff options
author | Alan Wu <XrXr@users.noreply.github.com> | 2020-09-03 14:18:02 -0400 |
---|---|---|
committer | Alan Wu <XrXr@users.noreply.github.com> | 2021-10-20 18:19:22 -0400 |
commit | 07dd5f22a5d3127981eea7602bd3d6c221f5d12e (patch) | |
tree | 72973fcef056aa53ef49b55baf02ac5b59d55200 | |
parent | 410323bd6d54c9f66f1d0af91d64102426191776 (diff) | |
download | ruby-07dd5f22a5d3127981eea7602bd3d6c221f5d12e.tar.gz |
Scraper touch-ups
- Support older Ruby versions
- Catch rip-relative jmp. Happens in -O0
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | gen_ujit_examples.rb | 11 |
2 files changed, 10 insertions, 4 deletions
diff --git a/.gitignore b/.gitignore index 8d11d7278a..4c2a8ca452 100644 --- a/.gitignore +++ b/.gitignore @@ -228,3 +228,6 @@ lcov*.info /rb_mjit_header.h /mjit_config.h /include/ruby-*/*/rb_mjit_min_header-*.h + +# UJIT +/ujit_examples.h diff --git a/gen_ujit_examples.rb b/gen_ujit_examples.rb index eaacd988b8..f521cd8d4f 100644 --- a/gen_ujit_examples.rb +++ b/gen_ujit_examples.rb @@ -61,19 +61,22 @@ def disassemble(offset) raise 'failed to find jmp' unless jmp_idx raise 'generated code for example too long' unless jmp_idx < 10 handler_instructions = instructions[(0..jmp_idx)] + + puts "Disassembly for the example handler:" + puts handler_instructions.map {|_, _, line| line} + + raise 'rip reference in example makes copying unsafe' if handler_instructions.any? { |_, _, full_line| full_line.downcase.include?('rip') } acceptable_mnemonics = %w(mov jmp lea call) unrecognized = nil handler_instructions.each { |i| unrecognized = i unless acceptable_mnemonics.include?(i[1]) } - raise "found a unrecognized \"#{unrecognized[1]}\" instruction in the example. List of recognized instructions: #{acceptable_mnemonics.join(', ')}" if unrecognized + raise "found an unrecognized \"#{unrecognized[1]}\" instruction in the example. List of recognized instructions: #{acceptable_mnemonics.join(', ')}" if unrecognized raise 'found multiple jmp instructions' if handler_instructions.count { |_, mnemonic, _| mnemonic == 'jmp' } > 1 + raise "the jmp instruction seems to be relative which isn't copiable" if instructions[jmp_idx][0].split.size > 4 raise 'found multiple call instructions' if handler_instructions.count { |_, mnemonic, _| mnemonic == 'call' } > 1 call_idx = handler_instructions.find_index { |_, mnemonic, _| mnemonic == 'call' } - puts "Disassembly for the example handler:" - puts handler_instructions.map{|_,_,line|line} - pre_call_bytes = [] post_call_bytes = [] handler_instructions.take(call_idx).each do |bytes, mnemonic, _| |