зеркало из https://github.com/github/ruby.git
Reverting all commits from r67479 to r67496 because of CI failures
Because hard to specify commits related to r67479 only. So please commit again. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67499 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
0cc2ffbc1b
Коммит
25c1fd3b90
9
NEWS
9
NEWS
|
@ -98,15 +98,6 @@ JIT::
|
|||
|
||||
* Default value of +--jit-min-calls+ is changed from 5 to 10,000
|
||||
|
||||
GC::
|
||||
|
||||
* New `GC.compact` method for compacting the heap.
|
||||
This function compacts live objects in the heap so that fewer pages may
|
||||
be used, and the heap may be more CoW friendly. [Feature #15626]
|
||||
|
||||
Details on the algorithm and caveats can be found here:
|
||||
https://bugs.ruby-lang.org/issues/15626
|
||||
|
||||
=== Miscellaneous changes
|
||||
|
||||
* Require compilers to support C99 [Misc #15347]
|
||||
|
|
2
array.c
2
array.c
|
@ -1326,7 +1326,7 @@ rb_ary_shift_m(int argc, VALUE *argv, VALUE ary)
|
|||
MJIT_FUNC_EXPORTED VALUE
|
||||
rb_ary_behead(VALUE ary, long n)
|
||||
{
|
||||
if (n<=0) return ary;
|
||||
if(n<=0) return ary;
|
||||
|
||||
rb_ary_modify_check(ary);
|
||||
if (ARY_SHARED_P(ary)) {
|
||||
|
|
8
class.c
8
class.c
|
@ -539,7 +539,6 @@ boot_defclass(const char *name, VALUE super)
|
|||
|
||||
rb_name_class(obj, id);
|
||||
rb_const_set((rb_cObject ? rb_cObject : obj), id, obj);
|
||||
rb_vm_add_root_module(id, obj);
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
@ -731,9 +730,6 @@ rb_define_class_id_under(VALUE outer, ID id, VALUE super)
|
|||
" (%"PRIsVALUE" is given but was %"PRIsVALUE")",
|
||||
outer, rb_id2str(id), RCLASS_SUPER(klass), super);
|
||||
}
|
||||
/* Class may have been defined in Ruby and not pin-rooted */
|
||||
rb_vm_add_root_module(id, klass);
|
||||
|
||||
return klass;
|
||||
}
|
||||
if (!super) {
|
||||
|
@ -744,7 +740,6 @@ rb_define_class_id_under(VALUE outer, ID id, VALUE super)
|
|||
rb_set_class_path_string(klass, outer, rb_id2str(id));
|
||||
rb_const_set(outer, id, klass);
|
||||
rb_class_inherited(super, klass);
|
||||
rb_vm_add_root_module(id, klass);
|
||||
rb_gc_register_mark_object(klass);
|
||||
|
||||
return klass;
|
||||
|
@ -782,13 +777,10 @@ rb_define_module(const char *name)
|
|||
rb_raise(rb_eTypeError, "%s is not a module (%"PRIsVALUE")",
|
||||
name, rb_obj_class(module));
|
||||
}
|
||||
/* Module may have been defined in Ruby and not pin-rooted */
|
||||
rb_vm_add_root_module(id, module);
|
||||
return module;
|
||||
}
|
||||
module = rb_define_module_id(id);
|
||||
rb_vm_add_root_module(id, module);
|
||||
rb_gc_register_mark_object(module);
|
||||
rb_const_set(rb_cObject, id, module);
|
||||
|
||||
return module;
|
||||
|
|
|
@ -574,7 +574,6 @@ static int
|
|||
iseq_add_mark_object_compile_time(const rb_iseq_t *iseq, VALUE v)
|
||||
{
|
||||
if (!SPECIAL_CONST_P(v)) {
|
||||
rb_gc_writebarrier((VALUE)iseq, v);
|
||||
rb_ary_push(ISEQ_COMPILE_DATA(iseq)->mark_ary, v);
|
||||
}
|
||||
return COMPILE_OK;
|
||||
|
@ -584,7 +583,6 @@ static inline VALUE
|
|||
freeze_literal(rb_iseq_t *iseq, VALUE lit)
|
||||
{
|
||||
lit = rb_fstring(lit);
|
||||
rb_gc_writebarrier((VALUE)iseq, lit);
|
||||
rb_ary_push(ISEQ_COMPILE_DATA(iseq)->mark_ary, lit);
|
||||
return lit;
|
||||
}
|
||||
|
@ -1366,10 +1364,12 @@ iseq_set_exception_local_table(rb_iseq_t *iseq)
|
|||
/* TODO: every id table is same -> share it.
|
||||
* Current problem is iseq_free().
|
||||
*/
|
||||
ID id_dollar_bang;
|
||||
ID *ids = (ID *)ALLOC_N(ID, 1);
|
||||
|
||||
CONST_ID(id_dollar_bang, "#$!");
|
||||
iseq->body->local_table_size = 1;
|
||||
ids[0] = idERROR_INFO;
|
||||
ids[0] = id_dollar_bang;
|
||||
iseq->body->local_table = ids;
|
||||
return COMPILE_OK;
|
||||
}
|
||||
|
|
|
@ -31,8 +31,8 @@ typedef enum {
|
|||
typedef struct rb_const_entry_struct {
|
||||
rb_const_flag_t flag;
|
||||
int line;
|
||||
VALUE value; /* should be mark */
|
||||
VALUE file; /* should be mark */
|
||||
const VALUE value; /* should be mark */
|
||||
const VALUE file; /* should be mark */
|
||||
} rb_const_entry_t;
|
||||
|
||||
VALUE rb_mod_private_constant(int argc, const VALUE *argv, VALUE obj);
|
||||
|
|
|
@ -70,7 +70,6 @@ firstline, predefined = __LINE__+1, %[\
|
|||
|
||||
$_ LASTLINE
|
||||
$~ BACKREF
|
||||
$! ERROR_INFO
|
||||
]
|
||||
|
||||
# VM ID OP Parser Token
|
||||
|
|
|
@ -1344,8 +1344,6 @@ void Init_generator(void)
|
|||
|
||||
eGeneratorError = rb_path2class("JSON::GeneratorError");
|
||||
eNestingError = rb_path2class("JSON::NestingError");
|
||||
rb_gc_register_mark_object(eGeneratorError);
|
||||
rb_gc_register_mark_object(eNestingError);
|
||||
|
||||
cState = rb_define_class_under(mGenerator, "State", rb_cObject);
|
||||
rb_define_alloc_func(cState, cState_s_allocate);
|
||||
|
|
|
@ -2091,8 +2091,6 @@ void Init_parser(void)
|
|||
cParser = rb_define_class_under(mExt, "Parser", rb_cObject);
|
||||
eParserError = rb_path2class("JSON::ParserError");
|
||||
eNestingError = rb_path2class("JSON::NestingError");
|
||||
rb_gc_register_mark_object(eParserError);
|
||||
rb_gc_register_mark_object(eNestingError);
|
||||
rb_define_alloc_func(cParser, cJSON_parser_s_allocate);
|
||||
rb_define_method(cParser, "initialize", cParser_initialize, -1);
|
||||
rb_define_method(cParser, "parse", cParser_parse, 0);
|
||||
|
|
|
@ -187,7 +187,6 @@ ossl_bn_initialize(int argc, VALUE *argv, VALUE self)
|
|||
BIGNUM *bn;
|
||||
VALUE str, bs;
|
||||
int base = 10;
|
||||
char *ptr;
|
||||
|
||||
if (rb_scan_args(argc, argv, "11", &str, &bs) == 2) {
|
||||
base = NUM2INT(bs);
|
||||
|
@ -214,14 +213,12 @@ ossl_bn_initialize(int argc, VALUE *argv, VALUE self)
|
|||
GetBN(self, bn);
|
||||
switch (base) {
|
||||
case 0:
|
||||
ptr = StringValuePtr(str);
|
||||
if (!BN_mpi2bn((unsigned char *)ptr, RSTRING_LENINT(str), bn)) {
|
||||
if (!BN_mpi2bn((unsigned char *)StringValuePtr(str), RSTRING_LENINT(str), bn)) {
|
||||
ossl_raise(eBNError, NULL);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
ptr = StringValuePtr(str);
|
||||
if (!BN_bin2bn((unsigned char *)ptr, RSTRING_LENINT(str), bn)) {
|
||||
if (!BN_bin2bn((unsigned char *)StringValuePtr(str), RSTRING_LENINT(str), bn)) {
|
||||
ossl_raise(eBNError, NULL);
|
||||
}
|
||||
break;
|
||||
|
|
1306
gc.c
1306
gc.c
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
4
gc.h
4
gc.h
|
@ -57,10 +57,6 @@ rb_gc_debug_body(const char *mode, const char *msg, int st, void *ptr)
|
|||
#define RUBY_GC_INFO if(0)printf
|
||||
#endif
|
||||
|
||||
#define RUBY_MARK_NO_PIN_UNLESS_NULL(ptr) do { \
|
||||
VALUE markobj = (ptr); \
|
||||
if (RTEST(markobj)) {rb_gc_mark_no_pin(markobj);} \
|
||||
} while (0)
|
||||
#define RUBY_MARK_UNLESS_NULL(ptr) do { \
|
||||
VALUE markobj = (ptr); \
|
||||
if (RTEST(markobj)) {rb_gc_mark(markobj);} \
|
||||
|
|
40
hash.c
40
hash.c
|
@ -781,7 +781,7 @@ ar_add_direct_with_hash(VALUE hash, st_data_t key, st_data_t val, st_hash_t hash
|
|||
}
|
||||
|
||||
static int
|
||||
ar_general_foreach(VALUE hash, int (*func)(ANYARGS), st_update_callback_func *replace, st_data_t arg)
|
||||
ar_foreach(VALUE hash, int (*func)(ANYARGS), st_data_t arg)
|
||||
{
|
||||
if (RHASH_AR_TABLE_SIZE(hash) > 0) {
|
||||
unsigned i, bound = RHASH_AR_TABLE_BOUND(hash);
|
||||
|
@ -799,20 +799,6 @@ ar_general_foreach(VALUE hash, int (*func)(ANYARGS), st_update_callback_func *re
|
|||
case ST_CHECK:
|
||||
case ST_STOP:
|
||||
return 0;
|
||||
case ST_REPLACE:
|
||||
if (replace) {
|
||||
VALUE key;
|
||||
VALUE value;
|
||||
|
||||
key = cur_entry->key;
|
||||
value = cur_entry->record;
|
||||
retval = (*replace)(&key, &value, arg, TRUE);
|
||||
|
||||
ar_table_entry *entry = RHASH_AR_TABLE_REF(hash, i);
|
||||
entry->key = key;
|
||||
entry->record = value;
|
||||
}
|
||||
break;
|
||||
case ST_DELETE:
|
||||
ar_clear_entry(RHASH_AR_TABLE_REF(hash, i));
|
||||
RHASH_AR_TABLE_SIZE_DEC(hash);
|
||||
|
@ -823,18 +809,6 @@ ar_general_foreach(VALUE hash, int (*func)(ANYARGS), st_update_callback_func *re
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
ar_foreach_with_replace(VALUE hash, int (*func)(ANYARGS), st_update_callback_func *replace, st_data_t arg)
|
||||
{
|
||||
return ar_general_foreach(hash, func, replace, arg);
|
||||
}
|
||||
|
||||
static int
|
||||
ar_foreach(VALUE hash, int (*func)(ANYARGS), st_data_t arg)
|
||||
{
|
||||
return ar_general_foreach(hash, func, NULL, arg);
|
||||
}
|
||||
|
||||
static int
|
||||
ar_foreach_check(VALUE hash, int (*func)(ANYARGS), st_data_t arg,
|
||||
st_data_t never)
|
||||
|
@ -871,7 +845,6 @@ ar_foreach_check(VALUE hash, int (*func)(ANYARGS), st_data_t arg,
|
|||
case ST_CONTINUE:
|
||||
break;
|
||||
case ST_STOP:
|
||||
case ST_REPLACE:
|
||||
return 0;
|
||||
case ST_DELETE: {
|
||||
if (!ar_empty_entry(cur_entry)) {
|
||||
|
@ -1284,17 +1257,6 @@ rb_hash_stlike_foreach(VALUE hash, int (*func)(ANYARGS), st_data_t arg)
|
|||
}
|
||||
}
|
||||
|
||||
int
|
||||
rb_hash_stlike_foreach_with_replace(VALUE hash, int (*func)(ANYARGS), st_update_callback_func *replace, st_data_t arg)
|
||||
{
|
||||
if (RHASH_AR_TABLE_P(hash)) {
|
||||
return ar_foreach_with_replace(hash, func, replace, arg);
|
||||
}
|
||||
else {
|
||||
return st_foreach_with_replace(RHASH_ST_TABLE(hash), func, replace, arg);
|
||||
}
|
||||
}
|
||||
|
||||
static VALUE
|
||||
hash_foreach_call(VALUE arg)
|
||||
{
|
||||
|
|
22
id_table.c
22
id_table.c
|
@ -266,28 +266,6 @@ rb_id_table_delete(struct rb_id_table *tbl, ID id)
|
|||
return hash_delete_index(tbl, index);
|
||||
}
|
||||
|
||||
void
|
||||
rb_id_table_foreach_with_replace(struct rb_id_table *tbl, rb_id_table_foreach_func_t *func, rb_id_table_update_callback_func_t *replace, void *data)
|
||||
{
|
||||
int i, capa = tbl->capa;
|
||||
|
||||
for (i=0; i<capa; i++) {
|
||||
if (ITEM_KEY_ISSET(tbl, i)) {
|
||||
const id_key_t key = ITEM_GET_KEY(tbl, i);
|
||||
enum rb_id_table_iterator_result ret = (*func)(Qundef, tbl->items[i].val, data);
|
||||
assert(key != 0);
|
||||
|
||||
if (ret == ID_TABLE_REPLACE) {
|
||||
VALUE val = tbl->items[i].val;
|
||||
ret = (*replace)(NULL, &val, data, TRUE);
|
||||
tbl->items[i].val = val;
|
||||
}
|
||||
else if (ret == ID_TABLE_STOP)
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
rb_id_table_foreach(struct rb_id_table *tbl, rb_id_table_foreach_func_t *func, void *data)
|
||||
{
|
||||
|
|
|
@ -9,7 +9,6 @@ enum rb_id_table_iterator_result {
|
|||
ID_TABLE_CONTINUE = ST_CONTINUE,
|
||||
ID_TABLE_STOP = ST_STOP,
|
||||
ID_TABLE_DELETE = ST_DELETE,
|
||||
ID_TABLE_REPLACE = ST_REPLACE,
|
||||
ID_TABLE_ITERATOR_RESULT_END
|
||||
};
|
||||
|
||||
|
@ -24,11 +23,9 @@ int rb_id_table_insert(struct rb_id_table *tbl, ID id, VALUE val);
|
|||
int rb_id_table_lookup(struct rb_id_table *tbl, ID id, VALUE *valp);
|
||||
int rb_id_table_delete(struct rb_id_table *tbl, ID id);
|
||||
|
||||
typedef enum rb_id_table_iterator_result rb_id_table_update_callback_func_t(ID *id, VALUE *val, void *data, int existing);
|
||||
typedef enum rb_id_table_iterator_result rb_id_table_foreach_func_t(ID id, VALUE val, void *data);
|
||||
typedef enum rb_id_table_iterator_result rb_id_table_foreach_values_func_t(VALUE val, void *data);
|
||||
void rb_id_table_foreach(struct rb_id_table *tbl, rb_id_table_foreach_func_t *func, void *data);
|
||||
void rb_id_table_foreach_with_replace(struct rb_id_table *tbl, rb_id_table_foreach_func_t *func, rb_id_table_update_callback_func_t *replace, void *data);
|
||||
void rb_id_table_foreach_values(struct rb_id_table *tbl, rb_id_table_foreach_values_func_t *func, void *data);
|
||||
|
||||
#endif /* RUBY_ID_TABLE_H */
|
||||
|
|
|
@ -507,15 +507,10 @@ COLDFUNC NORETURN(void rb_memerror(void));
|
|||
PUREFUNC(int rb_during_gc(void));
|
||||
void rb_gc_mark_locations(const VALUE*, const VALUE*);
|
||||
void rb_mark_tbl(struct st_table*);
|
||||
void rb_mark_tbl_no_pin(struct st_table*);
|
||||
void rb_gc_update_tbl_refs(st_table *ptr);
|
||||
void rb_mark_set(struct st_table*);
|
||||
void rb_mark_hash(struct st_table*);
|
||||
void rb_update_st_references(struct st_table *ht);
|
||||
void rb_gc_mark_maybe(VALUE);
|
||||
void rb_gc_mark(VALUE);
|
||||
void rb_gc_mark_no_pin(VALUE);
|
||||
VALUE rb_gc_new_location(VALUE);
|
||||
void rb_gc_force_recycle(VALUE);
|
||||
void rb_gc(void);
|
||||
void rb_gc_copy_finalizer(VALUE,VALUE);
|
||||
|
|
|
@ -512,7 +512,6 @@ enum ruby_value_type {
|
|||
RUBY_T_NODE = 0x1b,
|
||||
RUBY_T_ICLASS = 0x1c,
|
||||
RUBY_T_ZOMBIE = 0x1d,
|
||||
RUBY_T_MOVED = 0x1e,
|
||||
|
||||
RUBY_T_MASK = 0x1f
|
||||
};
|
||||
|
@ -543,7 +542,6 @@ enum ruby_value_type {
|
|||
#define T_UNDEF RUBY_T_UNDEF
|
||||
#define T_NODE RUBY_T_NODE
|
||||
#define T_ZOMBIE RUBY_T_ZOMBIE
|
||||
#define T_MOVED RUBY_T_MOVED
|
||||
#define T_MASK RUBY_T_MASK
|
||||
|
||||
#define RB_BUILTIN_TYPE(x) (int)(((struct RBasic*)(x))->flags & RUBY_T_MASK)
|
||||
|
@ -885,7 +883,7 @@ enum ruby_fl_type {
|
|||
|
||||
struct RUBY_ALIGNAS(SIZEOF_VALUE) RBasic {
|
||||
VALUE flags;
|
||||
VALUE klass;
|
||||
const VALUE klass;
|
||||
};
|
||||
|
||||
VALUE rb_obj_hide(VALUE obj);
|
||||
|
@ -1107,7 +1105,7 @@ struct RArray {
|
|||
struct RRegexp {
|
||||
struct RBasic basic;
|
||||
struct re_pattern_buffer *ptr;
|
||||
VALUE src;
|
||||
const VALUE src;
|
||||
unsigned long usecnt;
|
||||
};
|
||||
#define RREGEXP_PTR(r) (RREGEXP(r)->ptr)
|
||||
|
@ -1146,8 +1144,7 @@ struct rb_data_type_struct {
|
|||
void (*dmark)(void*);
|
||||
void (*dfree)(void*);
|
||||
size_t (*dsize)(const void *);
|
||||
void (*dcompact)(void*);
|
||||
void *reserved[1]; /* For future extension.
|
||||
void *reserved[2]; /* For future extension.
|
||||
This array *must* be filled with ZERO. */
|
||||
} function;
|
||||
const rb_data_type_t *parent;
|
||||
|
@ -1258,7 +1255,6 @@ int rb_big_sign(VALUE);
|
|||
#define RBIGNUM_NEGATIVE_P(b) (RBIGNUM_SIGN(b)==0)
|
||||
|
||||
#define R_CAST(st) (struct st*)
|
||||
#define RMOVED(obj) (R_CAST(RMoved)(obj))
|
||||
#define RBASIC(obj) (R_CAST(RBasic)(obj))
|
||||
#define ROBJECT(obj) (R_CAST(RObject)(obj))
|
||||
#define RCLASS(obj) (R_CAST(RClass)(obj))
|
||||
|
|
|
@ -96,7 +96,7 @@ struct st_table {
|
|||
|
||||
#define st_is_member(table,key) st_lookup((table),(key),(st_data_t *)0)
|
||||
|
||||
enum st_retval {ST_CONTINUE, ST_STOP, ST_DELETE, ST_CHECK, ST_REPLACE};
|
||||
enum st_retval {ST_CONTINUE, ST_STOP, ST_DELETE, ST_CHECK};
|
||||
|
||||
st_table *st_init_table(const struct st_hash_type *);
|
||||
st_table *st_init_table_with_size(const struct st_hash_type *, st_index_t);
|
||||
|
@ -118,7 +118,6 @@ typedef int st_update_callback_func(st_data_t *key, st_data_t *value, st_data_t
|
|||
* results of hash() are same and compare() returns 0, otherwise the
|
||||
* behavior is undefined */
|
||||
int st_update(st_table *table, st_data_t key, st_update_callback_func *func, st_data_t arg);
|
||||
int st_foreach_with_replace(st_table *tab, int (*func)(ANYARGS), st_update_callback_func *replace, st_data_t arg);
|
||||
int st_foreach(st_table *, int (*)(ANYARGS), st_data_t);
|
||||
int st_foreach_check(st_table *, int (*)(ANYARGS), st_data_t, st_data_t);
|
||||
st_index_t st_keys(st_table *table, st_data_t *keys, st_index_t size);
|
||||
|
|
42
internal.h
42
internal.h
|
@ -731,8 +731,8 @@ struct RBignum {
|
|||
|
||||
struct RRational {
|
||||
struct RBasic basic;
|
||||
VALUE num;
|
||||
VALUE den;
|
||||
const VALUE num;
|
||||
const VALUE den;
|
||||
};
|
||||
|
||||
#define RRATIONAL(obj) (R_CAST(RRational)(obj))
|
||||
|
@ -748,8 +748,8 @@ struct RFloat {
|
|||
|
||||
struct RComplex {
|
||||
struct RBasic basic;
|
||||
VALUE real;
|
||||
VALUE imag;
|
||||
const VALUE real;
|
||||
const VALUE imag;
|
||||
};
|
||||
|
||||
#define RCOMPLEX(obj) (R_CAST(RComplex)(obj))
|
||||
|
@ -816,8 +816,8 @@ struct RHash {
|
|||
st_table *st;
|
||||
struct ar_table_struct *ar; /* possibly 0 */
|
||||
} as;
|
||||
int iter_lev;
|
||||
VALUE ifnone;
|
||||
const int iter_lev;
|
||||
const VALUE ifnone;
|
||||
};
|
||||
|
||||
#ifdef RHASH_ITER_LEV
|
||||
|
@ -830,11 +830,6 @@ struct RHash {
|
|||
# define RHASH_SIZE(h) (RHASH_AR_TABLE_P(h) ? RHASH_AR_TABLE_SIZE_RAW(h) : RHASH_ST_SIZE(h))
|
||||
#endif /* #ifdef RHASH_ITER_LEV */
|
||||
|
||||
struct RMoved {
|
||||
VALUE flags;
|
||||
VALUE destination;
|
||||
};
|
||||
|
||||
/* missing/setproctitle.c */
|
||||
#ifndef HAVE_SETPROCTITLE
|
||||
extern void ruby_init_setproctitle(int argc, char *argv[]);
|
||||
|
@ -952,7 +947,7 @@ struct rb_classext_struct {
|
|||
*/
|
||||
rb_subclass_entry_t **module_subclasses;
|
||||
rb_serial_t class_serial;
|
||||
VALUE origin_;
|
||||
const VALUE origin_;
|
||||
VALUE refined_class;
|
||||
rb_alloc_func_t allocator;
|
||||
};
|
||||
|
@ -1070,10 +1065,10 @@ imemo_type_p(VALUE imemo, enum imemo_type imemo_type)
|
|||
/*! SVAR (Special VARiable) */
|
||||
struct vm_svar {
|
||||
VALUE flags;
|
||||
VALUE cref_or_me; /*!< class reference or rb_method_entry_t */
|
||||
VALUE lastline;
|
||||
VALUE backref;
|
||||
VALUE others;
|
||||
const VALUE cref_or_me; /*!< class reference or rb_method_entry_t */
|
||||
const VALUE lastline;
|
||||
const VALUE backref;
|
||||
const VALUE others;
|
||||
};
|
||||
|
||||
|
||||
|
@ -1083,7 +1078,7 @@ struct vm_svar {
|
|||
struct vm_throw_data {
|
||||
VALUE flags;
|
||||
VALUE reserved;
|
||||
VALUE throw_obj;
|
||||
const VALUE throw_obj;
|
||||
const struct rb_control_frame_struct *catch_frame;
|
||||
VALUE throw_state;
|
||||
};
|
||||
|
@ -1106,7 +1101,7 @@ struct vm_ifunc {
|
|||
VALUE flags;
|
||||
VALUE reserved;
|
||||
VALUE (*func)(ANYARGS);
|
||||
void *data;
|
||||
const void *data;
|
||||
struct vm_ifunc_argc argc;
|
||||
};
|
||||
|
||||
|
@ -1163,12 +1158,12 @@ void rb_strterm_mark(VALUE obj);
|
|||
struct MEMO {
|
||||
VALUE flags;
|
||||
VALUE reserved;
|
||||
VALUE v1;
|
||||
VALUE v2;
|
||||
const VALUE v1;
|
||||
const VALUE v2;
|
||||
union {
|
||||
long cnt;
|
||||
long state;
|
||||
VALUE value;
|
||||
const VALUE value;
|
||||
VALUE (*func)(ANYARGS);
|
||||
} u3;
|
||||
};
|
||||
|
@ -1571,7 +1566,6 @@ void rb_hash_bulk_insert(long, const VALUE *, VALUE);
|
|||
int rb_hash_stlike_lookup(VALUE hash, st_data_t key, st_data_t *pval);
|
||||
int rb_hash_stlike_delete(VALUE hash, st_data_t *pkey, st_data_t *pval);
|
||||
int rb_hash_stlike_foreach(VALUE hash, int (*func)(ANYARGS), st_data_t arg);
|
||||
int rb_hash_stlike_foreach_with_replace(VALUE hash, int (*func)(ANYARGS), st_update_callback_func *replace, st_data_t arg);
|
||||
int rb_hash_stlike_update(VALUE hash, st_data_t key, st_update_callback_func func, st_data_t arg);
|
||||
|
||||
/* inits.c */
|
||||
|
@ -2336,7 +2330,6 @@ extern unsigned long ruby_scan_digits(const char *str, ssize_t len, int base, si
|
|||
|
||||
/* variable.c (export) */
|
||||
void rb_mark_generic_ivar(VALUE);
|
||||
void rb_mv_generic_ivar(VALUE src, VALUE dst);
|
||||
VALUE rb_const_missing(VALUE klass, VALUE name);
|
||||
int rb_class_ivar_set(VALUE klass, ID vid, VALUE value);
|
||||
st_table *rb_st_copy(VALUE obj, struct st_table *orig_tbl);
|
||||
|
@ -2348,10 +2341,9 @@ VALUE rb_wb_unprotected_newobj_of(VALUE, VALUE);
|
|||
size_t rb_obj_memsize_of(VALUE);
|
||||
void rb_gc_verify_internal_consistency(void);
|
||||
|
||||
#define RB_OBJ_GC_FLAGS_MAX 6
|
||||
#define RB_OBJ_GC_FLAGS_MAX 5
|
||||
size_t rb_obj_gc_flags(VALUE, ID[], size_t);
|
||||
void rb_gc_mark_values(long n, const VALUE *values);
|
||||
void rb_gc_mark_stack_values(long n, const VALUE *values);
|
||||
|
||||
#if IMEMO_DEBUG
|
||||
VALUE rb_imemo_new_debug(enum imemo_type type, VALUE v1, VALUE v2, VALUE v3, VALUE v0, const char *file, int line);
|
||||
|
|
3
io.c
3
io.c
|
@ -10996,8 +10996,7 @@ nogvl_fcopyfile(struct copy_stream_struct *stp)
|
|||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
switch (errno) {
|
||||
case ENOTSUP:
|
||||
case EPERM:
|
||||
|
|
102
iseq.c
102
iseq.c
|
@ -136,11 +136,11 @@ rb_vm_insn_null_translator(const void *addr)
|
|||
return (VALUE)addr;
|
||||
}
|
||||
|
||||
typedef VALUE iseq_value_itr_t(void *ctx, VALUE obj);
|
||||
typedef void iseq_value_itr_t(void *ctx, VALUE obj);
|
||||
typedef VALUE rb_vm_insns_translator_t(const void *addr);
|
||||
|
||||
static int
|
||||
iseq_extract_values(VALUE *code, size_t pos, iseq_value_itr_t * func, void *data, rb_vm_insns_translator_t * translator)
|
||||
iseq_extract_values(const VALUE *code, size_t pos, iseq_value_itr_t * func, void *data, rb_vm_insns_translator_t * translator)
|
||||
{
|
||||
VALUE insn = translator((void *)code[pos]);
|
||||
int len = insn_len(insn);
|
||||
|
@ -156,10 +156,7 @@ iseq_extract_values(VALUE *code, size_t pos, iseq_value_itr_t * func, void *data
|
|||
{
|
||||
VALUE op = code[pos + op_no + 1];
|
||||
if (!SPECIAL_CONST_P(op)) {
|
||||
VALUE newop = func(data, op);
|
||||
if (newop != op) {
|
||||
code[pos + op_no + 1] = newop;
|
||||
}
|
||||
func(data, op);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -167,10 +164,7 @@ iseq_extract_values(VALUE *code, size_t pos, iseq_value_itr_t * func, void *data
|
|||
{
|
||||
union iseq_inline_storage_entry *const is = (union iseq_inline_storage_entry *)code[pos + op_no + 1];
|
||||
if (is->once.value) {
|
||||
VALUE nv = func(data, is->once.value);
|
||||
if (is->once.value != nv) {
|
||||
is->once.value = nv;
|
||||
}
|
||||
func(data, is->once.value);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -186,7 +180,7 @@ static void
|
|||
rb_iseq_each_value(const rb_iseq_t *iseq, iseq_value_itr_t * func, void *data)
|
||||
{
|
||||
unsigned int size;
|
||||
VALUE *code;
|
||||
const VALUE *code;
|
||||
size_t n;
|
||||
rb_vm_insns_translator_t * translator;
|
||||
const struct rb_iseq_constant_body *const body = iseq->body;
|
||||
|
@ -210,65 +204,10 @@ rb_iseq_each_value(const rb_iseq_t *iseq, iseq_value_itr_t * func, void *data)
|
|||
}
|
||||
}
|
||||
|
||||
static VALUE
|
||||
update_each_insn_value(void *ctx, VALUE obj)
|
||||
{
|
||||
return rb_gc_new_location(obj);
|
||||
}
|
||||
|
||||
void
|
||||
rb_iseq_update_references(rb_iseq_t *iseq)
|
||||
{
|
||||
if (iseq->body) {
|
||||
struct rb_iseq_constant_body *body = iseq->body;
|
||||
|
||||
body->variable.coverage = rb_gc_new_location(body->variable.coverage);
|
||||
body->variable.pc2branchindex = rb_gc_new_location(body->variable.pc2branchindex);
|
||||
body->location.label = rb_gc_new_location(body->location.label);
|
||||
body->location.base_label = rb_gc_new_location(body->location.base_label);
|
||||
body->location.pathobj = rb_gc_new_location(body->location.pathobj);
|
||||
if (body->local_iseq) {
|
||||
body->local_iseq = (struct rb_iseq_struct *)rb_gc_new_location((VALUE)body->local_iseq);
|
||||
}
|
||||
if (body->parent_iseq) {
|
||||
body->parent_iseq = (struct rb_iseq_struct *)rb_gc_new_location((VALUE)body->parent_iseq);
|
||||
}
|
||||
if (FL_TEST(iseq, ISEQ_MARKABLE_ISEQ)) {
|
||||
rb_iseq_each_value(iseq, update_each_insn_value, NULL);
|
||||
}
|
||||
|
||||
if (body->param.flags.has_kw && ISEQ_COMPILE_DATA(iseq) == NULL) {
|
||||
int i, j;
|
||||
|
||||
i = body->param.keyword->required_num;
|
||||
|
||||
for (j = 0; i < body->param.keyword->num; i++, j++) {
|
||||
VALUE obj = body->param.keyword->default_values[j];
|
||||
if (obj != Qundef) {
|
||||
body->param.keyword->default_values[j] = rb_gc_new_location(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (body->catch_table) {
|
||||
struct iseq_catch_table *table = body->catch_table;
|
||||
unsigned int i;
|
||||
for(i = 0; i < table->size; i++) {
|
||||
struct iseq_catch_table_entry *entry;
|
||||
entry = &table->entries[i];
|
||||
if (entry->iseq) {
|
||||
entry->iseq = (rb_iseq_t *)rb_gc_new_location((VALUE)entry->iseq);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static VALUE
|
||||
static void
|
||||
each_insn_value(void *ctx, VALUE obj)
|
||||
{
|
||||
rb_gc_mark_no_pin(obj);
|
||||
return obj;
|
||||
rb_gc_mark(obj);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -285,12 +224,12 @@ rb_iseq_mark(const rb_iseq_t *iseq)
|
|||
rb_iseq_each_value(iseq, each_insn_value, NULL);
|
||||
}
|
||||
|
||||
rb_gc_mark_no_pin(body->variable.coverage);
|
||||
rb_gc_mark_no_pin(body->variable.pc2branchindex);
|
||||
rb_gc_mark_no_pin(body->location.label);
|
||||
rb_gc_mark_no_pin(body->location.base_label);
|
||||
rb_gc_mark_no_pin(body->location.pathobj);
|
||||
RUBY_MARK_NO_PIN_UNLESS_NULL((VALUE)body->parent_iseq);
|
||||
rb_gc_mark(body->variable.coverage);
|
||||
rb_gc_mark(body->variable.pc2branchindex);
|
||||
rb_gc_mark(body->location.label);
|
||||
rb_gc_mark(body->location.base_label);
|
||||
rb_gc_mark(body->location.pathobj);
|
||||
RUBY_MARK_UNLESS_NULL((VALUE)body->parent_iseq);
|
||||
|
||||
if (body->param.flags.has_kw && ISEQ_COMPILE_DATA(iseq) == NULL) {
|
||||
const struct rb_iseq_param_keyword *const keyword = body->param.keyword;
|
||||
|
@ -313,7 +252,7 @@ rb_iseq_mark(const rb_iseq_t *iseq)
|
|||
const struct iseq_catch_table_entry *entry;
|
||||
entry = &table->entries[i];
|
||||
if (entry->iseq) {
|
||||
rb_gc_mark_no_pin((VALUE)entry->iseq);
|
||||
rb_gc_mark((VALUE)entry->iseq);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -324,16 +263,11 @@ rb_iseq_mark(const rb_iseq_t *iseq)
|
|||
}
|
||||
else if (FL_TEST_RAW(iseq, ISEQ_USE_COMPILE_DATA)) {
|
||||
const struct iseq_compile_data *const compile_data = ISEQ_COMPILE_DATA(iseq);
|
||||
if (RTEST(compile_data->mark_ary)) {
|
||||
rb_gc_mark(compile_data->mark_ary);
|
||||
rb_gc_mark_values(RARRAY_LEN(compile_data->mark_ary), RARRAY_CONST_PTR(compile_data->mark_ary));
|
||||
}
|
||||
RUBY_MARK_UNLESS_NULL(compile_data->err_info);
|
||||
if (RTEST(compile_data->catch_table_ary)) {
|
||||
rb_gc_mark(compile_data->catch_table_ary);
|
||||
rb_gc_mark_values(RARRAY_LEN(compile_data->catch_table_ary), RARRAY_CONST_PTR(compile_data->catch_table_ary));
|
||||
}
|
||||
VM_ASSERT(compile_data != NULL);
|
||||
|
||||
RUBY_MARK_UNLESS_NULL(compile_data->mark_ary);
|
||||
RUBY_MARK_UNLESS_NULL(compile_data->err_info);
|
||||
RUBY_MARK_UNLESS_NULL(compile_data->catch_table_ary);
|
||||
}
|
||||
else {
|
||||
/* executable */
|
||||
|
|
2
iseq.h
2
iseq.h
|
@ -234,7 +234,7 @@ struct iseq_catch_table_entry {
|
|||
* CATCH_TYPE_REDO, CATCH_TYPE_NEXT:
|
||||
* NULL.
|
||||
*/
|
||||
rb_iseq_t *iseq;
|
||||
const rb_iseq_t *iseq;
|
||||
|
||||
unsigned int start;
|
||||
unsigned int end;
|
||||
|
|
|
@ -1530,7 +1530,6 @@ module Net
|
|||
end
|
||||
@sock = SSLSocket.new(@sock, context)
|
||||
@sock.sync_close = true
|
||||
@sock.hostname = @host if @sock.respond_to? :hostname=
|
||||
ssl_socket_connect(@sock, @open_timeout)
|
||||
if context.verify_mode != VERIFY_NONE
|
||||
@sock.post_connection_check(@host)
|
||||
|
|
24
method.h
24
method.h
|
@ -40,9 +40,9 @@ typedef struct rb_scope_visi_struct {
|
|||
/*! CREF (Class REFerence) */
|
||||
typedef struct rb_cref_struct {
|
||||
VALUE flags;
|
||||
VALUE refinements;
|
||||
VALUE klass;
|
||||
struct rb_cref_struct * next;
|
||||
const VALUE refinements;
|
||||
const VALUE klass;
|
||||
struct rb_cref_struct * const next;
|
||||
const rb_scope_visibility_t scope_visi;
|
||||
} rb_cref_t;
|
||||
|
||||
|
@ -50,10 +50,10 @@ typedef struct rb_cref_struct {
|
|||
|
||||
typedef struct rb_method_entry_struct {
|
||||
VALUE flags;
|
||||
VALUE defined_class;
|
||||
const VALUE defined_class;
|
||||
struct rb_method_definition_struct * const def;
|
||||
ID called_id;
|
||||
VALUE owner;
|
||||
const VALUE owner;
|
||||
} rb_method_entry_t;
|
||||
|
||||
typedef struct rb_callable_method_entry_struct { /* same fields with rb_method_entry_t */
|
||||
|
@ -123,8 +123,8 @@ typedef struct rb_iseq_struct rb_iseq_t;
|
|||
#endif
|
||||
|
||||
typedef struct rb_method_iseq_struct {
|
||||
rb_iseq_t * iseqptr; /*!< iseq pointer, should be separated from iseqval */
|
||||
rb_cref_t * cref; /*!< class reference, should be marked */
|
||||
const rb_iseq_t * const iseqptr; /*!< iseq pointer, should be separated from iseqval */
|
||||
rb_cref_t * const cref; /*!< class reference, should be marked */
|
||||
} rb_method_iseq_t; /* check rb_add_method_iseq() when modify the fields */
|
||||
|
||||
typedef struct rb_method_cfunc_struct {
|
||||
|
@ -135,20 +135,20 @@ typedef struct rb_method_cfunc_struct {
|
|||
|
||||
typedef struct rb_method_attr_struct {
|
||||
ID id;
|
||||
VALUE location; /* should be marked */
|
||||
const VALUE location; /* should be marked */
|
||||
} rb_method_attr_t;
|
||||
|
||||
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;
|
||||
|
||||
typedef struct rb_method_refined_struct {
|
||||
struct rb_method_entry_struct * orig_me;
|
||||
VALUE owner;
|
||||
const struct rb_method_entry_struct * const orig_me;
|
||||
const VALUE owner;
|
||||
} rb_method_refined_t;
|
||||
|
||||
typedef struct rb_method_bmethod_struct {
|
||||
VALUE proc; /* should be marked */
|
||||
const VALUE proc; /* should be marked */
|
||||
struct rb_hook_list_struct *hooks;
|
||||
} rb_method_bmethod_t;
|
||||
|
||||
|
|
|
@ -1180,8 +1180,7 @@ mjit_copy_cache_from_main_thread(const rb_iseq_t *iseq, struct rb_call_cache *cc
|
|||
|
||||
if (UNLIKELY(mjit_opts.wait)) {
|
||||
mjit_copy_job_handler((void *)job);
|
||||
}
|
||||
else if (rb_workqueue_register(0, mjit_copy_job_handler, (void *)job)) {
|
||||
} else if (rb_workqueue_register(0, mjit_copy_job_handler, (void *)job)) {
|
||||
CRITICAL_SECTION_START(3, "in MJIT copy job wait");
|
||||
// checking `stop_worker_p` too because `RUBY_VM_CHECK_INTS(ec)` may not
|
||||
// lush mjit_copy_job_handler when EC_EXEC_TAG() is not TAG_NONE, and then
|
||||
|
|
8
parse.y
8
parse.y
|
@ -9307,7 +9307,7 @@ void
|
|||
rb_parser_fatal(struct parser_params *p, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
VALUE mesg = rb_str_new_cstr("internal parser error: ");
|
||||
VALUE mesg = rb_str_new_cstr("internal p error: ");
|
||||
|
||||
va_start(ap, fmt);
|
||||
rb_str_vcatf(mesg, fmt, ap);
|
||||
|
@ -9317,13 +9317,13 @@ rb_parser_fatal(struct parser_params *p, const char *fmt, ...)
|
|||
|
||||
mesg = rb_str_new(0, 0);
|
||||
append_lex_state_name(p->lex.state, mesg);
|
||||
compile_error(p, "lex.state: %"PRIsVALUE, mesg);
|
||||
compile_error(p, "p->lex.state: %"PRIsVALUE, mesg);
|
||||
rb_str_resize(mesg, 0);
|
||||
append_bitstack_value(p->cond_stack, mesg);
|
||||
compile_error(p, "cond_stack: %"PRIsVALUE, mesg);
|
||||
compile_error(p, "p->cond_stack: %"PRIsVALUE, mesg);
|
||||
rb_str_resize(mesg, 0);
|
||||
append_bitstack_value(p->cmdarg_stack, mesg);
|
||||
compile_error(p, "cmdarg_stack: %"PRIsVALUE, mesg);
|
||||
compile_error(p, "p->cmdarg_stack: %"PRIsVALUE, mesg);
|
||||
if (p->debug_output == rb_stdout)
|
||||
p->debug_output = rb_stderr;
|
||||
p->debug = TRUE;
|
||||
|
|
23
st.c
23
st.c
|
@ -1548,7 +1548,7 @@ st_update(st_table *tab, st_data_t key,
|
|||
different for ST_CHECK and when the current element is removed
|
||||
during traversing. */
|
||||
static inline int
|
||||
st_general_foreach(st_table *tab, int (*func)(ANYARGS), st_update_callback_func *replace, st_data_t arg,
|
||||
st_general_foreach(st_table *tab, int (*func)(ANYARGS), st_data_t arg,
|
||||
int check_p)
|
||||
{
|
||||
st_index_t bin;
|
||||
|
@ -1572,15 +1572,6 @@ st_general_foreach(st_table *tab, int (*func)(ANYARGS), st_update_callback_func
|
|||
rebuilds_num = tab->rebuilds_num;
|
||||
hash = curr_entry_ptr->hash;
|
||||
retval = (*func)(key, curr_entry_ptr->record, arg, 0);
|
||||
|
||||
if (retval == ST_REPLACE && replace) {
|
||||
st_data_t value;
|
||||
value = curr_entry_ptr->record;
|
||||
retval = (*replace)(&key, &value, arg, TRUE);
|
||||
curr_entry_ptr->key = key;
|
||||
curr_entry_ptr->record = value;
|
||||
}
|
||||
|
||||
if (rebuilds_num != tab->rebuilds_num) {
|
||||
retry:
|
||||
entries = tab->entries;
|
||||
|
@ -1609,8 +1600,6 @@ st_general_foreach(st_table *tab, int (*func)(ANYARGS), st_update_callback_func
|
|||
curr_entry_ptr = &entries[i];
|
||||
}
|
||||
switch (retval) {
|
||||
case ST_REPLACE:
|
||||
break;
|
||||
case ST_CONTINUE:
|
||||
break;
|
||||
case ST_CHECK:
|
||||
|
@ -1658,16 +1647,10 @@ st_general_foreach(st_table *tab, int (*func)(ANYARGS), st_update_callback_func
|
|||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
st_foreach_with_replace(st_table *tab, int (*func)(ANYARGS), st_update_callback_func *replace, st_data_t arg)
|
||||
{
|
||||
return st_general_foreach(tab, func, replace, arg, TRUE);
|
||||
}
|
||||
|
||||
int
|
||||
st_foreach(st_table *tab, int (*func)(ANYARGS), st_data_t arg)
|
||||
{
|
||||
return st_general_foreach(tab, func, NULL, arg, FALSE);
|
||||
return st_general_foreach(tab, func, arg, FALSE);
|
||||
}
|
||||
|
||||
/* See comments for function st_delete_safe. */
|
||||
|
@ -1675,7 +1658,7 @@ int
|
|||
st_foreach_check(st_table *tab, int (*func)(ANYARGS), st_data_t arg,
|
||||
st_data_t never ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return st_general_foreach(tab, func, NULL, arg, TRUE);
|
||||
return st_general_foreach(tab, func, arg, TRUE);
|
||||
}
|
||||
|
||||
/* Set up array KEYS by at most SIZE keys of head table TAB entries.
|
||||
|
|
7
symbol.c
7
symbol.c
|
@ -60,7 +60,12 @@ enum id_entry_type {
|
|||
ID_ENTRY_SIZE
|
||||
};
|
||||
|
||||
rb_symbols_t global_symbols = {tNEXT_ID-1};
|
||||
static struct symbols {
|
||||
rb_id_serial_t last_id;
|
||||
st_table *str_sym;
|
||||
VALUE ids;
|
||||
VALUE dsymbol_fstr_hash;
|
||||
} global_symbols = {tNEXT_ID-1};
|
||||
|
||||
static const struct st_hash_type symhash = {
|
||||
rb_str_hash_cmp,
|
||||
|
|
7
symbol.h
7
symbol.h
|
@ -54,13 +54,6 @@ id_type(ID id)
|
|||
|
||||
typedef uint32_t rb_id_serial_t;
|
||||
|
||||
typedef struct {
|
||||
rb_id_serial_t last_id;
|
||||
st_table *str_sym;
|
||||
VALUE ids;
|
||||
VALUE dsymbol_fstr_hash;
|
||||
} rb_symbols_t;
|
||||
|
||||
static inline rb_id_serial_t
|
||||
rb_id_to_serial(ID id)
|
||||
{
|
||||
|
|
|
@ -272,11 +272,6 @@ class OpenSSL::TestBN < OpenSSL::TestCase
|
|||
assert_equal(0, @e1.ucmp(-999))
|
||||
assert_instance_of(String, @e1.hash.to_s)
|
||||
end
|
||||
|
||||
def test_type_error
|
||||
bug15760 = '[ruby-core:92231] [Bug #15760]'
|
||||
assert_raise(TypeError, bug15760) { OpenSSL::BN.new(nil, 2) }
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
# frozen_string_literal: false
|
||||
require 'test/unit'
|
||||
require 'fiddle'
|
||||
|
||||
class TestGc < Test::Unit::TestCase
|
||||
class S
|
||||
|
|
|
@ -1,103 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
require 'test/unit'
|
||||
require 'fiddle'
|
||||
|
||||
class TestGCCompact < Test::Unit::TestCase
|
||||
if Fiddle::SIZEOF_LONG == Fiddle::SIZEOF_VOIDP
|
||||
def memory_location(obj)
|
||||
(Fiddle.dlwrap(obj) >> 1)
|
||||
end
|
||||
elsif Fiddle::SIZEOF_LONG_LONG == Fiddle::SIZEOF_VOIDP
|
||||
def memory_location(obj)
|
||||
(Fiddle.dlwrap(obj) >> 1) / 2
|
||||
end
|
||||
else
|
||||
raise "Not supported"
|
||||
end
|
||||
|
||||
def assert_object_ids(list)
|
||||
same_count = list.find_all { |obj|
|
||||
memory_location(obj) == obj.object_id
|
||||
}.count
|
||||
list.count - same_count
|
||||
end
|
||||
|
||||
def big_list
|
||||
1000.times.map {
|
||||
# try to make some empty slots by allocating an object and discarding
|
||||
Object.new
|
||||
Object.new
|
||||
} # likely next to each other
|
||||
end
|
||||
|
||||
# Find an object that's allocated in a slot that had a previous
|
||||
# tenant, and that tenant moved and is still alive
|
||||
def find_object_in_recycled_slot(addresses)
|
||||
new_object = nil
|
||||
|
||||
loop do
|
||||
new_object = Object.new
|
||||
if addresses.include? memory_location(new_object)
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
new_object
|
||||
end
|
||||
|
||||
def test_find_collided_object
|
||||
list_of_objects = big_list
|
||||
|
||||
ids = list_of_objects.map(&:object_id) # store id in map
|
||||
addresses = list_of_objects.map(&self.:memory_location)
|
||||
|
||||
# All object ids should be equal
|
||||
assert_equal 0, assert_object_ids(list_of_objects) # should be 0
|
||||
|
||||
GC.compact
|
||||
|
||||
# Some should have moved
|
||||
id_count = assert_object_ids(list_of_objects)
|
||||
skip "couldn't get objects to move" if id_count == 0
|
||||
assert_operator id_count, :>, 0
|
||||
|
||||
new_ids = list_of_objects.map(&:object_id)
|
||||
|
||||
# Object ids should not change after compaction
|
||||
assert_equal ids, new_ids
|
||||
|
||||
new_tenant = find_object_in_recycled_slot(addresses)
|
||||
assert new_tenant
|
||||
|
||||
# This is the object that used to be in new_object's position
|
||||
previous_tenant = list_of_objects[addresses.index(memory_location(new_tenant))]
|
||||
|
||||
assert_not_equal previous_tenant.object_id, new_tenant.object_id
|
||||
|
||||
# Should be able to look up object by object_id
|
||||
assert_equal new_tenant, ObjectSpace._id2ref(new_tenant.object_id)
|
||||
|
||||
# Should be able to look up object by object_id
|
||||
assert_equal previous_tenant, ObjectSpace._id2ref(previous_tenant.object_id)
|
||||
|
||||
int = (new_tenant.object_id >> 1)
|
||||
# These two should be the same! but they are not :(
|
||||
assert_equal int, ObjectSpace._id2ref(int.object_id)
|
||||
end
|
||||
|
||||
def test_many_collisions
|
||||
list_of_objects = big_list
|
||||
ids = list_of_objects.map(&:object_id)
|
||||
addresses = list_of_objects.map(&self.:memory_location)
|
||||
|
||||
GC.compact
|
||||
|
||||
new_tenants = 10.times.map {
|
||||
find_object_in_recycled_slot(addresses)
|
||||
}
|
||||
|
||||
collisions = GC.stat(:object_id_collisions)
|
||||
skip "couldn't get objects to collide" if collisions == 0
|
||||
assert_operator collisions, :>, 0
|
||||
end
|
||||
end
|
3
timev.h
3
timev.h
|
@ -1,9 +1,6 @@
|
|||
#ifndef RUBY_TIMEV_H
|
||||
#define RUBY_TIMEV_H
|
||||
|
||||
#if 0
|
||||
struct vtm {/* dummy for TAGS */};
|
||||
#endif
|
||||
PACKED_STRUCT_UNALIGNED(struct vtm {
|
||||
VALUE year; /* 2000 for example. Integer. */
|
||||
VALUE subsecx; /* 0 <= subsecx < TIME_SCALE. possibly Rational. */
|
||||
|
|
|
@ -796,56 +796,6 @@ blocks_clear_marked_index(struct transient_heap_block* block)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
transient_heap_block_update_refs(struct transient_heap* theap, struct transient_heap_block* block)
|
||||
{
|
||||
int i=0, n=0;
|
||||
|
||||
while (i<block->info.index) {
|
||||
void *ptr = &block->buff[i];
|
||||
struct transient_alloc_header *header = ptr;
|
||||
|
||||
unpoison_memory_region(header, sizeof *header, false);
|
||||
|
||||
void *poisoned = __asan_region_is_poisoned(header->obj, SIZEOF_VALUE);
|
||||
unpoison_object(header->obj, false);
|
||||
|
||||
header->obj = rb_gc_new_location(header->obj);
|
||||
|
||||
if (poisoned) {
|
||||
poison_object(header->obj);
|
||||
}
|
||||
|
||||
i += header->size;
|
||||
poison_memory_region(header, sizeof *header);
|
||||
n++;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
transient_heap_blocks_update_refs(struct transient_heap* theap, struct transient_heap_block *block, const char *type_str)
|
||||
{
|
||||
while (block) {
|
||||
transient_heap_block_update_refs(theap, block);
|
||||
block = block->info.next_block;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
rb_transient_heap_update_references(void)
|
||||
{
|
||||
struct transient_heap* theap = transient_heap_get();
|
||||
int i;
|
||||
|
||||
transient_heap_blocks_update_refs(theap, theap->using_blocks, "using_blocks");
|
||||
transient_heap_blocks_update_refs(theap, theap->marked_blocks, "marked_blocks");
|
||||
|
||||
for (i=0; i<theap->promoted_objects_index; i++) {
|
||||
VALUE obj = theap->promoted_objects[i];
|
||||
theap->promoted_objects[i] == rb_gc_new_location(obj);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
rb_transient_heap_start_marking(int full_marking)
|
||||
{
|
||||
|
|
|
@ -30,7 +30,6 @@ void rb_transient_heap_mark(VALUE obj, const void *ptr);
|
|||
void rb_transient_heap_promote(VALUE obj);
|
||||
void rb_transient_heap_start_marking(int full_marking);
|
||||
void rb_transient_heap_finish_marking(void);
|
||||
void rb_transient_heap_update_references(void);
|
||||
|
||||
/* for debug API */
|
||||
void rb_transient_heap_dump(void);
|
||||
|
@ -49,7 +48,6 @@ void rb_struct_transient_heap_evacuate(VALUE st, int promote);
|
|||
#define rb_transient_heap_verify() ((void)0)
|
||||
#define rb_transient_heap_promote(obj) ((void)0)
|
||||
#define rb_transient_heap_start_marking(full_marking) ((void)0)
|
||||
#define rb_transient_heap_update_references() ((void)0)
|
||||
#define rb_transient_heap_finish_marking() ((void)0)
|
||||
#define rb_transient_heap_mark(obj, ptr) ((void)0)
|
||||
|
||||
|
|
32
variable.c
32
variable.c
|
@ -1200,16 +1200,6 @@ rb_mark_generic_ivar(VALUE obj)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
rb_mv_generic_ivar(VALUE rsrc, VALUE dst)
|
||||
{
|
||||
st_data_t key = (st_data_t)rsrc;
|
||||
struct gen_ivtbl *ivtbl;
|
||||
|
||||
if (st_delete(generic_iv_tbl, &key, (st_data_t *)&ivtbl))
|
||||
st_insert(generic_iv_tbl, (st_data_t)dst, (st_data_t)ivtbl);
|
||||
}
|
||||
|
||||
void
|
||||
rb_free_generic_ivar(VALUE obj)
|
||||
{
|
||||
|
@ -1960,7 +1950,7 @@ rb_mod_const_missing(VALUE klass, VALUE name)
|
|||
static void
|
||||
autoload_mark(void *ptr)
|
||||
{
|
||||
rb_mark_tbl_no_pin((st_table *)ptr);
|
||||
rb_mark_tbl((st_table *)ptr);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1976,15 +1966,9 @@ autoload_memsize(const void *ptr)
|
|||
return st_memsize(tbl);
|
||||
}
|
||||
|
||||
static void
|
||||
autoload_compact(void *ptr)
|
||||
{
|
||||
rb_gc_update_tbl_refs((st_table *)ptr);
|
||||
}
|
||||
|
||||
static const rb_data_type_t autoload_data_type = {
|
||||
"autoload",
|
||||
{autoload_mark, autoload_free, autoload_memsize, autoload_compact,},
|
||||
{autoload_mark, autoload_free, autoload_memsize,},
|
||||
0, 0, RUBY_TYPED_FREE_IMMEDIATELY
|
||||
};
|
||||
|
||||
|
@ -2030,19 +2014,12 @@ struct autoload_data_i {
|
|||
struct list_head constants; /* <=> autoload_const.cnode */
|
||||
};
|
||||
|
||||
static void
|
||||
autoload_i_compact(void *ptr)
|
||||
{
|
||||
struct autoload_data_i *p = ptr;
|
||||
p->feature = rb_gc_new_location(p->feature);
|
||||
}
|
||||
|
||||
static void
|
||||
autoload_i_mark(void *ptr)
|
||||
{
|
||||
struct autoload_data_i *p = ptr;
|
||||
|
||||
rb_gc_mark_no_pin(p->feature);
|
||||
rb_gc_mark(p->feature);
|
||||
|
||||
/* allow GC to free us if no modules refer to this via autoload_const.ad */
|
||||
if (list_empty(&p->constants)) {
|
||||
|
@ -2069,7 +2046,7 @@ autoload_i_memsize(const void *ptr)
|
|||
|
||||
static const rb_data_type_t autoload_data_i_type = {
|
||||
"autoload_i",
|
||||
{autoload_i_mark, autoload_i_free, autoload_i_memsize, autoload_i_compact},
|
||||
{autoload_i_mark, autoload_i_free, autoload_i_memsize,},
|
||||
0, 0, RUBY_TYPED_FREE_IMMEDIATELY
|
||||
};
|
||||
|
||||
|
@ -2994,7 +2971,6 @@ rb_define_const(VALUE klass, const char *name, VALUE val)
|
|||
if (!rb_is_const_id(id)) {
|
||||
rb_warn("rb_define_const: invalid name `%s' for constant", name);
|
||||
}
|
||||
rb_gc_register_mark_object(val);
|
||||
rb_const_set(klass, id, val);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#define RUBY_RELEASE_YEAR 2019
|
||||
#define RUBY_RELEASE_MONTH 4
|
||||
#define RUBY_RELEASE_DAY 10
|
||||
#define RUBY_RELEASE_DAY 9
|
||||
|
||||
#include "ruby/version.h"
|
||||
|
||||
|
|
31
vm.c
31
vm.c
|
@ -2202,15 +2202,6 @@ rb_vm_call_cfunc(VALUE recv, VALUE (*func)(VALUE), VALUE arg,
|
|||
|
||||
/* vm */
|
||||
|
||||
void
|
||||
rb_vm_update_references(void *ptr)
|
||||
{
|
||||
if (ptr) {
|
||||
rb_vm_t *vm = ptr;
|
||||
rb_update_st_references(vm->frozen_strings);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
rb_vm_mark(void *ptr)
|
||||
{
|
||||
|
@ -2219,30 +2210,12 @@ rb_vm_mark(void *ptr)
|
|||
if (ptr) {
|
||||
rb_vm_t *vm = ptr;
|
||||
rb_thread_t *th = 0;
|
||||
long i, len;
|
||||
const VALUE *obj_ary;
|
||||
|
||||
list_for_each(&vm->living_threads, th, vmlt_node) {
|
||||
rb_gc_mark(th->self);
|
||||
}
|
||||
rb_gc_mark(vm->thgroup_default);
|
||||
rb_gc_mark(vm->mark_object_ary);
|
||||
|
||||
len = RARRAY_LEN(vm->mark_object_ary);
|
||||
obj_ary = RARRAY_CONST_PTR(vm->mark_object_ary);
|
||||
for (i=0; i < len; i++) {
|
||||
const VALUE *ptr;
|
||||
long j, jlen;
|
||||
|
||||
rb_gc_mark(*obj_ary);
|
||||
jlen = RARRAY_LEN(*obj_ary);
|
||||
ptr = RARRAY_CONST_PTR(*obj_ary);
|
||||
for (j=0; j < jlen; j++) {
|
||||
rb_gc_mark(*ptr++);
|
||||
}
|
||||
obj_ary++;
|
||||
}
|
||||
|
||||
rb_gc_mark(vm->load_path);
|
||||
rb_gc_mark(vm->load_path_snapshot);
|
||||
RUBY_MARK_UNLESS_NULL(vm->load_path_check_cache);
|
||||
|
@ -2252,8 +2225,6 @@ rb_vm_mark(void *ptr)
|
|||
rb_gc_mark(vm->top_self);
|
||||
RUBY_MARK_UNLESS_NULL(vm->coverages);
|
||||
rb_gc_mark(vm->defined_module_hash);
|
||||
/* Prevent classes from moving */
|
||||
rb_mark_tbl(rb_hash_tbl(vm->defined_module_hash, __FILE__, __LINE__));
|
||||
|
||||
if (vm->loading_table) {
|
||||
rb_mark_tbl(vm->loading_table);
|
||||
|
@ -2492,7 +2463,7 @@ rb_execution_context_mark(const rb_execution_context_t *ec)
|
|||
rb_control_frame_t *cfp = ec->cfp;
|
||||
rb_control_frame_t *limit_cfp = (void *)(ec->vm_stack + ec->vm_stack_size);
|
||||
|
||||
rb_gc_mark_stack_values((long)(sp - p), p);
|
||||
rb_gc_mark_values((long)(sp - p), p);
|
||||
|
||||
while (cfp != limit_cfp) {
|
||||
const VALUE *ep = cfp->ep;
|
||||
|
|
|
@ -36,7 +36,7 @@ enum arg_setup_type {
|
|||
static inline void
|
||||
arg_rest_dup(struct args_info *args)
|
||||
{
|
||||
if (!args->rest_dupped) {
|
||||
if(!args->rest_dupped) {
|
||||
args->rest = rb_ary_dup(args->rest);
|
||||
args->rest_dupped = TRUE;
|
||||
}
|
||||
|
|
|
@ -346,7 +346,7 @@ struct rb_iseq_constant_body {
|
|||
} type; /* instruction sequence type */
|
||||
|
||||
unsigned int iseq_size;
|
||||
VALUE *iseq_encoded; /* encoded iseq (insn addr and operands) */
|
||||
const VALUE *iseq_encoded; /* encoded iseq (insn addr and operands) */
|
||||
|
||||
/**
|
||||
* parameter information
|
||||
|
@ -414,7 +414,7 @@ struct rb_iseq_constant_body {
|
|||
int bits_start;
|
||||
int rest_start;
|
||||
const ID *table;
|
||||
VALUE *default_values;
|
||||
const VALUE *default_values;
|
||||
} *keyword;
|
||||
} param;
|
||||
|
||||
|
@ -433,7 +433,7 @@ struct rb_iseq_constant_body {
|
|||
const ID *local_table; /* must free */
|
||||
|
||||
/* catch table */
|
||||
struct iseq_catch_table *catch_table;
|
||||
const struct iseq_catch_table *catch_table;
|
||||
|
||||
/* for child iseq */
|
||||
const struct rb_iseq_struct *parent_iseq;
|
||||
|
@ -1029,7 +1029,7 @@ typedef struct {
|
|||
|
||||
typedef struct {
|
||||
VALUE flags; /* imemo header */
|
||||
rb_iseq_t *iseq;
|
||||
const rb_iseq_t *iseq;
|
||||
const VALUE *ep;
|
||||
const VALUE *env;
|
||||
unsigned int env_size;
|
||||
|
|
|
@ -484,7 +484,6 @@ rb_type_str(enum ruby_value_type type)
|
|||
case type_case(T_NODE);
|
||||
case type_case(T_ICLASS);
|
||||
case type_case(T_ZOMBIE);
|
||||
case type_case(T_MOVED);
|
||||
case T_MASK: break;
|
||||
}
|
||||
#undef type_case
|
||||
|
|
|
@ -670,8 +670,13 @@ rb_add_method(VALUE klass, ID mid, rb_method_type_t type, void *opts, rb_method_
|
|||
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_method_iseq_t iseq_body = {(rb_iseq_t *)iseq, cref};
|
||||
struct { /* should be same fields with rb_method_iseq_struct */
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче