2022-09-20 17:23:50 +03:00
|
|
|
# frozen_string_literal: true
|
2023-03-07 10:17:25 +03:00
|
|
|
# Part of this file is generated by tool/rjit/bindgen.rb.
|
|
|
|
# Run `make rjit-bindgen` to update code between "RJIT bindgen begin" and "RJIT bindgen end".
|
2023-03-07 10:15:30 +03:00
|
|
|
module RubyVM::RJIT # :nodoc: all
|
2023-03-19 08:13:40 +03:00
|
|
|
#
|
|
|
|
# Main: Used by RJIT
|
|
|
|
#
|
2023-03-12 08:31:18 +03:00
|
|
|
# This `class << C` section is for calling C functions with Primitive.
|
|
|
|
# For importing variables or macros, use tool/rjit/bindgen.rb instead.
|
|
|
|
class << C = Module.new
|
2023-03-10 22:55:48 +03:00
|
|
|
def mmap(mem_size)
|
|
|
|
Primitive.cexpr! 'SIZET2NUM((size_t)rjit_reserve_addr_space(NUM2UINT(mem_size)))'
|
2022-12-12 08:42:25 +03:00
|
|
|
end
|
|
|
|
|
2023-03-10 22:55:48 +03:00
|
|
|
def mprotect_write(mem_block, mem_size)
|
|
|
|
Primitive.mprotect_write(mem_block, mem_size)
|
|
|
|
end
|
|
|
|
|
|
|
|
def mprotect_exec(mem_block, mem_size)
|
|
|
|
Primitive.mprotect_exec(mem_block, mem_size)
|
2022-12-12 08:42:25 +03:00
|
|
|
end
|
|
|
|
|
2023-03-07 10:17:25 +03:00
|
|
|
def rjit_insn_exits
|
2023-03-18 08:31:41 +03:00
|
|
|
addr = Primitive.cexpr! 'SIZET2NUM((size_t)rjit_insn_exits)'
|
2022-12-27 09:46:40 +03:00
|
|
|
CType::Immediate.parse("size_t").new(addr)
|
|
|
|
end
|
|
|
|
|
2023-03-07 10:17:25 +03:00
|
|
|
def rb_rjit_counters
|
2023-03-18 08:31:41 +03:00
|
|
|
addr = Primitive.cexpr! 'SIZET2NUM((size_t)&rb_rjit_counters)'
|
2023-03-07 10:17:25 +03:00
|
|
|
rb_rjit_runtime_counters.new(addr)
|
2022-12-27 09:46:40 +03:00
|
|
|
end
|
|
|
|
|
2022-12-14 11:12:55 +03:00
|
|
|
# @param from [Integer] - From address
|
|
|
|
# @param to [Integer] - To address
|
2023-03-14 06:40:24 +03:00
|
|
|
def dump_disasm(from, to, test: false)
|
|
|
|
Primitive.dump_disasm(from, to, test)
|
2022-12-14 11:12:55 +03:00
|
|
|
end
|
|
|
|
|
2023-01-01 00:41:32 +03:00
|
|
|
# Convert a Ruby object to a VALUE in Integer
|
|
|
|
def to_value(obj)
|
|
|
|
Primitive.cexpr! 'SIZET2NUM((size_t)obj)'
|
|
|
|
end
|
|
|
|
|
2023-01-03 01:11:06 +03:00
|
|
|
def BASIC_OP_UNREDEFINED_P(op, klass)
|
|
|
|
Primitive.cexpr! 'RBOOL(BASIC_OP_UNREDEFINED_P(NUM2INT(op), NUM2INT(klass)))'
|
|
|
|
end
|
|
|
|
|
2023-01-08 00:21:14 +03:00
|
|
|
def rb_iseq_line_no(iseq, pos)
|
|
|
|
_iseq_addr = iseq.to_i
|
|
|
|
Primitive.cexpr! 'UINT2NUM(rb_iseq_line_no((const rb_iseq_t *)NUM2SIZET(_iseq_addr), NUM2SIZET(pos)))'
|
|
|
|
end
|
|
|
|
|
2023-01-08 08:24:30 +03:00
|
|
|
def rb_class_of(obj)
|
|
|
|
Primitive.cexpr! 'rb_class_of(obj)'
|
|
|
|
end
|
|
|
|
|
|
|
|
def rb_callable_method_entry(klass, mid)
|
|
|
|
cme_addr = Primitive.cexpr! 'SIZET2NUM((size_t)rb_callable_method_entry(klass, NUM2UINT(mid)))'
|
|
|
|
return nil if cme_addr == 0
|
2023-02-25 01:48:02 +03:00
|
|
|
rb_callable_method_entry_t.new(cme_addr)
|
2023-01-08 08:24:30 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
def METHOD_ENTRY_VISI(cme)
|
|
|
|
_cme_addr = cme.to_i
|
|
|
|
Primitive.cexpr! 'UINT2NUM(METHOD_ENTRY_VISI((const rb_callable_method_entry_t *)NUM2SIZET(_cme_addr)))'
|
|
|
|
end
|
|
|
|
|
2023-02-04 09:42:13 +03:00
|
|
|
def rb_simple_iseq_p(iseq)
|
|
|
|
_iseq_addr = iseq.to_i
|
|
|
|
Primitive.cexpr! 'RBOOL(rb_simple_iseq_p((rb_iseq_t *)NUM2SIZET(_iseq_addr)))'
|
|
|
|
end
|
|
|
|
|
2023-02-08 01:42:58 +03:00
|
|
|
def SPECIAL_CONST_P(obj)
|
|
|
|
_value = to_value(obj)
|
|
|
|
Primitive.cexpr! 'RBOOL(SPECIAL_CONST_P((VALUE)NUM2SIZET(_value)))'
|
|
|
|
end
|
|
|
|
|
|
|
|
def BUILTIN_TYPE(obj)
|
|
|
|
_value = to_value(obj)
|
|
|
|
Primitive.cexpr! 'INT2NUM(BUILTIN_TYPE((VALUE)NUM2SIZET(_value)))'
|
|
|
|
end
|
|
|
|
|
2023-03-04 09:03:23 +03:00
|
|
|
def RB_TYPE_P(obj, type)
|
|
|
|
Primitive.cexpr! 'RBOOL(RB_TYPE_P(obj, NUM2UINT(type)))'
|
|
|
|
end
|
|
|
|
|
2023-02-08 01:42:58 +03:00
|
|
|
def rb_shape_get_shape_id(obj)
|
|
|
|
_value = to_value(obj)
|
|
|
|
Primitive.cexpr! 'UINT2NUM((unsigned int)rb_shape_get_shape_id((VALUE)NUM2SIZET(_value)))'
|
|
|
|
end
|
|
|
|
|
|
|
|
def rb_shape_id_offset
|
|
|
|
Primitive.cexpr! 'INT2NUM(rb_shape_id_offset())'
|
|
|
|
end
|
|
|
|
|
|
|
|
def rb_shape_get_iv_index(shape_id, ivar_id)
|
|
|
|
Primitive.cstmt! %{
|
|
|
|
rb_shape_t *shape = rb_shape_get_shape_by_id((shape_id_t)NUM2SIZET(shape_id));
|
|
|
|
attr_index_t index;
|
|
|
|
bool found = rb_shape_get_iv_index(shape, (ID)NUM2SIZET(ivar_id), &index);
|
|
|
|
return found ? UINT2NUM(index) : Qnil;
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def FL_TEST_RAW(obj, flags)
|
2023-03-04 09:30:18 +03:00
|
|
|
Primitive.cexpr! 'RBOOL(FL_TEST_RAW(obj, (VALUE)NUM2SIZET(flags)))'
|
|
|
|
end
|
|
|
|
|
|
|
|
def FL_TEST(obj, flags)
|
|
|
|
Primitive.cexpr! 'RBOOL(FL_TEST(obj, (VALUE)NUM2SIZET(flags)))'
|
2023-02-08 01:42:58 +03:00
|
|
|
end
|
|
|
|
|
2023-03-07 10:17:25 +03:00
|
|
|
def rjit_for_each_iseq(&block)
|
|
|
|
Primitive.rjit_for_each_iseq(block)
|
2023-02-11 01:41:45 +03:00
|
|
|
end
|
|
|
|
|
2023-02-17 09:29:58 +03:00
|
|
|
def get_symbol_id(name)
|
|
|
|
Primitive.cexpr! 'SIZET2NUM((size_t)rb_get_symbol_id(name))'
|
|
|
|
end
|
|
|
|
|
2023-02-25 01:48:02 +03:00
|
|
|
def rb_vm_frame_method_entry(cfp)
|
|
|
|
_cfp = cfp.to_i
|
|
|
|
cme_addr = Primitive.cexpr! 'SIZET2NUM((size_t)rb_vm_frame_method_entry((const rb_control_frame_t *)NUM2SIZET(_cfp)))'
|
|
|
|
return nil if cme_addr == 0
|
|
|
|
rb_callable_method_entry_t.new(cme_addr)
|
|
|
|
end
|
|
|
|
|
|
|
|
def rb_class_get_superclass(klass)
|
|
|
|
Primitive.cexpr! 'rb_class_get_superclass(klass)'
|
|
|
|
end
|
|
|
|
|
2023-03-01 09:27:22 +03:00
|
|
|
def ID2SYM(id)
|
|
|
|
Primitive.cexpr! 'ID2SYM((ID)NUM2SIZET(id))'
|
|
|
|
end
|
|
|
|
|
2023-03-04 08:50:49 +03:00
|
|
|
def obj_is_kind_of(obj, c)
|
2023-03-01 09:27:22 +03:00
|
|
|
Primitive.cexpr! 'rb_obj_is_kind_of(obj, c)'
|
|
|
|
end
|
|
|
|
|
2023-03-10 09:14:43 +03:00
|
|
|
def imemo_type_p(ptr, type)
|
2023-03-02 09:06:57 +03:00
|
|
|
_ptr = ptr.to_i
|
2023-03-10 09:14:43 +03:00
|
|
|
Primitive.cexpr! 'RBOOL(imemo_type_p((VALUE)NUM2SIZET(_ptr), NUM2UINT(type)))'
|
2023-03-02 09:06:57 +03:00
|
|
|
end
|
|
|
|
|
2023-03-02 09:21:23 +03:00
|
|
|
def rb_iseq_only_optparam_p(iseq)
|
|
|
|
_iseq = iseq.to_i
|
|
|
|
Primitive.cstmt! %{
|
|
|
|
extern bool rb_iseq_only_optparam_p(const rb_iseq_t *iseq);
|
|
|
|
return RBOOL(rb_iseq_only_optparam_p((rb_iseq_t *)NUM2SIZET(_iseq)));
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2023-03-05 08:35:45 +03:00
|
|
|
def rb_iseq_only_kwparam_p(iseq)
|
|
|
|
_iseq = iseq.to_i
|
|
|
|
Primitive.cstmt! %{
|
|
|
|
extern bool rb_iseq_only_kwparam_p(const rb_iseq_t *iseq);
|
|
|
|
return RBOOL(rb_iseq_only_kwparam_p((rb_iseq_t *)NUM2SIZET(_iseq)));
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2023-03-03 08:14:26 +03:00
|
|
|
def rb_obj_frozen_p(obj)
|
|
|
|
Primitive.cexpr! 'rb_obj_frozen_p(obj)'
|
|
|
|
end
|
|
|
|
|
2023-03-03 09:23:47 +03:00
|
|
|
def rb_intern(str)
|
|
|
|
Primitive.cexpr! 'SIZET2NUM((size_t)rb_intern(RSTRING_PTR(str)))'
|
|
|
|
end
|
|
|
|
|
|
|
|
def rb_method_entry_at(klass, mid)
|
|
|
|
me_addr = Primitive.cexpr! 'SIZET2NUM((size_t)rb_method_entry_at(klass, (ID)NUM2SIZET(mid)))'
|
|
|
|
me_addr == 0 ? nil : rb_method_entry_t.new(me_addr)
|
|
|
|
end
|
|
|
|
|
2024-06-04 20:39:17 +03:00
|
|
|
def rb_shape_get_next_no_warnings(shape, obj, id)
|
2023-03-03 10:44:57 +03:00
|
|
|
_shape = shape.to_i
|
2024-06-04 20:39:17 +03:00
|
|
|
shape_addr = Primitive.cexpr! 'SIZET2NUM((size_t)rb_shape_get_next_no_warnings((rb_shape_t *)NUM2SIZET(_shape), obj, (ID)NUM2SIZET(id)))'
|
2023-03-03 10:44:57 +03:00
|
|
|
rb_shape_t.new(shape_addr)
|
|
|
|
end
|
|
|
|
|
|
|
|
def rb_shape_id(shape)
|
|
|
|
_shape = shape.to_i
|
|
|
|
Primitive.cexpr! 'SIZET2NUM((size_t)rb_shape_id((rb_shape_t *)NUM2SIZET(_shape)))'
|
|
|
|
end
|
|
|
|
|
2023-03-04 09:30:18 +03:00
|
|
|
def rb_class_attached_object(klass)
|
|
|
|
Primitive.cexpr! 'rb_class_attached_object(klass)'
|
|
|
|
end
|
|
|
|
|
2023-03-04 11:01:30 +03:00
|
|
|
def rb_singleton_class(obj)
|
|
|
|
Primitive.cexpr! 'rb_singleton_class(obj)'
|
|
|
|
end
|
|
|
|
|
2023-03-05 09:22:56 +03:00
|
|
|
def rb_aliased_callable_method_entry(cme)
|
|
|
|
_cme = cme.to_i
|
|
|
|
cme_addr = Primitive.cstmt! %{
|
|
|
|
extern const rb_callable_method_entry_t * rb_aliased_callable_method_entry(const rb_callable_method_entry_t *me);
|
|
|
|
return SIZET2NUM((size_t)rb_aliased_callable_method_entry((const rb_callable_method_entry_t *)NUM2SIZET(_cme)));
|
|
|
|
}
|
|
|
|
rb_callable_method_entry_t.new(cme_addr)
|
|
|
|
end
|
|
|
|
|
2023-03-05 09:42:03 +03:00
|
|
|
def rb_yjit_get_proc_ptr(proc_addr)
|
|
|
|
proc_t_addr = Primitive.cstmt! %{
|
2023-03-09 10:37:58 +03:00
|
|
|
extern rb_proc_t * rjit_get_proc_ptr(VALUE procv);
|
|
|
|
return SIZET2NUM((size_t)rjit_get_proc_ptr((VALUE)NUM2SIZET(proc_addr)));
|
2023-03-05 09:42:03 +03:00
|
|
|
}
|
|
|
|
rb_proc_t.new(proc_t_addr)
|
|
|
|
end
|
|
|
|
|
2022-10-13 00:37:02 +03:00
|
|
|
def rb_shape_get_shape_by_id(shape_id)
|
|
|
|
_shape_id = shape_id.to_i
|
2023-03-12 07:46:58 +03:00
|
|
|
shape_addr = Primitive.cexpr! 'SIZET2NUM((VALUE)rb_shape_get_shape_by_id((shape_id_t)NUM2UINT(_shape_id)))'
|
2022-10-13 00:37:02 +03:00
|
|
|
rb_shape_t.new(shape_addr)
|
|
|
|
end
|
|
|
|
|
2022-09-18 17:17:22 +03:00
|
|
|
def rb_iseq_check(iseq)
|
|
|
|
_iseq_addr = iseq.to_i
|
2023-03-12 07:46:58 +03:00
|
|
|
iseq_addr = Primitive.cexpr! 'SIZET2NUM((VALUE)rb_iseq_check((rb_iseq_t *)NUM2SIZET(_iseq_addr)))'
|
2022-09-18 17:17:22 +03:00
|
|
|
rb_iseq_t.new(iseq_addr)
|
|
|
|
end
|
|
|
|
|
|
|
|
def rb_iseq_path(iseq)
|
|
|
|
_iseq_addr = iseq.to_i
|
2023-03-12 07:46:58 +03:00
|
|
|
Primitive.cexpr! 'rb_iseq_path((rb_iseq_t *)NUM2SIZET(_iseq_addr))'
|
2022-09-18 17:17:22 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
def vm_ci_argc(ci)
|
|
|
|
_ci_addr = ci.to_i
|
2023-03-12 07:46:58 +03:00
|
|
|
Primitive.cexpr! 'UINT2NUM(vm_ci_argc((CALL_INFO)NUM2SIZET(_ci_addr)))'
|
2022-09-18 17:17:22 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
def vm_ci_flag(ci)
|
|
|
|
_ci_addr = ci.to_i
|
2023-03-12 07:46:58 +03:00
|
|
|
Primitive.cexpr! 'UINT2NUM(vm_ci_flag((CALL_INFO)NUM2SIZET(_ci_addr)))'
|
2022-09-18 17:17:22 +03:00
|
|
|
end
|
|
|
|
|
2023-03-28 07:58:50 +03:00
|
|
|
def vm_ci_kwarg(ci)
|
|
|
|
_ci_addr = ci.to_i
|
|
|
|
kwarg_addr = Primitive.cexpr! 'SIZET2NUM((size_t)vm_ci_kwarg((CALL_INFO)NUM2SIZET(_ci_addr)))'
|
|
|
|
kwarg_addr == 0 ? nil : rb_callinfo_kwarg.new(kwarg_addr)
|
|
|
|
end
|
|
|
|
|
2023-01-08 08:24:30 +03:00
|
|
|
def vm_ci_mid(ci)
|
|
|
|
_ci_addr = ci.to_i
|
2023-03-12 07:46:58 +03:00
|
|
|
Primitive.cexpr! 'SIZET2NUM((size_t)vm_ci_mid((CALL_INFO)NUM2SIZET(_ci_addr)))'
|
2023-01-08 08:24:30 +03:00
|
|
|
end
|
|
|
|
|
2023-03-07 10:17:25 +03:00
|
|
|
def rjit_opts
|
2023-03-12 07:46:58 +03:00
|
|
|
addr = Primitive.cexpr! 'SIZET2NUM((VALUE)&rb_rjit_opts)'
|
2023-03-19 07:27:07 +03:00
|
|
|
rb_rjit_options.new(addr)
|
2022-09-18 17:17:22 +03:00
|
|
|
end
|
|
|
|
|
2023-03-07 10:17:25 +03:00
|
|
|
def rjit_cancel_all(reason)
|
2022-12-24 12:13:40 +03:00
|
|
|
Primitive.cstmt! %{
|
2023-03-08 10:44:26 +03:00
|
|
|
rb_rjit_cancel_all(RSTRING_PTR(reason));
|
2022-12-24 12:13:40 +03:00
|
|
|
return Qnil;
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2023-02-11 04:41:59 +03:00
|
|
|
# Convert an encoded VM pointer to an insn BIN.
|
2022-09-18 17:17:22 +03:00
|
|
|
def rb_vm_insn_decode(encoded)
|
2023-02-11 04:41:59 +03:00
|
|
|
# Using rb_vm_insn_addr2opcode to return trace_ insns
|
2023-03-12 07:46:58 +03:00
|
|
|
Primitive.cexpr! 'INT2NUM(rb_vm_insn_addr2opcode((void *)NUM2SIZET(encoded)))'
|
2022-09-18 17:17:22 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
# Convert Integer VALUE to an actual Ruby object
|
|
|
|
def to_ruby(value)
|
2023-03-12 07:46:58 +03:00
|
|
|
Primitive.cexpr! '(VALUE)NUM2SIZET(value)'
|
2022-09-18 17:17:22 +03:00
|
|
|
end
|
|
|
|
|
2023-03-11 00:19:05 +03:00
|
|
|
def HAVE_LIBCAPSTONE
|
|
|
|
Primitive.cstmt! %{
|
|
|
|
#ifdef HAVE_LIBCAPSTONE
|
|
|
|
return Qtrue;
|
|
|
|
#else
|
|
|
|
return Qfalse;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2023-03-12 23:55:39 +03:00
|
|
|
def rjit_exit_traces
|
|
|
|
Primitive.cexpr! 'rjit_exit_traces()'
|
|
|
|
end
|
|
|
|
|
2023-03-13 08:27:43 +03:00
|
|
|
def rb_vm_ep_local_ep(ep)
|
|
|
|
_ep = ep.to_i
|
|
|
|
lep_addr = Primitive.cexpr! 'SIZET2NUM((size_t)rb_vm_ep_local_ep((const VALUE *)NUM2SIZET(_ep)))'
|
|
|
|
C.VALUE.new(lep_addr)
|
|
|
|
end
|
|
|
|
|
2023-03-19 08:13:40 +03:00
|
|
|
def rb_hash_keys(hash)
|
|
|
|
Primitive.cexpr! 'rb_hash_keys(hash)'
|
|
|
|
end
|
|
|
|
|
|
|
|
def rb_hash_stlike_lookup(hash, key)
|
|
|
|
Primitive.cstmt! %{
|
|
|
|
VALUE result = Qnil;
|
|
|
|
rb_hash_stlike_lookup(hash, key, &result);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
end
|
2023-03-19 08:57:31 +03:00
|
|
|
|
2023-03-19 09:13:25 +03:00
|
|
|
def rb_obj_class(obj)
|
|
|
|
Primitive.cexpr! 'rb_obj_class(obj)'
|
|
|
|
end
|
2023-03-19 23:46:09 +03:00
|
|
|
|
|
|
|
def rb_sym2id(sym)
|
|
|
|
Primitive.cexpr! 'SIZET2NUM((size_t)rb_sym2id(sym))'
|
|
|
|
end
|
|
|
|
|
|
|
|
def rb_callable_method_entry_or_negative(klass, mid)
|
|
|
|
cme_addr = Primitive.cexpr! 'SIZET2NUM((size_t)rb_callable_method_entry_or_negative(klass, (ID)NUM2SIZET(mid)))'
|
|
|
|
return nil if cme_addr == 0
|
|
|
|
rb_callable_method_entry_t.new(cme_addr)
|
|
|
|
end
|
|
|
|
|
|
|
|
def rb_method_basic_definition_p(klass, mid)
|
|
|
|
Primitive.cexpr! 'RBOOL(rb_method_basic_definition_p(klass, (ID)NUM2SIZET(mid)))'
|
|
|
|
end
|
|
|
|
|
|
|
|
def UNDEFINED_METHOD_ENTRY_P(cme)
|
|
|
|
_cme_addr = cme.to_i
|
|
|
|
Primitive.cexpr! 'RBOOL(UNDEFINED_METHOD_ENTRY_P((const rb_callable_method_entry_t *)NUM2SIZET(_cme_addr)))'
|
|
|
|
end
|
2023-03-21 10:10:14 +03:00
|
|
|
|
|
|
|
def RCLASS_ORIGIN(klass)
|
|
|
|
Primitive.cexpr! 'RCLASS_ORIGIN(klass)'
|
|
|
|
end
|
2024-03-06 19:04:22 +03:00
|
|
|
|
|
|
|
def RCLASS_SINGLETON_P(klass)
|
|
|
|
Primitive.cexpr! 'RCLASS_SINGLETON_P(klass)'
|
|
|
|
end
|
2023-03-19 08:13:40 +03:00
|
|
|
end
|
2023-03-10 22:42:02 +03:00
|
|
|
|
2023-03-19 08:13:40 +03:00
|
|
|
#
|
|
|
|
# Utilities: Not used by RJIT, but useful for debugging
|
|
|
|
#
|
|
|
|
class << C
|
2023-03-10 22:42:02 +03:00
|
|
|
# Convert insn BINs to encoded VM pointers.
|
|
|
|
def rb_vm_insn_encode(bin)
|
2023-03-12 07:46:58 +03:00
|
|
|
Primitive.cexpr! 'SIZET2NUM((VALUE)rb_vm_get_insns_address_table()[NUM2INT(bin)])'
|
2023-03-10 22:42:02 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
# Convert RubyVM::InstructionSequence to C.rb_iseq_t.
|
2022-09-18 17:17:22 +03:00
|
|
|
def rb_iseqw_to_iseq(iseqw)
|
2023-03-12 07:46:58 +03:00
|
|
|
iseq_addr = Primitive.cexpr! 'SIZET2NUM((VALUE)rb_iseqw_to_iseq(iseqw))'
|
2022-09-18 17:17:22 +03:00
|
|
|
rb_iseq_t.new(iseq_addr)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-03-07 10:15:30 +03:00
|
|
|
### RJIT bindgen begin ###
|
2022-09-18 17:17:22 +03:00
|
|
|
|
2023-03-20 07:18:09 +03:00
|
|
|
C::UNLIMITED_ARGUMENTS = Primitive.cexpr! %q{ LONG2NUM(UNLIMITED_ARGUMENTS) }
|
2023-03-12 08:31:18 +03:00
|
|
|
C::VM_ENV_DATA_INDEX_ME_CREF = Primitive.cexpr! %q{ LONG2NUM(VM_ENV_DATA_INDEX_ME_CREF) }
|
|
|
|
C::VM_ENV_DATA_INDEX_SPECVAL = Primitive.cexpr! %q{ LONG2NUM(VM_ENV_DATA_INDEX_SPECVAL) }
|
2023-03-12 08:54:09 +03:00
|
|
|
C::ARRAY_REDEFINED_OP_FLAG = Primitive.cexpr! %q{ SIZET2NUM(ARRAY_REDEFINED_OP_FLAG) }
|
|
|
|
C::BOP_AND = Primitive.cexpr! %q{ SIZET2NUM(BOP_AND) }
|
|
|
|
C::BOP_AREF = Primitive.cexpr! %q{ SIZET2NUM(BOP_AREF) }
|
|
|
|
C::BOP_EQ = Primitive.cexpr! %q{ SIZET2NUM(BOP_EQ) }
|
2023-03-19 08:13:40 +03:00
|
|
|
C::BOP_EQQ = Primitive.cexpr! %q{ SIZET2NUM(BOP_EQQ) }
|
2023-03-12 08:54:09 +03:00
|
|
|
C::BOP_FREEZE = Primitive.cexpr! %q{ SIZET2NUM(BOP_FREEZE) }
|
|
|
|
C::BOP_GE = Primitive.cexpr! %q{ SIZET2NUM(BOP_GE) }
|
|
|
|
C::BOP_GT = Primitive.cexpr! %q{ SIZET2NUM(BOP_GT) }
|
|
|
|
C::BOP_LE = Primitive.cexpr! %q{ SIZET2NUM(BOP_LE) }
|
|
|
|
C::BOP_LT = Primitive.cexpr! %q{ SIZET2NUM(BOP_LT) }
|
|
|
|
C::BOP_MINUS = Primitive.cexpr! %q{ SIZET2NUM(BOP_MINUS) }
|
|
|
|
C::BOP_MOD = Primitive.cexpr! %q{ SIZET2NUM(BOP_MOD) }
|
|
|
|
C::BOP_OR = Primitive.cexpr! %q{ SIZET2NUM(BOP_OR) }
|
|
|
|
C::BOP_PLUS = Primitive.cexpr! %q{ SIZET2NUM(BOP_PLUS) }
|
2023-03-27 05:20:03 +03:00
|
|
|
C::BUILTIN_ATTR_LEAF = Primitive.cexpr! %q{ SIZET2NUM(BUILTIN_ATTR_LEAF) }
|
2023-03-12 08:54:09 +03:00
|
|
|
C::HASH_REDEFINED_OP_FLAG = Primitive.cexpr! %q{ SIZET2NUM(HASH_REDEFINED_OP_FLAG) }
|
|
|
|
C::INTEGER_REDEFINED_OP_FLAG = Primitive.cexpr! %q{ SIZET2NUM(INTEGER_REDEFINED_OP_FLAG) }
|
|
|
|
C::INVALID_SHAPE_ID = Primitive.cexpr! %q{ SIZET2NUM(INVALID_SHAPE_ID) }
|
|
|
|
C::METHOD_VISI_PRIVATE = Primitive.cexpr! %q{ SIZET2NUM(METHOD_VISI_PRIVATE) }
|
|
|
|
C::METHOD_VISI_PROTECTED = Primitive.cexpr! %q{ SIZET2NUM(METHOD_VISI_PROTECTED) }
|
|
|
|
C::METHOD_VISI_PUBLIC = Primitive.cexpr! %q{ SIZET2NUM(METHOD_VISI_PUBLIC) }
|
2023-03-19 23:46:09 +03:00
|
|
|
C::METHOD_VISI_UNDEF = Primitive.cexpr! %q{ SIZET2NUM(METHOD_VISI_UNDEF) }
|
2023-03-12 08:54:09 +03:00
|
|
|
C::OBJ_TOO_COMPLEX_SHAPE_ID = Primitive.cexpr! %q{ SIZET2NUM(OBJ_TOO_COMPLEX_SHAPE_ID) }
|
|
|
|
C::OPTIMIZED_METHOD_TYPE_BLOCK_CALL = Primitive.cexpr! %q{ SIZET2NUM(OPTIMIZED_METHOD_TYPE_BLOCK_CALL) }
|
|
|
|
C::OPTIMIZED_METHOD_TYPE_CALL = Primitive.cexpr! %q{ SIZET2NUM(OPTIMIZED_METHOD_TYPE_CALL) }
|
|
|
|
C::OPTIMIZED_METHOD_TYPE_SEND = Primitive.cexpr! %q{ SIZET2NUM(OPTIMIZED_METHOD_TYPE_SEND) }
|
|
|
|
C::OPTIMIZED_METHOD_TYPE_STRUCT_AREF = Primitive.cexpr! %q{ SIZET2NUM(OPTIMIZED_METHOD_TYPE_STRUCT_AREF) }
|
|
|
|
C::OPTIMIZED_METHOD_TYPE_STRUCT_ASET = Primitive.cexpr! %q{ SIZET2NUM(OPTIMIZED_METHOD_TYPE_STRUCT_ASET) }
|
|
|
|
C::RARRAY_EMBED_FLAG = Primitive.cexpr! %q{ SIZET2NUM(RARRAY_EMBED_FLAG) }
|
|
|
|
C::RARRAY_EMBED_LEN_MASK = Primitive.cexpr! %q{ SIZET2NUM(RARRAY_EMBED_LEN_MASK) }
|
|
|
|
C::RARRAY_EMBED_LEN_SHIFT = Primitive.cexpr! %q{ SIZET2NUM(RARRAY_EMBED_LEN_SHIFT) }
|
2023-03-22 08:55:23 +03:00
|
|
|
C::RHASH_PASS_AS_KEYWORDS = Primitive.cexpr! %q{ SIZET2NUM(RHASH_PASS_AS_KEYWORDS) }
|
2023-03-12 08:54:09 +03:00
|
|
|
C::RMODULE_IS_REFINEMENT = Primitive.cexpr! %q{ SIZET2NUM(RMODULE_IS_REFINEMENT) }
|
|
|
|
C::ROBJECT_EMBED = Primitive.cexpr! %q{ SIZET2NUM(ROBJECT_EMBED) }
|
|
|
|
C::RSTRUCT_EMBED_LEN_MASK = Primitive.cexpr! %q{ SIZET2NUM(RSTRUCT_EMBED_LEN_MASK) }
|
2023-03-19 09:49:11 +03:00
|
|
|
C::RUBY_ENCODING_MASK = Primitive.cexpr! %q{ SIZET2NUM(RUBY_ENCODING_MASK) }
|
2023-03-12 08:54:09 +03:00
|
|
|
C::RUBY_EVENT_CLASS = Primitive.cexpr! %q{ SIZET2NUM(RUBY_EVENT_CLASS) }
|
|
|
|
C::RUBY_EVENT_C_CALL = Primitive.cexpr! %q{ SIZET2NUM(RUBY_EVENT_C_CALL) }
|
|
|
|
C::RUBY_EVENT_C_RETURN = Primitive.cexpr! %q{ SIZET2NUM(RUBY_EVENT_C_RETURN) }
|
|
|
|
C::RUBY_FIXNUM_FLAG = Primitive.cexpr! %q{ SIZET2NUM(RUBY_FIXNUM_FLAG) }
|
|
|
|
C::RUBY_FLONUM_FLAG = Primitive.cexpr! %q{ SIZET2NUM(RUBY_FLONUM_FLAG) }
|
|
|
|
C::RUBY_FLONUM_MASK = Primitive.cexpr! %q{ SIZET2NUM(RUBY_FLONUM_MASK) }
|
2023-03-19 23:36:26 +03:00
|
|
|
C::RUBY_FL_FREEZE = Primitive.cexpr! %q{ SIZET2NUM(RUBY_FL_FREEZE) }
|
2023-03-12 08:54:09 +03:00
|
|
|
C::RUBY_IMMEDIATE_MASK = Primitive.cexpr! %q{ SIZET2NUM(RUBY_IMMEDIATE_MASK) }
|
|
|
|
C::RUBY_SPECIAL_SHIFT = Primitive.cexpr! %q{ SIZET2NUM(RUBY_SPECIAL_SHIFT) }
|
|
|
|
C::RUBY_SYMBOL_FLAG = Primitive.cexpr! %q{ SIZET2NUM(RUBY_SYMBOL_FLAG) }
|
|
|
|
C::RUBY_T_ARRAY = Primitive.cexpr! %q{ SIZET2NUM(RUBY_T_ARRAY) }
|
2023-03-19 08:57:31 +03:00
|
|
|
C::RUBY_T_CLASS = Primitive.cexpr! %q{ SIZET2NUM(RUBY_T_CLASS) }
|
2023-03-22 08:55:23 +03:00
|
|
|
C::RUBY_T_HASH = Primitive.cexpr! %q{ SIZET2NUM(RUBY_T_HASH) }
|
2023-03-12 08:54:09 +03:00
|
|
|
C::RUBY_T_ICLASS = Primitive.cexpr! %q{ SIZET2NUM(RUBY_T_ICLASS) }
|
|
|
|
C::RUBY_T_MASK = Primitive.cexpr! %q{ SIZET2NUM(RUBY_T_MASK) }
|
|
|
|
C::RUBY_T_MODULE = Primitive.cexpr! %q{ SIZET2NUM(RUBY_T_MODULE) }
|
2023-03-27 03:41:05 +03:00
|
|
|
C::RUBY_T_OBJECT = Primitive.cexpr! %q{ SIZET2NUM(RUBY_T_OBJECT) }
|
2023-03-12 08:54:09 +03:00
|
|
|
C::RUBY_T_STRING = Primitive.cexpr! %q{ SIZET2NUM(RUBY_T_STRING) }
|
2023-03-13 08:27:43 +03:00
|
|
|
C::RUBY_T_SYMBOL = Primitive.cexpr! %q{ SIZET2NUM(RUBY_T_SYMBOL) }
|
2023-03-12 08:54:09 +03:00
|
|
|
C::SHAPE_FLAG_SHIFT = Primitive.cexpr! %q{ SIZET2NUM(SHAPE_FLAG_SHIFT) }
|
|
|
|
C::SHAPE_FROZEN = Primitive.cexpr! %q{ SIZET2NUM(SHAPE_FROZEN) }
|
|
|
|
C::SHAPE_ID_NUM_BITS = Primitive.cexpr! %q{ SIZET2NUM(SHAPE_ID_NUM_BITS) }
|
|
|
|
C::SHAPE_IVAR = Primitive.cexpr! %q{ SIZET2NUM(SHAPE_IVAR) }
|
|
|
|
C::SHAPE_MASK = Primitive.cexpr! %q{ SIZET2NUM(SHAPE_MASK) }
|
|
|
|
C::SHAPE_ROOT = Primitive.cexpr! %q{ SIZET2NUM(SHAPE_ROOT) }
|
|
|
|
C::STRING_REDEFINED_OP_FLAG = Primitive.cexpr! %q{ SIZET2NUM(STRING_REDEFINED_OP_FLAG) }
|
|
|
|
C::T_OBJECT = Primitive.cexpr! %q{ SIZET2NUM(T_OBJECT) }
|
|
|
|
C::VM_BLOCK_HANDLER_NONE = Primitive.cexpr! %q{ SIZET2NUM(VM_BLOCK_HANDLER_NONE) }
|
|
|
|
C::VM_CALL_ARGS_BLOCKARG = Primitive.cexpr! %q{ SIZET2NUM(VM_CALL_ARGS_BLOCKARG) }
|
|
|
|
C::VM_CALL_ARGS_SPLAT = Primitive.cexpr! %q{ SIZET2NUM(VM_CALL_ARGS_SPLAT) }
|
|
|
|
C::VM_CALL_FCALL = Primitive.cexpr! %q{ SIZET2NUM(VM_CALL_FCALL) }
|
Optimized forwarding callers and callees
This patch optimizes forwarding callers and callees. It only optimizes methods that only take `...` as their parameter, and then pass `...` to other calls.
Calls it optimizes look like this:
```ruby
def bar(a) = a
def foo(...) = bar(...) # optimized
foo(123)
```
```ruby
def bar(a) = a
def foo(...) = bar(1, 2, ...) # optimized
foo(123)
```
```ruby
def bar(*a) = a
def foo(...)
list = [1, 2]
bar(*list, ...) # optimized
end
foo(123)
```
All variants of the above but using `super` are also optimized, including a bare super like this:
```ruby
def foo(...)
super
end
```
This patch eliminates intermediate allocations made when calling methods that accept `...`.
We can observe allocation elimination like this:
```ruby
def m
x = GC.stat(:total_allocated_objects)
yield
GC.stat(:total_allocated_objects) - x
end
def bar(a) = a
def foo(...) = bar(...)
def test
m { foo(123) }
end
test
p test # allocates 1 object on master, but 0 objects with this patch
```
```ruby
def bar(a, b:) = a + b
def foo(...) = bar(...)
def test
m { foo(1, b: 2) }
end
test
p test # allocates 2 objects on master, but 0 objects with this patch
```
How does it work?
-----------------
This patch works by using a dynamic stack size when passing forwarded parameters to callees.
The caller's info object (known as the "CI") contains the stack size of the
parameters, so we pass the CI object itself as a parameter to the callee.
When forwarding parameters, the forwarding ISeq uses the caller's CI to determine how much stack to copy, then copies the caller's stack before calling the callee.
The CI at the forwarded call site is adjusted using information from the caller's CI.
I think this description is kind of confusing, so let's walk through an example with code.
```ruby
def delegatee(a, b) = a + b
def delegator(...)
delegatee(...) # CI2 (FORWARDING)
end
def caller
delegator(1, 2) # CI1 (argc: 2)
end
```
Before we call the delegator method, the stack looks like this:
```
Executing Line | Code | Stack
---------------+---------------------------------------+--------
1| def delegatee(a, b) = a + b | self
2| | 1
3| def delegator(...) | 2
4| # |
5| delegatee(...) # CI2 (FORWARDING) |
6| end |
7| |
8| def caller |
-> 9| delegator(1, 2) # CI1 (argc: 2) |
10| end |
```
The ISeq for `delegator` is tagged as "forwardable", so when `caller` calls in
to `delegator`, it writes `CI1` on to the stack as a local variable for the
`delegator` method. The `delegator` method has a special local called `...`
that holds the caller's CI object.
Here is the ISeq disasm fo `delegator`:
```
== disasm: #<ISeq:delegator@-e:1 (1,0)-(1,39)>
local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1])
[ 1] "..."@0
0000 putself ( 1)[LiCa]
0001 getlocal_WC_0 "..."@0
0003 send <calldata!mid:delegatee, argc:0, FCALL|FORWARDING>, nil
0006 leave [Re]
```
The local called `...` will contain the caller's CI: CI1.
Here is the stack when we enter `delegator`:
```
Executing Line | Code | Stack
---------------+---------------------------------------+--------
1| def delegatee(a, b) = a + b | self
2| | 1
3| def delegator(...) | 2
-> 4| # | CI1 (argc: 2)
5| delegatee(...) # CI2 (FORWARDING) | cref_or_me
6| end | specval
7| | type
8| def caller |
9| delegator(1, 2) # CI1 (argc: 2) |
10| end |
```
The CI at `delegatee` on line 5 is tagged as "FORWARDING", so it knows to
memcopy the caller's stack before calling `delegatee`. In this case, it will
memcopy self, 1, and 2 to the stack before calling `delegatee`. It knows how much
memory to copy from the caller because `CI1` contains stack size information
(argc: 2).
Before executing the `send` instruction, we push `...` on the stack. The
`send` instruction pops `...`, and because it is tagged with `FORWARDING`, it
knows to memcopy (using the information in the CI it just popped):
```
== disasm: #<ISeq:delegator@-e:1 (1,0)-(1,39)>
local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1])
[ 1] "..."@0
0000 putself ( 1)[LiCa]
0001 getlocal_WC_0 "..."@0
0003 send <calldata!mid:delegatee, argc:0, FCALL|FORWARDING>, nil
0006 leave [Re]
```
Instruction 001 puts the caller's CI on the stack. `send` is tagged with
FORWARDING, so it reads the CI and _copies_ the callers stack to this stack:
```
Executing Line | Code | Stack
---------------+---------------------------------------+--------
1| def delegatee(a, b) = a + b | self
2| | 1
3| def delegator(...) | 2
4| # | CI1 (argc: 2)
-> 5| delegatee(...) # CI2 (FORWARDING) | cref_or_me
6| end | specval
7| | type
8| def caller | self
9| delegator(1, 2) # CI1 (argc: 2) | 1
10| end | 2
```
The "FORWARDING" call site combines information from CI1 with CI2 in order
to support passing other values in addition to the `...` value, as well as
perfectly forward splat args, kwargs, etc.
Since we're able to copy the stack from `caller` in to `delegator`'s stack, we
can avoid allocating objects.
I want to do this to eliminate object allocations for delegate methods.
My long term goal is to implement `Class#new` in Ruby and it uses `...`.
I was able to implement `Class#new` in Ruby
[here](https://github.com/ruby/ruby/pull/9289).
If we adopt the technique in this patch, then we can optimize allocating
objects that take keyword parameters for `initialize`.
For example, this code will allocate 2 objects: one for `SomeObject`, and one
for the kwargs:
```ruby
SomeObject.new(foo: 1)
```
If we combine this technique, plus implement `Class#new` in Ruby, then we can
reduce allocations for this common operation.
Co-Authored-By: John Hawthorn <john@hawthorn.email>
Co-Authored-By: Alan Wu <XrXr@users.noreply.github.com>
2024-04-15 20:48:53 +03:00
|
|
|
C::VM_CALL_FORWARDING = Primitive.cexpr! %q{ SIZET2NUM(VM_CALL_FORWARDING) }
|
2023-03-12 08:54:09 +03:00
|
|
|
C::VM_CALL_KWARG = Primitive.cexpr! %q{ SIZET2NUM(VM_CALL_KWARG) }
|
|
|
|
C::VM_CALL_KW_SPLAT = Primitive.cexpr! %q{ SIZET2NUM(VM_CALL_KW_SPLAT) }
|
2023-03-20 07:18:09 +03:00
|
|
|
C::VM_CALL_KW_SPLAT_MUT = Primitive.cexpr! %q{ SIZET2NUM(VM_CALL_KW_SPLAT_MUT) }
|
2023-03-12 08:54:09 +03:00
|
|
|
C::VM_CALL_KW_SPLAT_bit = Primitive.cexpr! %q{ SIZET2NUM(VM_CALL_KW_SPLAT_bit) }
|
|
|
|
C::VM_CALL_OPT_SEND = Primitive.cexpr! %q{ SIZET2NUM(VM_CALL_OPT_SEND) }
|
|
|
|
C::VM_CALL_TAILCALL = Primitive.cexpr! %q{ SIZET2NUM(VM_CALL_TAILCALL) }
|
|
|
|
C::VM_CALL_TAILCALL_bit = Primitive.cexpr! %q{ SIZET2NUM(VM_CALL_TAILCALL_bit) }
|
2023-03-28 07:58:50 +03:00
|
|
|
C::VM_CALL_ZSUPER = Primitive.cexpr! %q{ SIZET2NUM(VM_CALL_ZSUPER) }
|
2023-03-12 08:54:09 +03:00
|
|
|
C::VM_ENV_DATA_INDEX_FLAGS = Primitive.cexpr! %q{ SIZET2NUM(VM_ENV_DATA_INDEX_FLAGS) }
|
|
|
|
C::VM_ENV_DATA_SIZE = Primitive.cexpr! %q{ SIZET2NUM(VM_ENV_DATA_SIZE) }
|
|
|
|
C::VM_ENV_FLAG_LOCAL = Primitive.cexpr! %q{ SIZET2NUM(VM_ENV_FLAG_LOCAL) }
|
|
|
|
C::VM_ENV_FLAG_WB_REQUIRED = Primitive.cexpr! %q{ SIZET2NUM(VM_ENV_FLAG_WB_REQUIRED) }
|
|
|
|
C::VM_FRAME_FLAG_BMETHOD = Primitive.cexpr! %q{ SIZET2NUM(VM_FRAME_FLAG_BMETHOD) }
|
|
|
|
C::VM_FRAME_FLAG_CFRAME = Primitive.cexpr! %q{ SIZET2NUM(VM_FRAME_FLAG_CFRAME) }
|
|
|
|
C::VM_FRAME_FLAG_CFRAME_KW = Primitive.cexpr! %q{ SIZET2NUM(VM_FRAME_FLAG_CFRAME_KW) }
|
|
|
|
C::VM_FRAME_FLAG_LAMBDA = Primitive.cexpr! %q{ SIZET2NUM(VM_FRAME_FLAG_LAMBDA) }
|
|
|
|
C::VM_FRAME_FLAG_MODIFIED_BLOCK_PARAM = Primitive.cexpr! %q{ SIZET2NUM(VM_FRAME_FLAG_MODIFIED_BLOCK_PARAM) }
|
|
|
|
C::VM_FRAME_MAGIC_BLOCK = Primitive.cexpr! %q{ SIZET2NUM(VM_FRAME_MAGIC_BLOCK) }
|
|
|
|
C::VM_FRAME_MAGIC_CFUNC = Primitive.cexpr! %q{ SIZET2NUM(VM_FRAME_MAGIC_CFUNC) }
|
|
|
|
C::VM_FRAME_MAGIC_METHOD = Primitive.cexpr! %q{ SIZET2NUM(VM_FRAME_MAGIC_METHOD) }
|
|
|
|
C::VM_METHOD_TYPE_ALIAS = Primitive.cexpr! %q{ SIZET2NUM(VM_METHOD_TYPE_ALIAS) }
|
|
|
|
C::VM_METHOD_TYPE_ATTRSET = Primitive.cexpr! %q{ SIZET2NUM(VM_METHOD_TYPE_ATTRSET) }
|
|
|
|
C::VM_METHOD_TYPE_BMETHOD = Primitive.cexpr! %q{ SIZET2NUM(VM_METHOD_TYPE_BMETHOD) }
|
|
|
|
C::VM_METHOD_TYPE_CFUNC = Primitive.cexpr! %q{ SIZET2NUM(VM_METHOD_TYPE_CFUNC) }
|
|
|
|
C::VM_METHOD_TYPE_ISEQ = Primitive.cexpr! %q{ SIZET2NUM(VM_METHOD_TYPE_ISEQ) }
|
|
|
|
C::VM_METHOD_TYPE_IVAR = Primitive.cexpr! %q{ SIZET2NUM(VM_METHOD_TYPE_IVAR) }
|
|
|
|
C::VM_METHOD_TYPE_MISSING = Primitive.cexpr! %q{ SIZET2NUM(VM_METHOD_TYPE_MISSING) }
|
|
|
|
C::VM_METHOD_TYPE_NOTIMPLEMENTED = Primitive.cexpr! %q{ SIZET2NUM(VM_METHOD_TYPE_NOTIMPLEMENTED) }
|
|
|
|
C::VM_METHOD_TYPE_OPTIMIZED = Primitive.cexpr! %q{ SIZET2NUM(VM_METHOD_TYPE_OPTIMIZED) }
|
|
|
|
C::VM_METHOD_TYPE_REFINED = Primitive.cexpr! %q{ SIZET2NUM(VM_METHOD_TYPE_REFINED) }
|
|
|
|
C::VM_METHOD_TYPE_UNDEF = Primitive.cexpr! %q{ SIZET2NUM(VM_METHOD_TYPE_UNDEF) }
|
|
|
|
C::VM_METHOD_TYPE_ZSUPER = Primitive.cexpr! %q{ SIZET2NUM(VM_METHOD_TYPE_ZSUPER) }
|
2023-03-18 09:34:36 +03:00
|
|
|
C::VM_SPECIAL_OBJECT_VMCORE = Primitive.cexpr! %q{ SIZET2NUM(VM_SPECIAL_OBJECT_VMCORE) }
|
2023-02-09 01:24:10 +03:00
|
|
|
|
2024-02-16 10:13:45 +03:00
|
|
|
def C.block_type_iseq = Primitive.cexpr!(%q{ SIZET2NUM(block_type_iseq) })
|
|
|
|
def C.idRespond_to_missing = Primitive.cexpr!(%q{ SIZET2NUM(idRespond_to_missing) })
|
|
|
|
def C.imemo_callinfo = Primitive.cexpr!(%q{ SIZET2NUM(imemo_callinfo) })
|
|
|
|
def C.imemo_iseq = Primitive.cexpr!(%q{ SIZET2NUM(imemo_iseq) })
|
|
|
|
def C.rb_block_param_proxy = Primitive.cexpr!(%q{ SIZET2NUM(rb_block_param_proxy) })
|
|
|
|
def C.rb_cArray = Primitive.cexpr!(%q{ SIZET2NUM(rb_cArray) })
|
|
|
|
def C.rb_cFalseClass = Primitive.cexpr!(%q{ SIZET2NUM(rb_cFalseClass) })
|
|
|
|
def C.rb_cFloat = Primitive.cexpr!(%q{ SIZET2NUM(rb_cFloat) })
|
|
|
|
def C.rb_cInteger = Primitive.cexpr!(%q{ SIZET2NUM(rb_cInteger) })
|
|
|
|
def C.rb_cNilClass = Primitive.cexpr!(%q{ SIZET2NUM(rb_cNilClass) })
|
|
|
|
def C.rb_cString = Primitive.cexpr!(%q{ SIZET2NUM(rb_cString) })
|
|
|
|
def C.rb_cSymbol = Primitive.cexpr!(%q{ SIZET2NUM(rb_cSymbol) })
|
|
|
|
def C.rb_cTrueClass = Primitive.cexpr!(%q{ SIZET2NUM(rb_cTrueClass) })
|
|
|
|
def C.rb_mRubyVMFrozenCore = Primitive.cexpr!(%q{ SIZET2NUM(rb_mRubyVMFrozenCore) })
|
|
|
|
def C.rb_rjit_global_events = Primitive.cexpr!(%q{ SIZET2NUM(rb_rjit_global_events) })
|
|
|
|
def C.rb_vm_insns_count = Primitive.cexpr!(%q{ SIZET2NUM(rb_vm_insns_count) })
|
2023-12-19 10:49:54 +03:00
|
|
|
|
2023-03-19 07:37:16 +03:00
|
|
|
def C.rb_ary_clear
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_ary_clear) }
|
|
|
|
end
|
|
|
|
|
2023-04-02 07:52:35 +03:00
|
|
|
def C.rb_ary_dup
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_ary_dup) }
|
|
|
|
end
|
|
|
|
|
2023-03-12 08:10:44 +03:00
|
|
|
def C.rb_ary_entry_internal
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_ary_entry_internal) }
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.rb_ary_push
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_ary_push) }
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.rb_ary_resurrect
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_ary_resurrect) }
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.rb_ary_store
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_ary_store) }
|
|
|
|
end
|
|
|
|
|
2023-03-19 07:37:16 +03:00
|
|
|
def C.rb_ary_tmp_new_from_values
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_ary_tmp_new_from_values) }
|
|
|
|
end
|
|
|
|
|
2023-04-02 09:06:45 +03:00
|
|
|
def C.rb_ary_unshift_m
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_ary_unshift_m) }
|
|
|
|
end
|
|
|
|
|
2023-03-18 10:00:18 +03:00
|
|
|
def C.rb_backref_get
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_backref_get) }
|
|
|
|
end
|
|
|
|
|
2023-03-12 08:10:44 +03:00
|
|
|
def C.rb_ec_ary_new_from_values
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_ec_ary_new_from_values) }
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.rb_ec_str_resurrect
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_ec_str_resurrect) }
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.rb_ensure_iv_list_size
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_ensure_iv_list_size) }
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.rb_fix_aref
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_fix_aref) }
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.rb_fix_div_fix
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_fix_div_fix) }
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.rb_fix_mod_fix
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_fix_mod_fix) }
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.rb_fix_mul_fix
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_fix_mul_fix) }
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.rb_gc_writebarrier
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_gc_writebarrier) }
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.rb_get_symbol_id
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_get_symbol_id) }
|
|
|
|
end
|
|
|
|
|
2023-03-19 07:20:37 +03:00
|
|
|
def C.rb_gvar_get
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_gvar_get) }
|
|
|
|
end
|
|
|
|
|
2023-03-12 08:10:44 +03:00
|
|
|
def C.rb_hash_aref
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_hash_aref) }
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.rb_hash_aset
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_hash_aset) }
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.rb_hash_bulk_insert
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_hash_bulk_insert) }
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.rb_hash_new
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_hash_new) }
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.rb_hash_new_with_size
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_hash_new_with_size) }
|
|
|
|
end
|
2023-03-13 08:09:04 +03:00
|
|
|
|
2023-06-22 02:02:08 +03:00
|
|
|
def C.rb_hash_resurrect
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_hash_resurrect) }
|
|
|
|
end
|
|
|
|
|
2023-03-13 08:09:04 +03:00
|
|
|
def C.rb_ivar_defined
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_ivar_defined) }
|
|
|
|
end
|
2023-03-12 08:10:44 +03:00
|
|
|
|
|
|
|
def C.rb_ivar_get
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_ivar_get) }
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.rb_obj_as_string_result
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_obj_as_string_result) }
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.rb_obj_is_kind_of
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_obj_is_kind_of) }
|
|
|
|
end
|
|
|
|
|
2023-03-19 07:24:28 +03:00
|
|
|
def C.rb_range_new
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_range_new) }
|
|
|
|
end
|
|
|
|
|
2023-03-18 10:00:18 +03:00
|
|
|
def C.rb_reg_last_match
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_reg_last_match) }
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.rb_reg_match_last
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_reg_match_last) }
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.rb_reg_match_post
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_reg_match_post) }
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.rb_reg_match_pre
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_reg_match_pre) }
|
|
|
|
end
|
|
|
|
|
2023-03-19 07:37:16 +03:00
|
|
|
def C.rb_reg_new_ary
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_reg_new_ary) }
|
|
|
|
end
|
|
|
|
|
2023-03-18 10:00:18 +03:00
|
|
|
def C.rb_reg_nth_match
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_reg_nth_match) }
|
|
|
|
end
|
|
|
|
|
2023-04-03 01:26:46 +03:00
|
|
|
def C.rb_rjit_branch_stub_hit
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_rjit_branch_stub_hit) }
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.rb_rjit_entry_stub_hit
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_rjit_entry_stub_hit) }
|
|
|
|
end
|
|
|
|
|
2023-03-19 09:49:11 +03:00
|
|
|
def C.rb_str_buf_append
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_str_buf_append) }
|
|
|
|
end
|
|
|
|
|
2023-03-19 09:33:10 +03:00
|
|
|
def C.rb_str_bytesize
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_str_bytesize) }
|
|
|
|
end
|
|
|
|
|
2023-03-12 08:10:44 +03:00
|
|
|
def C.rb_str_concat_literals
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_str_concat_literals) }
|
|
|
|
end
|
|
|
|
|
2023-03-19 23:36:26 +03:00
|
|
|
def C.rb_str_dup
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_str_dup) }
|
|
|
|
end
|
|
|
|
|
2023-03-12 08:10:44 +03:00
|
|
|
def C.rb_str_eql_internal
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_str_eql_internal) }
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.rb_str_getbyte
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_str_getbyte) }
|
|
|
|
end
|
|
|
|
|
2023-03-19 07:42:10 +03:00
|
|
|
def C.rb_str_intern
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_str_intern) }
|
|
|
|
end
|
|
|
|
|
2023-04-07 07:13:10 +03:00
|
|
|
def C.rb_sym_to_proc
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_sym_to_proc) }
|
|
|
|
end
|
|
|
|
|
2023-03-12 08:10:44 +03:00
|
|
|
def C.rb_vm_bh_to_procval
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_vm_bh_to_procval) }
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.rb_vm_concat_array
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_vm_concat_array) }
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.rb_vm_defined
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_vm_defined) }
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.rb_vm_get_ev_const
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_vm_get_ev_const) }
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.rb_vm_getclassvariable
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_vm_getclassvariable) }
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.rb_vm_ic_hit_p
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_vm_ic_hit_p) }
|
|
|
|
end
|
|
|
|
|
2023-04-18 23:53:37 +03:00
|
|
|
def C.rb_vm_opt_newarray_hash
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_vm_opt_newarray_hash) }
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.rb_vm_opt_newarray_max
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_vm_opt_newarray_max) }
|
|
|
|
end
|
|
|
|
|
2023-03-12 08:10:44 +03:00
|
|
|
def C.rb_vm_opt_newarray_min
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_vm_opt_newarray_min) }
|
|
|
|
end
|
|
|
|
|
Introduce a specialize instruction for Array#pack
Instructions for this code:
```ruby
# frozen_string_literal: true
[a].pack("C")
```
Before this commit:
```
== disasm: #<ISeq:<main>@test.rb:1 (1,0)-(3,13)>
0000 putself ( 3)[Li]
0001 opt_send_without_block <calldata!mid:a, argc:0, FCALL|VCALL|ARGS_SIMPLE>
0003 newarray 1
0005 putobject "C"
0007 opt_send_without_block <calldata!mid:pack, argc:1, ARGS_SIMPLE>
0009 leave
```
After this commit:
```
== disasm: #<ISeq:<main>@test.rb:1 (1,0)-(3,13)>
0000 putself ( 3)[Li]
0001 opt_send_without_block <calldata!mid:a, argc:0, FCALL|VCALL|ARGS_SIMPLE>
0003 putobject "C"
0005 opt_newarray_send 2, :pack
0008 leave
```
Co-authored-by: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com>
Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org>
2024-05-23 21:23:26 +03:00
|
|
|
def C.rb_vm_opt_newarray_pack
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_vm_opt_newarray_pack) }
|
|
|
|
end
|
|
|
|
|
2023-03-27 03:41:05 +03:00
|
|
|
def C.rb_vm_set_ivar_id
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_vm_set_ivar_id) }
|
|
|
|
end
|
|
|
|
|
2023-03-19 07:49:42 +03:00
|
|
|
def C.rb_vm_setclassvariable
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_vm_setclassvariable) }
|
|
|
|
end
|
|
|
|
|
2023-03-12 08:10:44 +03:00
|
|
|
def C.rb_vm_setinstancevariable
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_vm_setinstancevariable) }
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.rb_vm_splat_array
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_vm_splat_array) }
|
|
|
|
end
|
|
|
|
|
2023-03-18 09:27:16 +03:00
|
|
|
def C.rb_vm_throw
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_vm_throw) }
|
|
|
|
end
|
|
|
|
|
2023-03-20 09:19:58 +03:00
|
|
|
def C.rb_vm_yield_with_cfunc
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_vm_yield_with_cfunc) }
|
|
|
|
end
|
|
|
|
|
2023-04-02 22:56:27 +03:00
|
|
|
def C.rjit_build_kwhash
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rjit_build_kwhash) }
|
|
|
|
end
|
|
|
|
|
2023-03-12 08:10:44 +03:00
|
|
|
def C.rjit_full_cfunc_return
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rjit_full_cfunc_return) }
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.rjit_optimized_call
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rjit_optimized_call) }
|
|
|
|
end
|
|
|
|
|
2023-04-02 07:52:35 +03:00
|
|
|
def C.rjit_rb_ary_subseq_length
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rjit_rb_ary_subseq_length) }
|
|
|
|
end
|
|
|
|
|
2023-03-12 23:55:39 +03:00
|
|
|
def C.rjit_record_exit_stack
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rjit_record_exit_stack) }
|
|
|
|
end
|
|
|
|
|
2023-03-12 08:10:44 +03:00
|
|
|
def C.rjit_str_neq_internal
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rjit_str_neq_internal) }
|
|
|
|
end
|
|
|
|
|
2023-03-19 09:49:11 +03:00
|
|
|
def C.rjit_str_simple_append
|
|
|
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rjit_str_simple_append) }
|
|
|
|
end
|
|
|
|
|
2022-09-19 03:25:04 +03:00
|
|
|
def C.CALL_DATA
|
|
|
|
@CALL_DATA ||= self.rb_call_data
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.IC
|
|
|
|
@IC ||= self.iseq_inline_constant_cache
|
|
|
|
end
|
|
|
|
|
2023-02-09 01:36:55 +03:00
|
|
|
def C.ID
|
|
|
|
@ID ||= CType::Immediate.parse("unsigned long")
|
|
|
|
end
|
|
|
|
|
2022-09-19 03:25:04 +03:00
|
|
|
def C.IVC
|
|
|
|
@IVC ||= self.iseq_inline_iv_cache_entry
|
|
|
|
end
|
|
|
|
|
2023-02-16 08:26:04 +03:00
|
|
|
def C.RArray
|
|
|
|
@RArray ||= CType::Struct.new(
|
|
|
|
"RArray", Primitive.cexpr!("SIZEOF(struct RArray)"),
|
|
|
|
basic: [self.RBasic, Primitive.cexpr!("OFFSETOF((*((struct RArray *)NULL)), basic)")],
|
|
|
|
as: [CType::Union.new(
|
|
|
|
"", Primitive.cexpr!("SIZEOF(((struct RArray *)NULL)->as)"),
|
|
|
|
heap: CType::Struct.new(
|
|
|
|
"", Primitive.cexpr!("SIZEOF(((struct RArray *)NULL)->as.heap)"),
|
|
|
|
len: [CType::Immediate.parse("long"), Primitive.cexpr!("OFFSETOF(((struct RArray *)NULL)->as.heap, len)")],
|
|
|
|
aux: [CType::Union.new(
|
|
|
|
"", Primitive.cexpr!("SIZEOF(((struct RArray *)NULL)->as.heap.aux)"),
|
|
|
|
capa: CType::Immediate.parse("long"),
|
|
|
|
shared_root: self.VALUE,
|
|
|
|
), Primitive.cexpr!("OFFSETOF(((struct RArray *)NULL)->as.heap, aux)")],
|
|
|
|
ptr: [CType::Pointer.new { self.VALUE }, Primitive.cexpr!("OFFSETOF(((struct RArray *)NULL)->as.heap, ptr)")],
|
|
|
|
),
|
2023-12-22 22:20:45 +03:00
|
|
|
ary: CType::Array.new { self.VALUE },
|
2023-02-16 08:26:04 +03:00
|
|
|
), Primitive.cexpr!("OFFSETOF((*((struct RArray *)NULL)), as)")],
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2022-09-19 03:25:04 +03:00
|
|
|
def C.RB_BUILTIN
|
|
|
|
@RB_BUILTIN ||= self.rb_builtin_function
|
|
|
|
end
|
|
|
|
|
2023-02-08 12:48:32 +03:00
|
|
|
def C.RBasic
|
|
|
|
@RBasic ||= CType::Struct.new(
|
|
|
|
"RBasic", Primitive.cexpr!("SIZEOF(struct RBasic)"),
|
|
|
|
flags: [self.VALUE, Primitive.cexpr!("OFFSETOF((*((struct RBasic *)NULL)), flags)")],
|
|
|
|
klass: [self.VALUE, Primitive.cexpr!("OFFSETOF((*((struct RBasic *)NULL)), klass)")],
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2023-02-08 01:42:58 +03:00
|
|
|
def C.RObject
|
|
|
|
@RObject ||= CType::Struct.new(
|
|
|
|
"RObject", Primitive.cexpr!("SIZEOF(struct RObject)"),
|
|
|
|
basic: [self.RBasic, Primitive.cexpr!("OFFSETOF((*((struct RObject *)NULL)), basic)")],
|
|
|
|
as: [CType::Union.new(
|
|
|
|
"", Primitive.cexpr!("SIZEOF(((struct RObject *)NULL)->as)"),
|
|
|
|
heap: CType::Struct.new(
|
|
|
|
"", Primitive.cexpr!("SIZEOF(((struct RObject *)NULL)->as.heap)"),
|
|
|
|
ivptr: [CType::Pointer.new { self.VALUE }, Primitive.cexpr!("OFFSETOF(((struct RObject *)NULL)->as.heap, ivptr)")],
|
|
|
|
iv_index_tbl: [CType::Pointer.new { self.rb_id_table }, Primitive.cexpr!("OFFSETOF(((struct RObject *)NULL)->as.heap, iv_index_tbl)")],
|
|
|
|
),
|
2023-12-22 22:20:45 +03:00
|
|
|
ary: CType::Array.new { self.VALUE },
|
2023-02-08 01:42:58 +03:00
|
|
|
), Primitive.cexpr!("OFFSETOF((*((struct RObject *)NULL)), as)")],
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2023-03-19 09:24:57 +03:00
|
|
|
def C.RString
|
|
|
|
@RString ||= CType::Struct.new(
|
|
|
|
"RString", Primitive.cexpr!("SIZEOF(struct RString)"),
|
|
|
|
basic: [self.RBasic, Primitive.cexpr!("OFFSETOF((*((struct RString *)NULL)), basic)")],
|
2023-06-06 17:19:20 +03:00
|
|
|
len: [CType::Immediate.parse("long"), Primitive.cexpr!("OFFSETOF((*((struct RString *)NULL)), len)")],
|
2023-03-19 09:24:57 +03:00
|
|
|
as: [CType::Union.new(
|
|
|
|
"", Primitive.cexpr!("SIZEOF(((struct RString *)NULL)->as)"),
|
|
|
|
heap: CType::Struct.new(
|
|
|
|
"", Primitive.cexpr!("SIZEOF(((struct RString *)NULL)->as.heap)"),
|
|
|
|
ptr: [CType::Pointer.new { CType::Immediate.parse("char") }, Primitive.cexpr!("OFFSETOF(((struct RString *)NULL)->as.heap, ptr)")],
|
|
|
|
aux: [CType::Union.new(
|
|
|
|
"", Primitive.cexpr!("SIZEOF(((struct RString *)NULL)->as.heap.aux)"),
|
|
|
|
capa: CType::Immediate.parse("long"),
|
|
|
|
shared: self.VALUE,
|
|
|
|
), Primitive.cexpr!("OFFSETOF(((struct RString *)NULL)->as.heap, aux)")],
|
|
|
|
),
|
2023-04-05 00:30:06 +03:00
|
|
|
embed: CType::Struct.new(
|
|
|
|
"", Primitive.cexpr!("SIZEOF(((struct RString *)NULL)->as.embed)"),
|
2023-12-22 22:20:45 +03:00
|
|
|
ary: [CType::Array.new { CType::Immediate.parse("char") }, Primitive.cexpr!("OFFSETOF(((struct RString *)NULL)->as.embed, ary)")],
|
2023-04-05 00:30:06 +03:00
|
|
|
),
|
2023-03-19 09:24:57 +03:00
|
|
|
), Primitive.cexpr!("OFFSETOF((*((struct RString *)NULL)), as)")],
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2023-03-05 10:20:54 +03:00
|
|
|
def C.RStruct
|
|
|
|
@RStruct ||= CType::Struct.new(
|
|
|
|
"RStruct", Primitive.cexpr!("SIZEOF(struct RStruct)"),
|
|
|
|
basic: [self.RBasic, Primitive.cexpr!("OFFSETOF((*((struct RStruct *)NULL)), basic)")],
|
|
|
|
as: [CType::Union.new(
|
|
|
|
"", Primitive.cexpr!("SIZEOF(((struct RStruct *)NULL)->as)"),
|
|
|
|
heap: CType::Struct.new(
|
|
|
|
"", Primitive.cexpr!("SIZEOF(((struct RStruct *)NULL)->as.heap)"),
|
|
|
|
len: [CType::Immediate.parse("long"), Primitive.cexpr!("OFFSETOF(((struct RStruct *)NULL)->as.heap, len)")],
|
|
|
|
ptr: [CType::Pointer.new { self.VALUE }, Primitive.cexpr!("OFFSETOF(((struct RStruct *)NULL)->as.heap, ptr)")],
|
|
|
|
),
|
2023-12-22 22:20:45 +03:00
|
|
|
ary: CType::Array.new { self.VALUE },
|
2023-03-05 10:20:54 +03:00
|
|
|
), Primitive.cexpr!("OFFSETOF((*((struct RStruct *)NULL)), as)")],
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2022-10-03 18:14:32 +03:00
|
|
|
def C.attr_index_t
|
2023-10-19 00:05:48 +03:00
|
|
|
@attr_index_t ||= CType::Immediate.parse("uint32_t")
|
2022-10-03 18:14:32 +03:00
|
|
|
end
|
|
|
|
|
2022-09-19 03:25:04 +03:00
|
|
|
def C.iseq_inline_constant_cache
|
|
|
|
@iseq_inline_constant_cache ||= CType::Struct.new(
|
2022-09-21 16:32:28 +03:00
|
|
|
"iseq_inline_constant_cache", Primitive.cexpr!("SIZEOF(struct iseq_inline_constant_cache)"),
|
2022-09-22 16:25:33 +03:00
|
|
|
entry: [CType::Pointer.new { self.iseq_inline_constant_cache_entry }, Primitive.cexpr!("OFFSETOF((*((struct iseq_inline_constant_cache *)NULL)), entry)")],
|
|
|
|
segments: [CType::Pointer.new { self.ID }, Primitive.cexpr!("OFFSETOF((*((struct iseq_inline_constant_cache *)NULL)), segments)")],
|
2022-09-19 03:25:04 +03:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.iseq_inline_constant_cache_entry
|
|
|
|
@iseq_inline_constant_cache_entry ||= CType::Struct.new(
|
2022-09-21 16:32:28 +03:00
|
|
|
"iseq_inline_constant_cache_entry", Primitive.cexpr!("SIZEOF(struct iseq_inline_constant_cache_entry)"),
|
2022-09-22 16:25:33 +03:00
|
|
|
flags: [self.VALUE, Primitive.cexpr!("OFFSETOF((*((struct iseq_inline_constant_cache_entry *)NULL)), flags)")],
|
|
|
|
value: [self.VALUE, Primitive.cexpr!("OFFSETOF((*((struct iseq_inline_constant_cache_entry *)NULL)), value)")],
|
|
|
|
_unused1: [self.VALUE, Primitive.cexpr!("OFFSETOF((*((struct iseq_inline_constant_cache_entry *)NULL)), _unused1)")],
|
|
|
|
_unused2: [self.VALUE, Primitive.cexpr!("OFFSETOF((*((struct iseq_inline_constant_cache_entry *)NULL)), _unused2)")],
|
|
|
|
ic_cref: [CType::Pointer.new { self.rb_cref_t }, Primitive.cexpr!("OFFSETOF((*((struct iseq_inline_constant_cache_entry *)NULL)), ic_cref)")],
|
2022-09-19 03:25:04 +03:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.iseq_inline_iv_cache_entry
|
|
|
|
@iseq_inline_iv_cache_entry ||= CType::Struct.new(
|
2022-09-21 16:32:28 +03:00
|
|
|
"iseq_inline_iv_cache_entry", Primitive.cexpr!("SIZEOF(struct iseq_inline_iv_cache_entry)"),
|
2022-10-03 20:52:40 +03:00
|
|
|
value: [CType::Immediate.parse("uintptr_t"), Primitive.cexpr!("OFFSETOF((*((struct iseq_inline_iv_cache_entry *)NULL)), value)")],
|
2022-12-06 22:52:11 +03:00
|
|
|
iv_set_name: [self.ID, Primitive.cexpr!("OFFSETOF((*((struct iseq_inline_iv_cache_entry *)NULL)), iv_set_name)")],
|
2022-09-19 03:25:04 +03:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.iseq_inline_storage_entry
|
|
|
|
@iseq_inline_storage_entry ||= CType::Union.new(
|
2022-09-21 16:32:28 +03:00
|
|
|
"iseq_inline_storage_entry", Primitive.cexpr!("SIZEOF(union iseq_inline_storage_entry)"),
|
2022-09-19 03:25:04 +03:00
|
|
|
once: CType::Struct.new(
|
2022-09-21 16:32:28 +03:00
|
|
|
"", Primitive.cexpr!("SIZEOF(((union iseq_inline_storage_entry *)NULL)->once)"),
|
2022-09-22 16:25:33 +03:00
|
|
|
running_thread: [CType::Pointer.new { self.rb_thread_struct }, Primitive.cexpr!("OFFSETOF(((union iseq_inline_storage_entry *)NULL)->once, running_thread)")],
|
|
|
|
value: [self.VALUE, Primitive.cexpr!("OFFSETOF(((union iseq_inline_storage_entry *)NULL)->once, value)")],
|
2022-09-19 03:25:04 +03:00
|
|
|
),
|
|
|
|
ic_cache: self.iseq_inline_constant_cache,
|
|
|
|
iv_cache: self.iseq_inline_iv_cache_entry,
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2023-02-16 10:43:53 +03:00
|
|
|
def C.method_optimized_type
|
|
|
|
@method_optimized_type ||= CType::Immediate.parse("int")
|
|
|
|
end
|
|
|
|
|
2023-03-05 09:42:03 +03:00
|
|
|
def C.rb_block
|
|
|
|
@rb_block ||= CType::Struct.new(
|
|
|
|
"rb_block", Primitive.cexpr!("SIZEOF(struct rb_block)"),
|
|
|
|
as: [CType::Union.new(
|
|
|
|
"", Primitive.cexpr!("SIZEOF(((struct rb_block *)NULL)->as)"),
|
|
|
|
captured: self.rb_captured_block,
|
|
|
|
symbol: self.VALUE,
|
|
|
|
proc: self.VALUE,
|
|
|
|
), Primitive.cexpr!("OFFSETOF((*((struct rb_block *)NULL)), as)")],
|
|
|
|
type: [self.rb_block_type, Primitive.cexpr!("OFFSETOF((*((struct rb_block *)NULL)), type)")],
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.rb_block_type
|
|
|
|
@rb_block_type ||= CType::Immediate.parse("int")
|
|
|
|
end
|
|
|
|
|
2022-09-19 03:25:04 +03:00
|
|
|
def C.rb_builtin_function
|
|
|
|
@rb_builtin_function ||= CType::Struct.new(
|
2022-09-21 16:32:28 +03:00
|
|
|
"rb_builtin_function", Primitive.cexpr!("SIZEOF(struct rb_builtin_function)"),
|
2023-02-16 11:11:38 +03:00
|
|
|
func_ptr: [CType::Immediate.parse("void *"), Primitive.cexpr!("OFFSETOF((*((struct rb_builtin_function *)NULL)), func_ptr)")],
|
2022-09-22 16:25:33 +03:00
|
|
|
argc: [CType::Immediate.parse("int"), Primitive.cexpr!("OFFSETOF((*((struct rb_builtin_function *)NULL)), argc)")],
|
|
|
|
index: [CType::Immediate.parse("int"), Primitive.cexpr!("OFFSETOF((*((struct rb_builtin_function *)NULL)), index)")],
|
|
|
|
name: [CType::Pointer.new { CType::Immediate.parse("char") }, Primitive.cexpr!("OFFSETOF((*((struct rb_builtin_function *)NULL)), name)")],
|
2022-09-19 03:25:04 +03:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.rb_call_data
|
|
|
|
@rb_call_data ||= CType::Struct.new(
|
2022-09-21 16:32:28 +03:00
|
|
|
"rb_call_data", Primitive.cexpr!("SIZEOF(struct rb_call_data)"),
|
2022-09-22 16:25:33 +03:00
|
|
|
ci: [CType::Pointer.new { self.rb_callinfo }, Primitive.cexpr!("OFFSETOF((*((struct rb_call_data *)NULL)), ci)")],
|
|
|
|
cc: [CType::Pointer.new { self.rb_callcache }, Primitive.cexpr!("OFFSETOF((*((struct rb_call_data *)NULL)), cc)")],
|
2022-09-19 03:25:04 +03:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.rb_callable_method_entry_struct
|
|
|
|
@rb_callable_method_entry_struct ||= CType::Struct.new(
|
2022-09-21 16:32:28 +03:00
|
|
|
"rb_callable_method_entry_struct", Primitive.cexpr!("SIZEOF(struct rb_callable_method_entry_struct)"),
|
2022-09-22 16:25:33 +03:00
|
|
|
flags: [self.VALUE, Primitive.cexpr!("OFFSETOF((*((struct rb_callable_method_entry_struct *)NULL)), flags)")],
|
2023-02-25 01:48:02 +03:00
|
|
|
defined_class: [self.VALUE, Primitive.cexpr!("OFFSETOF((*((struct rb_callable_method_entry_struct *)NULL)), defined_class)"), true],
|
|
|
|
def: [CType::Pointer.new { self.rb_method_definition_struct }, Primitive.cexpr!("OFFSETOF((*((struct rb_callable_method_entry_struct *)NULL)), def)")],
|
|
|
|
called_id: [self.ID, Primitive.cexpr!("OFFSETOF((*((struct rb_callable_method_entry_struct *)NULL)), called_id)")],
|
|
|
|
owner: [self.VALUE, Primitive.cexpr!("OFFSETOF((*((struct rb_callable_method_entry_struct *)NULL)), owner)")],
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.rb_callable_method_entry_t
|
|
|
|
@rb_callable_method_entry_t ||= CType::Struct.new(
|
|
|
|
"rb_callable_method_entry_struct", Primitive.cexpr!("SIZEOF(struct rb_callable_method_entry_struct)"),
|
|
|
|
flags: [self.VALUE, Primitive.cexpr!("OFFSETOF((*((struct rb_callable_method_entry_struct *)NULL)), flags)")],
|
|
|
|
defined_class: [self.VALUE, Primitive.cexpr!("OFFSETOF((*((struct rb_callable_method_entry_struct *)NULL)), defined_class)"), true],
|
2022-09-22 16:25:33 +03:00
|
|
|
def: [CType::Pointer.new { self.rb_method_definition_struct }, Primitive.cexpr!("OFFSETOF((*((struct rb_callable_method_entry_struct *)NULL)), def)")],
|
|
|
|
called_id: [self.ID, Primitive.cexpr!("OFFSETOF((*((struct rb_callable_method_entry_struct *)NULL)), called_id)")],
|
|
|
|
owner: [self.VALUE, Primitive.cexpr!("OFFSETOF((*((struct rb_callable_method_entry_struct *)NULL)), owner)")],
|
2022-09-19 03:25:04 +03:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.rb_callcache
|
|
|
|
@rb_callcache ||= CType::Struct.new(
|
2022-09-21 16:32:28 +03:00
|
|
|
"rb_callcache", Primitive.cexpr!("SIZEOF(struct rb_callcache)"),
|
2022-09-22 16:25:33 +03:00
|
|
|
flags: [self.VALUE, Primitive.cexpr!("OFFSETOF((*((struct rb_callcache *)NULL)), flags)")],
|
|
|
|
klass: [self.VALUE, Primitive.cexpr!("OFFSETOF((*((struct rb_callcache *)NULL)), klass)")],
|
|
|
|
cme_: [CType::Pointer.new { self.rb_callable_method_entry_struct }, Primitive.cexpr!("OFFSETOF((*((struct rb_callcache *)NULL)), cme_)")],
|
|
|
|
call_: [self.vm_call_handler, Primitive.cexpr!("OFFSETOF((*((struct rb_callcache *)NULL)), call_)")],
|
|
|
|
aux_: [CType::Union.new(
|
2022-09-21 16:32:28 +03:00
|
|
|
"", Primitive.cexpr!("SIZEOF(((struct rb_callcache *)NULL)->aux_)"),
|
2022-10-03 18:14:32 +03:00
|
|
|
attr: CType::Struct.new(
|
|
|
|
"", Primitive.cexpr!("SIZEOF(((struct rb_callcache *)NULL)->aux_.attr)"),
|
2022-10-03 20:52:40 +03:00
|
|
|
value: [CType::Immediate.parse("uintptr_t"), Primitive.cexpr!("OFFSETOF(((struct rb_callcache *)NULL)->aux_.attr, value)")],
|
2022-10-03 18:14:32 +03:00
|
|
|
),
|
2022-09-19 03:25:04 +03:00
|
|
|
method_missing_reason: self.method_missing_reason,
|
|
|
|
v: self.VALUE,
|
2023-03-09 19:30:30 +03:00
|
|
|
bf: CType::Pointer.new { self.rb_builtin_function },
|
2022-09-22 16:25:33 +03:00
|
|
|
), Primitive.cexpr!("OFFSETOF((*((struct rb_callcache *)NULL)), aux_)")],
|
2022-09-19 03:25:04 +03:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.rb_callinfo
|
|
|
|
@rb_callinfo ||= CType::Struct.new(
|
2022-09-21 16:32:28 +03:00
|
|
|
"rb_callinfo", Primitive.cexpr!("SIZEOF(struct rb_callinfo)"),
|
2022-09-22 16:25:33 +03:00
|
|
|
flags: [self.VALUE, Primitive.cexpr!("OFFSETOF((*((struct rb_callinfo *)NULL)), flags)")],
|
|
|
|
kwarg: [CType::Pointer.new { self.rb_callinfo_kwarg }, Primitive.cexpr!("OFFSETOF((*((struct rb_callinfo *)NULL)), kwarg)")],
|
|
|
|
mid: [self.VALUE, Primitive.cexpr!("OFFSETOF((*((struct rb_callinfo *)NULL)), mid)")],
|
|
|
|
flag: [self.VALUE, Primitive.cexpr!("OFFSETOF((*((struct rb_callinfo *)NULL)), flag)")],
|
|
|
|
argc: [self.VALUE, Primitive.cexpr!("OFFSETOF((*((struct rb_callinfo *)NULL)), argc)")],
|
2022-09-19 03:25:04 +03:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2023-03-28 07:58:50 +03:00
|
|
|
def C.rb_callinfo_kwarg
|
|
|
|
@rb_callinfo_kwarg ||= CType::Struct.new(
|
|
|
|
"rb_callinfo_kwarg", Primitive.cexpr!("SIZEOF(struct rb_callinfo_kwarg)"),
|
|
|
|
keyword_len: [CType::Immediate.parse("int"), Primitive.cexpr!("OFFSETOF((*((struct rb_callinfo_kwarg *)NULL)), keyword_len)")],
|
2023-09-30 00:06:26 +03:00
|
|
|
references: [CType::Immediate.parse("int"), Primitive.cexpr!("OFFSETOF((*((struct rb_callinfo_kwarg *)NULL)), references)")],
|
2023-03-28 07:58:50 +03:00
|
|
|
keywords: [CType::Immediate.parse("void *"), Primitive.cexpr!("OFFSETOF((*((struct rb_callinfo_kwarg *)NULL)), keywords)")],
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2023-03-05 09:42:03 +03:00
|
|
|
def C.rb_captured_block
|
|
|
|
@rb_captured_block ||= CType::Struct.new(
|
|
|
|
"rb_captured_block", Primitive.cexpr!("SIZEOF(struct rb_captured_block)"),
|
|
|
|
self: [self.VALUE, Primitive.cexpr!("OFFSETOF((*((struct rb_captured_block *)NULL)), self)")],
|
|
|
|
ep: [CType::Pointer.new { self.VALUE }, Primitive.cexpr!("OFFSETOF((*((struct rb_captured_block *)NULL)), ep)")],
|
|
|
|
code: [CType::Union.new(
|
|
|
|
"", Primitive.cexpr!("SIZEOF(((struct rb_captured_block *)NULL)->code)"),
|
|
|
|
iseq: CType::Pointer.new { self.rb_iseq_t },
|
|
|
|
ifunc: CType::Pointer.new { self.vm_ifunc },
|
|
|
|
val: self.VALUE,
|
|
|
|
), Primitive.cexpr!("OFFSETOF((*((struct rb_captured_block *)NULL)), code)")],
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2024-03-02 02:10:19 +03:00
|
|
|
def C.rb_cfunc_t
|
|
|
|
@rb_cfunc_t ||= self.VALUE
|
|
|
|
end
|
|
|
|
|
2022-09-19 03:25:04 +03:00
|
|
|
def C.rb_control_frame_t
|
|
|
|
@rb_control_frame_t ||= CType::Struct.new(
|
2022-09-22 15:39:54 +03:00
|
|
|
"rb_control_frame_struct", Primitive.cexpr!("SIZEOF(struct rb_control_frame_struct)"),
|
2022-09-22 16:25:33 +03:00
|
|
|
pc: [CType::Pointer.new { self.VALUE }, Primitive.cexpr!("OFFSETOF((*((struct rb_control_frame_struct *)NULL)), pc)")],
|
|
|
|
sp: [CType::Pointer.new { self.VALUE }, Primitive.cexpr!("OFFSETOF((*((struct rb_control_frame_struct *)NULL)), sp)")],
|
|
|
|
iseq: [CType::Pointer.new { self.rb_iseq_t }, Primitive.cexpr!("OFFSETOF((*((struct rb_control_frame_struct *)NULL)), iseq)")],
|
|
|
|
self: [self.VALUE, Primitive.cexpr!("OFFSETOF((*((struct rb_control_frame_struct *)NULL)), self)")],
|
|
|
|
ep: [CType::Pointer.new { self.VALUE }, Primitive.cexpr!("OFFSETOF((*((struct rb_control_frame_struct *)NULL)), ep)")],
|
2023-02-16 11:11:38 +03:00
|
|
|
block_code: [CType::Immediate.parse("void *"), Primitive.cexpr!("OFFSETOF((*((struct rb_control_frame_struct *)NULL)), block_code)")],
|
2022-09-22 16:25:33 +03:00
|
|
|
jit_return: [CType::Pointer.new { CType::Immediate.parse("void") }, Primitive.cexpr!("OFFSETOF((*((struct rb_control_frame_struct *)NULL)), jit_return)")],
|
2022-09-19 03:25:04 +03:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.rb_cref_t
|
|
|
|
@rb_cref_t ||= CType::Struct.new(
|
2022-09-21 16:32:28 +03:00
|
|
|
"rb_cref_struct", Primitive.cexpr!("SIZEOF(struct rb_cref_struct)"),
|
2022-09-22 16:25:33 +03:00
|
|
|
flags: [self.VALUE, Primitive.cexpr!("OFFSETOF((*((struct rb_cref_struct *)NULL)), flags)")],
|
|
|
|
refinements: [self.VALUE, Primitive.cexpr!("OFFSETOF((*((struct rb_cref_struct *)NULL)), refinements)")],
|
|
|
|
klass_or_self: [self.VALUE, Primitive.cexpr!("OFFSETOF((*((struct rb_cref_struct *)NULL)), klass_or_self)")],
|
|
|
|
next: [CType::Pointer.new { self.rb_cref_struct }, Primitive.cexpr!("OFFSETOF((*((struct rb_cref_struct *)NULL)), next)")],
|
|
|
|
scope_visi: [self.rb_scope_visibility_t, Primitive.cexpr!("OFFSETOF((*((struct rb_cref_struct *)NULL)), scope_visi)")],
|
2022-09-19 03:25:04 +03:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.rb_execution_context_struct
|
|
|
|
@rb_execution_context_struct ||= CType::Struct.new(
|
2022-09-22 15:39:54 +03:00
|
|
|
"rb_execution_context_struct", Primitive.cexpr!("SIZEOF(struct rb_execution_context_struct)"),
|
2022-09-22 16:25:33 +03:00
|
|
|
vm_stack: [CType::Pointer.new { self.VALUE }, Primitive.cexpr!("OFFSETOF((*((struct rb_execution_context_struct *)NULL)), vm_stack)")],
|
|
|
|
vm_stack_size: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_execution_context_struct *)NULL)), vm_stack_size)")],
|
|
|
|
cfp: [CType::Pointer.new { self.rb_control_frame_t }, Primitive.cexpr!("OFFSETOF((*((struct rb_execution_context_struct *)NULL)), cfp)")],
|
|
|
|
tag: [CType::Pointer.new { self.rb_vm_tag }, Primitive.cexpr!("OFFSETOF((*((struct rb_execution_context_struct *)NULL)), tag)")],
|
|
|
|
interrupt_flag: [self.rb_atomic_t, Primitive.cexpr!("OFFSETOF((*((struct rb_execution_context_struct *)NULL)), interrupt_flag)")],
|
|
|
|
interrupt_mask: [self.rb_atomic_t, Primitive.cexpr!("OFFSETOF((*((struct rb_execution_context_struct *)NULL)), interrupt_mask)")],
|
|
|
|
fiber_ptr: [CType::Pointer.new { self.rb_fiber_t }, Primitive.cexpr!("OFFSETOF((*((struct rb_execution_context_struct *)NULL)), fiber_ptr)")],
|
|
|
|
thread_ptr: [CType::Pointer.new { self.rb_thread_struct }, Primitive.cexpr!("OFFSETOF((*((struct rb_execution_context_struct *)NULL)), thread_ptr)")],
|
|
|
|
local_storage: [CType::Pointer.new { self.rb_id_table }, Primitive.cexpr!("OFFSETOF((*((struct rb_execution_context_struct *)NULL)), local_storage)")],
|
|
|
|
local_storage_recursive_hash: [self.VALUE, Primitive.cexpr!("OFFSETOF((*((struct rb_execution_context_struct *)NULL)), local_storage_recursive_hash)")],
|
|
|
|
local_storage_recursive_hash_for_trace: [self.VALUE, Primitive.cexpr!("OFFSETOF((*((struct rb_execution_context_struct *)NULL)), local_storage_recursive_hash_for_trace)")],
|
2022-12-01 13:00:33 +03:00
|
|
|
storage: [self.VALUE, Primitive.cexpr!("OFFSETOF((*((struct rb_execution_context_struct *)NULL)), storage)")],
|
2022-09-22 16:25:33 +03:00
|
|
|
root_lep: [CType::Pointer.new { self.VALUE }, Primitive.cexpr!("OFFSETOF((*((struct rb_execution_context_struct *)NULL)), root_lep)")],
|
|
|
|
root_svar: [self.VALUE, Primitive.cexpr!("OFFSETOF((*((struct rb_execution_context_struct *)NULL)), root_svar)")],
|
|
|
|
trace_arg: [CType::Pointer.new { self.rb_trace_arg_struct }, Primitive.cexpr!("OFFSETOF((*((struct rb_execution_context_struct *)NULL)), trace_arg)")],
|
|
|
|
errinfo: [self.VALUE, Primitive.cexpr!("OFFSETOF((*((struct rb_execution_context_struct *)NULL)), errinfo)")],
|
|
|
|
passed_block_handler: [self.VALUE, Primitive.cexpr!("OFFSETOF((*((struct rb_execution_context_struct *)NULL)), passed_block_handler)")],
|
|
|
|
raised_flag: [CType::Immediate.parse("uint8_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_execution_context_struct *)NULL)), raised_flag)")],
|
|
|
|
private_const_reference: [self.VALUE, Primitive.cexpr!("OFFSETOF((*((struct rb_execution_context_struct *)NULL)), private_const_reference)")],
|
|
|
|
machine: [CType::Struct.new(
|
2022-09-22 15:39:54 +03:00
|
|
|
"", Primitive.cexpr!("SIZEOF(((struct rb_execution_context_struct *)NULL)->machine)"),
|
2022-09-22 16:25:33 +03:00
|
|
|
stack_start: [CType::Pointer.new { self.VALUE }, Primitive.cexpr!("OFFSETOF(((struct rb_execution_context_struct *)NULL)->machine, stack_start)")],
|
|
|
|
stack_end: [CType::Pointer.new { self.VALUE }, Primitive.cexpr!("OFFSETOF(((struct rb_execution_context_struct *)NULL)->machine, stack_end)")],
|
|
|
|
stack_maxsize: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF(((struct rb_execution_context_struct *)NULL)->machine, stack_maxsize)")],
|
|
|
|
), Primitive.cexpr!("OFFSETOF((*((struct rb_execution_context_struct *)NULL)), machine)")],
|
2022-09-19 03:25:04 +03:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.rb_execution_context_t
|
|
|
|
@rb_execution_context_t ||= self.rb_execution_context_struct
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.rb_iseq_constant_body
|
|
|
|
@rb_iseq_constant_body ||= CType::Struct.new(
|
2022-09-21 16:32:28 +03:00
|
|
|
"rb_iseq_constant_body", Primitive.cexpr!("SIZEOF(struct rb_iseq_constant_body)"),
|
2022-09-22 16:25:33 +03:00
|
|
|
type: [self.rb_iseq_type, Primitive.cexpr!("OFFSETOF((*((struct rb_iseq_constant_body *)NULL)), type)")],
|
|
|
|
iseq_size: [CType::Immediate.parse("unsigned int"), Primitive.cexpr!("OFFSETOF((*((struct rb_iseq_constant_body *)NULL)), iseq_size)")],
|
|
|
|
iseq_encoded: [CType::Pointer.new { self.VALUE }, Primitive.cexpr!("OFFSETOF((*((struct rb_iseq_constant_body *)NULL)), iseq_encoded)")],
|
|
|
|
param: [CType::Struct.new(
|
2022-09-21 16:32:28 +03:00
|
|
|
"", Primitive.cexpr!("SIZEOF(((struct rb_iseq_constant_body *)NULL)->param)"),
|
2022-09-22 16:25:33 +03:00
|
|
|
flags: [CType::Struct.new(
|
2022-09-21 16:32:28 +03:00
|
|
|
"", Primitive.cexpr!("SIZEOF(((struct rb_iseq_constant_body *)NULL)->param.flags)"),
|
2022-09-22 16:25:33 +03:00
|
|
|
has_lead: [CType::BitField.new(1, 0), 0],
|
|
|
|
has_opt: [CType::BitField.new(1, 1), 1],
|
|
|
|
has_rest: [CType::BitField.new(1, 2), 2],
|
|
|
|
has_post: [CType::BitField.new(1, 3), 3],
|
|
|
|
has_kw: [CType::BitField.new(1, 4), 4],
|
|
|
|
has_kwrest: [CType::BitField.new(1, 5), 5],
|
|
|
|
has_block: [CType::BitField.new(1, 6), 6],
|
|
|
|
ambiguous_param0: [CType::BitField.new(1, 7), 7],
|
|
|
|
accepts_no_kwarg: [CType::BitField.new(1, 0), 8],
|
|
|
|
ruby2_keywords: [CType::BitField.new(1, 1), 9],
|
Introduce Allocationless Anonymous Splat Forwarding
Ruby makes it easy to delegate all arguments from one method to another:
```ruby
def f(*args, **kw)
g(*args, **kw)
end
```
Unfortunately, this indirection decreases performance. One reason it
decreases performance is that this allocates an array and a hash per
call to `f`, even if `args` and `kw` are not modified.
Due to Ruby's ability to modify almost anything at runtime, it's
difficult to avoid the array allocation in the general case. For
example, it's not safe to avoid the allocation in a case like this:
```ruby
def f(*args, **kw)
foo(bar)
g(*args, **kw)
end
```
Because `foo` may be `eval` and `bar` may be a string referencing `args`
or `kw`.
To fix this correctly, you need to perform something similar to escape
analysis on the variables. However, there is a case where you can
avoid the allocation without doing escape analysis, and that is when
the splat variables are anonymous:
```ruby
def f(*, **)
g(*, **)
end
```
When splat variables are anonymous, it is not possible to reference
them directly, it is only possible to use them as splats to other
methods. Since that is the case, if `f` is called with a regular
splat and a keyword splat, it can pass the arguments directly to
`g` without copying them, avoiding allocation. For example:
```ruby
def g(a, b:)
a + b
end
def f(*, **)
g(*, **)
end
a = [1]
kw = {b: 2}
f(*a, **kw)
```
I call this technique: Allocationless Anonymous Splat Forwarding.
This is implemented using a couple additional iseq param flags,
anon_rest and anon_kwrest. If anon_rest is set, and an array splat
is passed when calling the method when the array splat can be used
without modification, `setup_parameters_complex` does not duplicate
it. Similarly, if anon_kwest is set, and a keyword splat is passed
when calling the method, `setup_parameters_complex` does not
duplicate it.
2023-12-01 01:58:42 +03:00
|
|
|
anon_rest: [CType::BitField.new(1, 2), 10],
|
|
|
|
anon_kwrest: [CType::BitField.new(1, 3), 11],
|
2024-03-27 01:29:38 +03:00
|
|
|
use_block: [CType::BitField.new(1, 4), 12],
|
Optimized forwarding callers and callees
This patch optimizes forwarding callers and callees. It only optimizes methods that only take `...` as their parameter, and then pass `...` to other calls.
Calls it optimizes look like this:
```ruby
def bar(a) = a
def foo(...) = bar(...) # optimized
foo(123)
```
```ruby
def bar(a) = a
def foo(...) = bar(1, 2, ...) # optimized
foo(123)
```
```ruby
def bar(*a) = a
def foo(...)
list = [1, 2]
bar(*list, ...) # optimized
end
foo(123)
```
All variants of the above but using `super` are also optimized, including a bare super like this:
```ruby
def foo(...)
super
end
```
This patch eliminates intermediate allocations made when calling methods that accept `...`.
We can observe allocation elimination like this:
```ruby
def m
x = GC.stat(:total_allocated_objects)
yield
GC.stat(:total_allocated_objects) - x
end
def bar(a) = a
def foo(...) = bar(...)
def test
m { foo(123) }
end
test
p test # allocates 1 object on master, but 0 objects with this patch
```
```ruby
def bar(a, b:) = a + b
def foo(...) = bar(...)
def test
m { foo(1, b: 2) }
end
test
p test # allocates 2 objects on master, but 0 objects with this patch
```
How does it work?
-----------------
This patch works by using a dynamic stack size when passing forwarded parameters to callees.
The caller's info object (known as the "CI") contains the stack size of the
parameters, so we pass the CI object itself as a parameter to the callee.
When forwarding parameters, the forwarding ISeq uses the caller's CI to determine how much stack to copy, then copies the caller's stack before calling the callee.
The CI at the forwarded call site is adjusted using information from the caller's CI.
I think this description is kind of confusing, so let's walk through an example with code.
```ruby
def delegatee(a, b) = a + b
def delegator(...)
delegatee(...) # CI2 (FORWARDING)
end
def caller
delegator(1, 2) # CI1 (argc: 2)
end
```
Before we call the delegator method, the stack looks like this:
```
Executing Line | Code | Stack
---------------+---------------------------------------+--------
1| def delegatee(a, b) = a + b | self
2| | 1
3| def delegator(...) | 2
4| # |
5| delegatee(...) # CI2 (FORWARDING) |
6| end |
7| |
8| def caller |
-> 9| delegator(1, 2) # CI1 (argc: 2) |
10| end |
```
The ISeq for `delegator` is tagged as "forwardable", so when `caller` calls in
to `delegator`, it writes `CI1` on to the stack as a local variable for the
`delegator` method. The `delegator` method has a special local called `...`
that holds the caller's CI object.
Here is the ISeq disasm fo `delegator`:
```
== disasm: #<ISeq:delegator@-e:1 (1,0)-(1,39)>
local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1])
[ 1] "..."@0
0000 putself ( 1)[LiCa]
0001 getlocal_WC_0 "..."@0
0003 send <calldata!mid:delegatee, argc:0, FCALL|FORWARDING>, nil
0006 leave [Re]
```
The local called `...` will contain the caller's CI: CI1.
Here is the stack when we enter `delegator`:
```
Executing Line | Code | Stack
---------------+---------------------------------------+--------
1| def delegatee(a, b) = a + b | self
2| | 1
3| def delegator(...) | 2
-> 4| # | CI1 (argc: 2)
5| delegatee(...) # CI2 (FORWARDING) | cref_or_me
6| end | specval
7| | type
8| def caller |
9| delegator(1, 2) # CI1 (argc: 2) |
10| end |
```
The CI at `delegatee` on line 5 is tagged as "FORWARDING", so it knows to
memcopy the caller's stack before calling `delegatee`. In this case, it will
memcopy self, 1, and 2 to the stack before calling `delegatee`. It knows how much
memory to copy from the caller because `CI1` contains stack size information
(argc: 2).
Before executing the `send` instruction, we push `...` on the stack. The
`send` instruction pops `...`, and because it is tagged with `FORWARDING`, it
knows to memcopy (using the information in the CI it just popped):
```
== disasm: #<ISeq:delegator@-e:1 (1,0)-(1,39)>
local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1])
[ 1] "..."@0
0000 putself ( 1)[LiCa]
0001 getlocal_WC_0 "..."@0
0003 send <calldata!mid:delegatee, argc:0, FCALL|FORWARDING>, nil
0006 leave [Re]
```
Instruction 001 puts the caller's CI on the stack. `send` is tagged with
FORWARDING, so it reads the CI and _copies_ the callers stack to this stack:
```
Executing Line | Code | Stack
---------------+---------------------------------------+--------
1| def delegatee(a, b) = a + b | self
2| | 1
3| def delegator(...) | 2
4| # | CI1 (argc: 2)
-> 5| delegatee(...) # CI2 (FORWARDING) | cref_or_me
6| end | specval
7| | type
8| def caller | self
9| delegator(1, 2) # CI1 (argc: 2) | 1
10| end | 2
```
The "FORWARDING" call site combines information from CI1 with CI2 in order
to support passing other values in addition to the `...` value, as well as
perfectly forward splat args, kwargs, etc.
Since we're able to copy the stack from `caller` in to `delegator`'s stack, we
can avoid allocating objects.
I want to do this to eliminate object allocations for delegate methods.
My long term goal is to implement `Class#new` in Ruby and it uses `...`.
I was able to implement `Class#new` in Ruby
[here](https://github.com/ruby/ruby/pull/9289).
If we adopt the technique in this patch, then we can optimize allocating
objects that take keyword parameters for `initialize`.
For example, this code will allocate 2 objects: one for `SomeObject`, and one
for the kwargs:
```ruby
SomeObject.new(foo: 1)
```
If we combine this technique, plus implement `Class#new` in Ruby, then we can
reduce allocations for this common operation.
Co-Authored-By: John Hawthorn <john@hawthorn.email>
Co-Authored-By: Alan Wu <XrXr@users.noreply.github.com>
2024-04-15 20:48:53 +03:00
|
|
|
forwardable: [CType::BitField.new(1, 5), 13],
|
2022-09-22 16:25:33 +03:00
|
|
|
), Primitive.cexpr!("OFFSETOF(((struct rb_iseq_constant_body *)NULL)->param, flags)")],
|
|
|
|
size: [CType::Immediate.parse("unsigned int"), Primitive.cexpr!("OFFSETOF(((struct rb_iseq_constant_body *)NULL)->param, size)")],
|
|
|
|
lead_num: [CType::Immediate.parse("int"), Primitive.cexpr!("OFFSETOF(((struct rb_iseq_constant_body *)NULL)->param, lead_num)")],
|
|
|
|
opt_num: [CType::Immediate.parse("int"), Primitive.cexpr!("OFFSETOF(((struct rb_iseq_constant_body *)NULL)->param, opt_num)")],
|
|
|
|
rest_start: [CType::Immediate.parse("int"), Primitive.cexpr!("OFFSETOF(((struct rb_iseq_constant_body *)NULL)->param, rest_start)")],
|
|
|
|
post_start: [CType::Immediate.parse("int"), Primitive.cexpr!("OFFSETOF(((struct rb_iseq_constant_body *)NULL)->param, post_start)")],
|
|
|
|
post_num: [CType::Immediate.parse("int"), Primitive.cexpr!("OFFSETOF(((struct rb_iseq_constant_body *)NULL)->param, post_num)")],
|
|
|
|
block_start: [CType::Immediate.parse("int"), Primitive.cexpr!("OFFSETOF(((struct rb_iseq_constant_body *)NULL)->param, block_start)")],
|
|
|
|
opt_table: [CType::Pointer.new { self.VALUE }, Primitive.cexpr!("OFFSETOF(((struct rb_iseq_constant_body *)NULL)->param, opt_table)")],
|
|
|
|
keyword: [CType::Pointer.new { self.rb_iseq_param_keyword }, Primitive.cexpr!("OFFSETOF(((struct rb_iseq_constant_body *)NULL)->param, keyword)")],
|
|
|
|
), Primitive.cexpr!("OFFSETOF((*((struct rb_iseq_constant_body *)NULL)), param)")],
|
|
|
|
location: [self.rb_iseq_location_t, Primitive.cexpr!("OFFSETOF((*((struct rb_iseq_constant_body *)NULL)), location)")],
|
|
|
|
insns_info: [self.iseq_insn_info, Primitive.cexpr!("OFFSETOF((*((struct rb_iseq_constant_body *)NULL)), insns_info)")],
|
|
|
|
local_table: [CType::Pointer.new { self.ID }, Primitive.cexpr!("OFFSETOF((*((struct rb_iseq_constant_body *)NULL)), local_table)")],
|
|
|
|
catch_table: [CType::Pointer.new { self.iseq_catch_table }, Primitive.cexpr!("OFFSETOF((*((struct rb_iseq_constant_body *)NULL)), catch_table)")],
|
|
|
|
parent_iseq: [CType::Pointer.new { self.rb_iseq_struct }, Primitive.cexpr!("OFFSETOF((*((struct rb_iseq_constant_body *)NULL)), parent_iseq)")],
|
|
|
|
local_iseq: [CType::Pointer.new { self.rb_iseq_struct }, Primitive.cexpr!("OFFSETOF((*((struct rb_iseq_constant_body *)NULL)), local_iseq)")],
|
|
|
|
is_entries: [CType::Pointer.new { self.iseq_inline_storage_entry }, Primitive.cexpr!("OFFSETOF((*((struct rb_iseq_constant_body *)NULL)), is_entries)")],
|
|
|
|
call_data: [CType::Pointer.new { self.rb_call_data }, Primitive.cexpr!("OFFSETOF((*((struct rb_iseq_constant_body *)NULL)), call_data)")],
|
|
|
|
variable: [CType::Struct.new(
|
2022-09-21 16:32:28 +03:00
|
|
|
"", Primitive.cexpr!("SIZEOF(((struct rb_iseq_constant_body *)NULL)->variable)"),
|
2022-09-22 16:25:33 +03:00
|
|
|
flip_count: [self.rb_snum_t, Primitive.cexpr!("OFFSETOF(((struct rb_iseq_constant_body *)NULL)->variable, flip_count)")],
|
|
|
|
script_lines: [self.VALUE, Primitive.cexpr!("OFFSETOF(((struct rb_iseq_constant_body *)NULL)->variable, script_lines)")],
|
|
|
|
coverage: [self.VALUE, Primitive.cexpr!("OFFSETOF(((struct rb_iseq_constant_body *)NULL)->variable, coverage)")],
|
|
|
|
pc2branchindex: [self.VALUE, Primitive.cexpr!("OFFSETOF(((struct rb_iseq_constant_body *)NULL)->variable, pc2branchindex)")],
|
|
|
|
original_iseq: [CType::Pointer.new { self.VALUE }, Primitive.cexpr!("OFFSETOF(((struct rb_iseq_constant_body *)NULL)->variable, original_iseq)")],
|
|
|
|
), Primitive.cexpr!("OFFSETOF((*((struct rb_iseq_constant_body *)NULL)), variable)")],
|
|
|
|
local_table_size: [CType::Immediate.parse("unsigned int"), Primitive.cexpr!("OFFSETOF((*((struct rb_iseq_constant_body *)NULL)), local_table_size)")],
|
|
|
|
ic_size: [CType::Immediate.parse("unsigned int"), Primitive.cexpr!("OFFSETOF((*((struct rb_iseq_constant_body *)NULL)), ic_size)")],
|
|
|
|
ise_size: [CType::Immediate.parse("unsigned int"), Primitive.cexpr!("OFFSETOF((*((struct rb_iseq_constant_body *)NULL)), ise_size)")],
|
|
|
|
ivc_size: [CType::Immediate.parse("unsigned int"), Primitive.cexpr!("OFFSETOF((*((struct rb_iseq_constant_body *)NULL)), ivc_size)")],
|
|
|
|
icvarc_size: [CType::Immediate.parse("unsigned int"), Primitive.cexpr!("OFFSETOF((*((struct rb_iseq_constant_body *)NULL)), icvarc_size)")],
|
|
|
|
ci_size: [CType::Immediate.parse("unsigned int"), Primitive.cexpr!("OFFSETOF((*((struct rb_iseq_constant_body *)NULL)), ci_size)")],
|
|
|
|
stack_max: [CType::Immediate.parse("unsigned int"), Primitive.cexpr!("OFFSETOF((*((struct rb_iseq_constant_body *)NULL)), stack_max)")],
|
2023-03-12 00:32:58 +03:00
|
|
|
builtin_attrs: [CType::Immediate.parse("unsigned int"), Primitive.cexpr!("OFFSETOF((*((struct rb_iseq_constant_body *)NULL)), builtin_attrs)")],
|
2024-02-12 22:40:07 +03:00
|
|
|
prism: [self._Bool, Primitive.cexpr!("OFFSETOF((*((struct rb_iseq_constant_body *)NULL)), prism)")],
|
2022-09-22 16:25:33 +03:00
|
|
|
mark_bits: [CType::Union.new(
|
2022-09-21 16:32:28 +03:00
|
|
|
"", Primitive.cexpr!("SIZEOF(((struct rb_iseq_constant_body *)NULL)->mark_bits)"),
|
2022-09-19 03:25:04 +03:00
|
|
|
list: CType::Pointer.new { self.iseq_bits_t },
|
|
|
|
single: self.iseq_bits_t,
|
2022-09-22 16:25:33 +03:00
|
|
|
), Primitive.cexpr!("OFFSETOF((*((struct rb_iseq_constant_body *)NULL)), mark_bits)")],
|
|
|
|
outer_variables: [CType::Pointer.new { self.rb_id_table }, Primitive.cexpr!("OFFSETOF((*((struct rb_iseq_constant_body *)NULL)), outer_variables)")],
|
|
|
|
mandatory_only_iseq: [CType::Pointer.new { self.rb_iseq_t }, Primitive.cexpr!("OFFSETOF((*((struct rb_iseq_constant_body *)NULL)), mandatory_only_iseq)")],
|
2023-08-09 02:06:22 +03:00
|
|
|
jit_entry: [self.rb_jit_func_t, Primitive.cexpr!("OFFSETOF((*((struct rb_iseq_constant_body *)NULL)), jit_entry)")],
|
|
|
|
jit_entry_calls: [CType::Immediate.parse("unsigned long"), Primitive.cexpr!("OFFSETOF((*((struct rb_iseq_constant_body *)NULL)), jit_entry_calls)")],
|
2023-03-07 10:17:25 +03:00
|
|
|
rjit_blocks: [self.VALUE, Primitive.cexpr!("OFFSETOF((*((struct rb_iseq_constant_body *)NULL)), rjit_blocks)"), true],
|
2022-09-19 03:25:04 +03:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.rb_iseq_location_t
|
|
|
|
@rb_iseq_location_t ||= CType::Struct.new(
|
2022-09-21 16:32:28 +03:00
|
|
|
"rb_iseq_location_struct", Primitive.cexpr!("SIZEOF(struct rb_iseq_location_struct)"),
|
2022-09-22 16:25:33 +03:00
|
|
|
pathobj: [self.VALUE, Primitive.cexpr!("OFFSETOF((*((struct rb_iseq_location_struct *)NULL)), pathobj)"), true],
|
|
|
|
base_label: [self.VALUE, Primitive.cexpr!("OFFSETOF((*((struct rb_iseq_location_struct *)NULL)), base_label)"), true],
|
|
|
|
label: [self.VALUE, Primitive.cexpr!("OFFSETOF((*((struct rb_iseq_location_struct *)NULL)), label)"), true],
|
2022-12-27 09:06:43 +03:00
|
|
|
first_lineno: [CType::Immediate.parse("int"), Primitive.cexpr!("OFFSETOF((*((struct rb_iseq_location_struct *)NULL)), first_lineno)")],
|
2022-09-22 16:25:33 +03:00
|
|
|
node_id: [CType::Immediate.parse("int"), Primitive.cexpr!("OFFSETOF((*((struct rb_iseq_location_struct *)NULL)), node_id)")],
|
|
|
|
code_location: [self.rb_code_location_t, Primitive.cexpr!("OFFSETOF((*((struct rb_iseq_location_struct *)NULL)), code_location)")],
|
2022-09-19 03:25:04 +03:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2023-03-19 07:14:35 +03:00
|
|
|
def C.rb_iseq_param_keyword
|
|
|
|
@rb_iseq_param_keyword ||= CType::Struct.new(
|
|
|
|
"rb_iseq_param_keyword", Primitive.cexpr!("SIZEOF(struct rb_iseq_param_keyword)"),
|
|
|
|
num: [CType::Immediate.parse("int"), Primitive.cexpr!("OFFSETOF((*((struct rb_iseq_param_keyword *)NULL)), num)")],
|
|
|
|
required_num: [CType::Immediate.parse("int"), Primitive.cexpr!("OFFSETOF((*((struct rb_iseq_param_keyword *)NULL)), required_num)")],
|
|
|
|
bits_start: [CType::Immediate.parse("int"), Primitive.cexpr!("OFFSETOF((*((struct rb_iseq_param_keyword *)NULL)), bits_start)")],
|
|
|
|
rest_start: [CType::Immediate.parse("int"), Primitive.cexpr!("OFFSETOF((*((struct rb_iseq_param_keyword *)NULL)), rest_start)")],
|
|
|
|
table: [CType::Pointer.new { self.ID }, Primitive.cexpr!("OFFSETOF((*((struct rb_iseq_param_keyword *)NULL)), table)")],
|
|
|
|
default_values: [CType::Pointer.new { self.VALUE }, Primitive.cexpr!("OFFSETOF((*((struct rb_iseq_param_keyword *)NULL)), default_values)")],
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2022-09-19 03:25:04 +03:00
|
|
|
def C.rb_iseq_struct
|
|
|
|
@rb_iseq_struct ||= CType::Struct.new(
|
2022-09-21 16:32:28 +03:00
|
|
|
"rb_iseq_struct", Primitive.cexpr!("SIZEOF(struct rb_iseq_struct)"),
|
2022-09-22 16:25:33 +03:00
|
|
|
flags: [self.VALUE, Primitive.cexpr!("OFFSETOF((*((struct rb_iseq_struct *)NULL)), flags)")],
|
|
|
|
wrapper: [self.VALUE, Primitive.cexpr!("OFFSETOF((*((struct rb_iseq_struct *)NULL)), wrapper)")],
|
|
|
|
body: [CType::Pointer.new { self.rb_iseq_constant_body }, Primitive.cexpr!("OFFSETOF((*((struct rb_iseq_struct *)NULL)), body)")],
|
|
|
|
aux: [CType::Union.new(
|
2022-09-21 16:32:28 +03:00
|
|
|
"", Primitive.cexpr!("SIZEOF(((struct rb_iseq_struct *)NULL)->aux)"),
|
2022-09-19 03:25:04 +03:00
|
|
|
compile_data: CType::Pointer.new { self.iseq_compile_data },
|
|
|
|
loader: CType::Struct.new(
|
2022-09-21 16:32:28 +03:00
|
|
|
"", Primitive.cexpr!("SIZEOF(((struct rb_iseq_struct *)NULL)->aux.loader)"),
|
2022-09-22 16:25:33 +03:00
|
|
|
obj: [self.VALUE, Primitive.cexpr!("OFFSETOF(((struct rb_iseq_struct *)NULL)->aux.loader, obj)")],
|
|
|
|
index: [CType::Immediate.parse("int"), Primitive.cexpr!("OFFSETOF(((struct rb_iseq_struct *)NULL)->aux.loader, index)")],
|
2022-09-19 03:25:04 +03:00
|
|
|
),
|
|
|
|
exec: CType::Struct.new(
|
2022-09-21 16:32:28 +03:00
|
|
|
"", Primitive.cexpr!("SIZEOF(((struct rb_iseq_struct *)NULL)->aux.exec)"),
|
2022-09-22 16:25:33 +03:00
|
|
|
local_hooks: [CType::Pointer.new { self.rb_hook_list_struct }, Primitive.cexpr!("OFFSETOF(((struct rb_iseq_struct *)NULL)->aux.exec, local_hooks)")],
|
|
|
|
global_trace_events: [self.rb_event_flag_t, Primitive.cexpr!("OFFSETOF(((struct rb_iseq_struct *)NULL)->aux.exec, global_trace_events)")],
|
2022-09-19 03:25:04 +03:00
|
|
|
),
|
2022-09-22 16:25:33 +03:00
|
|
|
), Primitive.cexpr!("OFFSETOF((*((struct rb_iseq_struct *)NULL)), aux)")],
|
2022-09-19 03:25:04 +03:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.rb_iseq_t
|
|
|
|
@rb_iseq_t ||= self.rb_iseq_struct
|
|
|
|
end
|
|
|
|
|
2023-03-16 21:05:54 +03:00
|
|
|
def C.rb_jit_func_t
|
|
|
|
@rb_jit_func_t ||= CType::Immediate.parse("void *")
|
|
|
|
end
|
|
|
|
|
2023-02-09 01:36:55 +03:00
|
|
|
def C.rb_method_attr_t
|
|
|
|
@rb_method_attr_t ||= CType::Struct.new(
|
|
|
|
"rb_method_attr_struct", Primitive.cexpr!("SIZEOF(struct rb_method_attr_struct)"),
|
|
|
|
id: [self.ID, Primitive.cexpr!("OFFSETOF((*((struct rb_method_attr_struct *)NULL)), id)")],
|
|
|
|
location: [self.VALUE, Primitive.cexpr!("OFFSETOF((*((struct rb_method_attr_struct *)NULL)), location)")],
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2023-03-05 09:42:03 +03:00
|
|
|
def C.rb_method_bmethod_t
|
|
|
|
@rb_method_bmethod_t ||= CType::Struct.new(
|
|
|
|
"rb_method_bmethod_struct", Primitive.cexpr!("SIZEOF(struct rb_method_bmethod_struct)"),
|
|
|
|
proc: [self.VALUE, Primitive.cexpr!("OFFSETOF((*((struct rb_method_bmethod_struct *)NULL)), proc)")],
|
|
|
|
hooks: [CType::Pointer.new { self.rb_hook_list_struct }, Primitive.cexpr!("OFFSETOF((*((struct rb_method_bmethod_struct *)NULL)), hooks)")],
|
|
|
|
defined_ractor: [self.VALUE, Primitive.cexpr!("OFFSETOF((*((struct rb_method_bmethod_struct *)NULL)), defined_ractor)")],
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2023-02-10 03:25:06 +03:00
|
|
|
def C.rb_method_cfunc_t
|
|
|
|
@rb_method_cfunc_t ||= CType::Struct.new(
|
|
|
|
"rb_method_cfunc_struct", Primitive.cexpr!("SIZEOF(struct rb_method_cfunc_struct)"),
|
2024-03-02 02:07:40 +03:00
|
|
|
func: [self.rb_cfunc_t, Primitive.cexpr!("OFFSETOF((*((struct rb_method_cfunc_struct *)NULL)), func)")],
|
2023-02-10 03:25:06 +03:00
|
|
|
invoker: [CType::Immediate.parse("void *"), Primitive.cexpr!("OFFSETOF((*((struct rb_method_cfunc_struct *)NULL)), invoker)")],
|
|
|
|
argc: [CType::Immediate.parse("int"), Primitive.cexpr!("OFFSETOF((*((struct rb_method_cfunc_struct *)NULL)), argc)")],
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2022-09-19 03:25:04 +03:00
|
|
|
def C.rb_method_definition_struct
|
|
|
|
@rb_method_definition_struct ||= CType::Struct.new(
|
2022-09-21 16:32:28 +03:00
|
|
|
"rb_method_definition_struct", Primitive.cexpr!("SIZEOF(struct rb_method_definition_struct)"),
|
2022-11-15 11:11:44 +03:00
|
|
|
type: [CType::BitField.new(4, 0), 0],
|
2022-09-22 16:25:33 +03:00
|
|
|
iseq_overload: [CType::BitField.new(1, 4), 4],
|
2023-09-20 19:26:31 +03:00
|
|
|
no_redef_warning: [CType::BitField.new(1, 5), 5],
|
|
|
|
aliased: [CType::BitField.new(1, 6), 6],
|
|
|
|
reference_count: [CType::BitField.new(28, 0), 32],
|
2022-09-22 16:25:33 +03:00
|
|
|
body: [CType::Union.new(
|
2022-09-21 16:32:28 +03:00
|
|
|
"", Primitive.cexpr!("SIZEOF(((struct rb_method_definition_struct *)NULL)->body)"),
|
2022-09-19 03:25:04 +03:00
|
|
|
iseq: self.rb_method_iseq_t,
|
|
|
|
cfunc: self.rb_method_cfunc_t,
|
|
|
|
attr: self.rb_method_attr_t,
|
|
|
|
alias: self.rb_method_alias_t,
|
|
|
|
refined: self.rb_method_refined_t,
|
|
|
|
bmethod: self.rb_method_bmethod_t,
|
|
|
|
optimized: self.rb_method_optimized_t,
|
2022-09-22 16:25:33 +03:00
|
|
|
), Primitive.cexpr!("OFFSETOF((*((struct rb_method_definition_struct *)NULL)), body)")],
|
|
|
|
original_id: [self.ID, Primitive.cexpr!("OFFSETOF((*((struct rb_method_definition_struct *)NULL)), original_id)")],
|
|
|
|
method_serial: [CType::Immediate.parse("uintptr_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_method_definition_struct *)NULL)), method_serial)")],
|
2022-09-19 03:25:04 +03:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2023-03-03 09:23:47 +03:00
|
|
|
def C.rb_method_entry_t
|
|
|
|
@rb_method_entry_t ||= CType::Struct.new(
|
|
|
|
"rb_method_entry_struct", Primitive.cexpr!("SIZEOF(struct rb_method_entry_struct)"),
|
|
|
|
flags: [self.VALUE, Primitive.cexpr!("OFFSETOF((*((struct rb_method_entry_struct *)NULL)), flags)")],
|
|
|
|
defined_class: [self.VALUE, Primitive.cexpr!("OFFSETOF((*((struct rb_method_entry_struct *)NULL)), defined_class)")],
|
|
|
|
def: [CType::Pointer.new { self.rb_method_definition_struct }, Primitive.cexpr!("OFFSETOF((*((struct rb_method_entry_struct *)NULL)), def)")],
|
|
|
|
called_id: [self.ID, Primitive.cexpr!("OFFSETOF((*((struct rb_method_entry_struct *)NULL)), called_id)")],
|
|
|
|
owner: [self.VALUE, Primitive.cexpr!("OFFSETOF((*((struct rb_method_entry_struct *)NULL)), owner)")],
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2022-09-19 03:25:04 +03:00
|
|
|
def C.rb_method_iseq_t
|
|
|
|
@rb_method_iseq_t ||= CType::Struct.new(
|
2022-09-21 16:32:28 +03:00
|
|
|
"rb_method_iseq_struct", Primitive.cexpr!("SIZEOF(struct rb_method_iseq_struct)"),
|
2022-09-22 16:25:33 +03:00
|
|
|
iseqptr: [CType::Pointer.new { self.rb_iseq_t }, Primitive.cexpr!("OFFSETOF((*((struct rb_method_iseq_struct *)NULL)), iseqptr)")],
|
|
|
|
cref: [CType::Pointer.new { self.rb_cref_t }, Primitive.cexpr!("OFFSETOF((*((struct rb_method_iseq_struct *)NULL)), cref)")],
|
2022-09-19 03:25:04 +03:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2023-02-16 10:43:53 +03:00
|
|
|
def C.rb_method_optimized_t
|
|
|
|
@rb_method_optimized_t ||= CType::Struct.new(
|
|
|
|
"rb_method_optimized", Primitive.cexpr!("SIZEOF(struct rb_method_optimized)"),
|
|
|
|
type: [self.method_optimized_type, Primitive.cexpr!("OFFSETOF((*((struct rb_method_optimized *)NULL)), type)")],
|
|
|
|
index: [CType::Immediate.parse("unsigned int"), Primitive.cexpr!("OFFSETOF((*((struct rb_method_optimized *)NULL)), index)")],
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2022-09-19 03:25:04 +03:00
|
|
|
def C.rb_method_type_t
|
2022-09-20 17:23:50 +03:00
|
|
|
@rb_method_type_t ||= CType::Immediate.parse("int")
|
2022-09-19 03:25:04 +03:00
|
|
|
end
|
|
|
|
|
2023-03-07 10:43:26 +03:00
|
|
|
def C.rb_proc_t
|
|
|
|
@rb_proc_t ||= CType::Struct.new(
|
|
|
|
"", Primitive.cexpr!("SIZEOF(rb_proc_t)"),
|
|
|
|
block: [self.rb_block, Primitive.cexpr!("OFFSETOF((*((rb_proc_t *)NULL)), block)")],
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2023-03-19 07:27:07 +03:00
|
|
|
def C.rb_rjit_options
|
|
|
|
@rb_rjit_options ||= CType::Struct.new(
|
|
|
|
"rb_rjit_options", Primitive.cexpr!("SIZEOF(struct rb_rjit_options)"),
|
|
|
|
on: [self._Bool, Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_options *)NULL)), on)")],
|
|
|
|
exec_mem_size: [CType::Immediate.parse("unsigned int"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_options *)NULL)), exec_mem_size)")],
|
2023-12-22 08:10:19 +03:00
|
|
|
call_threshold: [CType::Immediate.parse("unsigned int"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_options *)NULL)), call_threshold)")],
|
2023-03-19 07:27:07 +03:00
|
|
|
stats: [self._Bool, Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_options *)NULL)), stats)")],
|
2023-12-22 08:10:19 +03:00
|
|
|
disable: [self._Bool, Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_options *)NULL)), disable)")],
|
|
|
|
trace: [self._Bool, Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_options *)NULL)), trace)")],
|
2023-03-19 07:27:07 +03:00
|
|
|
trace_exits: [self._Bool, Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_options *)NULL)), trace_exits)")],
|
|
|
|
dump_disasm: [self._Bool, Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_options *)NULL)), dump_disasm)")],
|
2023-04-04 08:52:38 +03:00
|
|
|
verify_ctx: [self._Bool, Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_options *)NULL)), verify_ctx)")],
|
2023-03-19 07:27:07 +03:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2023-03-07 10:17:25 +03:00
|
|
|
def C.rb_rjit_runtime_counters
|
|
|
|
@rb_rjit_runtime_counters ||= CType::Struct.new(
|
|
|
|
"rb_rjit_runtime_counters", Primitive.cexpr!("SIZEOF(struct rb_rjit_runtime_counters)"),
|
|
|
|
rjit_insns_count: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), rjit_insns_count)")],
|
2023-03-22 08:28:36 +03:00
|
|
|
send_args_splat_kw_splat: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_args_splat_kw_splat)")],
|
2023-03-07 10:17:25 +03:00
|
|
|
send_args_splat: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_args_splat)")],
|
2023-03-22 08:55:23 +03:00
|
|
|
send_args_splat_not_array: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_args_splat_not_array)")],
|
|
|
|
send_args_splat_length_not_equal: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_args_splat_length_not_equal)")],
|
2023-03-26 08:13:35 +03:00
|
|
|
send_args_splat_cfunc_var_args: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_args_splat_cfunc_var_args)")],
|
2023-03-22 08:55:23 +03:00
|
|
|
send_args_splat_arity_error: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_args_splat_arity_error)")],
|
|
|
|
send_args_splat_ruby2_hash: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_args_splat_ruby2_hash)")],
|
2023-04-02 22:56:27 +03:00
|
|
|
send_args_splat_cfunc_zuper: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_args_splat_cfunc_zuper)")],
|
|
|
|
send_args_splat_cfunc_ruby2_keywords: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_args_splat_cfunc_ruby2_keywords)")],
|
2023-03-07 10:17:25 +03:00
|
|
|
send_kw_splat: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_kw_splat)")],
|
|
|
|
send_kwarg: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_kwarg)")],
|
2023-03-22 08:28:36 +03:00
|
|
|
send_klass_megamorphic: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_klass_megamorphic)")],
|
2023-03-07 10:17:25 +03:00
|
|
|
send_missing_cme: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_missing_cme)")],
|
|
|
|
send_private: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_private)")],
|
|
|
|
send_protected_check_failed: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_protected_check_failed)")],
|
|
|
|
send_tailcall: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_tailcall)")],
|
|
|
|
send_notimplemented: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_notimplemented)")],
|
|
|
|
send_missing: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_missing)")],
|
|
|
|
send_bmethod: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_bmethod)")],
|
|
|
|
send_alias: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_alias)")],
|
|
|
|
send_undef: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_undef)")],
|
|
|
|
send_zsuper: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_zsuper)")],
|
|
|
|
send_refined: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_refined)")],
|
|
|
|
send_stackoverflow: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_stackoverflow)")],
|
|
|
|
send_arity: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_arity)")],
|
|
|
|
send_c_tracing: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_c_tracing)")],
|
2023-03-19 08:57:31 +03:00
|
|
|
send_is_a_class_mismatch: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_is_a_class_mismatch)")],
|
2023-03-19 09:13:25 +03:00
|
|
|
send_instance_of_class_mismatch: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_instance_of_class_mismatch)")],
|
2023-04-02 21:07:50 +03:00
|
|
|
send_keywords: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_keywords)")],
|
2023-03-07 10:17:25 +03:00
|
|
|
send_blockiseq: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_blockiseq)")],
|
|
|
|
send_block_handler: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_block_handler)")],
|
|
|
|
send_block_setup: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_block_setup)")],
|
|
|
|
send_block_not_nil: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_block_not_nil)")],
|
|
|
|
send_block_not_proxy: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_block_not_proxy)")],
|
2023-04-02 21:01:23 +03:00
|
|
|
send_block_arg: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_block_arg)")],
|
2023-03-07 10:17:25 +03:00
|
|
|
send_iseq_kwparam: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_iseq_kwparam)")],
|
2023-04-02 03:24:06 +03:00
|
|
|
send_iseq_accepts_no_kwarg: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_iseq_accepts_no_kwarg)")],
|
|
|
|
send_iseq_has_opt: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_iseq_has_opt)")],
|
|
|
|
send_iseq_has_kwrest: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_iseq_has_kwrest)")],
|
2023-03-28 07:58:50 +03:00
|
|
|
send_iseq_ruby2_keywords: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_iseq_ruby2_keywords)")],
|
|
|
|
send_iseq_has_rest_and_captured: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_iseq_has_rest_and_captured)")],
|
2023-04-02 07:47:28 +03:00
|
|
|
send_iseq_has_rest_and_kw_supplied: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_iseq_has_rest_and_kw_supplied)")],
|
2023-03-28 07:58:50 +03:00
|
|
|
send_iseq_has_no_kw: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_iseq_has_no_kw)")],
|
|
|
|
send_iseq_zsuper: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_iseq_zsuper)")],
|
|
|
|
send_iseq_materialized_block: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_iseq_materialized_block)")],
|
|
|
|
send_iseq_has_rest: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_iseq_has_rest)")],
|
|
|
|
send_iseq_block_arg0_splat: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_iseq_block_arg0_splat)")],
|
|
|
|
send_iseq_kw_call: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_iseq_kw_call)")],
|
2024-01-19 03:53:28 +03:00
|
|
|
send_iseq_kw_splat: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_iseq_kw_splat)")],
|
2023-03-28 07:58:50 +03:00
|
|
|
send_iseq_splat: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_iseq_splat)")],
|
|
|
|
send_iseq_has_rest_and_optional: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_iseq_has_rest_and_optional)")],
|
|
|
|
send_iseq_arity_error: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_iseq_arity_error)")],
|
|
|
|
send_iseq_missing_optional_kw: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_iseq_missing_optional_kw)")],
|
2023-04-02 20:27:17 +03:00
|
|
|
send_iseq_too_many_kwargs: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_iseq_too_many_kwargs)")],
|
|
|
|
send_iseq_kwargs_mismatch: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_iseq_kwargs_mismatch)")],
|
2023-04-02 20:46:27 +03:00
|
|
|
send_iseq_splat_with_kw: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_iseq_splat_with_kw)")],
|
|
|
|
send_iseq_splat_arity_error: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_iseq_splat_arity_error)")],
|
2023-04-03 00:44:40 +03:00
|
|
|
send_iseq_has_rest_and_splat_not_equal: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_iseq_has_rest_and_splat_not_equal)")],
|
2023-03-07 10:17:25 +03:00
|
|
|
send_cfunc_variadic: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_cfunc_variadic)")],
|
|
|
|
send_cfunc_too_many_args: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_cfunc_too_many_args)")],
|
|
|
|
send_cfunc_ruby_array_varg: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_cfunc_ruby_array_varg)")],
|
2023-04-02 22:56:27 +03:00
|
|
|
send_cfunc_splat_with_kw: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_cfunc_splat_with_kw)")],
|
|
|
|
send_cfunc_tracing: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_cfunc_tracing)")],
|
|
|
|
send_cfunc_argc_mismatch: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_cfunc_argc_mismatch)")],
|
|
|
|
send_cfunc_toomany_args: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_cfunc_toomany_args)")],
|
2023-03-27 03:41:05 +03:00
|
|
|
send_attrset_splat: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_attrset_splat)")],
|
|
|
|
send_attrset_kwarg: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_attrset_kwarg)")],
|
|
|
|
send_attrset_method: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_attrset_method)")],
|
2023-03-07 10:17:25 +03:00
|
|
|
send_ivar_splat: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_ivar_splat)")],
|
|
|
|
send_ivar_opt_send: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_ivar_opt_send)")],
|
|
|
|
send_optimized_send_no_args: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_optimized_send_no_args)")],
|
|
|
|
send_optimized_send_not_sym_or_str: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_optimized_send_not_sym_or_str)")],
|
|
|
|
send_optimized_send_mid_class_changed: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_optimized_send_mid_class_changed)")],
|
|
|
|
send_optimized_send_mid_id_changed: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_optimized_send_mid_id_changed)")],
|
|
|
|
send_optimized_send_null_mid: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_optimized_send_null_mid)")],
|
|
|
|
send_optimized_send_send: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_optimized_send_send)")],
|
|
|
|
send_optimized_call_block: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_optimized_call_block)")],
|
|
|
|
send_optimized_call_kwarg: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_optimized_call_kwarg)")],
|
|
|
|
send_optimized_call_splat: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_optimized_call_splat)")],
|
|
|
|
send_optimized_struct_aref_error: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_optimized_struct_aref_error)")],
|
|
|
|
send_optimized_block_call: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_optimized_block_call)")],
|
|
|
|
send_optimized_struct_aset: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_optimized_struct_aset)")],
|
|
|
|
send_bmethod_not_iseq: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_bmethod_not_iseq)")],
|
|
|
|
send_bmethod_blockarg: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_bmethod_blockarg)")],
|
|
|
|
invokesuper_me_changed: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), invokesuper_me_changed)")],
|
2023-04-02 21:07:50 +03:00
|
|
|
invokesuper_block: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), invokesuper_block)")],
|
2023-03-13 08:27:43 +03:00
|
|
|
invokeblock_none: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), invokeblock_none)")],
|
|
|
|
invokeblock_symbol: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), invokeblock_symbol)")],
|
|
|
|
invokeblock_proc: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), invokeblock_proc)")],
|
2023-03-13 08:27:43 +03:00
|
|
|
invokeblock_tag_changed: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), invokeblock_tag_changed)")],
|
|
|
|
invokeblock_iseq_block_changed: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), invokeblock_iseq_block_changed)")],
|
2023-03-20 07:49:51 +03:00
|
|
|
invokeblock_iseq_arity: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), invokeblock_iseq_arity)")],
|
|
|
|
invokeblock_iseq_arg0_splat: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), invokeblock_iseq_arg0_splat)")],
|
2023-03-20 09:19:58 +03:00
|
|
|
invokeblock_ifunc_args_splat: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), invokeblock_ifunc_args_splat)")],
|
|
|
|
invokeblock_ifunc_kw_splat: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), invokeblock_ifunc_kw_splat)")],
|
2023-04-02 20:27:17 +03:00
|
|
|
invokeblock_iseq_arg0_args_splat: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), invokeblock_iseq_arg0_args_splat)")],
|
|
|
|
invokeblock_iseq_arg0_has_kw: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), invokeblock_iseq_arg0_has_kw)")],
|
2023-03-07 10:17:25 +03:00
|
|
|
getivar_megamorphic: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), getivar_megamorphic)")],
|
|
|
|
getivar_not_heap: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), getivar_not_heap)")],
|
|
|
|
getivar_special_const: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), getivar_special_const)")],
|
|
|
|
getivar_too_complex: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), getivar_too_complex)")],
|
|
|
|
optaref_arg_not_fixnum: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), optaref_arg_not_fixnum)")],
|
|
|
|
optaref_argc_not_one: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), optaref_argc_not_one)")],
|
|
|
|
optaref_recv_not_array: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), optaref_recv_not_array)")],
|
|
|
|
optaref_recv_not_hash: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), optaref_recv_not_hash)")],
|
|
|
|
optaref_send: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), optaref_send)")],
|
|
|
|
optgetconst_not_cached: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), optgetconst_not_cached)")],
|
|
|
|
optgetconst_cref: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), optgetconst_cref)")],
|
|
|
|
optgetconst_cache_miss: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), optgetconst_cache_miss)")],
|
|
|
|
setivar_frozen: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), setivar_frozen)")],
|
|
|
|
setivar_not_heap: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), setivar_not_heap)")],
|
|
|
|
setivar_megamorphic: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), setivar_megamorphic)")],
|
|
|
|
setivar_too_complex: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), setivar_too_complex)")],
|
|
|
|
expandarray_splat: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), expandarray_splat)")],
|
|
|
|
expandarray_postarg: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), expandarray_postarg)")],
|
|
|
|
expandarray_not_array: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), expandarray_not_array)")],
|
|
|
|
expandarray_rhs_too_small: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), expandarray_rhs_too_small)")],
|
|
|
|
getblockpp_block_param_modified: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), getblockpp_block_param_modified)")],
|
|
|
|
getblockpp_block_handler_none: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), getblockpp_block_handler_none)")],
|
|
|
|
getblockpp_not_gc_guarded: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), getblockpp_not_gc_guarded)")],
|
|
|
|
getblockpp_not_iseq_block: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), getblockpp_not_iseq_block)")],
|
|
|
|
compiled_block_count: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), compiled_block_count)")],
|
2022-12-27 09:46:40 +03:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2022-09-19 03:25:04 +03:00
|
|
|
def C.rb_serial_t
|
2022-09-20 17:23:50 +03:00
|
|
|
@rb_serial_t ||= CType::Immediate.parse("unsigned long long")
|
|
|
|
end
|
|
|
|
|
2022-10-13 00:37:02 +03:00
|
|
|
def C.rb_shape
|
|
|
|
@rb_shape ||= CType::Struct.new(
|
|
|
|
"rb_shape", Primitive.cexpr!("SIZEOF(struct rb_shape)"),
|
|
|
|
edges: [CType::Pointer.new { self.rb_id_table }, Primitive.cexpr!("OFFSETOF((*((struct rb_shape *)NULL)), edges)")],
|
|
|
|
edge_name: [self.ID, Primitive.cexpr!("OFFSETOF((*((struct rb_shape *)NULL)), edge_name)")],
|
2022-10-21 23:24:29 +03:00
|
|
|
next_iv_index: [self.attr_index_t, Primitive.cexpr!("OFFSETOF((*((struct rb_shape *)NULL)), next_iv_index)")],
|
2023-10-19 00:05:48 +03:00
|
|
|
capacity: [CType::Immediate.parse("uint32_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_shape *)NULL)), capacity)")],
|
2022-10-13 00:37:02 +03:00
|
|
|
type: [CType::Immediate.parse("uint8_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_shape *)NULL)), type)")],
|
Rename size_pool -> heap
Now that we've inlined the eden_heap into the size_pool, we should
rename the size_pool to heap. So that Ruby contains multiple heaps, with
different sized objects.
The term heap as a collection of memory pages is more in memory
management nomenclature, whereas size_pool was a name chosen out of
necessity during the development of the Variable Width Allocation
features of Ruby.
The concept of size pools was introduced in order to facilitate
different sized objects (other than the default 40 bytes). They wrapped
the eden heap and the tomb heap, and some related state, and provided a
reasonably simple way of duplicating all related concerns, to provide
multiple pools that all shared the same structure but held different
objects.
Since then various changes have happend in Ruby's memory layout:
* The concept of tomb heaps has been replaced by a global free pages list,
with each page having it's slot size reconfigured at the point when it
is resurrected
* the eden heap has been inlined into the size pool itself, so that now
the size pool directly controls the free_pages list, the sweeping
page, the compaction cursor and the other state that was previously
being managed by the eden heap.
Now that there is no need for a heap wrapper, we should refer to the
collection of pages containing Ruby objects as a heap again rather than
a size pool
2024-10-03 15:53:49 +03:00
|
|
|
heap_index: [CType::Immediate.parse("uint8_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_shape *)NULL)), heap_index)")],
|
2022-10-13 00:37:02 +03:00
|
|
|
parent_id: [self.shape_id_t, Primitive.cexpr!("OFFSETOF((*((struct rb_shape *)NULL)), parent_id)")],
|
2023-02-08 04:46:42 +03:00
|
|
|
ancestor_index: [CType::Pointer.new { self.redblack_node_t }, Primitive.cexpr!("OFFSETOF((*((struct rb_shape *)NULL)), ancestor_index)")],
|
2022-10-13 00:37:02 +03:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.rb_shape_t
|
|
|
|
@rb_shape_t ||= self.rb_shape
|
|
|
|
end
|
|
|
|
|
2023-03-04 11:01:30 +03:00
|
|
|
def C.rb_thread_struct
|
|
|
|
@rb_thread_struct ||= CType::Struct.new(
|
|
|
|
"rb_thread_struct", Primitive.cexpr!("SIZEOF(struct rb_thread_struct)"),
|
|
|
|
lt_node: [self.ccan_list_node, Primitive.cexpr!("OFFSETOF((*((struct rb_thread_struct *)NULL)), lt_node)")],
|
|
|
|
self: [self.VALUE, Primitive.cexpr!("OFFSETOF((*((struct rb_thread_struct *)NULL)), self)")],
|
|
|
|
ractor: [CType::Pointer.new { self.rb_ractor_t }, Primitive.cexpr!("OFFSETOF((*((struct rb_thread_struct *)NULL)), ractor)")],
|
|
|
|
vm: [CType::Pointer.new { self.rb_vm_t }, Primitive.cexpr!("OFFSETOF((*((struct rb_thread_struct *)NULL)), vm)")],
|
|
|
|
nt: [CType::Pointer.new { self.rb_native_thread }, Primitive.cexpr!("OFFSETOF((*((struct rb_thread_struct *)NULL)), nt)")],
|
|
|
|
ec: [CType::Pointer.new { self.rb_execution_context_t }, Primitive.cexpr!("OFFSETOF((*((struct rb_thread_struct *)NULL)), ec)")],
|
|
|
|
sched: [self.rb_thread_sched_item, Primitive.cexpr!("OFFSETOF((*((struct rb_thread_struct *)NULL)), sched)")],
|
2023-12-28 21:52:45 +03:00
|
|
|
mn_schedulable: [self._Bool, Primitive.cexpr!("OFFSETOF((*((struct rb_thread_struct *)NULL)), mn_schedulable)")],
|
2023-03-04 11:01:30 +03:00
|
|
|
serial: [self.rb_atomic_t, Primitive.cexpr!("OFFSETOF((*((struct rb_thread_struct *)NULL)), serial)")],
|
|
|
|
last_status: [self.VALUE, Primitive.cexpr!("OFFSETOF((*((struct rb_thread_struct *)NULL)), last_status)")],
|
|
|
|
calling: [CType::Pointer.new { self.rb_calling_info }, Primitive.cexpr!("OFFSETOF((*((struct rb_thread_struct *)NULL)), calling)")],
|
|
|
|
top_self: [self.VALUE, Primitive.cexpr!("OFFSETOF((*((struct rb_thread_struct *)NULL)), top_self)")],
|
|
|
|
top_wrapper: [self.VALUE, Primitive.cexpr!("OFFSETOF((*((struct rb_thread_struct *)NULL)), top_wrapper)")],
|
|
|
|
priority: [CType::Immediate.parse("int8_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_thread_struct *)NULL)), priority)")],
|
|
|
|
running_time_us: [CType::Immediate.parse("uint32_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_thread_struct *)NULL)), running_time_us)")],
|
|
|
|
blocking_region_buffer: [CType::Pointer.new { CType::Immediate.parse("void") }, Primitive.cexpr!("OFFSETOF((*((struct rb_thread_struct *)NULL)), blocking_region_buffer)")],
|
|
|
|
thgroup: [self.VALUE, Primitive.cexpr!("OFFSETOF((*((struct rb_thread_struct *)NULL)), thgroup)")],
|
|
|
|
value: [self.VALUE, Primitive.cexpr!("OFFSETOF((*((struct rb_thread_struct *)NULL)), value)")],
|
|
|
|
pending_interrupt_queue: [self.VALUE, Primitive.cexpr!("OFFSETOF((*((struct rb_thread_struct *)NULL)), pending_interrupt_queue)")],
|
|
|
|
pending_interrupt_mask_stack: [self.VALUE, Primitive.cexpr!("OFFSETOF((*((struct rb_thread_struct *)NULL)), pending_interrupt_mask_stack)")],
|
|
|
|
interrupt_lock: [self.rb_nativethread_lock_t, Primitive.cexpr!("OFFSETOF((*((struct rb_thread_struct *)NULL)), interrupt_lock)")],
|
|
|
|
unblock: [self.rb_unblock_callback, Primitive.cexpr!("OFFSETOF((*((struct rb_thread_struct *)NULL)), unblock)")],
|
|
|
|
locking_mutex: [self.VALUE, Primitive.cexpr!("OFFSETOF((*((struct rb_thread_struct *)NULL)), locking_mutex)")],
|
|
|
|
keeping_mutexes: [CType::Pointer.new { self.rb_mutex_struct }, Primitive.cexpr!("OFFSETOF((*((struct rb_thread_struct *)NULL)), keeping_mutexes)")],
|
|
|
|
join_list: [CType::Pointer.new { self.rb_waiting_list }, Primitive.cexpr!("OFFSETOF((*((struct rb_thread_struct *)NULL)), join_list)")],
|
|
|
|
invoke_arg: [CType::Union.new(
|
|
|
|
"", Primitive.cexpr!("SIZEOF(((struct rb_thread_struct *)NULL)->invoke_arg)"),
|
|
|
|
proc: CType::Struct.new(
|
|
|
|
"", Primitive.cexpr!("SIZEOF(((struct rb_thread_struct *)NULL)->invoke_arg.proc)"),
|
|
|
|
proc: [self.VALUE, Primitive.cexpr!("OFFSETOF(((struct rb_thread_struct *)NULL)->invoke_arg.proc, proc)")],
|
|
|
|
args: [self.VALUE, Primitive.cexpr!("OFFSETOF(((struct rb_thread_struct *)NULL)->invoke_arg.proc, args)")],
|
|
|
|
kw_splat: [CType::Immediate.parse("int"), Primitive.cexpr!("OFFSETOF(((struct rb_thread_struct *)NULL)->invoke_arg.proc, kw_splat)")],
|
|
|
|
),
|
|
|
|
func: CType::Struct.new(
|
|
|
|
"", Primitive.cexpr!("SIZEOF(((struct rb_thread_struct *)NULL)->invoke_arg.func)"),
|
|
|
|
func: [CType::Immediate.parse("void *"), Primitive.cexpr!("OFFSETOF(((struct rb_thread_struct *)NULL)->invoke_arg.func, func)")],
|
|
|
|
arg: [CType::Pointer.new { CType::Immediate.parse("void") }, Primitive.cexpr!("OFFSETOF(((struct rb_thread_struct *)NULL)->invoke_arg.func, arg)")],
|
|
|
|
),
|
|
|
|
), Primitive.cexpr!("OFFSETOF((*((struct rb_thread_struct *)NULL)), invoke_arg)")],
|
|
|
|
invoke_type: [self.thread_invoke_type, Primitive.cexpr!("OFFSETOF((*((struct rb_thread_struct *)NULL)), invoke_type)")],
|
|
|
|
stat_insn_usage: [self.VALUE, Primitive.cexpr!("OFFSETOF((*((struct rb_thread_struct *)NULL)), stat_insn_usage)")],
|
|
|
|
root_fiber: [CType::Pointer.new { self.rb_fiber_t }, Primitive.cexpr!("OFFSETOF((*((struct rb_thread_struct *)NULL)), root_fiber)")],
|
|
|
|
scheduler: [self.VALUE, Primitive.cexpr!("OFFSETOF((*((struct rb_thread_struct *)NULL)), scheduler)")],
|
|
|
|
blocking: [CType::Immediate.parse("unsigned int"), Primitive.cexpr!("OFFSETOF((*((struct rb_thread_struct *)NULL)), blocking)")],
|
|
|
|
name: [self.VALUE, Primitive.cexpr!("OFFSETOF((*((struct rb_thread_struct *)NULL)), name)")],
|
2023-11-16 20:29:11 +03:00
|
|
|
specific_storage: [CType::Pointer.new { CType::Pointer.new { CType::Immediate.parse("void") } }, Primitive.cexpr!("OFFSETOF((*((struct rb_thread_struct *)NULL)), specific_storage)")],
|
2023-03-04 11:01:30 +03:00
|
|
|
ext_config: [self.rb_ext_config, Primitive.cexpr!("OFFSETOF((*((struct rb_thread_struct *)NULL)), ext_config)")],
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2022-09-20 17:23:50 +03:00
|
|
|
def C.VALUE
|
2024-01-24 01:37:22 +03:00
|
|
|
@VALUE ||= CType::Immediate.find(
|
|
|
|
Primitive.cexpr!("SIZEOF(VALUE)"),
|
|
|
|
Primitive.cexpr!("SIGNED_TYPE_P(VALUE)"),
|
|
|
|
)
|
2022-09-19 03:25:04 +03:00
|
|
|
end
|
|
|
|
|
2022-10-03 18:14:32 +03:00
|
|
|
def C.shape_id_t
|
2024-01-24 01:37:22 +03:00
|
|
|
@shape_id_t ||= CType::Immediate.find(
|
|
|
|
Primitive.cexpr!("SIZEOF(shape_id_t)"),
|
|
|
|
Primitive.cexpr!("SIGNED_TYPE_P(shape_id_t)"),
|
|
|
|
)
|
2022-10-03 18:14:32 +03:00
|
|
|
end
|
|
|
|
|
2023-02-08 01:42:58 +03:00
|
|
|
def C.rb_id_table
|
|
|
|
CType::Stub.new(:rb_id_table)
|
|
|
|
end
|
|
|
|
|
2022-09-19 03:25:04 +03:00
|
|
|
def C.vm_call_handler
|
|
|
|
CType::Stub.new(:vm_call_handler)
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.method_missing_reason
|
|
|
|
CType::Stub.new(:method_missing_reason)
|
|
|
|
end
|
|
|
|
|
2023-03-05 09:42:03 +03:00
|
|
|
def C.vm_ifunc
|
|
|
|
CType::Stub.new(:vm_ifunc)
|
|
|
|
end
|
|
|
|
|
2022-09-19 03:25:04 +03:00
|
|
|
def C.rb_cref_struct
|
|
|
|
CType::Stub.new(:rb_cref_struct)
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.rb_scope_visibility_t
|
|
|
|
CType::Stub.new(:rb_scope_visibility_t)
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.rb_vm_tag
|
|
|
|
CType::Stub.new(:rb_vm_tag)
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.rb_atomic_t
|
|
|
|
CType::Stub.new(:rb_atomic_t)
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.rb_fiber_t
|
|
|
|
CType::Stub.new(:rb_fiber_t)
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.rb_trace_arg_struct
|
|
|
|
CType::Stub.new(:rb_trace_arg_struct)
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.rb_iseq_type
|
|
|
|
CType::Stub.new(:rb_iseq_type)
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.iseq_insn_info
|
|
|
|
CType::Stub.new(:iseq_insn_info)
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.iseq_catch_table
|
|
|
|
CType::Stub.new(:iseq_catch_table)
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.rb_snum_t
|
|
|
|
CType::Stub.new(:rb_snum_t)
|
|
|
|
end
|
|
|
|
|
2024-02-12 22:40:07 +03:00
|
|
|
def C._Bool
|
|
|
|
CType::Bool.new
|
|
|
|
end
|
|
|
|
|
2022-09-19 03:25:04 +03:00
|
|
|
def C.iseq_bits_t
|
|
|
|
CType::Stub.new(:iseq_bits_t)
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.rb_code_location_t
|
|
|
|
CType::Stub.new(:rb_code_location_t)
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.iseq_compile_data
|
|
|
|
CType::Stub.new(:iseq_compile_data)
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.rb_hook_list_struct
|
|
|
|
CType::Stub.new(:rb_hook_list_struct)
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.rb_event_flag_t
|
|
|
|
CType::Stub.new(:rb_event_flag_t)
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.rb_method_alias_t
|
|
|
|
CType::Stub.new(:rb_method_alias_t)
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.rb_method_refined_t
|
|
|
|
CType::Stub.new(:rb_method_refined_t)
|
|
|
|
end
|
|
|
|
|
2023-02-08 04:46:42 +03:00
|
|
|
def C.redblack_node_t
|
|
|
|
CType::Stub.new(:redblack_node_t)
|
|
|
|
end
|
|
|
|
|
2022-09-19 03:25:04 +03:00
|
|
|
def C.ccan_list_node
|
|
|
|
CType::Stub.new(:ccan_list_node)
|
|
|
|
end
|
|
|
|
|
2023-03-04 11:01:30 +03:00
|
|
|
def C.rb_ractor_t
|
|
|
|
CType::Stub.new(:rb_ractor_t)
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.rb_vm_t
|
|
|
|
CType::Stub.new(:rb_vm_t)
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.rb_native_thread
|
|
|
|
CType::Stub.new(:rb_native_thread)
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.rb_thread_sched_item
|
|
|
|
CType::Stub.new(:rb_thread_sched_item)
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.rb_calling_info
|
|
|
|
CType::Stub.new(:rb_calling_info)
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.rb_nativethread_lock_t
|
|
|
|
CType::Stub.new(:rb_nativethread_lock_t)
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.rb_unblock_callback
|
|
|
|
CType::Stub.new(:rb_unblock_callback)
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.rb_mutex_struct
|
|
|
|
CType::Stub.new(:rb_mutex_struct)
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.rb_waiting_list
|
|
|
|
CType::Stub.new(:rb_waiting_list)
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.thread_invoke_type
|
|
|
|
CType::Stub.new(:thread_invoke_type)
|
|
|
|
end
|
|
|
|
|
|
|
|
def C.rb_ext_config
|
|
|
|
CType::Stub.new(:rb_ext_config)
|
|
|
|
end
|
|
|
|
|
2023-03-07 10:15:30 +03:00
|
|
|
### RJIT bindgen end ###
|
2023-03-07 10:17:25 +03:00
|
|
|
end if Primitive.rjit_enabled_p
|