From: Matt Birkholz Date: Tue, 25 Nov 2014 15:07:19 +0000 (-0700) Subject: smp: unshare: interpreter_state, dstack, current_transaction... X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=a6596d120ad68effb9c11ada3b53153ac6a5c34f;p=mit-scheme.git smp: unshare: interpreter_state, dstack, current_transaction... ...scheme_fenv, scheme_fenv_p, dstack_position, current_winding_record, interpreter_state, prim_apply_error_code, critical_section_hook, critical_section_hook_p, critical_section_name. Pulled initializations into a new initialize_processor_early function and used it in both main and the co-processors' work. --- diff --git a/src/microcode/boot.c b/src/microcode/boot.c index 555d90fe3..21f50c76f 100644 --- a/src/microcode/boot.c +++ b/src/microcode/boot.c @@ -54,15 +54,16 @@ extern SCHEME_OBJECT make_microcode_identification_vector (void); # define HOOK_ENTER_INTERPRETER(func) func () #endif +extern void initialize_processor_early (void); static void start_scheme (void); static void Enter_Interpreter (void); const char * scheme_program_name; const char * OS_Name; const char * OS_Variant; -struct obstack scratch_obstack; -struct obstack ffi_obstack; -void * initial_C_stack_pointer; +__thread struct obstack scratch_obstack; +__thread struct obstack ffi_obstack; +static void * initial_C_stack_pointer; static char * reload_saved_string; static unsigned int reload_saved_string_length; @@ -108,10 +109,8 @@ main_name (int argc, const char ** argv) #ifdef __OS2__ OS2_initialize_early (); #endif - obstack_init (&scratch_obstack); - obstack_init (&ffi_obstack); - dstack_initialize (); - transaction_initialize (); + initialize_processor_early (); + reload_saved_string = 0; reload_saved_string_length = 0; read_command_line_options (argc, argv); @@ -139,6 +138,15 @@ main_name (int argc, const char ** argv) termination_init_error (); return (0); } + +void +initialize_processor_early (void) +{ + obstack_init (&scratch_obstack); + obstack_init (&ffi_obstack); + dstack_initialize (); + transaction_initialize (); +} /* Boot Scheme */ diff --git a/src/microcode/critsec.h b/src/microcode/critsec.h index fa2b817d5..b21ea0f20 100644 --- a/src/microcode/critsec.h +++ b/src/microcode/critsec.h @@ -31,14 +31,14 @@ USA. #ifndef SCM_CRITSEC_H #define SCM_CRITSEC_H 1 -extern const char * critical_section_name; -extern bool critical_section_hook_p; -extern void (*critical_section_hook) (const char *); +extern __thread const char * critical_section_name; +extern __thread bool critical_section_hook_p; +extern __thread void (*critical_section_hook) (const char *); #define DECLARE_CRITICAL_SECTION() \ - const char * critical_section_name = 0; \ - bool critical_section_hook_p; \ - void (*critical_section_hook) (const char *) + __thread const char * critical_section_name = 0; \ + __thread bool critical_section_hook_p; \ + __thread void (*critical_section_hook) (const char *) #define ENTER_CRITICAL_SECTION(name) critical_section_name = (name) #define RENAME_CRITICAL_SECTION(name) critical_section_name = (name) diff --git a/src/microcode/dstack.h b/src/microcode/dstack.h index 319b0f2ff..24f12edd9 100644 --- a/src/microcode/dstack.h +++ b/src/microcode/dstack.h @@ -54,7 +54,7 @@ extern void dstack_alloc_and_protect initialize that space, and create an unwind protection frame that invokes `protector' when the stack is unwound. */ -extern void * dstack_position; +extern __thread void * dstack_position; /* The current stack pointer. */ extern void dstack_set_position (void * position); diff --git a/src/microcode/extern.h b/src/microcode/extern.h index 4b1435865..3df6fd8b8 100644 --- a/src/microcode/extern.h +++ b/src/microcode/extern.h @@ -187,8 +187,8 @@ extern __thread bool trapping; extern const char * scheme_program_name; extern const char * OS_Name; extern const char * OS_Variant; -extern struct obstack scratch_obstack; -extern struct obstack ffi_obstack; +extern __thread struct obstack scratch_obstack; +extern __thread struct obstack ffi_obstack; extern SCHEME_OBJECT * memory_block_start; extern SCHEME_OBJECT * memory_block_end; diff --git a/src/microcode/floenv.c b/src/microcode/floenv.c index 4bc007729..207986c07 100644 --- a/src/microcode/floenv.c +++ b/src/microcode/floenv.c @@ -56,8 +56,8 @@ typedef char fenv_t; typedef char fexcept_t; #endif -static bool scheme_fenv_p = false; -static fenv_t scheme_fenv; +static __thread bool scheme_fenv_p = false; +static __thread fenv_t scheme_fenv; static void cache_float_environment (void) diff --git a/src/microcode/interp.c b/src/microcode/interp.c index 057ce4a91..8aece778f 100644 --- a/src/microcode/interp.c +++ b/src/microcode/interp.c @@ -196,7 +196,7 @@ extern void fixup_float_environment (void); /* The EVAL/APPLY yin/yang */ -interpreter_state_t interpreter_state = NULL_INTERPRETER_STATE; +__thread interpreter_state_t interpreter_state = NULL_INTERPRETER_STATE; void bind_interpreter_state (interpreter_state_t s) @@ -250,7 +250,7 @@ abort_to_interpreter_argument (void) return (interpreter_throw_argument); } -long prim_apply_error_code; +__thread long prim_apply_error_code; void Interpret (int pop_return_p) diff --git a/src/microcode/interp.h b/src/microcode/interp.h index 3600e6dbd..283ad0045 100644 --- a/src/microcode/interp.h +++ b/src/microcode/interp.h @@ -155,8 +155,8 @@ struct interpreter_state_s extern void abort_to_interpreter (int) NORETURN; extern int abort_to_interpreter_argument (void); -extern interpreter_state_t interpreter_state; -extern long prim_apply_error_code; +extern __thread interpreter_state_t interpreter_state; +extern __thread long prim_apply_error_code; extern void bind_interpreter_state (interpreter_state_t); extern void unbind_interpreter_state (interpreter_state_t); diff --git a/src/microcode/prossmp.c b/src/microcode/prossmp.c index 1f99d547d..5cf831fd9 100644 --- a/src/microcode/prossmp.c +++ b/src/microcode/prossmp.c @@ -206,6 +206,8 @@ setup_processors (int count) RESET_HISTORY (); } +extern void initialize_processor_early (void); + static void * work (void *p) { @@ -214,6 +216,7 @@ work (void *p) trace (";%d Start.", self->id); assert (self->id != 0); assert (self != processors); + initialize_processor_early (); reset_processor_allocator (self); RESET_HISTORY (); diff --git a/src/microcode/transact.c b/src/microcode/transact.c index 4afbd6a05..c3ab6695c 100644 --- a/src/microcode/transact.c +++ b/src/microcode/transact.c @@ -46,7 +46,7 @@ struct transaction enum transaction_state state; }; -static struct transaction * current_transaction; +static __thread struct transaction * current_transaction; static void guarantee_current_transaction (const char * proc) diff --git a/src/microcode/wind.c b/src/microcode/wind.c index 65c383bbf..33f29ad12 100644 --- a/src/microcode/wind.c +++ b/src/microcode/wind.c @@ -52,9 +52,9 @@ struct winding_record void * environment; }; -static struct obstack dstack; -static struct winding_record * current_winding_record; -void * dstack_position; +static __thread struct obstack dstack; +static __thread struct winding_record * current_winding_record; +__thread void * dstack_position; void dstack_initialize (void)