Ruby  1.9.3p551(2014-11-13revision48407)
gc.h
Go to the documentation of this file.
1 
2 #ifndef RUBY_GC_H
3 #define RUBY_GC_H 1
4 
5 #if defined(__x86_64__) && defined(__GNUC__)
6 #define SET_MACHINE_STACK_END(p) __asm__ volatile ("movq\t%%rsp, %0" : "=r" (*(p)))
7 #elif defined(__i386) && defined(__GNUC__)
8 #define SET_MACHINE_STACK_END(p) __asm__ volatile ("movl\t%%esp, %0" : "=r" (*(p)))
9 #else
10 NOINLINE(void rb_gc_set_stack_end(VALUE **stack_end_p));
11 #define SET_MACHINE_STACK_END(p) rb_gc_set_stack_end(p)
12 #define USE_CONSERVATIVE_STACK_END
13 #endif
14 
15 /* for GC debug */
16 
17 #ifndef RUBY_MARK_FREE_DEBUG
18 #define RUBY_MARK_FREE_DEBUG 0
19 #endif
20 
21 #if RUBY_MARK_FREE_DEBUG
22 extern int ruby_gc_debug_indent;
23 
24 static inline void
25 rb_gc_debug_indent(void)
26 {
27  printf("%*s", ruby_gc_debug_indent, "");
28 }
29 
30 static inline void
31 rb_gc_debug_body(const char *mode, const char *msg, int st, void *ptr)
32 {
33  if (st == 0) {
34  ruby_gc_debug_indent--;
35  }
36  rb_gc_debug_indent();
37  printf("%s: %s %s (%p)\n", mode, st ? "->" : "<-", msg, ptr);
38 
39  if (st) {
40  ruby_gc_debug_indent++;
41  }
42 
43  fflush(stdout);
44 }
45 
46 #define RUBY_MARK_ENTER(msg) rb_gc_debug_body("mark", (msg), 1, ptr)
47 #define RUBY_MARK_LEAVE(msg) rb_gc_debug_body("mark", (msg), 0, ptr)
48 #define RUBY_FREE_ENTER(msg) rb_gc_debug_body("free", (msg), 1, ptr)
49 #define RUBY_FREE_LEAVE(msg) rb_gc_debug_body("free", (msg), 0, ptr)
50 #define RUBY_GC_INFO rb_gc_debug_indent(); printf
51 
52 #else
53 #define RUBY_MARK_ENTER(msg)
54 #define RUBY_MARK_LEAVE(msg)
55 #define RUBY_FREE_ENTER(msg)
56 #define RUBY_FREE_LEAVE(msg)
57 #define RUBY_GC_INFO if(0)printf
58 #endif
59 
60 #define RUBY_MARK_UNLESS_NULL(ptr) if(RTEST(ptr)){rb_gc_mark(ptr);}
61 #define RUBY_FREE_UNLESS_NULL(ptr) if(ptr){ruby_xfree(ptr);(ptr)=NULL;}
62 
63 #if STACK_GROW_DIRECTION > 0
64 # define STACK_UPPER(x, a, b) (a)
65 #elif STACK_GROW_DIRECTION < 0
66 # define STACK_UPPER(x, a, b) (b)
67 #else
69 int ruby_get_stack_grow_direction(volatile VALUE *addr);
70 # define stack_growup_p(x) ( \
71  (ruby_stack_grow_direction ? \
72  ruby_stack_grow_direction : \
73  ruby_get_stack_grow_direction(x)) > 0)
74 # define STACK_UPPER(x, a, b) (stack_growup_p(x) ? (a) : (b))
75 #endif
76 
77 #if STACK_GROW_DIRECTION
78 #define STACK_GROW_DIR_DETECTION
79 #define STACK_DIR_UPPER(a,b) STACK_UPPER(0, (a), (b))
80 #else
81 #define STACK_GROW_DIR_DETECTION VALUE stack_grow_dir_detection
82 #define STACK_DIR_UPPER(a,b) STACK_UPPER(&stack_grow_dir_detection, (a), (b))
83 #endif
84 #define IS_STACK_DIR_UPPER() STACK_DIR_UPPER(1,0)
85 
86 #if defined __GNUC__ && __GNUC__ >= 4
87 #pragma GCC visibility push(default)
88 #endif
89 
92  int (*callback)(void *start, void *end, size_t stride, void *data),
93  void *data);
94 
95 #if defined __GNUC__ && __GNUC__ >= 4
96 #pragma GCC visibility pop
97 #endif
98 
99 #endif /* RUBY_GC_H */
unsigned long VALUE
Definition: ruby.h:88
int ruby_get_stack_grow_direction(volatile VALUE *addr)
Definition: gc.c:1315
void rb_objspace_each_objects(each_obj_callback *callback, void *data)
Definition: gc.c:2789
void callback(ffi_cif *cif, void *resp, void **args, void *ctx)
Definition: closure.c:53
int ruby_stack_grow_direction
Definition: gc.c:1313
#define NOINLINE(x)
Definition: ruby.h:37
void * data
Definition: yaml2byte.c:131
static VALUE VALUE obj
Definition: tcltklib.c:3147
VALUE mode
Definition: tcltklib.c:1655
void rb_gc_set_stack_end(VALUE **stack_end_p)
Definition: thread.c:2992
return ptr
Definition: tcltklib.c:780
VALUE msg
Definition: tcltklib.c:842
gz end
Definition: zlib.c:2033
char * start
Definition: yaml2byte.c:126
int ruby_gc_debug_indent
Definition: gc.c:114
#define RUBY_EXTERN
Definition: defines.h:258
size_t rb_objspace_data_type_memsize(VALUE obj)
Definition: gc.c:1273
Tcl_Interp *int * st
Definition: stubs.c:508