mruby 3.3.0
mruby is the lightweight implementation of the Ruby language
Loading...
Searching...
No Matches
gc.h
Go to the documentation of this file.
1
7#ifndef MRUBY_GC_H
8#define MRUBY_GC_H
9
10#include "common.h"
11
16
17
18struct mrb_state;
19
20#define MRB_EACH_OBJ_OK 0
21#define MRB_EACH_OBJ_BREAK 1
22typedef int (mrb_each_object_callback)(struct mrb_state *mrb, struct RBasic *obj, void *data);
23void mrb_objspace_each_objects(struct mrb_state *mrb, mrb_each_object_callback *callback, void *data);
24size_t mrb_objspace_page_slot_size(void);
25MRB_API void mrb_free_context(struct mrb_state *mrb, struct mrb_context *c);
26
27#ifndef MRB_GC_ARENA_SIZE
28#define MRB_GC_ARENA_SIZE 100
29#endif
30
31typedef enum {
32 MRB_GC_STATE_ROOT = 0,
33 MRB_GC_STATE_MARK,
34 MRB_GC_STATE_SWEEP
35} mrb_gc_state;
36
37/* Disable MSVC warning "C4200: nonstandard extension used: zero-sized array
38 * in struct/union" when in C++ mode */
39#ifdef _MSC_VER
40#pragma warning(push)
41#pragma warning(disable : 4200)
42#endif
43
44#ifdef _MSC_VER
45#pragma warning(pop)
46#endif
47
48typedef struct mrb_gc {
49 struct mrb_heap_page *heaps; /* all heaps pages */
50 struct mrb_heap_page *free_heaps;/* heaps for allocation */
51 struct mrb_heap_page *sweeps; /* page where sweep starts */
52 struct RBasic *gray_list; /* list of gray objects to be traversed incrementally */
53 struct RBasic *atomic_gray_list; /* list of objects to be traversed atomically */
54 size_t live; /* count of live objects */
55 size_t live_after_mark; /* old generation objects */
56 size_t threshold; /* threshold to start GC */
57 size_t oldgen_threshold; /* threshold to kick major GC */
58 mrb_gc_state state; /* current state of gc */
59 int interval_ratio;
60 int step_ratio;
61 int current_white_part :2; /* make white object by white_part */
62 mrb_bool iterating :1; /* currently iterating over objects */
63 mrb_bool disabled :1; /* GC disabled */
64 mrb_bool generational :1; /* generational GC mode */
65 mrb_bool full :1; /* major GC mode */
66 mrb_bool out_of_memory :1; /* out-of-memory error occurred */
67
68#ifdef MRB_GC_FIXED_ARENA
69 struct RBasic *arena[MRB_GC_ARENA_SIZE]; /* GC protection array */
70#else
71 struct RBasic **arena; /* GC protection array */
72 int arena_capa; /* size of protection array */
73#endif
74 int arena_idx;
75} mrb_gc;
76
77MRB_API mrb_bool mrb_object_dead_p(struct mrb_state *mrb, struct RBasic *object);
78
79#define MRB_GC_RED 7
80
82
83#endif /* MRUBY_GC_H */
mruby Boolean.
mruby common platform definition"
#define MRB_END_DECL
End declarations in C mode.
Definition common.h:28
#define MRB_BEGIN_DECL
Start declarations in C mode.
Definition common.h:26
#define MRB_API
Declare a public mruby API function.
Definition common.h:79
Definition object.h:19
Definition mruby.h:199
Definition gc.h:48
Definition gc.c:151
Definition mruby.h:256