ruby-changes:55292
From: kazu <ko1@a...>
Date: Wed, 10 Apr 2019 18:15:30 +0900 (JST)
Subject: [ruby-changes:55292] kazu:r67499 (trunk): Reverting all commits from r67479 to r67496 because of CI failures
kazu 2019-04-10 18:15:21 +0900 (Wed, 10 Apr 2019) New Revision: 67499 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=67499 Log: Reverting all commits from r67479 to r67496 because of CI failures Because hard to specify commits related to r67479 only. So please commit again. Removed files: trunk/test/ruby/test_gc_compact.rb Modified files: trunk/NEWS trunk/array.c trunk/class.c trunk/compile.c trunk/constant.h trunk/defs/id.def trunk/ext/json/generator/generator.c trunk/ext/json/parser/parser.c trunk/ext/openssl/ossl_bn.c trunk/gc.c trunk/gc.h trunk/hash.c trunk/id_table.c trunk/id_table.h trunk/include/ruby/intern.h trunk/include/ruby/ruby.h trunk/include/ruby/st.h trunk/internal.h trunk/io.c trunk/iseq.c trunk/iseq.h trunk/lib/net/imap.rb trunk/method.h trunk/mjit_worker.c trunk/parse.y trunk/st.c trunk/symbol.c trunk/symbol.h trunk/test/openssl/test_bn.rb trunk/test/ruby/test_gc.rb trunk/timev.h trunk/transient_heap.c trunk/transient_heap.h trunk/variable.c trunk/version.h trunk/vm.c trunk/vm_args.c trunk/vm_core.h trunk/vm_eval.c trunk/vm_method.c Index: test/ruby/test_gc_compact.rb =================================================================== --- test/ruby/test_gc_compact.rb (revision 67498) +++ test/ruby/test_gc_compact.rb (nonexistent) @@ -1,103 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/test/ruby/test_gc_compact.rb#L0 -# 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 Property changes on: test/ruby/test_gc_compact.rb ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -LF \ No newline at end of property Index: defs/id.def =================================================================== --- defs/id.def (revision 67498) +++ defs/id.def (revision 67499) @@ -70,7 +70,6 @@ firstline, predefined = __LINE__+1, %[\ https://github.com/ruby/ruby/blob/trunk/defs/id.def#L70 $_ LASTLINE $~ BACKREF - $! ERROR_INFO ] # VM ID OP Parser Token Index: ext/openssl/ossl_bn.c =================================================================== --- ext/openssl/ossl_bn.c (revision 67498) +++ ext/openssl/ossl_bn.c (revision 67499) @@ -187,7 +187,6 @@ ossl_bn_initialize(int argc, VALUE *argv https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_bn.c#L187 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 https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_bn.c#L213 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; Index: ext/json/generator/generator.c =================================================================== --- ext/json/generator/generator.c (revision 67498) +++ ext/json/generator/generator.c (revision 67499) @@ -1344,8 +1344,6 @@ void Init_generator(void) https://github.com/ruby/ruby/blob/trunk/ext/json/generator/generator.c#L1344 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); Index: variable.c =================================================================== --- variable.c (revision 67498) +++ variable.c (revision 67499) @@ -1201,16 +1201,6 @@ rb_mark_generic_ivar(VALUE obj) https://github.com/ruby/ruby/blob/trunk/variable.c#L1201 } 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) { st_data_t key = (st_data_t)obj; @@ -1960,7 +1950,7 @@ rb_mod_const_missing(VALUE klass, VALUE https://github.com/ruby/ruby/blob/trunk/variable.c#L1950 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) https://github.com/ruby/ruby/blob/trunk/variable.c#L1966 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 }; @@ -2031,18 +2015,11 @@ struct autoload_data_i { https://github.com/ruby/ruby/blob/trunk/variable.c#L2015 }; 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) https://github.com/ruby/ruby/blob/trunk/variable.c#L2046 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 https://github.com/ruby/ruby/blob/trunk/variable.c#L2971 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); } Index: include/ruby/intern.h =================================================================== --- include/ruby/intern.h (revision 67498) +++ include/ruby/intern.h (revision 67499) @@ -507,15 +507,10 @@ COLDFUNC NORETURN(void rb_memerror(void) https://github.com/ruby/ruby/blob/trunk/include/ruby/intern.h#L507 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); Index: st.c =================================================================== --- st.c (revision 67498) +++ st.c (revision 67499) @@ -1548,7 +1548,7 @@ st_update(st_table *tab, st_data_t key, https://github.com/ruby/ruby/blob/trunk/st.c#L1548 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 (* https://github.com/ruby/ruby/blob/trunk/st.c#L1572 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 (* https://github.com/ruby/ruby/blob/trunk/st.c#L1600 curr_entry_ptr = &entries[i]; } switch (retval) { - case ST_REPLACE: - break; case ST_CONTINUE: break; case ST_CHECK: @@ -1659,15 +1648,9 @@ st_general_foreach(st_table *tab, int (* https://github.com/ruby/ruby/blob/trunk/st.c#L1648 } 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 https://github.com/ruby/ruby/blob/trunk/st.c#L1658 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. Index: vm_eval.c =================================================================== --- vm_eval.c (revision 67498) +++ vm_eval.c (revision 67499) @@ -484,7 +484,6 @@ rb_type_str(enum ruby_value_type type) https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L484 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 Index: include/ruby/st.h =================================================================== --- include/ruby/st.h (revision 67498) +++ include/ruby/st.h (revision 67499) @@ -96,7 +96,7 @@ struct st_table { https://github.com/ruby/ruby/blob/trunk/include/ruby/st.h#L96 #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_d https://github.com/ruby/ruby/blob/trunk/include/ruby/st.h#L118 * 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); Index: hash.c =================================================================== --- hash.c (revision 67498) +++ hash.c (revision 67499) @@ -781,7 +781,7 @@ ar_add_direct_with_hash(VALUE hash, st_d https://github.com/ruby/ruby/blob/trunk/hash.c#L781 } 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 (*fun https://github.com/ruby/ruby/blob/trunk/hash.c#L799 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); @@ -824,18 +810,6 @@ ar_general_foreach(VALUE hash, int (*fun https://github.com/ruby/ruby/blob/trunk/hash.c#L810 } 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) https://github.com/ruby/ruby/blob/trunk/hash.c#L845 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 ( https://github.com/ruby/ruby/blob/trunk/hash.c#L1257 } } -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) { Index: id_table.h =================================================================== --- id_table.h (revision 67498) +++ id_table.h (revision 67499) @@ -9,7 +9,6 @@ enum rb_id_table_iterator_result { https://github.com/ruby/ruby/blob/trunk/id_table.h#L9 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_tabl https://github.com/ruby/ruby/blob/trunk/id_table.h#L23 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 */ Index: gc.c =================================================================== --- gc.c (revision 67498) +++ gc.c (revision 67499) @@ -29,7 +29,6 @@ https://github.com/ruby/ruby/blob/trunk/gc.c#L29 #include "ruby_atomic.h" #include "probes.h" #include "id_table.h" -#include "symbol.h" #include <stdio.h> #include <stdarg.h> #include <setjmp.h> @@ -195,9 +194,6 @@ static ruby_gc_params_t gc_params = { https://github.com/ruby/ruby/blob/trunk/gc.c#L194 FALSE, }; -static st_table *id_to_obj_tbl; -static st_table *obj_to_id_tbl; - /* GC_DEBUG: * enable to embed GC debugging information. */ @@ -408,7 +404,6 @@ typedef struct RVALUE { https://github.com/ruby/ruby/blob/trunk/gc.c#L404 VALUE flags; /* always 0 for freed obj */ struct RVALUE *next; } free; - struct RMoved moved; struct RBasic basic; struct RObject object; struct RClass klass; @@ -586,7 +581,6 @@ typedef struct rb_objspace { https://github.com/ruby/ruby/blob/trunk/gc.c#L581 #if USE_RGENGC size_t minor_gc_count; size_t major_gc_count; - size_t object_id_collisions; #if RGENGC_PROFILE > 0 size_t total_generated_normal_object_count; size_t total_generated_shady_object_count; @@ -641,12 +635,6 @@ typedef struct rb_objspace { https://github.com/ruby/ruby/blob/trunk/gc.c#L635 size_t error_count; #endif } rgengc; - - struct { - size_t considered_count_table[T_MASK]; - size_t moved_count_table[T_MASK]; - } rcompactor; - #if GC_ENABLE_INCREMENTAL_MARK struct { size_t pooled_slots; @@ -694,8 +682,6 @@ struct heap_page { https://github.com/ruby/ruby/blob/trunk/gc.c#L682 #if USE_RGENGC bits_t wb_unprotected_bits[HEAP_PAGE_BITMAP_LIMIT]; #endif - /* If set, the object is not movable */ - bits_t pinned_bits[HEAP_PAGE_BITMAP_LIMIT]; /* the following three bitmaps are cleared at the beginning of full GC */ bits_t mark_bits[HEAP_PAGE_BITMAP_LIMIT]; #if USE_RGENGC @@ -720,7 +706,6 @@ struct heap_page { https://github.com/ruby/ruby/blob/trunk/gc.c#L706 /* getting bitmap */ #define GET_HEAP_MARK_BITS(x) (&GET_HEAP_PAGE(x)->mark_bits[0]) -#define GET_HEAP_PINNED_BITS(x) (&GET_HEAP_PAGE(x)->pinned_bits[0]) #if USE_RGENGC #define GET_HEAP_UNCOLLECTIBLE_BITS(x) (&GET_HEAP_PAGE(x)->uncollectible_bits[0]) #define GET_HEAP_WB_UNPROTECTED_BITS(x) (&GET_HEAP_PAGE(x)->wb_unprotected_bits[0]) @@ -841,9 +826,7 @@ VALUE rb_mGC; https://github.com/ruby/ruby/blob/trunk/gc.c#L826 int (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/