-
Notifications
You must be signed in to change notification settings - Fork 186
/
Copy pathgc.c
66 lines (54 loc) · 1.88 KB
/
gc.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
* Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved. This
* code is released under a tri EPL/GPL/LGPL license. You can use it,
* redistribute it and/or modify it under the terms of the:
*
* Eclipse Public License version 2.0, or
* GNU General Public License version 2, or
* GNU Lesser General Public License version 2.1.
*/
#include <truffleruby-impl.h>
#include <internal/gc.h>
// GC, rb_gc_*
void rb_gc_register_address(VALUE *address) {
/* TODO: This should guard the address of the pointer, not the
object pointed to, but we haven't yet found a good way to implement
that, or a real world use case where it is required. */
polyglot_invoke(RUBY_CEXT, "rb_gc_register_address", address, rb_tr_unwrap(*address));
}
void rb_gc_unregister_address(VALUE *address) {
polyglot_invoke(RUBY_CEXT, "rb_gc_unregister_address", address);
}
void rb_gc_mark(VALUE ptr) {
polyglot_invoke(RUBY_CEXT, "rb_gc_mark", ptr);
}
void rb_gc_mark_maybe(VALUE ptr) {
if (!RB_TYPE_P(ptr, T_NONE)) {
polyglot_invoke(RUBY_CEXT, "rb_gc_mark", ptr);
}
}
VALUE rb_gc_enable() {
return RUBY_CEXT_INVOKE("rb_gc_enable");
}
VALUE rb_gc_disable() {
return RUBY_CEXT_INVOKE("rb_gc_disable");
}
void rb_gc(void) {
RUBY_CEXT_INVOKE_NO_WRAP("rb_gc");
}
void rb_gc_force_recycle(VALUE obj) {
// Comments in MRI imply rb_gc_force_recycle functions as a GC guard
RB_GC_GUARD(obj);
}
VALUE rb_gc_latest_gc_info(VALUE key) {
return RUBY_CEXT_INVOKE("rb_gc_latest_gc_info", key);
}
void rb_gc_register_mark_object(VALUE obj) {
RUBY_CEXT_INVOKE_NO_WRAP("rb_gc_register_mark_object", obj);
}
void rb_global_variable(VALUE *obj) {
/* TODO: This should guard the address of the pointer, not the
object pointed to, but we haven't yet found a good way to implement
that, or a real world use case where it is required. */
RUBY_CEXT_INVOKE_NO_WRAP("rb_global_variable", *obj);
}