Skip to content

Commit db8a046

Browse files
authored
Merge branch 'master' into zjit-more-opt-send-specializeds
2 parents 2d7f5f3 + f4135fe commit db8a046

31 files changed

+527
-373
lines changed

.git-blame-ignore-revs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,5 @@ d2c5867357ed88eccc28c2b3bd4a46e206e7ff85
3434
# Miss-and-revived commits
3535
a0f7de814ae5c299d6ce99bed5fb308a05d50ba0
3636
d4e24021d39e1f80f0055b55d91f8d5f22e15084
37+
7a56c316418980b8a41fcbdc94067b2bda2ad112
38+
e90282be7ba1bc8e3119f6e1a2c80356ceb3f80a

NEWS.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,26 @@ Note that each entry is kept to a minimum, see links for details.
1414

1515
Note: We're only listing outstanding class updates.
1616

17+
* Kernel
18+
19+
* `Kernel#inspect` now check for the existence of a `#instance_variables_to_inspect` method
20+
allowing to control which instance variables are displayed in the `#inspect` string:
21+
22+
```ruby
23+
class DatabaseConfig
24+
def initialize(host, user, password)
25+
@host = host
26+
@user = user
27+
@password = password
28+
end
29+
30+
private def instance_variables_to_inspect = [:@host, :@user]
31+
end
32+
33+
conf = DatabaseConfig.new("localhost", "root", "hunter2")
34+
conf.inspect #=> #<DatabaseConfig:0x0000000104def350 @host="localhost", @user="root">
35+
```
36+
1737
* Binding
1838

1939
* `Binding#local_variables` does no longer include numbered parameters.

common.mk

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -490,17 +490,19 @@ docs: srcs-doc $(DOCTARGETS)
490490
pkgconfig-data: $(ruby_pc)
491491
$(ruby_pc): $(srcdir)/template/ruby.pc.in config.status
492492

493+
INSTALL_ALL = all
494+
493495
install-all: pre-install-all do-install-all post-install-all
494496
pre-install-all:: all pre-install-local pre-install-ext pre-install-gem pre-install-doc
495497
do-install-all: pre-install-all $(DOT_WAIT) docs
496-
$(INSTRUBY) --make="$(MAKE)" $(INSTRUBY_ARGS) --install=all $(INSTALL_DOC_OPTS)
498+
$(INSTRUBY) --make="$(MAKE)" $(INSTRUBY_ARGS) --install=$(INSTALL_ALL) $(INSTALL_DOC_OPTS)
497499
post-install-all:: post-install-local post-install-ext post-install-gem post-install-doc
498500
@$(NULLCMD)
499501

500502
install-nodoc: pre-install-nodoc do-install-nodoc post-install-nodoc
501503
pre-install-nodoc:: pre-install-local pre-install-ext pre-install-gem
502504
do-install-nodoc: main pre-install-nodoc
503-
$(INSTRUBY) --make="$(MAKE)" $(INSTRUBY_ARGS) --install=all --exclude=doc
505+
$(INSTRUBY) --make="$(MAKE)" $(INSTRUBY_ARGS) --install=$(INSTALL_ALL) --exclude=doc
504506
post-install-nodoc:: post-install-local post-install-ext post-install-gem
505507

506508
install-local: pre-install-local do-install-local post-install-local
@@ -575,7 +577,7 @@ what-where-all: no-install-all
575577
no-install-all: pre-no-install-all dont-install-all post-no-install-all
576578
pre-no-install-all:: pre-no-install-local pre-no-install-ext pre-no-install-doc
577579
dont-install-all: $(PROGRAM)
578-
$(INSTRUBY) -n --make="$(MAKE)" $(INSTRUBY_ARGS) --install=all $(INSTALL_DOC_OPTS)
580+
$(INSTRUBY) -n --make="$(MAKE)" $(INSTRUBY_ARGS) --install=$(INSTALL_ALL) $(INSTALL_DOC_OPTS)
579581
post-no-install-all:: post-no-install-local post-no-install-ext post-no-install-doc
580582
@$(NULLCMD)
581583

ext/objspace/objspace_dump.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -817,9 +817,6 @@ shape_id_i(shape_id_t shape_id, void *data)
817817
dump_append(dc, ",\"edge_name\":");
818818
dump_append_id(dc, shape->edge_name);
819819

820-
break;
821-
case SHAPE_T_OBJECT:
822-
dump_append(dc, ", \"shape_type\":\"T_OBJECT\"");
823820
break;
824821
case SHAPE_OBJ_ID:
825822
dump_append(dc, ", \"shape_type\":\"OBJ_ID\"");

gc.c

Lines changed: 43 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ rb_gc_run_obj_finalizer(VALUE objid, long count, VALUE (*callback)(long i, void
288288
saved.finished = 0;
289289
saved.final = Qundef;
290290

291+
rb_ractor_ignore_belonging(true);
291292
EC_PUSH_TAG(ec);
292293
enum ruby_tag_type state = EC_EXEC_TAG();
293294
if (state != TAG_NONE) {
@@ -306,6 +307,7 @@ rb_gc_run_obj_finalizer(VALUE objid, long count, VALUE (*callback)(long i, void
306307
rb_check_funcall(saved.final, idCall, 1, &objid);
307308
}
308309
EC_POP_TAG();
310+
rb_ractor_ignore_belonging(false);
309311
#undef RESTORE_FINALIZER
310312
}
311313

@@ -379,19 +381,9 @@ rb_gc_set_shape(VALUE obj, uint32_t shape_id)
379381
uint32_t
380382
rb_gc_rebuild_shape(VALUE obj, size_t heap_id)
381383
{
382-
shape_id_t orig_shape_id = rb_obj_shape_id(obj);
383-
if (rb_shape_too_complex_p(orig_shape_id)) {
384-
return (uint32_t)orig_shape_id;
385-
}
386-
387-
shape_id_t initial_shape_id = rb_shape_root(heap_id);
388-
shape_id_t new_shape_id = rb_shape_traverse_from_new_root(initial_shape_id, orig_shape_id);
384+
RUBY_ASSERT(RB_TYPE_P(obj, T_OBJECT));
389385

390-
if (new_shape_id == INVALID_SHAPE_ID) {
391-
return 0;
392-
}
393-
394-
return (uint32_t)new_shape_id;
386+
return (uint32_t)rb_shape_transition_heap(obj, heap_id);
395387
}
396388

397389
void rb_vm_update_references(void *ptr);
@@ -2103,6 +2095,15 @@ rb_gc_obj_free_vm_weak_references(VALUE obj)
21032095
break;
21042096
case T_IMEMO:
21052097
switch (imemo_type(obj)) {
2098+
case imemo_callcache: {
2099+
const struct rb_callcache *cc = (const struct rb_callcache *)obj;
2100+
2101+
if (vm_cc_refinement_p(cc)) {
2102+
rb_vm_delete_cc_refinement(cc);
2103+
}
2104+
2105+
break;
2106+
}
21062107
case imemo_callinfo:
21072108
rb_vm_ci_free((const struct rb_callinfo *)obj);
21082109
break;
@@ -3937,6 +3938,23 @@ vm_weak_table_foreach_update_weak_key(st_data_t *key, st_data_t *value, st_data_
39373938
return ret;
39383939
}
39393940

3941+
static int
3942+
vm_weak_table_cc_refinement_foreach(st_data_t key, st_data_t data, int error)
3943+
{
3944+
struct global_vm_table_foreach_data *iter_data = (struct global_vm_table_foreach_data *)data;
3945+
3946+
return iter_data->callback((VALUE)key, iter_data->data);
3947+
}
3948+
3949+
static int
3950+
vm_weak_table_cc_refinement_foreach_update_update(st_data_t *key, st_data_t data, int existing)
3951+
{
3952+
struct global_vm_table_foreach_data *iter_data = (struct global_vm_table_foreach_data *)data;
3953+
3954+
return iter_data->update_callback((VALUE *)key, iter_data->data);
3955+
}
3956+
3957+
39403958
static int
39413959
vm_weak_table_str_sym_foreach(st_data_t key, st_data_t value, st_data_t data, int error)
39423960
{
@@ -4186,8 +4204,21 @@ rb_gc_vm_weak_table_foreach(vm_table_foreach_callback_func callback,
41864204
);
41874205
break;
41884206
}
4207+
case RB_GC_VM_CC_REFINEMENT_TABLE: {
4208+
if (vm->cc_refinement_table) {
4209+
set_foreach_with_replace(
4210+
vm->cc_refinement_table,
4211+
vm_weak_table_cc_refinement_foreach,
4212+
vm_weak_table_cc_refinement_foreach_update_update,
4213+
(st_data_t)&foreach_data
4214+
);
4215+
}
4216+
break;
4217+
}
41894218
case RB_GC_VM_WEAK_TABLE_COUNT:
41904219
rb_bug("Unreacheable");
4220+
default:
4221+
rb_bug("rb_gc_vm_weak_table_foreach: unknown table %d", table);
41914222
}
41924223
}
41934224

gc/gc.h

Lines changed: 54 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -31,56 +31,74 @@ enum rb_gc_vm_weak_tables {
3131
RB_GC_VM_ID2REF_TABLE,
3232
RB_GC_VM_GENERIC_FIELDS_TABLE,
3333
RB_GC_VM_FROZEN_STRINGS_TABLE,
34+
RB_GC_VM_CC_REFINEMENT_TABLE,
3435
RB_GC_VM_WEAK_TABLE_COUNT
3536
};
3637

38+
#if USE_MODULAR_GC
39+
# define MODULAR_GC_FN
40+
#else
41+
// This takes advantage of internal linkage winning when appearing first.
42+
// See C99 6.2.2p4.
43+
# define MODULAR_GC_FN static
44+
#endif
45+
46+
#if USE_MODULAR_GC
3747
RUBY_SYMBOL_EXPORT_BEGIN
38-
unsigned int rb_gc_vm_lock(void);
39-
void rb_gc_vm_unlock(unsigned int lev);
40-
unsigned int rb_gc_cr_lock(void);
41-
void rb_gc_cr_unlock(unsigned int lev);
42-
unsigned int rb_gc_vm_lock_no_barrier(void);
43-
void rb_gc_vm_unlock_no_barrier(unsigned int lev);
44-
void rb_gc_vm_barrier(void);
45-
size_t rb_gc_obj_optimal_size(VALUE obj);
46-
void rb_gc_mark_children(void *objspace, VALUE obj);
47-
void rb_gc_vm_weak_table_foreach(vm_table_foreach_callback_func callback, vm_table_update_callback_func update_callback, void *data, bool weak_only, enum rb_gc_vm_weak_tables table);
48-
void rb_gc_update_object_references(void *objspace, VALUE obj);
49-
void rb_gc_update_vm_references(void *objspace);
50-
void rb_gc_event_hook(VALUE obj, rb_event_flag_t event);
51-
void *rb_gc_get_objspace(void);
48+
#endif
49+
50+
// These functions cannot be defined as static because they are used by other
51+
// files in Ruby.
5252
size_t rb_size_mul_or_raise(size_t x, size_t y, VALUE exc);
53-
void rb_gc_run_obj_finalizer(VALUE objid, long count, VALUE (*callback)(long i, void *data), void *data);
54-
void rb_gc_set_pending_interrupt(void);
55-
void rb_gc_unset_pending_interrupt(void);
56-
void rb_gc_obj_free_vm_weak_references(VALUE obj);
57-
bool rb_gc_obj_free(void *objspace, VALUE obj);
58-
void rb_gc_save_machine_context(void);
59-
void rb_gc_mark_roots(void *objspace, const char **categoryp);
60-
void rb_gc_ractor_newobj_cache_foreach(void (*func)(void *cache, void *data), void *data);
61-
bool rb_gc_multi_ractor_p(void);
62-
void rb_objspace_reachable_objects_from_root(void (func)(const char *category, VALUE, void *), void *passing_data);
6353
void rb_objspace_reachable_objects_from(VALUE obj, void (func)(VALUE, void *), void *data);
6454
void rb_obj_info_dump(VALUE obj);
6555
const char *rb_obj_info(VALUE obj);
66-
bool rb_gc_shutdown_call_finalizer_p(VALUE obj);
67-
uint32_t rb_gc_get_shape(VALUE obj);
68-
void rb_gc_set_shape(VALUE obj, uint32_t shape_id);
69-
uint32_t rb_gc_rebuild_shape(VALUE obj, size_t heap_id);
7056
size_t rb_obj_memsize_of(VALUE obj);
71-
void rb_gc_prepare_heap_process_object(VALUE obj);
7257
bool ruby_free_at_exit_p(void);
73-
bool rb_memerror_reentered(void);
74-
bool rb_obj_id_p(VALUE);
58+
void rb_objspace_reachable_objects_from_root(void (func)(const char *category, VALUE, void *), void *passing_data);
59+
60+
MODULAR_GC_FN unsigned int rb_gc_vm_lock(void);
61+
MODULAR_GC_FN void rb_gc_vm_unlock(unsigned int lev);
62+
MODULAR_GC_FN unsigned int rb_gc_cr_lock(void);
63+
MODULAR_GC_FN void rb_gc_cr_unlock(unsigned int lev);
64+
MODULAR_GC_FN unsigned int rb_gc_vm_lock_no_barrier(void);
65+
MODULAR_GC_FN void rb_gc_vm_unlock_no_barrier(unsigned int lev);
66+
MODULAR_GC_FN void rb_gc_vm_barrier(void);
67+
MODULAR_GC_FN size_t rb_gc_obj_optimal_size(VALUE obj);
68+
MODULAR_GC_FN void rb_gc_mark_children(void *objspace, VALUE obj);
69+
MODULAR_GC_FN void rb_gc_vm_weak_table_foreach(vm_table_foreach_callback_func callback, vm_table_update_callback_func update_callback, void *data, bool weak_only, enum rb_gc_vm_weak_tables table);
70+
MODULAR_GC_FN void rb_gc_update_object_references(void *objspace, VALUE obj);
71+
MODULAR_GC_FN void rb_gc_update_vm_references(void *objspace);
72+
MODULAR_GC_FN void rb_gc_event_hook(VALUE obj, rb_event_flag_t event);
73+
MODULAR_GC_FN void *rb_gc_get_objspace(void);
74+
MODULAR_GC_FN void rb_gc_run_obj_finalizer(VALUE objid, long count, VALUE (*callback)(long i, void *data), void *data);
75+
MODULAR_GC_FN void rb_gc_set_pending_interrupt(void);
76+
MODULAR_GC_FN void rb_gc_unset_pending_interrupt(void);
77+
MODULAR_GC_FN void rb_gc_obj_free_vm_weak_references(VALUE obj);
78+
MODULAR_GC_FN bool rb_gc_obj_free(void *objspace, VALUE obj);
79+
MODULAR_GC_FN void rb_gc_save_machine_context(void);
80+
MODULAR_GC_FN void rb_gc_mark_roots(void *objspace, const char **categoryp);
81+
MODULAR_GC_FN void rb_gc_ractor_newobj_cache_foreach(void (*func)(void *cache, void *data), void *data);
82+
MODULAR_GC_FN bool rb_gc_multi_ractor_p(void);
83+
MODULAR_GC_FN bool rb_gc_shutdown_call_finalizer_p(VALUE obj);
84+
MODULAR_GC_FN uint32_t rb_gc_get_shape(VALUE obj);
85+
MODULAR_GC_FN void rb_gc_set_shape(VALUE obj, uint32_t shape_id);
86+
MODULAR_GC_FN uint32_t rb_gc_rebuild_shape(VALUE obj, size_t heap_id);
87+
MODULAR_GC_FN void rb_gc_prepare_heap_process_object(VALUE obj);
88+
MODULAR_GC_FN bool rb_memerror_reentered(void);
89+
MODULAR_GC_FN bool rb_obj_id_p(VALUE);
7590

7691
#if USE_MODULAR_GC
77-
bool rb_gc_event_hook_required_p(rb_event_flag_t event);
78-
void *rb_gc_get_ractor_newobj_cache(void);
79-
void rb_gc_initialize_vm_context(struct rb_gc_vm_context *context);
80-
void rb_gc_worker_thread_set_vm_context(struct rb_gc_vm_context *context);
81-
void rb_gc_worker_thread_unset_vm_context(struct rb_gc_vm_context *context);
92+
MODULAR_GC_FN bool rb_gc_event_hook_required_p(rb_event_flag_t event);
93+
MODULAR_GC_FN void *rb_gc_get_ractor_newobj_cache(void);
94+
MODULAR_GC_FN void rb_gc_initialize_vm_context(struct rb_gc_vm_context *context);
95+
MODULAR_GC_FN void rb_gc_worker_thread_set_vm_context(struct rb_gc_vm_context *context);
96+
MODULAR_GC_FN void rb_gc_worker_thread_unset_vm_context(struct rb_gc_vm_context *context);
8297
#endif
98+
99+
#if USE_MODULAR_GC
83100
RUBY_SYMBOL_EXPORT_END
101+
#endif
84102

85103
void rb_ractor_finish_marking(void);
86104

internal/set_table.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ size_t rb_set_table_size(const struct set_table *tbl);
3737
set_table *rb_set_init_table_with_size(set_table *tab, const struct st_hash_type *, st_index_t);
3838
#define set_init_numtable rb_set_init_numtable
3939
set_table *rb_set_init_numtable(void);
40+
#define set_init_numtable_with_size rb_set_init_numtable_with_size
41+
set_table *rb_set_init_numtable_with_size(st_index_t size);
4042
#define set_delete rb_set_delete
4143
int rb_set_delete(set_table *, st_data_t *); /* returns 0:notfound 1:deleted */
4244
#define set_insert rb_set_insert

internal/variable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ int rb_gen_fields_tbl_get(VALUE obj, ID id, struct gen_fields_tbl **fields_tbl);
5252
void rb_obj_copy_ivs_to_hash_table(VALUE obj, st_table *table);
5353
void rb_obj_init_too_complex(VALUE obj, st_table *table);
5454
void rb_evict_ivars_to_hash(VALUE obj);
55-
void rb_evict_fields_to_hash(VALUE obj);
55+
shape_id_t rb_evict_fields_to_hash(VALUE obj);
5656
VALUE rb_obj_field_get(VALUE obj, shape_id_t target_shape_id);
5757
void rb_ivar_set_internal(VALUE obj, ID id, VALUE val);
5858
void rb_obj_field_set(VALUE obj, shape_id_t target_shape_id, VALUE val);

method.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,9 @@ void rb_scope_visibility_set(rb_method_visibility_t);
254254

255255
VALUE rb_unnamed_parameters(int arity);
256256

257+
void rb_vm_insert_cc_refinement(const struct rb_callcache *cc);
258+
void rb_vm_delete_cc_refinement(const struct rb_callcache *cc);
259+
257260
void rb_clear_method_cache(VALUE klass_or_module, ID mid);
258261
void rb_clear_all_refinement_method_cache(void);
259262
void rb_invalidate_method_caches(struct rb_id_table *cm_tbl, struct rb_id_table *cc_tbl);

0 commit comments

Comments
 (0)