mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* gc.c (rb_objspace_t): packed globals. [ruby-dev:34348]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15995 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
a39883b74a
commit
01f468d138
2 changed files with 72 additions and 26 deletions
|
@ -1,4 +1,6 @@
|
|||
Mon Apr 14 12:44:13 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
Mon Apr 14 12:47:02 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* gc.c (rb_objspace_t): packed globals. [ruby-dev:34348]
|
||||
|
||||
* gc.c (finalizers): removed. [ruby-dev:34349]
|
||||
|
||||
|
|
94
gc.c
94
gc.c
|
@ -84,19 +84,9 @@ void *alloca ();
|
|||
#endif
|
||||
#endif
|
||||
|
||||
static unsigned long malloc_increase = 0;
|
||||
static unsigned long malloc_limit = GC_MALLOC_LIMIT;
|
||||
static VALUE nomem_error;
|
||||
|
||||
static int dont_gc;
|
||||
static int during_gc;
|
||||
static int need_call_final = 0;
|
||||
static st_table *finalizer_table = 0;
|
||||
|
||||
#define MARK_STACK_MAX 1024
|
||||
static VALUE mark_stack[MARK_STACK_MAX];
|
||||
static VALUE *mark_stack_ptr;
|
||||
static int mark_stack_overflow;
|
||||
|
||||
int ruby_gc_debug_indent = 0;
|
||||
|
||||
|
@ -139,24 +129,83 @@ typedef struct RVALUE {
|
|||
#pragma pack(pop)
|
||||
#endif
|
||||
|
||||
static RVALUE *freelist = 0;
|
||||
static RVALUE *deferred_final_list = 0;
|
||||
|
||||
#define HEAPS_INCREMENT 10
|
||||
static struct heaps_slot {
|
||||
struct heaps_slot {
|
||||
void *membase;
|
||||
RVALUE *slot;
|
||||
int limit;
|
||||
} *heaps;
|
||||
static int heaps_length = 0;
|
||||
static int heaps_used = 0;
|
||||
};
|
||||
|
||||
#define HEAP_MIN_SLOTS 10000
|
||||
static int heap_slots = HEAP_MIN_SLOTS;
|
||||
|
||||
#define FREE_MIN 4096
|
||||
|
||||
static RVALUE *himem, *lomem;
|
||||
struct gc_list {
|
||||
VALUE *varptr;
|
||||
struct gc_list *next;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
struct {
|
||||
unsigned long limit;
|
||||
unsigned long increase;
|
||||
} params;
|
||||
struct {
|
||||
int slots;
|
||||
struct heaps_slot *ptr;
|
||||
int length;
|
||||
int used;
|
||||
RVALUE *freelist;
|
||||
RVALUE *range[2];
|
||||
} heap;
|
||||
struct {
|
||||
int dont_gc;
|
||||
int during_gc;
|
||||
} flags;
|
||||
struct {
|
||||
int need_call;
|
||||
st_table *table;
|
||||
RVALUE *deferred;
|
||||
} final;
|
||||
struct {
|
||||
VALUE buffer[MARK_STACK_MAX];
|
||||
VALUE *ptr;
|
||||
int overflow;
|
||||
} markstack;
|
||||
struct gc_list *global_list;
|
||||
} rb_objspace_t;
|
||||
|
||||
static rb_objspace_t rb_objspace = {{GC_MALLOC_LIMIT}, {HEAP_MIN_SLOTS}};
|
||||
/* #define objspace GET_VM()->objspace */
|
||||
#define malloc_limit objspace->params.limit
|
||||
#define malloc_increase objspace->params.increase
|
||||
#define heap_slots objspace->heap.slots
|
||||
#define heaps objspace->heap.ptr
|
||||
#define heaps_length objspace->heap.length
|
||||
#define heaps_used objspace->heap.used
|
||||
#define freelist objspace->heap.freelist
|
||||
#define lomem objspace->heap.range[0]
|
||||
#define himem objspace->heap.range[1]
|
||||
#define dont_gc objspace->flags.dont_gc
|
||||
#define during_gc objspace->flags.during_gc
|
||||
#define need_call_final objspace->final.need_call
|
||||
#define finalizer_table objspace->final.table
|
||||
#define deferred_final_list objspace->final.deferred
|
||||
#define mark_stack objspace->markstack.buffer
|
||||
#define mark_stack_ptr objspace->markstack.ptr
|
||||
#define mark_stack_overflow objspace->markstack.overflow
|
||||
#define global_List objspace->global_list
|
||||
|
||||
rb_objspace_t *
|
||||
rb_objspace_alloc(void)
|
||||
{
|
||||
rb_objspace_t *objspace = ALLOC(rb_objspace_t);
|
||||
memset(objspace, 0, sizeof(*objspace));
|
||||
malloc_limit = GC_MALLOC_LIMIT;
|
||||
heap_slots = HEAP_MIN_SLOTS;
|
||||
return objspace;
|
||||
}
|
||||
|
||||
#define objspace (&rb_objspace)
|
||||
|
||||
extern st_table *rb_class_tbl;
|
||||
VALUE *rb_gc_stack_start = 0;
|
||||
|
@ -371,11 +420,6 @@ rb_gc_disable(void)
|
|||
|
||||
VALUE rb_mGC;
|
||||
|
||||
static struct gc_list {
|
||||
VALUE *varptr;
|
||||
struct gc_list *next;
|
||||
} *global_List = 0;
|
||||
|
||||
void
|
||||
rb_gc_register_address(VALUE *addr)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue