Class: RubyVM::RJIT::JITState
- Inherits:
-
Struct
- Object
- Struct
- RubyVM::RJIT::JITState
- Defined in:
- lib/ruby_vm/rjit/jit_state.rb
Instance Attribute Summary collapse
-
#block ⇒ Object
Returns the value of attribute block.
-
#cfp ⇒ Object
Returns the value of attribute cfp.
-
#iseq ⇒ Object
Returns the value of attribute iseq.
-
#pc ⇒ Object
Returns the value of attribute pc.
-
#record_boundary_patch_point ⇒ Object
Returns the value of attribute record_boundary_patch_point.
-
#side_exit_for_pc ⇒ Object
Returns the value of attribute side_exit_for_pc.
-
#stack_size_for_pc ⇒ Object
Returns the value of attribute stack_size_for_pc.
Instance Method Summary collapse
- #at_current_insn? ⇒ Boolean
-
#initialize(side_exit_for_pc: {}, record_boundary_patch_point: false) ⇒ JITState
constructor
A new instance of JITState.
- #insn ⇒ Object
- #operand(index, signed: false, ruby: false) ⇒ Object
- #peek_at_block_handler(level) ⇒ Object
- #peek_at_local(n) ⇒ Object
- #peek_at_self ⇒ Object
- #peek_at_stack(depth_from_top) ⇒ Object
Constructor Details
#initialize(side_exit_for_pc: {}, record_boundary_patch_point: false) ⇒ JITState
Returns a new instance of JITState.
11 |
# File 'lib/ruby_vm/rjit/jit_state.rb', line 11 def initialize(side_exit_for_pc: {}, record_boundary_patch_point: false, **) = super |
Instance Attribute Details
#block ⇒ Object
Returns the value of attribute block
2 3 4 |
# File 'lib/ruby_vm/rjit/jit_state.rb', line 2 def block @block end |
#cfp ⇒ Object
Returns the value of attribute cfp
2 3 4 |
# File 'lib/ruby_vm/rjit/jit_state.rb', line 2 def cfp @cfp end |
#iseq ⇒ Object
Returns the value of attribute iseq
2 3 4 |
# File 'lib/ruby_vm/rjit/jit_state.rb', line 2 def iseq @iseq end |
#pc ⇒ Object
Returns the value of attribute pc
2 3 4 |
# File 'lib/ruby_vm/rjit/jit_state.rb', line 2 def pc @pc end |
#record_boundary_patch_point ⇒ Object
Returns the value of attribute record_boundary_patch_point
2 3 4 |
# File 'lib/ruby_vm/rjit/jit_state.rb', line 2 def record_boundary_patch_point @record_boundary_patch_point end |
#side_exit_for_pc ⇒ Object
Returns the value of attribute side_exit_for_pc
2 3 4 |
# File 'lib/ruby_vm/rjit/jit_state.rb', line 2 def side_exit_for_pc @side_exit_for_pc end |
#stack_size_for_pc ⇒ Object
Returns the value of attribute stack_size_for_pc
2 3 4 |
# File 'lib/ruby_vm/rjit/jit_state.rb', line 2 def stack_size_for_pc @stack_size_for_pc end |
Instance Method Details
#at_current_insn? ⇒ Boolean
26 27 28 |
# File 'lib/ruby_vm/rjit/jit_state.rb', line 26 def at_current_insn? pc == cfp.pc.to_i end |
#insn ⇒ Object
13 14 15 |
# File 'lib/ruby_vm/rjit/jit_state.rb', line 13 def insn Compiler.decode_insn(C.VALUE.new(pc).*) end |
#operand(index, signed: false, ruby: false) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/ruby_vm/rjit/jit_state.rb', line 17 def operand(index, signed: false, ruby: false) addr = pc + (index + 1) * Fiddle::SIZEOF_VOIDP value = Fiddle::Pointer.new(addr)[0, Fiddle::SIZEOF_VOIDP].unpack(signed ? 'q' : 'Q')[0] if ruby value = C.to_ruby(value) end value end |
#peek_at_block_handler(level) ⇒ Object
49 50 51 52 |
# File 'lib/ruby_vm/rjit/jit_state.rb', line 49 def peek_at_block_handler(level) ep = ep_at_level(cfp, level:) ep[C::VM_ENV_DATA_INDEX_SPECVAL] end |
#peek_at_local(n) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/ruby_vm/rjit/jit_state.rb', line 30 def peek_at_local(n) local_table_size = iseq.body.local_table_size offset = -C::VM_ENV_DATA_SIZE - local_table_size + n + 1 value = (cfp.ep + offset).* C.to_ruby(value) end |
#peek_at_self ⇒ Object
45 46 47 |
# File 'lib/ruby_vm/rjit/jit_state.rb', line 45 def peek_at_self C.to_ruby(cfp.self) end |
#peek_at_stack(depth_from_top) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/ruby_vm/rjit/jit_state.rb', line 37 def peek_at_stack(depth_from_top) raise 'not at current insn' unless at_current_insn? offset = -(1 + depth_from_top) # rb_rjit_branch_stub_hit updates SP, so you don't need to worry about sp_offset value = (cfp.sp + offset).* C.to_ruby(value) end |