diff --git a/src/mzscheme/gc2/compact.c b/src/mzscheme/gc2/compact.c index bc07267df0..9a8e94225e 100644 --- a/src/mzscheme/gc2/compact.c +++ b/src/mzscheme/gc2/compact.c @@ -4646,11 +4646,13 @@ static void check_not_freed(MPage *page, const void *p) static long dump_info_array[BIGBLOCK_MIN_SIZE]; #if KEEP_BACKPOINTERS -# define MAX_FOUND_OBJECTS 500 +# define MAX_FOUND_OBJECTS 5000 +int GC_show_trace = 0; int GC_trace_for_tag = 57; int GC_path_length_limit = 1000; static int found_object_count; static void *found_objects[MAX_FOUND_OBJECTS]; +void (*GC_for_each_found)(void *p) = NULL; #endif static long scan_tagged_mpage(void **p, MPage *page) @@ -4688,8 +4690,12 @@ static long scan_tagged_mpage(void **p, MPage *page) dump_info_array[tag + _num_tags_] += size; #if KEEP_BACKPOINTERS - if (tag == GC_trace_for_tag && (found_object_count < MAX_FOUND_OBJECTS)) { - found_objects[found_object_count++] = p; + if (tag == GC_trace_for_tag) { + if (found_object_count < MAX_FOUND_OBJECTS) { + found_objects[found_object_count++] = p; + } + if (GC_for_each_found) + GC_for_each_found(p); } #endif @@ -4805,6 +4811,8 @@ void GC_dump(void) #if KEEP_BACKPOINTERS found_object_count = 0; + if (GC_for_each_found) + avoid_collection++; #endif GCPRINT(GCOUTF, "t=tagged a=atomic v=array x=xtagged g=tagarray\n"); @@ -4947,9 +4955,11 @@ void GC_dump(void) && (page->type == kind) && (((GC_trace_for_tag >= (BIGBLOCK_MIN_SIZE >> LOG_WORD_SIZE)) && (page->u.size > GC_trace_for_tag)) - || (page->u.size == -GC_trace_for_tag)) - && (found_object_count < MAX_FOUND_OBJECTS)) { - found_objects[found_object_count++] = page->block_start; + || (page->u.size == -GC_trace_for_tag))) { + if (found_object_count < MAX_FOUND_OBJECTS) + found_objects[found_object_count++] = page->block_start; + if (GC_for_each_found) + GC_for_each_found(page->block_start); } #endif } @@ -5038,20 +5048,24 @@ void GC_dump(void) (100.0 * ((double)page_reservations - memory_in_use)) / memory_in_use); #if KEEP_BACKPOINTERS - avoid_collection++; - GCPRINT(GCOUTF, "Begin Trace\n"); - for (i = 0; i < found_object_count; i++) { - void *p; - int limit = GC_path_length_limit; - p = found_objects[i]; - p = print_out_pointer("==* ", p); - while (p && limit) { - p = print_out_pointer(" <- ", p); - limit--; + if (GC_show_trace) { + avoid_collection++; + GCPRINT(GCOUTF, "Begin Trace\n"); + for (i = 0; i < found_object_count; i++) { + void *p; + int limit = GC_path_length_limit; + p = found_objects[i]; + p = print_out_pointer("==* ", p); + while (p && limit) { + p = print_out_pointer(" <- ", p); + limit--; + } } + GCPRINT(GCOUTF, "End Trace\n"); + GC_trace_for_tag = 57; + --avoid_collection; } - GCPRINT(GCOUTF, "End Trace\n"); - GC_trace_for_tag = 57; - --avoid_collection; + if (GC_for_each_found) + avoid_collection++; #endif } diff --git a/src/mzscheme/src/hash.c b/src/mzscheme/src/hash.c index 550e05ee01..59594aeec7 100644 --- a/src/mzscheme/src/hash.c +++ b/src/mzscheme/src/hash.c @@ -823,6 +823,7 @@ void scheme_init_hash_key_procs(void) PROC(scheme_namespace_type, hash_general); PROC(scheme_config_type, hash_general); PROC(scheme_thread_cell_type, hash_general); + PROC(scheme_thread_cell_values_type, hash_general); PROC(scheme_will_executor_type, hash_general); PROC(scheme_stx_type, hash_general); PROC(scheme_module_index_type, hash_general); diff --git a/src/mzscheme/src/mzmark.c b/src/mzscheme/src/mzmark.c index 848614e531..314ccbed21 100644 --- a/src/mzscheme/src/mzmark.c +++ b/src/mzscheme/src/mzmark.c @@ -3582,6 +3582,32 @@ int mark_thread_set_FIXUP(void *p) { #define mark_thread_set_IS_CONST_SIZE 1 +int mark_thread_cell_SIZE(void *p) { + return + gcBYTES_TO_WORDS(sizeof(Thread_Cell)); +} + +int mark_thread_cell_MARK(void *p) { + Thread_Cell *c = (Thread_Cell *)p; + + gcMARK(c->def_val); + + return + gcBYTES_TO_WORDS(sizeof(Thread_Cell)); +} + +int mark_thread_cell_FIXUP(void *p) { + Thread_Cell *c = (Thread_Cell *)p; + + gcFIXUP(c->def_val); + + return + gcBYTES_TO_WORDS(sizeof(Thread_Cell)); +} + +#define mark_thread_cell_IS_ATOMIC 0 +#define mark_thread_cell_IS_CONST_SIZE 1 + #endif /* THREAD */ diff --git a/src/mzscheme/src/mzmarksrc.c b/src/mzscheme/src/mzmarksrc.c index 60a1239468..1c14fd792d 100644 --- a/src/mzscheme/src/mzmarksrc.c +++ b/src/mzscheme/src/mzmarksrc.c @@ -1434,6 +1434,15 @@ mark_thread_set { gcBYTES_TO_WORDS(sizeof(Scheme_Thread_Set)); } +mark_thread_cell { + mark: + Thread_Cell *c = (Thread_Cell *)p; + + gcMARK(c->def_val); + + size: + gcBYTES_TO_WORDS(sizeof(Thread_Cell)); +} END thread; diff --git a/src/mzscheme/src/port.c b/src/mzscheme/src/port.c index 4942e5a2f3..ee695dea38 100644 --- a/src/mzscheme/src/port.c +++ b/src/mzscheme/src/port.c @@ -7298,21 +7298,22 @@ static Scheme_Object *sch_shell_execute(int c, Scheme_Object *argv[]) scheme_wrong_type("shell-execute", SCHEME_PATH_STRING_STR, 3, c, argv); { show = 0; -# define mzseCMP(id) \ - if (SAME_OBJ(scheme_intern_symbol(# id), argv[4])) \ +# define mzseCMP(id, str) \ + if (SAME_OBJ(scheme_intern_symbol(str), argv[4]) \ + SAME_OBJ(scheme_intern_symbol(# id), argv[4])) \ show = mzseSHOW(id) - mzseCMP(SW_HIDE); - mzseCMP(SW_MAXIMIZE); - mzseCMP(SW_MINIMIZE); - mzseCMP(SW_RESTORE); - mzseCMP(SW_SHOW); - mzseCMP(SW_SHOWDEFAULT); - mzseCMP(SW_SHOWMAXIMIZED); - mzseCMP(SW_SHOWMINIMIZED); - mzseCMP(SW_SHOWMINNOACTIVE); - mzseCMP(SW_SHOWNA); - mzseCMP(SW_SHOWNOACTIVATE); - mzseCMP(SW_SHOWNORMAL); + mzseCMP(SW_HIDE, "sw_hide"); + mzseCMP(SW_MAXIMIZE, "sw_maximize"); + mzseCMP(SW_MINIMIZE, "sw_minimize"); + mzseCMP(SW_RESTORE, "sw_restore"); + mzseCMP(SW_SHOW, "sw_show"); + mzseCMP(SW_SHOWDEFAULT, "sw_showdefault"); + mzseCMP(SW_SHOWMAXIMIZED, "sw_showmaximized"); + mzseCMP(SW_SHOWMINIMIZED, "sw_showminimized"); + mzseCMP(SW_SHOWMINNOACTIVE, "sw_showminnoactive"); + mzseCMP(SW_SHOWNA, "sw_showna"); + mzseCMP(SW_SHOWNOACTIVATE, "sw_shownoactivate"); + mzseCMP(SW_SHOWNORMAL, "sw_shownormal"); if (!show) scheme_wrong_type("shell-execute", "show-mode symbol", 4, c, argv); diff --git a/src/mzscheme/src/salloc.c b/src/mzscheme/src/salloc.c index 37518d8d59..3e884f5a2f 100644 --- a/src/mzscheme/src/salloc.c +++ b/src/mzscheme/src/salloc.c @@ -930,8 +930,16 @@ static void count_managed(Scheme_Custodian *m, int *c, int *a, int *u, int *t, #endif #if MZ_PRECISE_GC_TRACE +extern int GC_show_trace; extern int GC_trace_for_tag; extern int GC_path_length_limit; +extern void (*GC_for_each_found)(void *p); + +static Scheme_Object *cons_accum_result; +static void cons_onto_list(void *p) +{ + cons_accum_result = scheme_make_pair((Scheme_Object *)p, cons_accum_result); +} #endif #if defined(USE_TAGGED_ALLOCATION) || MZ_PRECISE_GC_TRACE @@ -978,7 +986,8 @@ void scheme_print_tagged_value(const char *prefix, if (!xtagged) { type = scheme_write_to_string_w_max((Scheme_Object *)v, &len, max_w); - if (!scheme_strncmp(type, "#') || (type[8] == ':'))) { char buffer[256]; char *run, *sus, *kill, *clean, *deq, *all, *t2; int state = ((Scheme_Thread *)v)->running, len2; @@ -1316,6 +1325,9 @@ Scheme_Object *scheme_dump_gc_stats(int c, Scheme_Object *p[]) # if MZ_PRECISE_GC_TRACE GC_trace_for_tag = -1; + GC_show_trace = 0; + GC_for_each_found = NULL; + cons_accum_result = scheme_void; if (c && SCHEME_SYMBOLP(p[0])) { Scheme_Object *sym; char *s; @@ -1331,15 +1343,21 @@ Scheme_Object *scheme_dump_gc_stats(int c, Scheme_Object *p[]) tn = scheme_get_type_name(i); if (tn && !strcmp(tn, s)) { GC_trace_for_tag = i; + GC_show_trace = 1; break; } } } else if (SCHEME_INTP(p[0])) { GC_trace_for_tag = SCHEME_INT_VAL(p[0]); + GC_show_trace = 1; } if ((c > 1) && SCHEME_INTP(p[1])) GC_path_length_limit = SCHEME_INT_VAL(p[1]); - else + else if ((c > 1) && SCHEME_SYMBOLP(p[1]) && !strcmp("cons", SCHEME_SYM_VAL(p[1]))) { + GC_for_each_found = cons_onto_list; + cons_accum_result = scheme_null; + GC_show_trace = 0; + } else GC_path_length_limit = 1000; #endif @@ -1420,7 +1438,11 @@ Scheme_Object *scheme_dump_gc_stats(int c, Scheme_Object *p[]) scheme_console_printf(" (dump-memory-stats num) - prints paths to objects with tag num.\n"); scheme_console_printf(" (dump-memory-stats -num) - prints paths to objects of size num.\n"); scheme_console_printf(" (dump-memory-stats sym/num len) - limits path to size len.\n"); + scheme_console_printf(" (dump-memory-stats sym/num 'cons) - builds list instead of showing paths.\n"); scheme_console_printf("End Help\n"); + + result = cons_accum_result; + cons_accum_result = scheme_void; # endif scheme_console_printf("End Dump\n"); diff --git a/src/mzscheme/src/schminc.h b/src/mzscheme/src/schminc.h index 3e3ea1a885..8a9fd1fffe 100644 --- a/src/mzscheme/src/schminc.h +++ b/src/mzscheme/src/schminc.h @@ -11,9 +11,9 @@ EXPECTED_PRIM_COUNT to the new value, and then USE_COMPILED_STARTUP can be set to 1 again. */ -#define USE_COMPILED_STARTUP 1 +#define USE_COMPILED_STARTUP 0 -#define EXPECTED_PRIM_COUNT 837 +#define EXPECTED_PRIM_COUNT 838 #ifdef MZSCHEME_SOMETHING_OMITTED # undef USE_COMPILED_STARTUP diff --git a/src/mzscheme/src/schvers.h b/src/mzscheme/src/schvers.h index c16bebdff5..2629181c15 100644 --- a/src/mzscheme/src/schvers.h +++ b/src/mzscheme/src/schvers.h @@ -9,6 +9,6 @@ #define MZSCHEME_VERSION_MAJOR 299 -#define MZSCHEME_VERSION_MINOR 401 +#define MZSCHEME_VERSION_MINOR 402 -#define MZSCHEME_VERSION "299.401" _MZ_SPECIAL_TAG +#define MZSCHEME_VERSION "299.402" _MZ_SPECIAL_TAG diff --git a/src/mzscheme/src/stypes.h b/src/mzscheme/src/stypes.h index ab842c29ad..b0f410b90b 100644 --- a/src/mzscheme/src/stypes.h +++ b/src/mzscheme/src/stypes.h @@ -144,66 +144,67 @@ enum { scheme_readtable_type, /* 126 */ scheme_intdef_context_type, /* 127 */ scheme_lexical_rib_type, /* 128 */ + scheme_thread_cell_values_type, /* 129 */ #ifdef MZTAG_REQUIRED - _scheme_last_normal_type_, /* 129 */ + _scheme_last_normal_type_, /* 130 */ - scheme_rt_comp_env, /* 130 */ - scheme_rt_constant_binding, /* 131 */ - scheme_rt_resolve_info, /* 132 */ - scheme_rt_compile_info, /* 133 */ - scheme_rt_cont_mark, /* 134 */ - scheme_rt_saved_stack, /* 135 */ - scheme_rt_reply_item, /* 136 */ - scheme_rt_closure_info, /* 137 */ - scheme_rt_overflow, /* 138 */ - scheme_rt_dyn_wind_cell, /* 139 */ - scheme_rt_cont_mark_chain, /* 140 */ - scheme_rt_dyn_wind_info, /* 141 */ - scheme_rt_dyn_wind, /* 142 */ - scheme_rt_dup_check, /* 143 */ - scheme_rt_thread_memory, /* 144 */ - scheme_rt_input_file, /* 145 */ - scheme_rt_input_fd, /* 146 */ - scheme_rt_oskit_console_input, /* 147 */ - scheme_rt_tested_input_file, /* 148 */ - scheme_rt_tested_output_file, /* 149 */ - scheme_rt_indexed_string, /* 150 */ - scheme_rt_output_file, /* 151 */ - scheme_rt_load_handler_data, /* 152 */ - scheme_rt_pipe, /* 153 */ - scheme_rt_beos_process, /* 154 */ - scheme_rt_system_child, /* 155 */ - scheme_rt_tcp, /* 156 */ - scheme_rt_write_data, /* 157 */ - scheme_rt_tcp_select_info, /* 158 */ - scheme_rt_namespace_option, /* 159 */ - scheme_rt_param_data, /* 160 */ - scheme_rt_will, /* 161 */ - scheme_rt_will_registration, /* 162 */ - scheme_rt_struct_proc_info, /* 163 */ - scheme_rt_linker_name, /* 164 */ - scheme_rt_param_map, /* 165 */ - scheme_rt_finalization, /* 166 */ - scheme_rt_finalizations, /* 167 */ - scheme_rt_cpp_object, /* 168 */ - scheme_rt_cpp_array_object, /* 169 */ - scheme_rt_stack_object, /* 170 */ - scheme_rt_preallocated_object, /* 171 */ - scheme_thread_hop_type, /* 172 */ - scheme_rt_srcloc, /* 173 */ - scheme_rt_evt, /* 174 */ - scheme_rt_syncing, /* 175 */ - scheme_rt_comp_prefix, /* 176 */ - scheme_rt_user_input, /* 177 */ - scheme_rt_user_output, /* 178 */ - scheme_rt_compact_port, /* 179 */ - scheme_rt_read_special_dw, /* 180 */ - scheme_rt_regwork, /* 181 */ - scheme_rt_buf_holder, /* 182 */ - scheme_rt_parameterization, /* 183 */ - scheme_rt_print_params, /* 184 */ - scheme_rt_read_params, /* 185 */ + scheme_rt_comp_env, /* 131 */ + scheme_rt_constant_binding, /* 132 */ + scheme_rt_resolve_info, /* 133 */ + scheme_rt_compile_info, /* 134 */ + scheme_rt_cont_mark, /* 135 */ + scheme_rt_saved_stack, /* 136 */ + scheme_rt_reply_item, /* 137 */ + scheme_rt_closure_info, /* 138 */ + scheme_rt_overflow, /* 139 */ + scheme_rt_dyn_wind_cell, /* 140 */ + scheme_rt_cont_mark_chain, /* 141 */ + scheme_rt_dyn_wind_info, /* 142 */ + scheme_rt_dyn_wind, /* 143 */ + scheme_rt_dup_check, /* 144 */ + scheme_rt_thread_memory, /* 145 */ + scheme_rt_input_file, /* 146 */ + scheme_rt_input_fd, /* 147 */ + scheme_rt_oskit_console_input, /* 148 */ + scheme_rt_tested_input_file, /* 149 */ + scheme_rt_tested_output_file, /* 150 */ + scheme_rt_indexed_string, /* 151 */ + scheme_rt_output_file, /* 152 */ + scheme_rt_load_handler_data, /* 153 */ + scheme_rt_pipe, /* 154 */ + scheme_rt_beos_process, /* 155 */ + scheme_rt_system_child, /* 156 */ + scheme_rt_tcp, /* 157 */ + scheme_rt_write_data, /* 158 */ + scheme_rt_tcp_select_info, /* 159 */ + scheme_rt_namespace_option, /* 160 */ + scheme_rt_param_data, /* 161 */ + scheme_rt_will, /* 162 */ + scheme_rt_will_registration, /* 163 */ + scheme_rt_struct_proc_info, /* 164 */ + scheme_rt_linker_name, /* 165 */ + scheme_rt_param_map, /* 166 */ + scheme_rt_finalization, /* 167 */ + scheme_rt_finalizations, /* 168 */ + scheme_rt_cpp_object, /* 169 */ + scheme_rt_cpp_array_object, /* 170 */ + scheme_rt_stack_object, /* 171 */ + scheme_rt_preallocated_object, /* 172 */ + scheme_thread_hop_type, /* 173 */ + scheme_rt_srcloc, /* 174 */ + scheme_rt_evt, /* 175 */ + scheme_rt_syncing, /* 176 */ + scheme_rt_comp_prefix, /* 177 */ + scheme_rt_user_input, /* 178 */ + scheme_rt_user_output, /* 179 */ + scheme_rt_compact_port, /* 180 */ + scheme_rt_read_special_dw, /* 181 */ + scheme_rt_regwork, /* 182 */ + scheme_rt_buf_holder, /* 183 */ + scheme_rt_parameterization, /* 184 */ + scheme_rt_print_params, /* 185 */ + scheme_rt_read_params, /* 186 */ #endif _scheme_last_type_ diff --git a/src/mzscheme/src/thread.c b/src/mzscheme/src/thread.c index c1645e8413..1279340fef 100644 --- a/src/mzscheme/src/thread.c +++ b/src/mzscheme/src/thread.c @@ -214,6 +214,18 @@ extern long GC_get_memory_use(void *c); extern MZ_DLLIMPORT long GC_get_memory_use(); #endif +typedef struct Thread_Cell { + Scheme_Object so; + char inherited; + Scheme_Object *def_val; + /* A thread's thread_cell table maps cells to keys weakly. + This table maps keys to values weakly. The two weak + levels ensure that thread cells are properly GCed + when the value of a thread cell references the thread + cell. */ + Scheme_Bucket_Table *vals; +} Thread_Cell; + static Scheme_Object *empty_symbol, *initial_symbol; static Scheme_Object *read_symbol, *write_symbol, *execute_symbol, *delete_symbol, *exists_symbol; @@ -288,6 +300,7 @@ static Scheme_Object *make_thread_cell(int argc, Scheme_Object *args[]); static Scheme_Object *thread_cell_p(int argc, Scheme_Object *args[]); static Scheme_Object *thread_cell_get(int argc, Scheme_Object *args[]); static Scheme_Object *thread_cell_set(int argc, Scheme_Object *args[]); +static Scheme_Object *thread_cell_values(int argc, Scheme_Object *args[]); static Scheme_Object *make_security_guard(int argc, Scheme_Object *argv[]); static Scheme_Object *security_guard_p(int argc, Scheme_Object *argv[]); @@ -606,6 +619,11 @@ void scheme_init_thread(Scheme_Env *env) "thread-cell-set!", 2, 2), env); + scheme_add_global_constant("current-preserved-thread-cell-values", + scheme_make_prim_w_arity(thread_cell_values, + "current-preserved-thread-cell-values", + 0, 1), + env); scheme_add_global_constant("make-will-executor", @@ -3219,7 +3237,7 @@ void scheme_push_break_enable(Scheme_Cont_Frame_Data *cframe, int on, int post_c Scheme_Object *v = NULL; if (recycle_cell) { - if (!SCHEME_TRUEP(SCHEME_IPTR_VAL(recycle_cell)) == !on) { + if (!SCHEME_TRUEP(((Thread_Cell *)recycle_cell)->def_val) == !on) { v = recycle_cell; recycle_cell = NULL; } @@ -4552,7 +4570,7 @@ static int resume_suspend_ready(Scheme_Object *o, Scheme_Schedule_Info *sinfo) static Scheme_Object *make_thread_dead(int argc, Scheme_Object *argv[]) { if (!SAME_TYPE(SCHEME_TYPE(argv[0]), scheme_thread_type)) - scheme_wrong_type("thread-resume-evt", "thread", 0, argc, argv); + scheme_wrong_type("thread-dead-evt", "thread", 0, argc, argv); return scheme_get_thread_dead((Scheme_Thread *)argv[0]); } @@ -5331,14 +5349,14 @@ static Scheme_Object *evts_to_evt(int argc, Scheme_Object *argv[]) Scheme_Object *scheme_make_thread_cell(Scheme_Object *def_val, int inherited) { - Scheme_Object *c; + Thread_Cell *c; - c = scheme_alloc_object(); - c->type = scheme_thread_cell_type; - SCHEME_IPTR_VAL(c) = def_val; - SCHEME_PINT_VAL(c) = inherited; + c = MALLOC_ONE_TAGGED(Thread_Cell); + c->so.type = scheme_thread_cell_type; + c->def_val = def_val; + c->inherited = !!inherited; - return c; + return (Scheme_Object *)c; } Scheme_Object *scheme_thread_cell_get(Scheme_Object *cell, Scheme_Thread_Cell_Table *cells) @@ -5349,7 +5367,7 @@ Scheme_Object *scheme_thread_cell_get(Scheme_Object *cell, Scheme_Thread_Cell_Ta if (v) return v; else - return SCHEME_IPTR_VAL(cell); + return ((Thread_Cell *)cell)->def_val; } void scheme_thread_cell_set(Scheme_Object *cell, Scheme_Thread_Cell_Table *cells, Scheme_Object *v) @@ -5357,9 +5375,10 @@ void scheme_thread_cell_set(Scheme_Object *cell, Scheme_Thread_Cell_Table *cells scheme_add_to_table(cells, (const char *)cell, (void *)v, 0); } -Scheme_Thread_Cell_Table *scheme_inherit_cells(Scheme_Thread_Cell_Table *cells) +static Scheme_Thread_Cell_Table *inherit_cells(Scheme_Thread_Cell_Table *cells, + Scheme_Thread_Cell_Table *t, + int inherited) { - Scheme_Bucket_Table *t; Scheme_Bucket *bucket; Scheme_Object *cell, *v; int i; @@ -5367,14 +5386,14 @@ Scheme_Thread_Cell_Table *scheme_inherit_cells(Scheme_Thread_Cell_Table *cells) if (!cells) cells = scheme_current_thread->cell_values; - t = scheme_make_bucket_table(20, SCHEME_hash_weak_ptr); - + if (!t) + t = scheme_make_bucket_table(20, SCHEME_hash_weak_ptr); for (i = cells->size; i--; ) { bucket = cells->buckets[i]; if (bucket && bucket->val && bucket->key) { cell = (Scheme_Object *)HT_EXTRACT_WEAK(bucket->key); - if (cell && SCHEME_PINT_VAL(cell)) { + if (cell && (((Thread_Cell *)cell)->inherited == inherited)) { v = (Scheme_Object *)bucket->val; scheme_add_to_table(t, (const char *)cell, v, 0); } @@ -5384,9 +5403,43 @@ Scheme_Thread_Cell_Table *scheme_inherit_cells(Scheme_Thread_Cell_Table *cells) return t; } +Scheme_Thread_Cell_Table *scheme_inherit_cells(Scheme_Thread_Cell_Table *cells) +{ + return inherit_cells(cells, NULL, 1); +} + +static Scheme_Object *thread_cell_values(int argc, Scheme_Object *argv[]) +{ + if (argc == 1) { + Scheme_Thread_Cell_Table *naya; + + if (!SAME_TYPE(scheme_thread_cell_values_type, SCHEME_TYPE(argv[0]))) { + scheme_wrong_type("current-preserved-thread-cell-values", "thread cell values", 0, argc, argv); + return NULL; + } + + naya = inherit_cells(NULL, NULL, 0); + inherit_cells((Scheme_Thread_Cell_Table *)SCHEME_PTR_VAL(argv[0]), naya, 1); + + scheme_current_thread->cell_values = naya; + + return scheme_void; + } else { + Scheme_Object *o, *ht; + + ht = (Scheme_Object *)inherit_cells(NULL, NULL, 1); + + o = scheme_alloc_small_object(); + o->type = scheme_thread_cell_values_type; + SCHEME_PTR_VAL(o) = ht; + + return o; + } +} + static Scheme_Object *make_thread_cell(int argc, Scheme_Object *argv[]) { - return scheme_make_thread_cell(argv[0], argc && SCHEME_TRUEP(argv[1])); + return scheme_make_thread_cell(argv[0], (argc > 1) && SCHEME_TRUEP(argv[1])); } static Scheme_Object *thread_cell_p(int argc, Scheme_Object *argv[]) @@ -5757,7 +5810,7 @@ void scheme_set_root_param(int p, Scheme_Object *v) { Scheme_Parameterization *paramz; paramz = (Scheme_Parameterization *)scheme_current_thread->init_config->cell; - SCHEME_IPTR_VAL(paramz->prims[p]) = v; + ((Thread_Cell *)(paramz->prims[p]))->def_val = v; } static void make_initial_config(Scheme_Thread *p) @@ -6702,6 +6755,7 @@ static void register_traversers(void) GC_REG_TRAV(scheme_evt_set_type, mark_evt_set); GC_REG_TRAV(scheme_thread_set_type, mark_thread_set); GC_REG_TRAV(scheme_config_type, mark_config); + GC_REG_TRAV(scheme_thread_cell_type, mark_thread_cell); GC_REG_TRAV(scheme_rt_namespace_option, mark_namespace_option); GC_REG_TRAV(scheme_rt_param_data, mark_param_data); diff --git a/src/mzscheme/src/type.c b/src/mzscheme/src/type.c index 482f5872eb..99390ec793 100644 --- a/src/mzscheme/src/type.c +++ b/src/mzscheme/src/type.c @@ -214,6 +214,7 @@ scheme_init_type (Scheme_Env *env) set_name(scheme_thread_set_type, ""); set_name(scheme_thread_cell_type, ""); + set_name(scheme_thread_cell_values_type, ""); set_name(scheme_string_converter_type, ""); @@ -524,9 +525,9 @@ void scheme_register_traversers(void) GC_REG_TRAV(scheme_progress_evt_type, twoptr_obj); - GC_REG_TRAV(scheme_thread_cell_type, iptr_obj); - GC_REG_TRAV(scheme_already_comp_type, iptr_obj); + + GC_REG_TRAV(scheme_thread_cell_values_type, small_object); } END_XFORM_SKIP;