mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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.
This commit is contained in:
parent
726bdd4d35
commit
a3e58f4df8
3 changed files with 17 additions and 12 deletions
|
@ -176,21 +176,21 @@ module RubyVM::MicroJIT
|
||||||
else
|
else
|
||||||
raise 'Unkonwn platform. Only Mach-O on macOS and ELF on Linux are supported'
|
raise 'Unkonwn platform. Only Mach-O on macOS and ELF on Linux are supported'
|
||||||
end
|
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 print_warning(text)
|
||||||
|
text = "ujit warning: #{text}"
|
||||||
|
text = "\x1b[1m#{text}\x1b[0m" if STDOUT.tty?
|
||||||
|
STDOUT.puts(text)
|
||||||
end
|
end
|
||||||
|
|
||||||
def comma_separated_hex_string(nums)
|
def comma_separated_hex_string(nums)
|
||||||
nums.map{ |byte| '0x'+byte}.join(', ')
|
nums.map{ |byte| '0x'+byte}.join(', ')
|
||||||
end
|
end
|
||||||
|
|
||||||
def pre_call_bytes
|
|
||||||
scrape unless @pre_call_bytes
|
|
||||||
comma_separated_hex_string(@pre_call_bytes)
|
|
||||||
end
|
|
||||||
|
|
||||||
def post_call_bytes
|
|
||||||
scrape unless @post_call_bytes
|
|
||||||
comma_separated_hex_string(@post_call_bytes)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -12,5 +12,7 @@
|
||||||
edit: __FILE__,
|
edit: __FILE__,
|
||||||
} -%>
|
} -%>
|
||||||
|
|
||||||
static const uint8_t ujit_pre_call_bytes[] = { <%= RubyVM::MicroJIT.pre_call_bytes %> };
|
% success, pre_call_bytes, post_call_bytes = RubyVM::MicroJIT.scrape
|
||||||
static const uint8_t ujit_post_call_bytes[] = { <%= RubyVM::MicroJIT.post_call_bytes %> };
|
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 %> };
|
||||||
|
|
|
@ -505,6 +505,9 @@ rb_ujit_enabled_p(void)
|
||||||
void
|
void
|
||||||
rb_ujit_init(void)
|
rb_ujit_init(void)
|
||||||
{
|
{
|
||||||
|
if (!ujit_scrape_successful) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// Initialize the code blocks
|
// Initialize the code blocks
|
||||||
size_t mem_size = 64 * 1024 * 1024;
|
size_t mem_size = 64 * 1024 * 1024;
|
||||||
uint8_t* mem_block = alloc_exec_mem(mem_size);
|
uint8_t* mem_block = alloc_exec_mem(mem_size);
|
||||||
|
|
Loading…
Add table
Reference in a new issue