summaryrefslogtreecommitdiff
path: root/lib/ruby_vm/mjit/jit_state.rb
diff options
context:
space:
mode:
authorTakashi Kokubun <[email protected]>2023-01-02 22:53:14 -0800
committerTakashi Kokubun <[email protected]>2023-03-05 22:11:20 -0800
commita8dec34961d7734ad975e44efa8aae361a1c4f5a (patch)
tree5849c716f37c959d9276ddb8c598fe1142a7f6fa /lib/ruby_vm/mjit/jit_state.rb
parent21696ad81ec40cf9cd146836dc8c945f1e485774 (diff)
Implement initial opt_lt
Diffstat (limited to 'lib/ruby_vm/mjit/jit_state.rb')
-rw-r--r--lib/ruby_vm/mjit/jit_state.rb18
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/ruby_vm/mjit/jit_state.rb b/lib/ruby_vm/mjit/jit_state.rb
index 97e5b7ffdd..97331e8108 100644
--- a/lib/ruby_vm/mjit/jit_state.rb
+++ b/lib/ruby_vm/mjit/jit_state.rb
@@ -1,10 +1,13 @@
module RubyVM::MJIT
class JITState < Struct.new(
- :iseq, # @param `RubyVM::MJIT::CPointer::Struct_rb_iseq_t`
- :pc, # @param [Integer] The JIT target PC
- :cfp, # @param `RubyVM::MJIT::CPointer::Struct_rb_control_frame_t` The JIT source CFP (before MJIT is called)
- :block, # @param [RubyVM::MJIT::Block]
+ :iseq, # @param `RubyVM::MJIT::CPointer::Struct_rb_iseq_t`
+ :pc, # @param [Integer] The JIT target PC
+ :cfp, # @param `RubyVM::MJIT::CPointer::Struct_rb_control_frame_t` The JIT source CFP (before MJIT is called)
+ :block, # @param [RubyVM::MJIT::Block]
+ :side_exits, # @param [Hash{ Integer => Integer }] { PC => address }
)
+ def initialize(side_exits: {}, **) = super
+
def operand(index)
C.VALUE.new(pc)[index + 1]
end
@@ -12,5 +15,12 @@ module RubyVM::MJIT
def at_current_insn?
pc == cfp.pc.to_i
end
+
+ def peek_at_stack(offset_from_top)
+ raise 'not at current insn' unless at_current_insn?
+ offset = -(1 + offset_from_top)
+ value = (cfp.sp + offset).*
+ C.to_ruby(value)
+ end
end
end