Ruby: include/ruby/internal/intern/gc.h File Reference

Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)

Functions
gc.h File Reference

Public APIs related to rb_mGC. More...

`#include "ruby/internal/dllexport.h"`
`#include "ruby/internal/value.h"`
`#include "ruby/backward/2/attributes.h"`

Go to the source code of this file.

## Functions
void | rb_memerror (void)
int | rb_during_gc (void)
void | rb_gc_mark_locations (const VALUE *, const VALUE *)
void | rb_mark_tbl (struct st_table *)
void | rb_mark_tbl_no_pin (struct st_table *)
void | rb_mark_set (struct st_table *)
void | rb_mark_hash (struct st_table *)
void | rb_gc_update_tbl_refs (st_table *ptr)
void | rb_gc_mark_maybe (VALUE)
void | rb_gc_mark (VALUE)
void | rb_gc_mark_movable (VALUE)
VALUE | rb_gc_location (VALUE)
void | rb_gc_force_recycle (VALUE)
void | rb_gc (void)
void | rb_gc_copy_finalizer (VALUE, VALUE)
VALUE | rb_gc_enable (void)
VALUE | rb_gc_disable (void)
VALUE | rb_gc_start (void)
VALUE | rb_define_finalizer (VALUE, VALUE)
VALUE | rb_undefine_finalizer (VALUE)
size_t | rb_gc_count (void)
size_t | rb_gc_stat (VALUE)
VALUE | rb_gc_latest_gc_info (VALUE)
void | rb_gc_adjust_memory_usage (ssize_t)

## Detailed Description

Public APIs related to rb_mGC.

Author
  Ruby developers ruby-.nosp@m.core.nosp@m.@ruby.nosp@m.-lan.nosp@m.g.org

Copyright
  This file is a part of the programming language Ruby. Permission is hereby granted, to either redistribute and/or modify this file, provided that the conditions mentioned in the file COPYING are met. Consult the file for details.

Warning
  Symbols prefixed with either `RBIMPL` or `rbimpl` are implementation details. Don't take them as canon. They could rapidly appear then vanish. The name (path) of this header file is also an implementation detail. Do not expect it to persist at the place it is now. Developers are free to move it anywhere anytime at will.

Note
  To ruby-core: remember that this header can be possibly recursively included from extension libraries written in C++. Do not expect for instance `__VA_ARGS__` is always available. We assume C99 for ruby itself but we don't assume languages of extension libraries. They could be written in C++98.

Definition in file gc.h.

## Function Documentation

## ◆ rb_define_finalizer()

VALUE rb_define_finalizer | ( | VALUE | obj,
|  | VALUE | block
| ) |  |

Definition at line 3604 of file gc.c.

## ◆ rb_during_gc()

int rb_during_gc | ( | void |  | ) |

Definition at line 9505 of file gc.c.

References during_gc, and rb_objspace.

Referenced by rb_ec_stack_overflow().

## ◆ rb_gc()

void rb_gc | ( | void |  | ) |

Definition at line 9497 of file gc.c.

References GPR_DEFAULT_REASON, and rb_objspace.

Referenced by rb_fdopen(), rb_gc_for_fd(), rb_gc_start(), rb_reg_region_copy(), and rsock_s_accept().

## ◆ rb_gc_adjust_memory_usage()

void rb_gc_adjust_memory_usage | ( | ssize_t | diff | ) |

Definition at line 11062 of file gc.c.

References MEMOP_TYPE_REALLOC, and rb_objspace.

## ◆ rb_gc_copy_finalizer()

void rb_gc_copy_finalizer | ( | VALUE | dest,
|  | VALUE | obj
| ) |  |

Definition at line 3612 of file gc.c.

References finalizer_table, FL_FINALIZE, FL_SET, FL_TEST, rb_objspace, st_insert, and st_lookup.

## ◆ rb_gc_count()

size_t rb_gc_count | ( | void |  | ) |

Definition at line 9529 of file gc.c.

References rb_objspace::count, and rb_objspace::profile.

## ◆ rb_gc_disable()

VALUE rb_gc_disable | ( | void |  | ) |

Definition at line 9925 of file gc.c.

References rb_objspace, and rb_objspace_gc_disable().

## ◆ rb_gc_enable()

VALUE rb_gc_enable | ( | void |  | ) |

Definition at line 9888 of file gc.c.

References rb_objspace, and rb_objspace_gc_enable().

## ◆ rb_gc_force_recycle()

void rb_gc_force_recycle | ( | VALUE | obj | ) |

Definition at line 7968 of file gc.c.

References CLEAR_IN_BITMAP, heap_page::flags, gc_report, GET_HEAP_MARK_BITS, GET_HEAP_MARKING_BITS, GET_HEAP_PAGE, GET_HEAP_PINNED_BITS, GET_HEAP_UNCOLLECTIBLE_BITS, GET_HEAP_WB_UNPROTECTED_BITS, is_incremental_marking, rb_objspace::mark_stack, MARKED_IN_BITMAP, rb_objspace::old_objects, rb_objspace::profile, rb_objspace, RB_VM_LOCK_ENTER, RB_VM_LOCK_LEAVE, rb_objspace::rgengc, and rb_objspace::total_freed_objects.

Referenced by rb_big_isqrt(), rb_parser_free(), and rb_str_tmp_frozen_release().

## ◆ rb_gc_latest_gc_info()

VALUE rb_gc_latest_gc_info | ( | VALUE | key | ) |

Definition at line 9634 of file gc.c.

References key, and rb_objspace.

## ◆ rb_gc_location()

VALUE rb_gc_location | ( | VALUE | value | ) |

Definition at line 9003 of file gc.c.

References BUILTIN_TYPE, GC_ASSERT, RMOVED, SPECIAL_CONST_P, T_MOVED, T_NONE, and iseq_inline_constant_cache_entry::value.

Referenced by rb_execution_context_update(), rb_fiber_update_self(), rb_iseq_update_references(), rb_raw_obj_info(), and rb_vm_update_references().

## ◆ rb_gc_mark()

void rb_gc_mark | ( | VALUE | ptr | ) |

Definition at line 6112 of file gc.c.

References ptr.

Referenced by random_mark(), rb_ast_mark(), rb_execution_context_mark(), rb_hook_list_mark(), rb_iseq_mark(), rb_iseq_mark_insn_storage(), rb_mark_end_proc(), rb_strterm_mark(), and rb_vm_mark().

## ◆ rb_gc_mark_locations()

void rb_gc_mark_locations | ( | const VALUE * | start,
|  | const VALUE * | end
| ) |  |

Definition at line 5580 of file gc.c.

References heap_page::start.

Referenced by rb_execution_context_mark().

## ◆ rb_gc_mark_maybe()

void rb_gc_mark_maybe | ( | VALUE | obj | ) |

Definition at line 5931 of file gc.c.

Referenced by rb_gvar_var_marker().

## ◆ rb_gc_mark_movable()

void rb_gc_mark_movable | ( | VALUE | ptr | ) |

Definition at line 6106 of file gc.c.

References ptr.

Referenced by rb_execution_context_mark(), rb_fiber_mark_self(), rb_gvar_val_marker(), rb_iseq_mark(), and rb_vm_mark().

## ◆ rb_gc_start()

VALUE rb_gc_start | ( | void |  | ) |

Definition at line 9490 of file gc.c.

References Qnil, and rb_gc().

## ◆ rb_gc_stat()

size_t rb_gc_stat | ( | VALUE | key | ) |

Definition at line 9853 of file gc.c.

References key, and SYMBOL_P.

## ◆ rb_gc_update_tbl_refs()

void rb_gc_update_tbl_refs | ( | st_table * | ptr | ) |

Definition at line 8850 of file gc.c.

References ptr, and rb_objspace.

Referenced by rb_vm_update_references().

## ◆ rb_mark_hash()

void rb_mark_hash | ( | struct st_table * | tbl | ) |

Definition at line 5750 of file gc.c.

## ◆ rb_mark_set()

void rb_mark_set | ( | struct st_table * | tbl | ) |

Definition at line 5686 of file gc.c.

Referenced by rb_iseq_build_from_ary().

## ◆ rb_mark_tbl()

void rb_mark_tbl | ( | struct st_table * | tbl | ) |

Definition at line 5893 of file gc.c.

Referenced by rb_vm_mark().

## ◆ rb_mark_tbl_no_pin()

void rb_mark_tbl_no_pin | ( | struct st_table * | tbl | ) |

Definition at line 5899 of file gc.c.

## ◆ rb_memerror()

void rb_memerror | ( | void |  | ) |

Definition at line 10309 of file gc.c.

References during_gc, EC_JUMP_TAG, rb_execution_context_struct::errinfo, gc_raise_tag::exc, EXIT_FAILURE, gc_enter_event_rb_memerror, nomem_error, NULL, RAISED_NOMEMORY, rb_ec_raised_clear, rb_ec_raised_p, rb_ec_raised_set, rb_objspace_of, ruby_vm_special_exception_copy(), and TAG_RAISE.

Referenced by rb_gc_unprotect_logging(), and rb_reg_start_with_p().

## ◆ rb_undefine_finalizer()

VALUE rb_undefine_finalizer | ( | VALUE | obj | ) |

Definition at line 3453 of file gc.c.

References finalizer_table, FL_FINALIZE, FL_UNSET, rb_check_frozen, rb_objspace, and st_delete.