summaryrefslogtreecommitdiff
path: root/tool/ruby_vm
diff options
context:
space:
mode:
authorMaxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com>2021-01-28 16:58:20 -0500
committerAlan Wu <XrXr@users.noreply.github.com>2021-10-20 18:19:28 -0400
commit2e561ff255ea69e50f2d53240332cfd96463ef06 (patch)
tree3711eca121d493aa1f7a7f4e557333275a905c1e /tool/ruby_vm
parent3c7251b41b8850aab7c64c4885669e9c099d2465 (diff)
downloadruby-2e561ff255ea69e50f2d53240332cfd96463ef06.tar.gz
Restore interpreter regs in ujit hook. Implement leave bytecode.
Diffstat (limited to 'tool/ruby_vm')
-rw-r--r--tool/ruby_vm/models/micro_jit.rb10
-rw-r--r--tool/ruby_vm/models/micro_jit/example_instructions.rb12
-rw-r--r--tool/ruby_vm/views/vm.inc.erb9
3 files changed, 12 insertions, 19 deletions
diff --git a/tool/ruby_vm/models/micro_jit.rb b/tool/ruby_vm/models/micro_jit.rb
index 9bbce73150..5e376ebb3a 100644
--- a/tool/ruby_vm/models/micro_jit.rb
+++ b/tool/ruby_vm/models/micro_jit.rb
@@ -176,10 +176,9 @@ module RubyVM::MicroJIT
disassemble(handler_offset)
end
- def make_result(success, without_pc, with_pc)
+ def make_result(success, with_pc)
[success ? 1 : 0,
[
- ['ujit_without_ec', without_pc],
['ujit_with_ec', with_pc],
]
]
@@ -193,19 +192,18 @@ module RubyVM::MicroJIT
when :linux
linux_scrape(instruction_id)
else
- raise 'Unkonwn platform. Only Mach-O on macOS and ELF on Linux are supported'
+ raise 'Unknown platform. Only Mach-O on macOS and ELF on Linux are supported'
end
end
def scrape
- without_ec = scrape_instruction(RubyVM::Instructions.find_index { |insn| insn.name == 'ujit_call_example' })
with_ec = scrape_instruction(RubyVM::Instructions.find_index { |insn| insn.name == 'ujit_call_example_with_ec' })
- make_result(true, without_ec, with_ec)
+ make_result(true, with_ec)
rescue => e
print_warning("scrape failed: #{e.message}")
int3 = '0xcc'
failure_result = ScrapeResult.new(int3, int3, ['int3'])
- make_result(false, failure_result, failure_result)
+ make_result(false, failure_result)
end
def print_warning(text)
diff --git a/tool/ruby_vm/models/micro_jit/example_instructions.rb b/tool/ruby_vm/models/micro_jit/example_instructions.rb
index 111346f6e9..23ecf72a3b 100644
--- a/tool/ruby_vm/models/micro_jit/example_instructions.rb
+++ b/tool/ruby_vm/models/micro_jit/example_instructions.rb
@@ -13,11 +13,10 @@
class RubyVM::MicroJIT::ExampleInstructions
include RubyVM::CEscape
- attr_reader :name, :call_line
+ attr_reader :name
- def initialize(name, call_line)
+ def initialize(name)
@name = name
- @call_line = call_line
end
def pretty_name
@@ -64,12 +63,7 @@ class RubyVM::MicroJIT::ExampleInstructions
false
end
- @all_examples = [
- new('ujit_call_example', 'reg_pc = rb_ujit_empty_func(GET_CFP());'),
- new('ujit_call_example_with_ec', 'reg_pc = rb_ujit_empty_func_with_ec(GET_CFP(), ec);')
- ]
-
def self.to_a
- @all_examples
+ [new('ujit_call_example_with_ec')]
end
end
diff --git a/tool/ruby_vm/views/vm.inc.erb b/tool/ruby_vm/views/vm.inc.erb
index 235eb30b11..57a860efcf 100644
--- a/tool/ruby_vm/views/vm.inc.erb
+++ b/tool/ruby_vm/views/vm.inc.erb
@@ -26,15 +26,16 @@
% end
%
% RubyVM::MicroJIT::ExampleInstructions.to_a.each do |insn|
-INSN_ENTRY(<%= insn.name %>)
+INSN_ENTRY(ujit_call_example_with_ec)
{
- START_OF_ORIGINAL_INSN(<%= insn.name %>);
+ START_OF_ORIGINAL_INSN(ujit_call_example_with_ec);
#if USE_MACHINE_REGS
// assumes USE_MACHINE_REGS, aka reg_pc setup,
// aka #define SET_PC(x) (reg_cfp->pc = reg_pc = (x))
- <%= insn.call_line %>
+ rb_ujit_empty_func_with_ec(GET_CFP(), ec);
+ RESTORE_REGS();
#endif
- END_INSN(<%= insn.name %>);
+ END_INSN(ujit_call_example_with_ec);
}
% end
%