YJIT: Move ROBJECT_OFFSET_* to yjit.c (#8157)

This commit is contained in:
Takashi Kokubun 2023-08-02 07:15:29 -07:00 коммит произвёл GitHub
Родитель 1d096c1e53
Коммит d405410e3c
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
5 изменённых файлов: 18 добавлений и 16 удалений

Просмотреть файл

@ -119,13 +119,6 @@ struct RObject {
} as;
};
/* Offsets for YJIT */
#ifndef __cplusplus
static const int32_t ROBJECT_OFFSET_AS_HEAP_IVPTR = offsetof(struct RObject, as.heap.ivptr);
static const int32_t ROBJECT_OFFSET_AS_HEAP_IV_INDEX_TBL = offsetof(struct RObject, as.heap.iv_index_tbl);
static const int32_t ROBJECT_OFFSET_AS_ARY = offsetof(struct RObject, as.ary);
#endif
RBIMPL_ATTR_PURE_UNLESS_DEBUG()
RBIMPL_ATTR_ARTIFICIAL()
/**

7
yjit.c
Просмотреть файл

@ -38,6 +38,13 @@
#include <errno.h>
// Field offsets for the RObject struct
enum robject_offsets {
ROBJECT_OFFSET_AS_HEAP_IVPTR = offsetof(struct RObject, as.heap.ivptr),
ROBJECT_OFFSET_AS_HEAP_IV_INDEX_TBL = offsetof(struct RObject, as.heap.iv_index_tbl),
ROBJECT_OFFSET_AS_ARY = offsetof(struct RObject, as.ary),
};
// Field offsets for the RString struct
enum rstring_offsets {
RUBY_OFFSET_RSTRING_LEN = offsetof(struct RString, len)

Просмотреть файл

@ -84,7 +84,7 @@ fn main() {
// From include/ruby/internal/core/rbasic.h
.allowlist_type("RBasic")
.allowlist_type("rstring_offsets")
// From include/ruby/internal/core/rstring.h
.allowlist_type("ruby_rstring_flags")
// From internal.h
@ -179,7 +179,6 @@ fn main() {
// From include/ruby/internal/core/robject.h
.allowlist_type("ruby_robject_flags")
.allowlist_var("ROBJECT_OFFSET_.*")
// From include/ruby/internal/core/rarray.h
.allowlist_type("ruby_rarray_flags")
@ -327,6 +326,8 @@ fn main() {
.allowlist_function("rb_yjit_assert_holding_vm_lock")
.allowlist_function("rb_yjit_sendish_sp_pops")
.allowlist_function("rb_yjit_invokeblock_sp_pops")
.allowlist_type("robject_offsets")
.allowlist_type("rstring_offsets")
// from vm_sync.h
.allowlist_function("rb_vm_barrier")

Просмотреть файл

@ -2054,7 +2054,7 @@ fn gen_get_ivar(
// See ROBJECT_IVPTR() from include/ruby/internal/core/robject.h
// Load the variable
let offs = ROBJECT_OFFSET_AS_ARY + (ivar_index * SIZEOF_VALUE) as i32;
let offs = ROBJECT_OFFSET_AS_ARY as i32 + (ivar_index * SIZEOF_VALUE) as i32;
let ivar_opnd = Opnd::mem(64, recv, offs);
// Push the ivar on the stack
@ -2064,7 +2064,7 @@ fn gen_get_ivar(
// Compile time value is *not* embedded.
// Get a pointer to the extended table
let tbl_opnd = asm.load(Opnd::mem(64, recv, ROBJECT_OFFSET_AS_HEAP_IVPTR));
let tbl_opnd = asm.load(Opnd::mem(64, recv, ROBJECT_OFFSET_AS_HEAP_IVPTR as i32));
// Read the ivar from the extended table
let ivar_opnd = Opnd::mem(64, tbl_opnd, (SIZEOF_VALUE * ivar_index) as i32);
@ -2126,7 +2126,7 @@ fn gen_write_iv(
if embed_test_result {
// Find the IV offset
let offs = ROBJECT_OFFSET_AS_ARY + (ivar_index * SIZEOF_VALUE) as i32;
let offs = ROBJECT_OFFSET_AS_ARY as i32 + (ivar_index * SIZEOF_VALUE) as i32;
let ivar_opnd = Opnd::mem(64, recv, offs);
// Write the IV
@ -2136,7 +2136,7 @@ fn gen_write_iv(
// Compile time value is *not* embedded.
// Get a pointer to the extended table
let tbl_opnd = asm.load(Opnd::mem(64, recv, ROBJECT_OFFSET_AS_HEAP_IVPTR));
let tbl_opnd = asm.load(Opnd::mem(64, recv, ROBJECT_OFFSET_AS_HEAP_IVPTR as i32));
// Write the ivar in to the extended table
let ivar_opnd = Opnd::mem(64, tbl_opnd, (SIZEOF_VALUE * ivar_index) as i32);

Просмотреть файл

@ -251,9 +251,6 @@ pub const RMODULE_IS_REFINEMENT: ruby_rmodule_flags = 32768;
pub type ruby_rmodule_flags = u32;
pub const ROBJECT_EMBED: ruby_robject_flags = 8192;
pub type ruby_robject_flags = u32;
pub const ROBJECT_OFFSET_AS_HEAP_IVPTR: i32 = 16;
pub const ROBJECT_OFFSET_AS_HEAP_IV_INDEX_TBL: i32 = 24;
pub const ROBJECT_OFFSET_AS_ARY: i32 = 16;
pub type rb_block_call_func = ::std::option::Option<
unsafe extern "C" fn(
yielded_arg: VALUE,
@ -1060,6 +1057,10 @@ pub type ruby_vminsn_type = u32;
pub type rb_iseq_callback = ::std::option::Option<
unsafe extern "C" fn(arg1: *const rb_iseq_t, arg2: *mut ::std::os::raw::c_void),
>;
pub const ROBJECT_OFFSET_AS_HEAP_IVPTR: robject_offsets = 16;
pub const ROBJECT_OFFSET_AS_HEAP_IV_INDEX_TBL: robject_offsets = 24;
pub const ROBJECT_OFFSET_AS_ARY: robject_offsets = 16;
pub type robject_offsets = u32;
pub const RUBY_OFFSET_RSTRING_LEN: rstring_offsets = 16;
pub type rstring_offsets = u32;
pub type rb_seq_param_keyword_struct = rb_iseq_constant_body__bindgen_ty_1_rb_iseq_param_keyword;