diff options
-rw-r--r-- | otherlibs/systhreads/st_stubs.c | 8 | ||||
-rw-r--r-- | runtime/bigarray.c | 2 | ||||
-rw-r--r-- | runtime/caml/compatibility.h | 5 | ||||
-rw-r--r-- | runtime/caml/domain.h | 4 | ||||
-rw-r--r-- | runtime/caml/domain_state.tbl | 18 | ||||
-rw-r--r-- | runtime/caml/memory.h | 70 | ||||
-rw-r--r-- | runtime/caml/mlvalues.h | 2 | ||||
-rw-r--r-- | runtime/caml/signals.h | 2 | ||||
-rw-r--r-- | runtime/compare.c | 13 | ||||
-rw-r--r-- | runtime/domain.c | 5 | ||||
-rw-r--r-- | runtime/fail_nat.c | 6 | ||||
-rw-r--r-- | runtime/interp.c | 4 | ||||
-rw-r--r-- | runtime/minor_gc.c | 14 | ||||
-rw-r--r-- | runtime/roots_byt.c | 6 | ||||
-rw-r--r-- | runtime/roots_nat.c | 6 | ||||
-rw-r--r-- | runtime/signals.c | 3 | ||||
-rw-r--r-- | runtime/signals_nat.c | 2 |
17 files changed, 88 insertions, 82 deletions
diff --git a/otherlibs/systhreads/st_stubs.c b/otherlibs/systhreads/st_stubs.c index 1991b4cde4..f828516677 100644 --- a/otherlibs/systhreads/st_stubs.c +++ b/otherlibs/systhreads/st_stubs.c @@ -94,7 +94,7 @@ struct caml_thread_struct { value * stack_threshold; value * sp; /* Saved value of Caml_state->extern_sp for this thread */ value * trapsp; /* Saved value of Caml_state->trapsp for this thread */ - struct caml__roots_block * local_roots; /* Saved value of caml_local_roots */ + struct caml__roots_block * local_roots; /* Saved value of Caml_state->local_roots */ struct longjmp_buffer * external_raise; /* Saved Caml_state->external_raise */ #endif int backtrace_pos; /* Saved Caml_state->backtrace_pos */ @@ -179,7 +179,6 @@ static inline void caml_thread_save_runtime_state(void) curr_thread->last_retaddr = Caml_state->last_return_address; curr_thread->gc_regs = Caml_state->gc_regs; curr_thread->exception_pointer = Caml_state->exn_handler; - curr_thread->local_roots = caml_local_roots; #ifdef WITH_SPACETIME curr_thread->spacetime_trie_node_ptr = caml_spacetime_trie_node_ptr; @@ -192,9 +191,9 @@ static inline void caml_thread_save_runtime_state(void) curr_thread->stack_threshold = Caml_state->stack_threshold; curr_thread->sp = Caml_state->extern_sp; curr_thread->trapsp = Caml_state->trapsp; - curr_thread->local_roots = caml_local_roots; curr_thread->external_raise = Caml_state->external_raise; #endif + curr_thread->local_roots = Caml_state->local_roots; curr_thread->backtrace_pos = Caml_state->backtrace_pos; curr_thread->backtrace_buffer = Caml_state->backtrace_buffer; curr_thread->backtrace_last_exn = Caml_state->backtrace_last_exn; @@ -209,7 +208,6 @@ static inline void caml_thread_restore_runtime_state(void) Caml_state->last_return_address = curr_thread->last_retaddr; Caml_state->gc_regs = curr_thread->gc_regs; Caml_state->exn_handler = curr_thread->exception_pointer; - caml_local_roots = curr_thread->local_roots; #ifdef WITH_SPACETIME caml_spacetime_trie_node_ptr = curr_thread->spacetime_trie_node_ptr; @@ -222,9 +220,9 @@ static inline void caml_thread_restore_runtime_state(void) Caml_state->stack_threshold = curr_thread->stack_threshold; Caml_state->extern_sp = curr_thread->sp; Caml_state->trapsp = curr_thread->trapsp; - caml_local_roots = curr_thread->local_roots; Caml_state->external_raise = curr_thread->external_raise; #endif + Caml_state->local_roots = curr_thread->local_roots; Caml_state->backtrace_pos = curr_thread->backtrace_pos; Caml_state->backtrace_buffer = curr_thread->backtrace_buffer; Caml_state->backtrace_last_exn = curr_thread->backtrace_last_exn; diff --git a/runtime/bigarray.c b/runtime/bigarray.c index 62d3d3dec6..6073390933 100644 --- a/runtime/bigarray.c +++ b/runtime/bigarray.c @@ -209,7 +209,7 @@ CAMLexport int caml_ba_compare(value v1, value v2) if (e1 < e2) return -1; \ if (e1 > e2) return 1; \ if (e1 != e2) { \ - caml_compare_unordered = 1; \ + Caml_state->compare_unordered = 1; \ if (e1 == e1) return 1; \ if (e2 == e2) return -1; \ } \ diff --git a/runtime/caml/compatibility.h b/runtime/caml/compatibility.h index 841949551a..3ea15e2562 100644 --- a/runtime/caml/compatibility.h +++ b/runtime/caml/compatibility.h @@ -235,10 +235,6 @@ /* **** meta.c */ /* **** minor_gc.c */ -#define young_start (caml_state->young_start) -#define young_end (Caml_state->young_end) -#define young_ptr (Caml_state->young_ptr) -#define young_limit (Caml_state->young_limit) #define ref_table caml_ref_table #define minor_collection caml_minor_collection #define check_urgent_gc caml_check_urgent_gc @@ -255,7 +251,6 @@ #define format_caml_exception caml_format_exception /*SP*/ /* **** roots.c */ -#define local_roots caml_local_roots #define scan_roots_hook caml_scan_roots_hook #define do_local_roots caml_do_local_roots diff --git a/runtime/caml/domain.h b/runtime/caml/domain.h index 3e843be2fd..13af5b82a5 100644 --- a/runtime/caml/domain.h +++ b/runtime/caml/domain.h @@ -24,12 +24,12 @@ extern "C" { #include "domain_state.h" -CAMLextern caml_domain_state* Caml_state; - void caml_init_domain(void); #endif /* CAML_INTERNALS */ +CAMLextern caml_domain_state* Caml_state; + #ifdef __cplusplus } #endif diff --git a/runtime/caml/domain_state.tbl b/runtime/caml/domain_state.tbl index 2bbd5993ce..22a646f71e 100644 --- a/runtime/caml/domain_state.tbl +++ b/runtime/caml/domain_state.tbl @@ -32,6 +32,18 @@ DOMAIN_STATE(char*, top_of_stack) DOMAIN_STATE(char*, bottom_of_stack) DOMAIN_STATE(uintnat, last_return_address) DOMAIN_STATE(value*, gc_regs) +/* See roots_nat.c */ + +DOMAIN_STATE(intnat, backtrace_active) +DOMAIN_STATE(intnat, backtrace_pos) +DOMAIN_STATE(backtrace_slot*, backtrace_buffer) +DOMAIN_STATE(value, backtrace_last_exn) +/* See backtrace.c */ + +DOMAIN_STATE(intnat, compare_unordered) +DOMAIN_STATE(intnat, requested_major_slice) +DOMAIN_STATE(intnat, requested_minor_gc) +DOMAIN_STATE(struct caml__roots_block *, local_roots) DOMAIN_STATE(double, stat_minor_words) DOMAIN_STATE(double, stat_promoted_words) @@ -43,9 +55,3 @@ DOMAIN_STATE(intnat, stat_top_heap_wsz) DOMAIN_STATE(intnat, stat_compactions) DOMAIN_STATE(intnat, stat_heap_chunks) /* See gc_ctrl.c */ - -DOMAIN_STATE(intnat, backtrace_active) -DOMAIN_STATE(intnat, backtrace_pos) -DOMAIN_STATE(backtrace_slot*, backtrace_buffer) -DOMAIN_STATE(value, backtrace_last_exn) -/* See backtrace.c */ diff --git a/runtime/caml/memory.h b/runtime/caml/memory.h index e8cc3fe4e5..b98ae23107 100644 --- a/runtime/caml/memory.h +++ b/runtime/caml/memory.h @@ -28,9 +28,9 @@ #include "minor_gc.h" #include "memprof.h" #endif /* CAML_INTERNALS */ -#include "domain.h" #include "misc.h" #include "mlvalues.h" +#include "domain.h" #ifdef __cplusplus extern "C" { @@ -272,8 +272,6 @@ struct caml__roots_block { value *tables [5]; }; -CAMLextern struct caml__roots_block *caml_local_roots; /* defined in roots.c */ - /* The following macros are used to declare C local variables and function parameters of type [value]. @@ -306,7 +304,7 @@ CAMLextern struct caml__roots_block *caml_local_roots; /* defined in roots.c */ */ #define CAMLparam0() \ - struct caml__roots_block *caml__frame = caml_local_roots + struct caml__roots_block *caml__frame = Caml_state->local_roots #define CAMLparam1(x) \ CAMLparam0 (); \ @@ -356,10 +354,11 @@ CAMLextern struct caml__roots_block *caml_local_roots; /* defined in roots.c */ #define CAMLxparam1(x) \ struct caml__roots_block caml__roots_##x; \ + caml_domain_state* domain_state_##x = Caml_state; \ CAMLunused_start int caml__dummy_##x = ( \ (void) caml__frame, \ - (caml__roots_##x.next = caml_local_roots), \ - (caml_local_roots = &caml__roots_##x), \ + (caml__roots_##x.next = domain_state_##x->local_roots), \ + (domain_state_##x->local_roots = &caml__roots_##x), \ (caml__roots_##x.nitems = 1), \ (caml__roots_##x.ntables = 1), \ (caml__roots_##x.tables [0] = &x), \ @@ -368,10 +367,11 @@ CAMLextern struct caml__roots_block *caml_local_roots; /* defined in roots.c */ #define CAMLxparam2(x, y) \ struct caml__roots_block caml__roots_##x; \ + caml_domain_state* domain_state_##x = Caml_state; \ CAMLunused_start int caml__dummy_##x = ( \ (void) caml__frame, \ - (caml__roots_##x.next = caml_local_roots), \ - (caml_local_roots = &caml__roots_##x), \ + (caml__roots_##x.next = domain_state_##x->local_roots), \ + (domain_state_##x->local_roots = &caml__roots_##x), \ (caml__roots_##x.nitems = 1), \ (caml__roots_##x.ntables = 2), \ (caml__roots_##x.tables [0] = &x), \ @@ -381,10 +381,11 @@ CAMLextern struct caml__roots_block *caml_local_roots; /* defined in roots.c */ #define CAMLxparam3(x, y, z) \ struct caml__roots_block caml__roots_##x; \ + caml_domain_state* domain_state_##x = Caml_state; \ CAMLunused_start int caml__dummy_##x = ( \ (void) caml__frame, \ - (caml__roots_##x.next = caml_local_roots), \ - (caml_local_roots = &caml__roots_##x), \ + (caml__roots_##x.next = domain_state_##x->local_roots), \ + (domain_state_##x->local_roots = &caml__roots_##x), \ (caml__roots_##x.nitems = 1), \ (caml__roots_##x.ntables = 3), \ (caml__roots_##x.tables [0] = &x), \ @@ -395,10 +396,11 @@ CAMLextern struct caml__roots_block *caml_local_roots; /* defined in roots.c */ #define CAMLxparam4(x, y, z, t) \ struct caml__roots_block caml__roots_##x; \ + caml_domain_state* domain_state_##x = Caml_state; \ CAMLunused_start int caml__dummy_##x = ( \ (void) caml__frame, \ - (caml__roots_##x.next = caml_local_roots), \ - (caml_local_roots = &caml__roots_##x), \ + (caml__roots_##x.next = domain_state_##x->local_roots), \ + (domain_state_##x->local_roots = &caml__roots_##x), \ (caml__roots_##x.nitems = 1), \ (caml__roots_##x.ntables = 4), \ (caml__roots_##x.tables [0] = &x), \ @@ -410,10 +412,11 @@ CAMLextern struct caml__roots_block *caml_local_roots; /* defined in roots.c */ #define CAMLxparam5(x, y, z, t, u) \ struct caml__roots_block caml__roots_##x; \ + caml_domain_state* domain_state_##x = Caml_state; \ CAMLunused_start int caml__dummy_##x = ( \ (void) caml__frame, \ - (caml__roots_##x.next = caml_local_roots), \ - (caml_local_roots = &caml__roots_##x), \ + (caml__roots_##x.next = domain_state_##x->local_roots), \ + (domain_state_##x->local_roots = &caml__roots_##x), \ (caml__roots_##x.nitems = 1), \ (caml__roots_##x.ntables = 5), \ (caml__roots_##x.tables [0] = &x), \ @@ -426,10 +429,11 @@ CAMLextern struct caml__roots_block *caml_local_roots; /* defined in roots.c */ #define CAMLxparamN(x, size) \ struct caml__roots_block caml__roots_##x; \ + caml_domain_state* domain_state_##x = Caml_state; \ CAMLunused_start int caml__dummy_##x = ( \ (void) caml__frame, \ - (caml__roots_##x.next = caml_local_roots), \ - (caml_local_roots = &caml__roots_##x), \ + (caml__roots_##x.next = domain_state_##x->local_roots), \ + (domain_state_##x->local_roots = &caml__roots_##x), \ (caml__roots_##x.nitems = (size)), \ (caml__roots_##x.ntables = 1), \ (caml__roots_##x.tables[0] = &(x[0])), \ @@ -465,7 +469,7 @@ CAMLextern struct caml__roots_block *caml_local_roots; /* defined in roots.c */ CAMLxparamN (x, (size)) -#define CAMLdrop caml_local_roots = caml__frame +#define CAMLdrop Caml_state->local_roots = caml__frame #define CAMLreturn0 do{ \ CAMLdrop; \ @@ -514,16 +518,18 @@ CAMLextern struct caml__roots_block *caml_local_roots; /* defined in roots.c */ #define Begin_roots1(r0) { \ struct caml__roots_block caml__roots_block; \ - caml__roots_block.next = caml_local_roots; \ - caml_local_roots = &caml__roots_block; \ + caml_domain_state* domain_state = Caml_state; \ + caml__roots_block.next = domain_state->local_roots; \ + domain_state->local_roots = &caml__roots_block; \ caml__roots_block.nitems = 1; \ caml__roots_block.ntables = 1; \ caml__roots_block.tables[0] = &(r0); #define Begin_roots2(r0, r1) { \ struct caml__roots_block caml__roots_block; \ - caml__roots_block.next = caml_local_roots; \ - caml_local_roots = &caml__roots_block; \ + caml_domain_state* domain_state = Caml_state; \ + caml__roots_block.next = domain_state->local_roots; \ + domain_state->local_roots = &caml__roots_block; \ caml__roots_block.nitems = 1; \ caml__roots_block.ntables = 2; \ caml__roots_block.tables[0] = &(r0); \ @@ -531,8 +537,9 @@ CAMLextern struct caml__roots_block *caml_local_roots; /* defined in roots.c */ #define Begin_roots3(r0, r1, r2) { \ struct caml__roots_block caml__roots_block; \ - caml__roots_block.next = caml_local_roots; \ - caml_local_roots = &caml__roots_block; \ + caml_domain_state* domain_state = Caml_state; \ + caml__roots_block.next = domain_state->local_roots; \ + domain_state->local_roots = &caml__roots_block; \ caml__roots_block.nitems = 1; \ caml__roots_block.ntables = 3; \ caml__roots_block.tables[0] = &(r0); \ @@ -541,8 +548,9 @@ CAMLextern struct caml__roots_block *caml_local_roots; /* defined in roots.c */ #define Begin_roots4(r0, r1, r2, r3) { \ struct caml__roots_block caml__roots_block; \ - caml__roots_block.next = caml_local_roots; \ - caml_local_roots = &caml__roots_block; \ + caml_domain_state* domain_state = Caml_state; \ + caml__roots_block.next = domain_state->local_roots; \ + domain_state->local_roots = &caml__roots_block; \ caml__roots_block.nitems = 1; \ caml__roots_block.ntables = 4; \ caml__roots_block.tables[0] = &(r0); \ @@ -552,8 +560,9 @@ CAMLextern struct caml__roots_block *caml_local_roots; /* defined in roots.c */ #define Begin_roots5(r0, r1, r2, r3, r4) { \ struct caml__roots_block caml__roots_block; \ - caml__roots_block.next = caml_local_roots; \ - caml_local_roots = &caml__roots_block; \ + caml_domain_state* domain_state = Caml_state; \ + caml__roots_block.next = domain_state->local_roots; \ + domain_state->local_roots = &caml__roots_block; \ caml__roots_block.nitems = 1; \ caml__roots_block.ntables = 5; \ caml__roots_block.tables[0] = &(r0); \ @@ -564,13 +573,14 @@ CAMLextern struct caml__roots_block *caml_local_roots; /* defined in roots.c */ #define Begin_roots_block(table, size) { \ struct caml__roots_block caml__roots_block; \ - caml__roots_block.next = caml_local_roots; \ - caml_local_roots = &caml__roots_block; \ + caml_domain_state* domain_state = Caml_state; \ + caml__roots_block.next = domain_state->local_roots; \ + domain_state->local_roots = &caml__roots_block; \ caml__roots_block.nitems = (size); \ caml__roots_block.ntables = 1; \ caml__roots_block.tables[0] = (table); -#define End_roots() caml_local_roots = caml__roots_block.next; } +#define End_roots() Caml_state->local_roots = caml__roots_block.next; } /* [caml_register_global_root] registers a global C variable as a memory root diff --git a/runtime/caml/mlvalues.h b/runtime/caml/mlvalues.h index ec30b20a1e..a20c09a14d 100644 --- a/runtime/caml/mlvalues.h +++ b/runtime/caml/mlvalues.h @@ -64,6 +64,8 @@ typedef unsigned int tag_t; /* Actually, an unsigned char */ typedef uintnat color_t; typedef uintnat mark_t; +#include "domain_state.h" + /* Longs vs blocks. */ #define Is_long(x) (((x) & 1) != 0) #define Is_block(x) (((x) & 1) == 0) diff --git a/runtime/caml/signals.h b/runtime/caml/signals.h index 209027ab50..654cd8dd42 100644 --- a/runtime/caml/signals.h +++ b/runtime/caml/signals.h @@ -33,8 +33,6 @@ extern "C" { #ifdef CAML_INTERNALS CAMLextern intnat volatile caml_pending_signals[]; CAMLextern int volatile caml_something_to_do; -extern int volatile caml_requested_major_slice; -extern int volatile caml_requested_minor_gc; void caml_update_young_limit(void); void caml_request_major_slice (void); diff --git a/runtime/compare.c b/runtime/compare.c index fd7ed763d3..974e0c01f9 100644 --- a/runtime/compare.c +++ b/runtime/compare.c @@ -30,7 +30,6 @@ struct compare_item { value * v1, * v2; mlsize_t count; }; #define COMPARE_STACK_INIT_SIZE 8 #define COMPARE_STACK_MIN_ALLOC_SIZE 32 #define COMPARE_STACK_MAX_SIZE (1024*1024) -CAMLexport int caml_compare_unordered; struct compare_stack { struct compare_item init_stack[COMPARE_STACK_INIT_SIZE]; @@ -140,9 +139,9 @@ static intnat do_compare_val(struct compare_stack* stk, int res; int (*compare)(value v1, value v2) = Custom_ops_val(v2)->compare_ext; if (compare == NULL) break; /* for backward compatibility */ - caml_compare_unordered = 0; + Caml_state->compare_unordered = 0; res = compare(v1, v2); - if (caml_compare_unordered && !total) return UNORDERED; + if (Caml_state->compare_unordered && !total) return UNORDERED; if (res != 0) return res; goto next_item; } @@ -163,9 +162,9 @@ static intnat do_compare_val(struct compare_stack* stk, int res; int (*compare)(value v1, value v2) = Custom_ops_val(v1)->compare_ext; if (compare == NULL) break; /* for backward compatibility */ - caml_compare_unordered = 0; + Caml_state->compare_unordered = 0; res = compare(v1, v2); - if (caml_compare_unordered && !total) return UNORDERED; + if (Caml_state->compare_unordered && !total) return UNORDERED; if (res != 0) return res; goto next_item; } @@ -261,9 +260,9 @@ static intnat do_compare_val(struct compare_stack* stk, compare_free_stack(stk); caml_invalid_argument("compare: abstract value"); } - caml_compare_unordered = 0; + Caml_state->compare_unordered = 0; res = compare(v1, v2); - if (caml_compare_unordered && !total) return UNORDERED; + if (Caml_state->compare_unordered && !total) return UNORDERED; if (res != 0) return res; break; } diff --git a/runtime/domain.c b/runtime/domain.c index 488dee5727..a5966eae19 100644 --- a/runtime/domain.c +++ b/runtime/domain.c @@ -71,4 +71,9 @@ void caml_init_domain () Caml_state->backtrace_pos = 0; Caml_state->backtrace_buffer = NULL; Caml_state->backtrace_last_exn = Val_unit; + + Caml_state->compare_unordered = 0; + Caml_state->local_roots = NULL; + Caml_state->requested_major_slice = 0; + Caml_state->requested_minor_gc = 0; } diff --git a/runtime/fail_nat.c b/runtime/fail_nat.c index 19c5f49d5a..7da45bc4d6 100644 --- a/runtime/fail_nat.c +++ b/runtime/fail_nat.c @@ -61,9 +61,9 @@ void caml_raise(value v) Unlock_exn(); if (Caml_state->exn_handler == NULL) caml_fatal_uncaught_exception(v); - while (caml_local_roots != NULL && - (char *) caml_local_roots < Caml_state->exn_handler) { - caml_local_roots = caml_local_roots->next; + while (Caml_state->local_roots != NULL && + (char *) Caml_state->local_roots < Caml_state->exn_handler) { + Caml_state->local_roots = Caml_state->local_roots->next; } caml_raise_exception(Caml_state, v); diff --git a/runtime/interp.c b/runtime/interp.c index 126b5d7d31..04609762e2 100644 --- a/runtime/interp.c +++ b/runtime/interp.c @@ -242,14 +242,14 @@ value caml_interprete(code_t prog, asize_t prog_size) #if defined(THREADED_CODE) && defined(ARCH_SIXTYFOUR) && !defined(ARCH_CODE32) jumptbl_base = Jumptbl_base; #endif - initial_local_roots = caml_local_roots; + initial_local_roots = Caml_state->local_roots; initial_sp_offset = (char *) Caml_state->stack_high - (char *) Caml_state->extern_sp; initial_external_raise = Caml_state->external_raise; caml_callback_depth++; saved_pc = NULL; if (sigsetjmp(raise_buf.buf, 0)) { - caml_local_roots = initial_local_roots; + Caml_state->local_roots = initial_local_roots; sp = Caml_state->extern_sp; accu = Caml_state->exn_bucket; pc = saved_pc; saved_pc = NULL; diff --git a/runtime/minor_gc.c b/runtime/minor_gc.c index 0b25cce6f2..a05923a5ce 100644 --- a/runtime/minor_gc.c +++ b/runtime/minor_gc.c @@ -129,7 +129,7 @@ void caml_set_minor_heap_size (asize_t bsz) CAMLassert (bsz % sizeof (value) == 0); if (Caml_state->young_ptr != Caml_state->young_alloc_end){ CAML_INSTR_INT ("force_minor/set_minor_heap_size@", 1); - caml_requested_minor_gc = 0; + Caml_state->requested_minor_gc = 0; Caml_state->young_trigger = Caml_state->young_alloc_mid; caml_update_young_limit(); caml_empty_minor_heap (); @@ -430,10 +430,10 @@ CAMLexport void caml_gc_dispatch (void) caml_instr_alloc_jump = 0; #endif - if (trigger == Caml_state->young_alloc_start || caml_requested_minor_gc){ + if (trigger == Caml_state->young_alloc_start || Caml_state->requested_minor_gc){ /* The minor heap is full, we must do a minor collection. */ /* reset the pointers first because the end hooks might allocate */ - caml_requested_minor_gc = 0; + Caml_state->requested_minor_gc = 0; Caml_state->young_trigger = Caml_state->young_alloc_mid; caml_update_young_limit(); caml_empty_minor_heap (); @@ -441,9 +441,9 @@ CAMLexport void caml_gc_dispatch (void) if (caml_gc_phase == Phase_idle) caml_major_collection_slice (-1); CAML_INSTR_TIME (tmr, "dispatch/minor"); } - if (trigger != Caml_state->young_alloc_start || caml_requested_major_slice){ + if (trigger != Caml_state->young_alloc_start || Caml_state->requested_major_slice){ /* The minor heap is half-full, do a major GC slice. */ - caml_requested_major_slice = 0; + Caml_state->requested_major_slice = 0; Caml_state->young_trigger = Caml_state->young_alloc_start; caml_update_young_limit(); caml_major_collection_slice (-1); @@ -484,7 +484,7 @@ void caml_alloc_small_dispatch (tag_t tag, intnat wosize, int flags) */ CAMLexport void caml_minor_collection (void) { - caml_requested_minor_gc = 1; + Caml_state->requested_minor_gc = 1; caml_gc_dispatch (); } @@ -507,7 +507,7 @@ static void realloc_generic_table }else{ asize_t sz; asize_t cur_ptr = tbl->ptr - tbl->base; - CAMLassert (caml_requested_minor_gc); + CAMLassert (Caml_state->requested_minor_gc); tbl->size *= 2; sz = (tbl->size + tbl->reserve) * element_size; diff --git a/runtime/roots_byt.c b/runtime/roots_byt.c index 4ba8389694..37a1fc27f5 100644 --- a/runtime/roots_byt.c +++ b/runtime/roots_byt.c @@ -27,8 +27,6 @@ #include "caml/roots.h" #include "caml/stacks.h" -CAMLexport struct caml__roots_block *caml_local_roots = NULL; - CAMLexport void (*caml_scan_roots_hook) (scanning_action f) = NULL; /* FIXME should rename to [caml_oldify_minor_roots] and synchronise with @@ -46,7 +44,7 @@ void caml_oldify_local_roots (void) caml_oldify_one (*sp, sp); } /* Local C roots */ /* FIXME do the old-frame trick ? */ - for (lr = caml_local_roots; lr != NULL; lr = lr->next) { + for (lr = Caml_state->local_roots; lr != NULL; lr = lr->next) { for (i = 0; i < lr->ntables; i++){ for (j = 0; j < lr->nitems; j++){ sp = &(lr->tables[i][j]); @@ -85,7 +83,7 @@ void caml_do_roots (scanning_action f, int do_globals) f(caml_global_data, &caml_global_data); CAML_INSTR_TIME (tmr, "major_roots/global"); /* The stack and the local C roots */ - caml_do_local_roots(f, Caml_state->extern_sp, Caml_state->stack_high, caml_local_roots); + caml_do_local_roots(f, Caml_state->extern_sp, Caml_state->stack_high, Caml_state->local_roots); CAML_INSTR_TIME (tmr, "major_roots/local"); /* Global C roots */ caml_scan_global_roots(f); diff --git a/runtime/roots_nat.c b/runtime/roots_nat.c index abd6f1753c..e2f1106f67 100644 --- a/runtime/roots_nat.c +++ b/runtime/roots_nat.c @@ -31,8 +31,6 @@ /* Roots registered from C functions */ -struct caml__roots_block *caml_local_roots = NULL; - void (*caml_scan_roots_hook) (scanning_action) = NULL; /* The hashtable of frame descriptors */ @@ -312,7 +310,7 @@ void caml_oldify_local_roots (void) } } /* Local C roots */ - for (lr = caml_local_roots; lr != NULL; lr = lr->next) { + for (lr = Caml_state->local_roots; lr != NULL; lr = lr->next) { for (i = 0; i < lr->ntables; i++){ for (j = 0; j < lr->nitems; j++){ root = &(lr->tables[i][j]); @@ -411,7 +409,7 @@ void caml_do_roots (scanning_action f, int do_globals) CAML_INSTR_TIME (tmr, "major_roots/dynamic_global"); /* The stack and local roots */ caml_do_local_roots(f, Caml_state->bottom_of_stack, Caml_state->last_return_address, - Caml_state->gc_regs, caml_local_roots); + Caml_state->gc_regs, Caml_state->local_roots); CAML_INSTR_TIME (tmr, "major_roots/local"); /* Global C roots */ caml_scan_global_roots(f); diff --git a/runtime/signals.c b/runtime/signals.c index b944e5e566..d4ca4e9a1c 100644 --- a/runtime/signals.c +++ b/runtime/signals.c @@ -276,9 +276,6 @@ void caml_update_young_limit (void) /* Arrange for a garbage collection to be performed as soon as possible */ -int volatile caml_requested_major_slice = 0; -int volatile caml_requested_minor_gc = 0; - void caml_request_major_slice (void) { caml_requested_major_slice = 1; diff --git a/runtime/signals_nat.c b/runtime/signals_nat.c index 6d9495a879..b2cf7d3b75 100644 --- a/runtime/signals_nat.c +++ b/runtime/signals_nat.c @@ -86,7 +86,7 @@ void caml_garbage_collection(void) be correctly implemented. */ caml_memprof_renew_minor_sample(); - if (caml_requested_major_slice || caml_requested_minor_gc || + if (Caml_state->requested_major_slice || Caml_state->requested_minor_gc || Caml_state->young_ptr - Caml_state->young_trigger < Max_young_whsize){ caml_gc_dispatch (); } |