[前][次][番号順一覧][スレッド一覧]

ruby-changes:68556

From: Alan <ko1@a...>
Date: Thu, 21 Oct 2021 08:08:14 +0900 (JST)
Subject: [ruby-changes:68556] 07dd5f22a5 (master): Scraper touch-ups

https://git.ruby-lang.org/ruby.git/commit/?id=07dd5f22a5

From 07dd5f22a5d3127981eea7602bd3d6c221f5d12e Mon Sep 17 00:00:00 2001
From: Alan Wu <XrXr@u...>
Date: Thu, 3 Sep 2020 14:18:02 -0400
Subject: Scraper touch-ups

- Support older Ruby versions
- Catch rip-relative jmp. Happens in -O0
---
 .gitignore           |  3 +++
 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 https://github.com/ruby/ruby/blob/trunk/.gitignore#L228
 /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) https://github.com/ruby/ruby/blob/trunk/gen_ujit_examples.rb#L61
   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, _|
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]