THREAD_LOCAL 3m
svn: r12278
This commit is contained in:
parent
94fd055498
commit
498a7cd75b
|
@ -10,6 +10,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "platforms.h"
|
||||
#include "gc2.h"
|
||||
|
||||
#define NUMBER_OF_TAGS 512
|
||||
|
@ -160,7 +161,7 @@ unsigned long (*GC_get_thread_stack_base)(void);
|
|||
void (*GC_mark_xtagged)(void *obj);
|
||||
void (*GC_fixup_xtagged)(void *obj);
|
||||
|
||||
void **GC_variable_stack;
|
||||
THREAD_LOCAL void **GC_variable_stack;
|
||||
|
||||
void **GC_get_variable_stack() { return GC_variable_stack; }
|
||||
void GC_set_variable_stack(void **p) { GC_variable_stack = p; }
|
||||
|
|
|
@ -262,7 +262,7 @@ GC2_EXTERN void GC_finalization_weak_ptr(void **p, int offset);
|
|||
/* Cooperative GC */
|
||||
/***************************************************************************/
|
||||
|
||||
GC2_EXTERN void **GC_variable_stack;
|
||||
GC2_EXTERN THREAD_LOCAL void **GC_variable_stack;
|
||||
/*
|
||||
See the general overview in README. */
|
||||
|
||||
|
|
|
@ -354,8 +354,8 @@ int GC_is_allocated(void *p)
|
|||
The size count helps us trigger collection quickly when we're running out of space; see
|
||||
the test in allocate_big.
|
||||
*/
|
||||
unsigned long GC_gen0_alloc_page_ptr = 0;
|
||||
unsigned long GC_gen0_alloc_page_end = 0;
|
||||
THREAD_LOCAL unsigned long GC_gen0_alloc_page_ptr = 0;
|
||||
THREAD_LOCAL unsigned long GC_gen0_alloc_page_end = 0;
|
||||
|
||||
/* miscellaneous variables */
|
||||
static const char *zero_sized[4]; /* all 0-sized allocs get this */
|
||||
|
@ -888,7 +888,7 @@ static void *get_backtrace(struct mpage *page, void *ptr)
|
|||
/* With the exception of the "traverse" macro and resultant simplification, */
|
||||
/* this code is entirely lifted from compact.c */
|
||||
/*****************************************************************************/
|
||||
void **GC_variable_stack;
|
||||
THREAD_LOCAL void **GC_variable_stack;
|
||||
|
||||
void **GC_get_variable_stack()
|
||||
{
|
||||
|
@ -1155,7 +1155,7 @@ typedef struct MarkSegment {
|
|||
void **stop_here; /* this is only used for its address */
|
||||
} MarkSegment;
|
||||
|
||||
static MarkSegment *mark_stack = NULL;
|
||||
static THREAD_LOCAL MarkSegment *mark_stack = NULL;
|
||||
|
||||
inline static MarkSegment* mark_stack_create_frame() {
|
||||
MarkSegment *mark_frame = (MarkSegment*)malloc(STACK_PART_SIZE);
|
||||
|
@ -1188,7 +1188,7 @@ inline static void push_ptr(void *ptr)
|
|||
}
|
||||
}
|
||||
|
||||
/* at this point, we're guaranteed to be good to push a pointers */
|
||||
/* at this point, we're guaranteed to be good to push pointers */
|
||||
*(mark_stack->top++) = ptr;
|
||||
}
|
||||
|
||||
|
@ -1199,8 +1199,7 @@ inline static int pop_ptr(void **ptr)
|
|||
/* if there is a previous page, go to it */
|
||||
mark_stack = mark_stack->prev;
|
||||
} else {
|
||||
/* if there isn't a previous page, then we've hit the bottom of the
|
||||
stack */
|
||||
/* if there isn't a previous page, then we've hit the bottom of the stack */
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -2497,16 +2496,15 @@ static void garbage_collect(int force_full)
|
|||
|
||||
while(gc->run_queue) {
|
||||
struct finalizer *f;
|
||||
void **gcs;
|
||||
void **saved_gc_variable_stack;
|
||||
|
||||
f = gc->run_queue; gc->run_queue = gc->run_queue->next;
|
||||
if(!gc->run_queue) gc->last_in_queue = NULL;
|
||||
|
||||
GCDEBUG((DEBUGOUTF, "Running finalizers %p for pointer %p (lvl %i)\n",
|
||||
f, f->p, f->eager_level));
|
||||
gcs = GC_variable_stack;
|
||||
GCDEBUG((DEBUGOUTF, "Running finalizers %p for pointer %p (lvl %i)\n", f, f->p, f->eager_level));
|
||||
saved_gc_variable_stack = GC_variable_stack;
|
||||
f->f(f->p, f->data);
|
||||
GC_variable_stack = gcs;
|
||||
GC_variable_stack = saved_gc_variable_stack;
|
||||
}
|
||||
run_account_hooks();
|
||||
running_finalizers = 0;
|
||||
|
|
|
@ -66,7 +66,6 @@ typedef struct Gen0 {
|
|||
struct mpage *curr_alloc_page;
|
||||
struct mpage *pages;
|
||||
struct mpage *big_pages;
|
||||
unsigned long GC_gen0_alloc_page_ptr;
|
||||
unsigned long current_size;
|
||||
unsigned long max_size;
|
||||
} Gen0;
|
||||
|
|
|
@ -21,3 +21,14 @@
|
|||
#ifndef GC_ALIGN_EIGHT
|
||||
# define GC_ALIGN_EIGHT
|
||||
#endif
|
||||
|
||||
#ifdef MZ_USE_PLACES
|
||||
# if _MSC_VER
|
||||
# define THREAD_LOCAL __declspec(thread)
|
||||
# else
|
||||
# define THREAD_LOCAL __thread
|
||||
# endif
|
||||
#else
|
||||
# define THREAD_LOCAL /* empty */
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1094,7 +1094,7 @@ static void _jit_prolog_again(mz_jit_state *jitter, int n, int ret_addr_reg)
|
|||
#endif
|
||||
|
||||
#ifdef CAN_INLINE_ALLOC
|
||||
extern unsigned long GC_gen0_alloc_page_ptr;
|
||||
extern THREAD_LOCAL unsigned long GC_gen0_alloc_page_ptr;
|
||||
long GC_initial_word(int sizeb);
|
||||
long GC_compute_alloc_size(long sizeb);
|
||||
long GC_alloc_alignment(void);
|
||||
|
|
|
@ -399,7 +399,7 @@ MZ_EXTERN void scheme_gc_ptr_ok(void *p);
|
|||
MZ_EXTERN void scheme_collect_garbage(void);
|
||||
|
||||
#ifdef MZ_PRECISE_GC
|
||||
MZ_EXTERN void **GC_variable_stack;
|
||||
MZ_EXTERN THREAD_LOCAL void **GC_variable_stack;
|
||||
MZ_EXTERN void GC_register_traversers(short tag, Size_Proc size, Mark_Proc mark, Fixup_Proc fixup,
|
||||
int is_constant_size, int is_atomic);
|
||||
MZ_EXTERN void *GC_resolve(void *p);
|
||||
|
|
Loading…
Reference in New Issue
Block a user