File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -1945,4 +1945,15 @@ def rb_exception_set_message(e, mesg)
1945
1945
def rb_global_variable ( obj )
1946
1946
GLOBALLY_PRESERVED_VALUES << obj
1947
1947
end
1948
+
1949
+ GC_REGISTERED_ADDRESSES = { }
1950
+ def rb_gc_register_address ( address , obj )
1951
+ Truffle ::Interop . to_native ( address ) unless Truffle ::Interop . pointer? ( address )
1952
+ GC_REGISTERED_ADDRESSES [ address ] = obj
1953
+ end
1954
+
1955
+ def rb_gc_unregister_address ( address )
1956
+ Truffle ::Interop . to_native ( address ) unless Truffle ::Interop . pointer? ( address )
1957
+ GC_REGISTERED_ADDRESSES . delete ( address )
1958
+ end
1948
1959
end
Original file line number Diff line number Diff line change 13
13
// GC, rb_gc_*
14
14
15
15
void rb_gc_register_address (VALUE * address ) {
16
+ /* TODO: This should guard the address of the pointer, not the
17
+ object pointed to, but we haven't yet found a good way to implement
18
+ that, or a real world use case where it is required. */
19
+ polyglot_invoke (RUBY_CEXT , "rb_gc_register_address" , address , rb_tr_unwrap (* address ));
16
20
}
17
21
18
22
void rb_gc_unregister_address (VALUE * address ) {
19
- // VALUE is only ever in managed memory. So, it is already garbage collected.
23
+ polyglot_invoke ( RUBY_CEXT , "rb_gc_unregister_address" , address );
20
24
}
21
25
22
26
void rb_gc_mark (VALUE ptr ) {
You can’t perform that action at this time.
0 commit comments