ruby/lib/ruby_vm/rjit/context.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

31 строка
812 B
Ruby
Исходник Обычный вид История

2023-02-07 02:44:34 +03:00
module RubyVM::MJIT
class Context < Struct.new(
2023-02-08 11:47:01 +03:00
:stack_size, # @param [Integer] The number of values on the stack
:sp_offset, # @param [Integer] JIT sp offset relative to the interpreter's sp
:chain_depth, # @param [Integer] jit_chain_guard depth
2023-02-07 02:44:34 +03:00
)
2023-02-08 11:47:01 +03:00
def initialize(stack_size: 0, sp_offset: 0, chain_depth: 0) = super
2023-01-01 00:41:32 +03:00
2023-02-07 02:44:34 +03:00
def stack_push(size = 1)
self.stack_size += size
self.sp_offset += size
2023-02-09 04:17:36 +03:00
stack_opnd(0)
2023-02-07 02:44:34 +03:00
end
2023-01-03 09:53:14 +03:00
2023-02-07 02:44:34 +03:00
def stack_pop(size = 1)
2023-02-09 04:17:36 +03:00
opnd = stack_opnd(0)
2023-02-07 02:44:34 +03:00
self.stack_size -= size
self.sp_offset -= size
2023-02-09 04:17:36 +03:00
opnd
2023-02-07 02:44:34 +03:00
end
2023-02-08 22:10:04 +03:00
def stack_opnd(depth_from_top)
[SP, C.VALUE.size * (self.sp_offset - 1 - depth_from_top)]
end
2023-02-10 03:25:06 +03:00
def sp_opnd(offset_bytes = 0)
2023-02-08 22:10:04 +03:00
[SP, (C.VALUE.size * self.sp_offset) + offset_bytes]
end
2023-01-03 09:53:14 +03:00
end
2022-12-24 01:17:32 +03:00
end