Ruby 1.9.2p136(2010-12-25revision30365)

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

# gc.h

Go to the documentation of this file.

    00001
    00002 #ifndef RUBY_GC_H
    00003 #define RUBY_GC_H 1
    00004
    00005 #if defined(__x86_64__) && defined(__GNUC__)
    00006 #define SET_MACHINE_STACK_END(p) __asm__("movq\t%%rsp, %0" : "=r" (*p))
    00007 #elif defined(__i386) && defined(__GNUC__)
    00008 #define SET_MACHINE_STACK_END(p) __asm__("movl\t%%esp, %0" : "=r" (*p))
    00009 #else
    00010 NOINLINE(void rb_gc_set_stack_end(VALUE **stack_end_p));
    00011 #define SET_MACHINE_STACK_END(p) rb_gc_set_stack_end(p)
    00012 #define USE_CONSERVATIVE_STACK_END
    00013 #endif
    00014
    00015 /* for GC debug */
    00016
    00017 #ifndef RUBY_MARK_FREE_DEBUG
    00018 #define RUBY_MARK_FREE_DEBUG 0
    00019 #endif
    00020
    00021 #if RUBY_MARK_FREE_DEBUG
    00022 extern int ruby_gc_debug_indent;
    00023
    00024 static void
    00025 rb_gc_debug_indent(void)
    00026 {
    00027     printf("%*s", ruby_gc_debug_indent, "");
    00028 }
    00029
    00030 static void
    00031 rb_gc_debug_body(const char *mode, const char *msg, int st, void *ptr)
    00032 {
    00033     if (st == 0) {
    00034         ruby_gc_debug_indent--;
    00035     }
    00036     rb_gc_debug_indent();
    00037     printf("%s: %s %s (%p)\n", mode, st ? "->" : "<-", msg, ptr);
    00038
    00039     if (st) {
    00040         ruby_gc_debug_indent++;
    00041     }
    00042
    00043     fflush(stdout);
    00044 }
    00045
    00046 #define RUBY_MARK_ENTER(msg) rb_gc_debug_body("mark", msg, 1, ptr)
    00047 #define RUBY_MARK_LEAVE(msg) rb_gc_debug_body("mark", msg, 0, ptr)
    00048 #define RUBY_FREE_ENTER(msg) rb_gc_debug_body("free", msg, 1, ptr)
    00049 #define RUBY_FREE_LEAVE(msg) rb_gc_debug_body("free", msg, 0, ptr)
    00050 #define RUBY_GC_INFO         rb_gc_debug_indent(); printf
    00051
    00052 #else
    00053 #define RUBY_MARK_ENTER(msg)
    00054 #define RUBY_MARK_LEAVE(msg)
    00055 #define RUBY_FREE_ENTER(msg)
    00056 #define RUBY_FREE_LEAVE(msg)
    00057 #define RUBY_GC_INFO if(0)printf
    00058 #endif
    00059
    00060 #define RUBY_MARK_UNLESS_NULL(ptr) if(RTEST(ptr)){rb_gc_mark(ptr);}
    00061 #define RUBY_FREE_UNLESS_NULL(ptr) if(ptr){ruby_xfree(ptr);}
    00062
    00063 #if STACK_GROW_DIRECTION > 0
    00064 # define STACK_UPPER(x, a, b) a
    00065 #elif STACK_GROW_DIRECTION < 0
    00066 # define STACK_UPPER(x, a, b) b
    00067 #else
    00068 RUBY_EXTERN int ruby_stack_grow_direction;
    00069 int ruby_get_stack_grow_direction(volatile VALUE *addr);
    00070 # define stack_growup_p(x) (                    \
    00071         (ruby_stack_grow_direction ?            \
    00072          ruby_stack_grow_direction :            \
    00073          ruby_get_stack_grow_direction(x)) > 0)
    00074 # define STACK_UPPER(x, a, b) (stack_growup_p(x) ? a : b)
    00075 #endif
    00076
    00077 #endif /* RUBY_GC_H */
    00078