summaryrefslogtreecommitdiff
path: root/tool
diff options
context:
space:
mode:
authorAlan Wu <XrXr@users.noreply.github.com>2020-10-05 07:21:45 -0400
committerAlan Wu <XrXr@users.noreply.github.com>2021-10-20 18:19:24 -0400
commita3e58f4df827f36681e4fdebfef8e05a6ceb5c10 (patch)
tree864ef42e6566910483bacb371a5e10d5e037a1c1 /tool
parent726bdd4d35861f0373d7508ab4ac7b2c781edf51 (diff)
Compile with MicroJIT disabled when scrape fails
This is just so we can build successfully on -O0 and other cases that are not supported by the code scraper.
Diffstat (limited to 'tool')
-rw-r--r--tool/ruby_vm/models/micro_jit.rb20
-rw-r--r--tool/ruby_vm/views/ujit_examples.inc.erb6
2 files changed, 14 insertions, 12 deletions
diff --git a/tool/ruby_vm/models/micro_jit.rb b/tool/ruby_vm/models/micro_jit.rb
index 4473f617fc..eb20fe7335 100644
--- a/tool/ruby_vm/models/micro_jit.rb
+++ b/tool/ruby_vm/models/micro_jit.rb
@@ -176,20 +176,20 @@ module RubyVM::MicroJIT
else
raise 'Unkonwn platform. Only Mach-O on macOS and ELF on Linux are supported'
end
+ [true, comma_separated_hex_string(@pre_call_bytes), comma_separated_hex_string(@post_call_bytes)]
+ rescue => e
+ print_warning("scrape failed: #{e.message}")
+ [false, '', '']
end
- def comma_separated_hex_string(nums)
- nums.map{ |byte| '0x'+byte}.join(', ')
- end
-
- def pre_call_bytes
- scrape unless @pre_call_bytes
- comma_separated_hex_string(@pre_call_bytes)
+ def print_warning(text)
+ text = "ujit warning: #{text}"
+ text = "\x1b[1m#{text}\x1b[0m" if STDOUT.tty?
+ STDOUT.puts(text)
end
- def post_call_bytes
- scrape unless @post_call_bytes
- comma_separated_hex_string(@post_call_bytes)
+ def comma_separated_hex_string(nums)
+ nums.map{ |byte| '0x'+byte}.join(', ')
end
end
end
diff --git a/tool/ruby_vm/views/ujit_examples.inc.erb b/tool/ruby_vm/views/ujit_examples.inc.erb
index a301c5ca74..5fefcd4674 100644
--- a/tool/ruby_vm/views/ujit_examples.inc.erb
+++ b/tool/ruby_vm/views/ujit_examples.inc.erb
@@ -12,5 +12,7 @@
edit: __FILE__,
} -%>
-static const uint8_t ujit_pre_call_bytes[] = { <%= RubyVM::MicroJIT.pre_call_bytes %> };
-static const uint8_t ujit_post_call_bytes[] = { <%= RubyVM::MicroJIT.post_call_bytes %> };
+% success, pre_call_bytes, post_call_bytes = RubyVM::MicroJIT.scrape
+static const uint8_t ujit_scrape_successful = <%= success %>;
+static const uint8_t ujit_pre_call_bytes[] = { <%= pre_call_bytes %> };
+static const uint8_t ujit_post_call_bytes[] = { <%= post_call_bytes %> };