Rename rb_gc_new_location to rb_gc_location

The function will return new or existing locations depending on whether
or not the object actually moved, so give it a more appropriate name.
This commit is contained in:
Aaron Patterson 2019-05-18 12:23:47 +03:00
Родитель bbb84a16fa
Коммит 154a67f140
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 953170BCB4FFAFC6
6 изменённых файлов: 27 добавлений и 27 удалений

22
gc.c
Просмотреть файл

@ -7625,11 +7625,11 @@ hash_replace_ref(st_data_t *key, st_data_t *value, st_data_t argp, int existing)
rb_objspace_t *objspace = (rb_objspace_t *)argp; rb_objspace_t *objspace = (rb_objspace_t *)argp;
if (gc_object_moved_p(objspace, (VALUE)*key)) { if (gc_object_moved_p(objspace, (VALUE)*key)) {
*key = rb_gc_new_location((VALUE)*key); *key = rb_gc_location((VALUE)*key);
} }
if (gc_object_moved_p(objspace, (VALUE)*value)) { if (gc_object_moved_p(objspace, (VALUE)*value)) {
*value = rb_gc_new_location((VALUE)*value); *value = rb_gc_location((VALUE)*value);
} }
return ST_CONTINUE; return ST_CONTINUE;
@ -7789,7 +7789,7 @@ check_id_table_move(ID id, VALUE value, void *data)
/* Returns the new location of an object, if it moved. Otherwise returns /* Returns the new location of an object, if it moved. Otherwise returns
* the existing location. */ * the existing location. */
VALUE VALUE
rb_gc_new_location(VALUE value) rb_gc_location(VALUE value)
{ {
VALUE destination; VALUE destination;
@ -7825,7 +7825,7 @@ update_id_table(ID *key, VALUE * value, void *data, int existing)
rb_objspace_t *objspace = (rb_objspace_t *)data; rb_objspace_t *objspace = (rb_objspace_t *)data;
if (gc_object_moved_p(objspace, (VALUE)*value)) { if (gc_object_moved_p(objspace, (VALUE)*value)) {
*value = rb_gc_new_location((VALUE)*value); *value = rb_gc_location((VALUE)*value);
} }
return ID_TABLE_CONTINUE; return ID_TABLE_CONTINUE;
@ -7846,11 +7846,11 @@ update_const_table(VALUE value, void *data)
rb_objspace_t * objspace = (rb_objspace_t *)data; rb_objspace_t * objspace = (rb_objspace_t *)data;
if (gc_object_moved_p(objspace, ce->value)) { if (gc_object_moved_p(objspace, ce->value)) {
ce->value = rb_gc_new_location(ce->value); ce->value = rb_gc_location(ce->value);
} }
if (gc_object_moved_p(objspace, ce->file)) { if (gc_object_moved_p(objspace, ce->file)) {
ce->file = rb_gc_new_location(ce->file); ce->file = rb_gc_location(ce->file);
} }
return ID_TABLE_CONTINUE; return ID_TABLE_CONTINUE;
@ -8096,8 +8096,8 @@ gc_update_references(rb_objspace_t * objspace)
rb_objspace_each_objects_without_setup(gc_ref_update, objspace); rb_objspace_each_objects_without_setup(gc_ref_update, objspace);
rb_vm_update_references(vm); rb_vm_update_references(vm);
rb_transient_heap_update_references(); rb_transient_heap_update_references();
global_symbols.ids = rb_gc_new_location(global_symbols.ids); global_symbols.ids = rb_gc_location(global_symbols.ids);
global_symbols.dsymbol_fstr_hash = rb_gc_new_location(global_symbols.dsymbol_fstr_hash); global_symbols.dsymbol_fstr_hash = rb_gc_location(global_symbols.dsymbol_fstr_hash);
gc_update_table_refs(objspace, global_symbols.str_sym); gc_update_table_refs(objspace, global_symbols.str_sym);
gc_update_table_refs(objspace, finalizer_table); gc_update_table_refs(objspace, finalizer_table);
} }
@ -8157,7 +8157,7 @@ static void
root_obj_check_moved_i(const char *category, VALUE obj, void *data) root_obj_check_moved_i(const char *category, VALUE obj, void *data)
{ {
if (gc_object_moved_p(&rb_objspace, obj)) { if (gc_object_moved_p(&rb_objspace, obj)) {
rb_bug("ROOT %s points to MOVED: %p -> %s\n", category, (void *)obj, obj_info(rb_gc_new_location(obj))); rb_bug("ROOT %s points to MOVED: %p -> %s\n", category, (void *)obj, obj_info(rb_gc_location(obj)));
} }
} }
@ -8166,7 +8166,7 @@ reachable_object_check_moved_i(VALUE ref, void *data)
{ {
VALUE parent = (VALUE)data; VALUE parent = (VALUE)data;
if (gc_object_moved_p(&rb_objspace, ref)) { if (gc_object_moved_p(&rb_objspace, ref)) {
rb_bug("Object %s points to MOVED: %p -> %s\n", obj_info(parent), (void *)ref, obj_info(rb_gc_new_location(ref))); rb_bug("Object %s points to MOVED: %p -> %s\n", obj_info(parent), (void *)ref, obj_info(rb_gc_location(ref)));
} }
} }
@ -11126,7 +11126,7 @@ rb_raw_obj_info(char *buff, const int buff_size, VALUE obj)
break; break;
} }
case T_MOVED: { case T_MOVED: {
snprintf(buff, buff_size, "-> %p", (void*)rb_gc_new_location(obj)); snprintf(buff, buff_size, "-> %p", (void*)rb_gc_location(obj));
break; break;
} }
case T_HASH: { case T_HASH: {

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

@ -515,7 +515,7 @@ void rb_update_st_references(struct st_table *ht);
void rb_gc_mark_maybe(VALUE); void rb_gc_mark_maybe(VALUE);
void rb_gc_mark(VALUE); void rb_gc_mark(VALUE);
void rb_gc_mark_no_pin(VALUE); void rb_gc_mark_no_pin(VALUE);
VALUE rb_gc_new_location(VALUE); VALUE rb_gc_location(VALUE);
void rb_gc_force_recycle(VALUE); void rb_gc_force_recycle(VALUE);
void rb_gc(void); void rb_gc(void);
void rb_gc_copy_finalizer(VALUE,VALUE); void rb_gc_copy_finalizer(VALUE,VALUE);

20
iseq.c
Просмотреть файл

@ -214,7 +214,7 @@ rb_iseq_each_value(const rb_iseq_t *iseq, iseq_value_itr_t * func, void *data)
static VALUE static VALUE
update_each_insn_value(void *ctx, VALUE obj) update_each_insn_value(void *ctx, VALUE obj)
{ {
return rb_gc_new_location(obj); return rb_gc_location(obj);
} }
void void
@ -223,16 +223,16 @@ rb_iseq_update_references(rb_iseq_t *iseq)
if (iseq->body) { if (iseq->body) {
struct rb_iseq_constant_body *body = iseq->body; struct rb_iseq_constant_body *body = iseq->body;
body->variable.coverage = rb_gc_new_location(body->variable.coverage); body->variable.coverage = rb_gc_location(body->variable.coverage);
body->variable.pc2branchindex = rb_gc_new_location(body->variable.pc2branchindex); body->variable.pc2branchindex = rb_gc_location(body->variable.pc2branchindex);
body->location.label = rb_gc_new_location(body->location.label); body->location.label = rb_gc_location(body->location.label);
body->location.base_label = rb_gc_new_location(body->location.base_label); body->location.base_label = rb_gc_location(body->location.base_label);
body->location.pathobj = rb_gc_new_location(body->location.pathobj); body->location.pathobj = rb_gc_location(body->location.pathobj);
if (body->local_iseq) { if (body->local_iseq) {
body->local_iseq = (struct rb_iseq_struct *)rb_gc_new_location((VALUE)body->local_iseq); body->local_iseq = (struct rb_iseq_struct *)rb_gc_location((VALUE)body->local_iseq);
} }
if (body->parent_iseq) { if (body->parent_iseq) {
body->parent_iseq = (struct rb_iseq_struct *)rb_gc_new_location((VALUE)body->parent_iseq); body->parent_iseq = (struct rb_iseq_struct *)rb_gc_location((VALUE)body->parent_iseq);
} }
if (FL_TEST(iseq, ISEQ_MARKABLE_ISEQ)) { if (FL_TEST(iseq, ISEQ_MARKABLE_ISEQ)) {
rb_iseq_each_value(iseq, update_each_insn_value, NULL); rb_iseq_each_value(iseq, update_each_insn_value, NULL);
@ -246,7 +246,7 @@ rb_iseq_update_references(rb_iseq_t *iseq)
for (j = 0; i < body->param.keyword->num; i++, j++) { for (j = 0; i < body->param.keyword->num; i++, j++) {
VALUE obj = body->param.keyword->default_values[j]; VALUE obj = body->param.keyword->default_values[j];
if (obj != Qundef) { if (obj != Qundef) {
body->param.keyword->default_values[j] = rb_gc_new_location(obj); body->param.keyword->default_values[j] = rb_gc_location(obj);
} }
} }
} }
@ -258,7 +258,7 @@ rb_iseq_update_references(rb_iseq_t *iseq)
struct iseq_catch_table_entry *entry; struct iseq_catch_table_entry *entry;
entry = &table->entries[i]; entry = &table->entries[i];
if (entry->iseq) { if (entry->iseq) {
entry->iseq = (rb_iseq_t *)rb_gc_new_location((VALUE)entry->iseq); entry->iseq = (rb_iseq_t *)rb_gc_location((VALUE)entry->iseq);
} }
} }
} }

4
mjit.c
Просмотреть файл

@ -119,7 +119,7 @@ mjit_update_references(const rb_iseq_t *iseq)
CRITICAL_SECTION_START(4, "mjit_update_references"); CRITICAL_SECTION_START(4, "mjit_update_references");
if (iseq->body->jit_unit) { if (iseq->body->jit_unit) {
iseq->body->jit_unit->iseq = (rb_iseq_t *)rb_gc_new_location((VALUE)iseq->body->jit_unit->iseq); iseq->body->jit_unit->iseq = (rb_iseq_t *)rb_gc_location((VALUE)iseq->body->jit_unit->iseq);
// We need to invalidate JIT-ed code for the ISeq because it embeds pointer addresses. // We need to invalidate JIT-ed code for the ISeq because it embeds pointer addresses.
// To efficiently do that, we use the same thing as TracePoint and thus everything is cancelled for now. // To efficiently do that, we use the same thing as TracePoint and thus everything is cancelled for now.
mjit_call_p = false; // TODO: instead of cancelling all, invalidate only this one and recompile it with some threshold. mjit_call_p = false; // TODO: instead of cancelling all, invalidate only this one and recompile it with some threshold.
@ -131,7 +131,7 @@ mjit_update_references(const rb_iseq_t *iseq)
struct rb_mjit_unit *unit = NULL; struct rb_mjit_unit *unit = NULL;
list_for_each(&stale_units.head, unit, unode) { list_for_each(&stale_units.head, unit, unode) {
if (unit->iseq == iseq) { if (unit->iseq == iseq) {
unit->iseq = (rb_iseq_t *)rb_gc_new_location((VALUE)unit->iseq); unit->iseq = (rb_iseq_t *)rb_gc_location((VALUE)unit->iseq);
} }
} }
CRITICAL_SECTION_FINISH(4, "mjit_update_references"); CRITICAL_SECTION_FINISH(4, "mjit_update_references");

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

@ -816,7 +816,7 @@ transient_heap_block_update_refs(struct transient_heap* theap, struct transient_
void *poisoned = __asan_region_is_poisoned((void *)header->obj, SIZEOF_VALUE); void *poisoned = __asan_region_is_poisoned((void *)header->obj, SIZEOF_VALUE);
unpoison_object(header->obj, false); unpoison_object(header->obj, false);
header->obj = rb_gc_new_location(header->obj); header->obj = rb_gc_location(header->obj);
if (poisoned) { if (poisoned) {
poison_object(header->obj); poison_object(header->obj);
@ -848,7 +848,7 @@ rb_transient_heap_update_references(void)
for (i=0; i<theap->promoted_objects_index; i++) { for (i=0; i<theap->promoted_objects_index; i++) {
VALUE obj = theap->promoted_objects[i]; VALUE obj = theap->promoted_objects[i];
theap->promoted_objects[i] = rb_gc_new_location(obj); theap->promoted_objects[i] = rb_gc_location(obj);
} }
} }

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

@ -2030,7 +2030,7 @@ static void
autoload_i_compact(void *ptr) autoload_i_compact(void *ptr)
{ {
struct autoload_data_i *p = ptr; struct autoload_data_i *p = ptr;
p->feature = rb_gc_new_location(p->feature); p->feature = rb_gc_location(p->feature);
} }
static void static void