[Bug #19584] [DOC] Tweek description of rb_gc_register_address
This commit is contained in:
parent
f99af43980
commit
4adcfc8cd7
12
gc.c
12
gc.c
@ -9209,10 +9209,16 @@ rb_gc_register_address(VALUE *addr)
|
|||||||
tmp->varptr = addr;
|
tmp->varptr = addr;
|
||||||
global_list = tmp;
|
global_list = tmp;
|
||||||
|
|
||||||
/* obj has to be guarded here because the allocation above could trigger a
|
/*
|
||||||
* GC. However, C extensions could pass a pointer to a global variable
|
* Because some C extensions have assignment-then-register bugs,
|
||||||
* which does not exist on the stack and thus could get swept. */
|
* we guard `obj` here so that it would not get swept defensively.
|
||||||
|
*/
|
||||||
RB_GC_GUARD(obj);
|
RB_GC_GUARD(obj);
|
||||||
|
if (0 && !SPECIAL_CONST_P(obj)) {
|
||||||
|
rb_warn("Object is assigned to registering address already: %"PRIsVALUE,
|
||||||
|
rb_obj_class(obj));
|
||||||
|
rb_print_backtrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -399,10 +399,15 @@ VALUE rb_gc_latest_gc_info(VALUE key_or_buf);
|
|||||||
void rb_gc_adjust_memory_usage(ssize_t diff);
|
void rb_gc_adjust_memory_usage(ssize_t diff);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inform the garbage collector that `valptr` points to a live Ruby object that
|
* Inform the garbage collector that the global or static variable pointed by
|
||||||
* should not be moved. Note that extensions should use this API on global
|
* `valptr` stores a live Ruby object that should not be moved. Note that
|
||||||
* constants instead of assuming constants defined in Ruby are always alive.
|
* extensions should use this API on global constants instead of assuming
|
||||||
* Ruby code can remove global constants.
|
* constants defined in Ruby are always alive. Ruby code can remove global
|
||||||
|
* constants.
|
||||||
|
*
|
||||||
|
* Because this registration itself has a possibility to trigger a GC, this
|
||||||
|
* function must be called before any GC-able objects is assigned to the
|
||||||
|
* address pointed by `valptr`.
|
||||||
*/
|
*/
|
||||||
void rb_gc_register_address(VALUE *valptr);
|
void rb_gc_register_address(VALUE *valptr);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user