mirror of
https://github.com/ruby/ruby.git
synced 2026-08-01 02:20:48 +08:00
Implement callcache using declare weak references
This commit is contained in:
parent
a7ef2a9b0c
commit
ade779b1e1
Notes:
git
2025-12-25 14:19:00 +00:00
11
gc.c
11
gc.c
@ -1209,6 +1209,17 @@ rb_gc_handle_weak_references(VALUE obj)
|
||||
rb_bug("rb_gc_handle_weak_references: unknown T_DATA");
|
||||
}
|
||||
break;
|
||||
|
||||
case T_IMEMO: {
|
||||
GC_ASSERT(imemo_type(obj) == imemo_callcache);
|
||||
|
||||
struct rb_callcache *cc = (struct rb_callcache *)obj;
|
||||
if (!rb_gc_handle_weak_references_alive_p(cc->klass)) {
|
||||
vm_cc_invalidate(cc);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
rb_bug("rb_gc_handle_weak_references: type not supported\n");
|
||||
}
|
||||
|
||||
1
imemo.c
1
imemo.c
@ -372,7 +372,6 @@ rb_imemo_mark_and_move(VALUE obj, bool reference_updating)
|
||||
RUBY_ASSERT(RB_TYPE_P(cc->klass, T_CLASS) || RB_TYPE_P(cc->klass, T_ICLASS));
|
||||
RUBY_ASSERT(IMEMO_TYPE_P((VALUE)cc->cme_, imemo_ment));
|
||||
|
||||
rb_gc_mark_weak((VALUE *)&cc->klass);
|
||||
if ((vm_cc_super_p(cc) || vm_cc_refinement_p(cc))) {
|
||||
rb_gc_mark_movable((VALUE)cc->cme_);
|
||||
}
|
||||
|
||||
@ -342,6 +342,8 @@ vm_cc_new(VALUE klass,
|
||||
{
|
||||
cc_check_class(klass);
|
||||
struct rb_callcache *cc = SHAREABLE_IMEMO_NEW(struct rb_callcache, imemo_callcache, klass);
|
||||
rb_gc_declare_weak_references((VALUE)cc);
|
||||
|
||||
*((struct rb_callable_method_entry_struct **)&cc->cme_) = (struct rb_callable_method_entry_struct *)cme;
|
||||
*((vm_call_handler *)&cc->call_) = call;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user