mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
refactor constify most of rb_method_definition_t
Most (if not all) of the fields of rb_method_definition_t are never meant to be modified once after they are stored. Marking them const makes it possible for compilers to warn on unintended modifications.
This commit is contained in:
parent
3632a812c0
commit
cf33608203
Notes:
git
2019-09-30 10:27:07 +09:00
6 changed files with 68 additions and 71 deletions
2
gc.c
2
gc.c
|
@ -7831,7 +7831,7 @@ void rb_update_st_references(struct st_table *ht)
|
||||||
static void
|
static void
|
||||||
gc_ref_update_method_entry(rb_objspace_t *objspace, rb_method_entry_t *me)
|
gc_ref_update_method_entry(rb_objspace_t *objspace, rb_method_entry_t *me)
|
||||||
{
|
{
|
||||||
rb_method_definition_t *def = me->def;
|
const rb_method_definition_t *def = me->def;
|
||||||
|
|
||||||
UPDATE_IF_MOVED(objspace, me->owner);
|
UPDATE_IF_MOVED(objspace, me->owner);
|
||||||
UPDATE_IF_MOVED(objspace, me->defined_class);
|
UPDATE_IF_MOVED(objspace, me->defined_class);
|
||||||
|
|
40
method.h
40
method.h
|
@ -122,32 +122,32 @@ typedef struct rb_iseq_struct rb_iseq_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct rb_method_iseq_struct {
|
typedef struct rb_method_iseq_struct {
|
||||||
rb_iseq_t * iseqptr; /*!< iseq pointer, should be separated from iseqval */
|
const rb_iseq_t *const iseqptr; /*!< iseq pointer, should be separated from iseqval */
|
||||||
rb_cref_t * cref; /*!< class reference, should be marked */
|
rb_cref_t *const cref; /*!< class reference, should be marked */
|
||||||
} rb_method_iseq_t; /* check rb_add_method_iseq() when modify the fields */
|
} rb_method_iseq_t;
|
||||||
|
|
||||||
typedef struct rb_method_cfunc_struct {
|
typedef struct rb_method_cfunc_struct {
|
||||||
VALUE (*func)(ANYARGS);
|
VALUE (*const func)(ANYARGS);
|
||||||
VALUE (*invoker)(VALUE recv, int argc, const VALUE *argv, VALUE (*func)(ANYARGS));
|
VALUE (*const invoker)(VALUE recv, int argc, const VALUE *argv, VALUE (*func)(ANYARGS));
|
||||||
int argc;
|
const int argc;
|
||||||
} rb_method_cfunc_t;
|
} rb_method_cfunc_t;
|
||||||
|
|
||||||
typedef struct rb_method_attr_struct {
|
typedef struct rb_method_attr_struct {
|
||||||
ID id;
|
const ID id;
|
||||||
VALUE location; /* should be marked */
|
const VALUE location; /* should be marked */
|
||||||
} rb_method_attr_t;
|
} rb_method_attr_t;
|
||||||
|
|
||||||
typedef struct rb_method_alias_struct {
|
typedef struct rb_method_alias_struct {
|
||||||
struct rb_method_entry_struct * original_me; /* original_me->klass is original owner */
|
const struct rb_method_entry_struct *const original_me; /* original_me->klass is original owner */
|
||||||
} rb_method_alias_t;
|
} rb_method_alias_t;
|
||||||
|
|
||||||
typedef struct rb_method_refined_struct {
|
typedef struct rb_method_refined_struct {
|
||||||
struct rb_method_entry_struct * orig_me;
|
const struct rb_method_entry_struct *const orig_me;
|
||||||
VALUE owner;
|
const VALUE owner;
|
||||||
} rb_method_refined_t;
|
} rb_method_refined_t;
|
||||||
|
|
||||||
typedef struct rb_method_bmethod_struct {
|
typedef struct rb_method_bmethod_struct {
|
||||||
VALUE proc; /* should be marked */
|
const VALUE proc; /* should be marked */
|
||||||
struct rb_hook_list_struct *hooks;
|
struct rb_hook_list_struct *hooks;
|
||||||
} rb_method_bmethod_t;
|
} rb_method_bmethod_t;
|
||||||
|
|
||||||
|
@ -159,22 +159,22 @@ enum method_optimized_type {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct rb_method_definition_struct {
|
struct rb_method_definition_struct {
|
||||||
BITFIELD(rb_method_type_t, type, VM_METHOD_TYPE_MINIMUM_BITS);
|
BITFIELD(rb_method_type_t, const type, VM_METHOD_TYPE_MINIMUM_BITS);
|
||||||
int alias_count : 28;
|
int alias_count : 28;
|
||||||
int complemented_count : 28;
|
int complemented_count : 28;
|
||||||
|
|
||||||
union {
|
union {
|
||||||
rb_method_iseq_t iseq;
|
const rb_method_iseq_t iseq;
|
||||||
rb_method_cfunc_t cfunc;
|
const rb_method_cfunc_t cfunc;
|
||||||
rb_method_attr_t attr;
|
const rb_method_attr_t attr;
|
||||||
rb_method_alias_t alias;
|
const rb_method_alias_t alias;
|
||||||
rb_method_refined_t refined;
|
const rb_method_refined_t refined;
|
||||||
rb_method_bmethod_t bmethod;
|
rb_method_bmethod_t bmethod;
|
||||||
|
|
||||||
enum method_optimized_type optimize_type;
|
const enum method_optimized_type optimize_type;
|
||||||
} body;
|
} body;
|
||||||
|
|
||||||
ID original_id;
|
const ID original_id;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct rb_method_definition_struct rb_method_definition_t;
|
typedef struct rb_method_definition_struct rb_method_definition_t;
|
||||||
|
|
9
proc.c
9
proc.c
|
@ -15,6 +15,8 @@
|
||||||
#include "vm_core.h"
|
#include "vm_core.h"
|
||||||
#include "iseq.h"
|
#include "iseq.h"
|
||||||
|
|
||||||
|
extern const rb_method_definition_t *rb_method_definition_create(rb_method_type_t type, ID mid);
|
||||||
|
|
||||||
/* Proc.new with no block will raise an exception in the future
|
/* Proc.new with no block will raise an exception in the future
|
||||||
* versions */
|
* versions */
|
||||||
#define PROC_NEW_REQUIRES_BLOCK 0
|
#define PROC_NEW_REQUIRES_BLOCK 0
|
||||||
|
@ -1475,15 +1477,12 @@ mnew_missing(VALUE klass, VALUE obj, ID id, VALUE mclass)
|
||||||
struct METHOD *data;
|
struct METHOD *data;
|
||||||
VALUE method = TypedData_Make_Struct(mclass, struct METHOD, &method_data_type, data);
|
VALUE method = TypedData_Make_Struct(mclass, struct METHOD, &method_data_type, data);
|
||||||
rb_method_entry_t *me;
|
rb_method_entry_t *me;
|
||||||
rb_method_definition_t *def;
|
const rb_method_definition_t *def;
|
||||||
|
|
||||||
RB_OBJ_WRITE(method, &data->recv, obj);
|
RB_OBJ_WRITE(method, &data->recv, obj);
|
||||||
RB_OBJ_WRITE(method, &data->klass, klass);
|
RB_OBJ_WRITE(method, &data->klass, klass);
|
||||||
|
|
||||||
def = ZALLOC(rb_method_definition_t);
|
def = rb_method_definition_create(VM_METHOD_TYPE_MISSING, id);
|
||||||
def->type = VM_METHOD_TYPE_MISSING;
|
|
||||||
def->original_id = id;
|
|
||||||
|
|
||||||
me = rb_method_entry_create(id, klass, METHOD_VISI_UNDEF, def);
|
me = rb_method_entry_create(id, klass, METHOD_VISI_UNDEF, def);
|
||||||
|
|
||||||
RB_OBJ_WRITE(method, &data->me, me);
|
RB_OBJ_WRITE(method, &data->me, me);
|
||||||
|
|
|
@ -491,7 +491,7 @@ rb_iseq_check(const rb_iseq_t *iseq)
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline const rb_iseq_t *
|
static inline const rb_iseq_t *
|
||||||
def_iseq_ptr(rb_method_definition_t *def)
|
def_iseq_ptr(const rb_method_definition_t *def)
|
||||||
{
|
{
|
||||||
#if VM_CHECK_MODE > 0
|
#if VM_CHECK_MODE > 0
|
||||||
if (def->type != VM_METHOD_TYPE_ISEQ) rb_bug("def_iseq_ptr: not iseq (%d)", def->type);
|
if (def->type != VM_METHOD_TYPE_ISEQ) rb_bug("def_iseq_ptr: not iseq (%d)", def->type);
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
#include "ruby/config.h"
|
#include "ruby/config.h"
|
||||||
#include "debug_counter.h"
|
#include "debug_counter.h"
|
||||||
|
|
||||||
extern rb_method_definition_t *rb_method_definition_create(rb_method_type_t type, ID mid);
|
extern const rb_method_definition_t *rb_method_definition_create(rb_method_type_t type, ID mid);
|
||||||
extern void rb_method_definition_set(const rb_method_entry_t *me, rb_method_definition_t *def, void *opts);
|
extern void rb_method_definition_set(const rb_method_entry_t *me, rb_method_definition_t *def, void *opts);
|
||||||
extern int rb_method_definition_eq(const rb_method_definition_t *d1, const rb_method_definition_t *d2);
|
extern int rb_method_definition_eq(const rb_method_definition_t *d1, const rb_method_definition_t *d2);
|
||||||
extern VALUE rb_make_no_method_exception(VALUE exc, VALUE format, VALUE obj,
|
extern VALUE rb_make_no_method_exception(VALUE exc, VALUE format, VALUE obj,
|
||||||
|
@ -2589,9 +2589,9 @@ aliased_callable_method_entry(const rb_callable_method_entry_t *me)
|
||||||
RB_OBJ_WRITE(me, &me->def->body.alias.original_me, cme);
|
RB_OBJ_WRITE(me, &me->def->body.alias.original_me, cme);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
rb_method_definition_t *def =
|
const rb_method_definition_t *def =
|
||||||
rb_method_definition_create(VM_METHOD_TYPE_ALIAS, me->def->original_id);
|
rb_method_definition_create(VM_METHOD_TYPE_ALIAS, me->def->original_id);
|
||||||
rb_method_definition_set((rb_method_entry_t *)me, def, (void *)cme);
|
rb_method_definition_set((rb_method_entry_t *)me, (void *)def, (void *)cme);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
80
vm_method.c
80
vm_method.c
|
@ -132,9 +132,7 @@ rb_add_method_cfunc(VALUE klass, ID mid, VALUE (*func)(ANYARGS), int argc, rb_me
|
||||||
{
|
{
|
||||||
if (argc < -2 || 15 < argc) rb_raise(rb_eArgError, "arity out of range: %d for -2..15", argc);
|
if (argc < -2 || 15 < argc) rb_raise(rb_eArgError, "arity out of range: %d for -2..15", argc);
|
||||||
if (func != rb_f_notimplement) {
|
if (func != rb_f_notimplement) {
|
||||||
rb_method_cfunc_t opt;
|
rb_method_cfunc_t opt = { func, 0, argc, };
|
||||||
opt.func = func;
|
|
||||||
opt.argc = argc;
|
|
||||||
rb_add_method(klass, mid, VM_METHOD_TYPE_CFUNC, &opt, visi);
|
rb_add_method(klass, mid, VM_METHOD_TYPE_CFUNC, &opt, visi);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -213,14 +211,6 @@ static VALUE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
setup_method_cfunc_struct(rb_method_cfunc_t *cfunc, VALUE (*func)(), int argc)
|
|
||||||
{
|
|
||||||
cfunc->func = func;
|
|
||||||
cfunc->argc = argc;
|
|
||||||
cfunc->invoker = call_cfunc_invoker_func(argc);
|
|
||||||
}
|
|
||||||
|
|
||||||
MJIT_FUNC_EXPORTED void
|
MJIT_FUNC_EXPORTED void
|
||||||
rb_method_definition_set(const rb_method_entry_t *me, rb_method_definition_t *def, void *opts)
|
rb_method_definition_set(const rb_method_entry_t *me, rb_method_definition_t *def, void *opts)
|
||||||
{
|
{
|
||||||
|
@ -250,8 +240,13 @@ rb_method_definition_set(const rb_method_entry_t *me, rb_method_definition_t *de
|
||||||
}
|
}
|
||||||
case VM_METHOD_TYPE_CFUNC:
|
case VM_METHOD_TYPE_CFUNC:
|
||||||
{
|
{
|
||||||
rb_method_cfunc_t *cfunc = (rb_method_cfunc_t *)opts;
|
const rb_method_cfunc_t *p = (const rb_method_cfunc_t *)opts;
|
||||||
setup_method_cfunc_struct(UNALIGNED_MEMBER_PTR(def, body.cfunc), cfunc->func, cfunc->argc);
|
rb_method_cfunc_t c = {
|
||||||
|
p->func,
|
||||||
|
call_cfunc_invoker_func(p->argc),
|
||||||
|
p->argc,
|
||||||
|
};
|
||||||
|
memcpy((void *)&def->body.cfunc, &c, sizeof c);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case VM_METHOD_TYPE_ATTRSET:
|
case VM_METHOD_TYPE_ATTRSET:
|
||||||
|
@ -261,7 +256,7 @@ rb_method_definition_set(const rb_method_entry_t *me, rb_method_definition_t *de
|
||||||
rb_control_frame_t *cfp;
|
rb_control_frame_t *cfp;
|
||||||
int line;
|
int line;
|
||||||
|
|
||||||
def->body.attr.id = (ID)(VALUE)opts;
|
memcpy((void *)&def->body.attr, &(rb_method_attr_t) { (ID)(VALUE)opts }, sizeof(rb_method_attr_t));
|
||||||
|
|
||||||
cfp = rb_vm_get_ruby_level_next_cfp(ec, ec->cfp);
|
cfp = rb_vm_get_ruby_level_next_cfp(ec, ec->cfp);
|
||||||
|
|
||||||
|
@ -275,14 +270,21 @@ rb_method_definition_set(const rb_method_entry_t *me, rb_method_definition_t *de
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case VM_METHOD_TYPE_BMETHOD:
|
case VM_METHOD_TYPE_BMETHOD:
|
||||||
RB_OBJ_WRITE(me, &def->body.bmethod.proc, (VALUE)opts);
|
memcpy((void *)&def->body.bmethod, &(rb_method_bmethod_t) { (VALUE)opts }, sizeof(rb_method_bmethod_t));
|
||||||
|
RB_OBJ_WRITTEN(me, &def->body.bmethod.proc, (VALUE)opts);
|
||||||
return;
|
return;
|
||||||
case VM_METHOD_TYPE_NOTIMPLEMENTED:
|
case VM_METHOD_TYPE_NOTIMPLEMENTED:
|
||||||
setup_method_cfunc_struct(UNALIGNED_MEMBER_PTR(def, body.cfunc), rb_f_notimplement, -1);
|
{
|
||||||
return;
|
rb_method_cfunc_t f = { rb_f_notimplement, call_cfunc_m1, -1, };
|
||||||
|
memcpy((void *)&def->body.cfunc, &f, sizeof f);
|
||||||
|
return;
|
||||||
|
}
|
||||||
case VM_METHOD_TYPE_OPTIMIZED:
|
case VM_METHOD_TYPE_OPTIMIZED:
|
||||||
def->body.optimize_type = (enum method_optimized_type)opts;
|
{
|
||||||
return;
|
enum method_optimized_type t = (enum method_optimized_type)opts;
|
||||||
|
memcpy((void *)&def->body.optimize_type, &t, sizeof t);
|
||||||
|
return;
|
||||||
|
}
|
||||||
case VM_METHOD_TYPE_REFINED:
|
case VM_METHOD_TYPE_REFINED:
|
||||||
{
|
{
|
||||||
const rb_method_refined_t *refined = (rb_method_refined_t *)opts;
|
const rb_method_refined_t *refined = (rb_method_refined_t *)opts;
|
||||||
|
@ -304,7 +306,7 @@ rb_method_definition_set(const rb_method_entry_t *me, rb_method_definition_t *de
|
||||||
static void
|
static void
|
||||||
method_definition_reset(const rb_method_entry_t *me)
|
method_definition_reset(const rb_method_entry_t *me)
|
||||||
{
|
{
|
||||||
rb_method_definition_t *def = me->def;
|
const rb_method_definition_t *def = me->def;
|
||||||
|
|
||||||
switch(def->type) {
|
switch(def->type) {
|
||||||
case VM_METHOD_TYPE_ISEQ:
|
case VM_METHOD_TYPE_ISEQ:
|
||||||
|
@ -337,14 +339,16 @@ method_definition_reset(const rb_method_entry_t *me)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MJIT_FUNC_EXPORTED rb_method_definition_t *
|
MJIT_FUNC_EXPORTED const rb_method_definition_t *
|
||||||
rb_method_definition_create(rb_method_type_t type, ID mid)
|
rb_method_definition_create(rb_method_type_t type, ID mid)
|
||||||
{
|
{
|
||||||
rb_method_definition_t *def;
|
rb_method_definition_t template = {
|
||||||
def = ZALLOC(rb_method_definition_t);
|
.type = type,
|
||||||
def->type = type;
|
.original_id = mid,
|
||||||
def->original_id = mid;
|
};
|
||||||
return def;
|
void *ptr = ALLOC(rb_method_definition_t);
|
||||||
|
memcpy(ptr, &template, sizeof template);
|
||||||
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static rb_method_definition_t *
|
static rb_method_definition_t *
|
||||||
|
@ -405,7 +409,7 @@ rb_method_entry_clone(const rb_method_entry_t *src_me)
|
||||||
MJIT_FUNC_EXPORTED const rb_callable_method_entry_t *
|
MJIT_FUNC_EXPORTED const rb_callable_method_entry_t *
|
||||||
rb_method_entry_complement_defined_class(const rb_method_entry_t *src_me, ID called_id, VALUE defined_class)
|
rb_method_entry_complement_defined_class(const rb_method_entry_t *src_me, ID called_id, VALUE defined_class)
|
||||||
{
|
{
|
||||||
rb_method_definition_t *def = src_me->def;
|
const rb_method_definition_t *def = src_me->def;
|
||||||
rb_method_entry_t *me;
|
rb_method_entry_t *me;
|
||||||
struct {
|
struct {
|
||||||
const struct rb_method_entry_struct *orig_me;
|
const struct rb_method_entry_struct *orig_me;
|
||||||
|
@ -423,13 +427,13 @@ rb_method_entry_complement_defined_class(const rb_method_entry_t *src_me, ID cal
|
||||||
def = NULL;
|
def = NULL;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
def = method_definition_addref_complement(def);
|
def = method_definition_addref_complement((rb_method_definition_t *)def);
|
||||||
}
|
}
|
||||||
me = rb_method_entry_alloc(called_id, src_me->owner, defined_class, def);
|
me = rb_method_entry_alloc(called_id, src_me->owner, defined_class, def);
|
||||||
METHOD_ENTRY_FLAGS_COPY(me, src_me);
|
METHOD_ENTRY_FLAGS_COPY(me, src_me);
|
||||||
if (!def) {
|
if (!def) {
|
||||||
def = rb_method_definition_create(VM_METHOD_TYPE_REFINED, called_id);
|
def = rb_method_definition_create(VM_METHOD_TYPE_REFINED, called_id);
|
||||||
rb_method_definition_set(me, def, &refined);
|
rb_method_definition_set(me, (rb_method_definition_t *)def, &refined);
|
||||||
}
|
}
|
||||||
|
|
||||||
VM_ASSERT(RB_TYPE_P(me->owner, T_MODULE));
|
VM_ASSERT(RB_TYPE_P(me->owner, T_MODULE));
|
||||||
|
@ -459,7 +463,7 @@ make_method_entry_refined(VALUE owner, rb_method_entry_t *me)
|
||||||
struct rb_method_entry_struct *orig_me;
|
struct rb_method_entry_struct *orig_me;
|
||||||
VALUE owner;
|
VALUE owner;
|
||||||
} refined;
|
} refined;
|
||||||
rb_method_definition_t *def;
|
const rb_method_definition_t *def;
|
||||||
|
|
||||||
rb_vm_check_redefinition_opt_method(me, me->owner);
|
rb_vm_check_redefinition_opt_method(me, me->owner);
|
||||||
|
|
||||||
|
@ -472,7 +476,7 @@ make_method_entry_refined(VALUE owner, rb_method_entry_t *me)
|
||||||
refined.owner = owner;
|
refined.owner = owner;
|
||||||
|
|
||||||
def = rb_method_definition_create(VM_METHOD_TYPE_REFINED, me->called_id);
|
def = rb_method_definition_create(VM_METHOD_TYPE_REFINED, me->called_id);
|
||||||
rb_method_definition_set(me, def, (void *)&refined);
|
rb_method_definition_set(me, (void *)def, (void *)&refined);
|
||||||
METHOD_ENTRY_VISI_SET(me, METHOD_VISI_PUBLIC);
|
METHOD_ENTRY_VISI_SET(me, METHOD_VISI_PUBLIC);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -515,7 +519,7 @@ check_override_opt_method(VALUE klass, VALUE arg)
|
||||||
*/
|
*/
|
||||||
static rb_method_entry_t *
|
static rb_method_entry_t *
|
||||||
rb_method_entry_make(VALUE klass, ID mid, VALUE defined_class, rb_method_visibility_t visi,
|
rb_method_entry_make(VALUE klass, ID mid, VALUE defined_class, rb_method_visibility_t visi,
|
||||||
rb_method_type_t type, rb_method_definition_t *def, ID original_id, void *opts)
|
rb_method_type_t type, const rb_method_definition_t *def, ID original_id, void *opts)
|
||||||
{
|
{
|
||||||
rb_method_entry_t *me;
|
rb_method_entry_t *me;
|
||||||
struct rb_id_table *mtbl;
|
struct rb_id_table *mtbl;
|
||||||
|
@ -556,7 +560,7 @@ rb_method_entry_make(VALUE klass, ID mid, VALUE defined_class, rb_method_visibil
|
||||||
/* check re-definition */
|
/* check re-definition */
|
||||||
if (rb_id_table_lookup(mtbl, mid, &data)) {
|
if (rb_id_table_lookup(mtbl, mid, &data)) {
|
||||||
rb_method_entry_t *old_me = (rb_method_entry_t *)data;
|
rb_method_entry_t *old_me = (rb_method_entry_t *)data;
|
||||||
rb_method_definition_t *old_def = old_me->def;
|
const rb_method_definition_t *old_def = old_me->def;
|
||||||
|
|
||||||
if (rb_method_definition_eq(old_def, def)) return old_me;
|
if (rb_method_definition_eq(old_def, def)) return old_me;
|
||||||
rb_vm_check_redefinition_opt_method(old_me, klass);
|
rb_vm_check_redefinition_opt_method(old_me, klass);
|
||||||
|
@ -595,7 +599,7 @@ rb_method_entry_make(VALUE klass, ID mid, VALUE defined_class, rb_method_visibil
|
||||||
/* create method entry */
|
/* create method entry */
|
||||||
me = rb_method_entry_create(mid, defined_class, visi, NULL);
|
me = rb_method_entry_create(mid, defined_class, visi, NULL);
|
||||||
if (def == NULL) def = rb_method_definition_create(type, original_id);
|
if (def == NULL) def = rb_method_definition_create(type, original_id);
|
||||||
rb_method_definition_set(me, def, opts);
|
rb_method_definition_set(me, (void *)def, opts);
|
||||||
|
|
||||||
rb_clear_method_cache_by_class(klass);
|
rb_clear_method_cache_by_class(klass);
|
||||||
|
|
||||||
|
@ -665,13 +669,7 @@ rb_add_method(VALUE klass, ID mid, rb_method_type_t type, void *opts, rb_method_
|
||||||
MJIT_FUNC_EXPORTED void
|
MJIT_FUNC_EXPORTED void
|
||||||
rb_add_method_iseq(VALUE klass, ID mid, const rb_iseq_t *iseq, rb_cref_t *cref, rb_method_visibility_t visi)
|
rb_add_method_iseq(VALUE klass, ID mid, const rb_iseq_t *iseq, rb_cref_t *cref, rb_method_visibility_t visi)
|
||||||
{
|
{
|
||||||
struct { /* should be same fields with rb_method_iseq_struct */
|
rb_method_iseq_t iseq_body = { iseq, cref };
|
||||||
const rb_iseq_t *iseqptr;
|
|
||||||
rb_cref_t *cref;
|
|
||||||
} iseq_body;
|
|
||||||
|
|
||||||
iseq_body.iseqptr = iseq;
|
|
||||||
iseq_body.cref = cref;
|
|
||||||
rb_add_method(klass, mid, VM_METHOD_TYPE_ISEQ, &iseq_body, visi);
|
rb_add_method(klass, mid, VM_METHOD_TYPE_ISEQ, &iseq_body, visi);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue