diff options
-rw-r--r-- | runtime/array.c | 2 | ||||
-rw-r--r-- | runtime/caml/domain_state.tbl | 4 | ||||
-rw-r--r-- | runtime/caml/minor_gc.h | 8 | ||||
-rw-r--r-- | runtime/caml/weak.h | 2 | ||||
-rw-r--r-- | runtime/compact.c | 12 | ||||
-rw-r--r-- | runtime/custom.c | 2 | ||||
-rw-r--r-- | runtime/domain.c | 2 | ||||
-rw-r--r-- | runtime/intern.c | 2 | ||||
-rw-r--r-- | runtime/major_gc.c | 4 | ||||
-rw-r--r-- | runtime/memory.c | 4 | ||||
-rw-r--r-- | runtime/minor_gc.c | 51 | ||||
-rw-r--r-- | runtime/weak.c | 2 |
12 files changed, 51 insertions, 44 deletions
diff --git a/runtime/array.c b/runtime/array.c index 44180da9fa..e43b5613b0 100644 --- a/runtime/array.c +++ b/runtime/array.c @@ -626,7 +626,7 @@ CAMLprim value caml_array_fill(value array, if (caml_gc_phase == Phase_mark) caml_darken(old, NULL); } if (is_val_young_block) - add_to_ref_table (&Caml_state->minor_tables->ref, fp); + add_to_ref_table (Caml_state->ref_table, fp); } if (is_val_young_block) caml_check_urgent_gc (Val_unit); } diff --git a/runtime/caml/domain_state.tbl b/runtime/caml/domain_state.tbl index c522d722cb..80ac7875bd 100644 --- a/runtime/caml/domain_state.tbl +++ b/runtime/caml/domain_state.tbl @@ -31,7 +31,9 @@ DOMAIN_STATE(value*, young_trigger) DOMAIN_STATE(asize_t, minor_heap_wsz) DOMAIN_STATE(intnat, in_minor_collection) DOMAIN_STATE(double, extra_heap_resources_minor) -DOMAIN_STATE(struct caml_minor_tables*, minor_tables) +DOMAIN_STATE(struct caml_ref_table*, ref_table) +DOMAIN_STATE(struct caml_ephe_ref_table*, ephe_ref_table) +DOMAIN_STATE(struct caml_custom_table*, custom_table) /* See minor_gc.c */ DOMAIN_STATE(value*, stack_low) diff --git a/runtime/caml/minor_gc.h b/runtime/caml/minor_gc.h index 2b58f1900e..44d2d50cf7 100644 --- a/runtime/caml/minor_gc.h +++ b/runtime/caml/minor_gc.h @@ -49,12 +49,6 @@ struct caml_custom_table CAML_TABLE_STRUCT(struct caml_custom_elt); /* Table of custom blocks in the minor heap that contain finalizers or GC speed parameters. */ -struct caml_minor_tables { - struct caml_ref_table ref; - struct caml_ephe_ref_table ephe_ref; - struct caml_custom_table custom; -}; - extern void caml_set_minor_heap_size (asize_t); /* size in bytes */ extern void caml_empty_minor_heap (void); CAMLextern void caml_gc_dispatch (void); @@ -70,7 +64,7 @@ extern void caml_alloc_ephe_table (struct caml_ephe_ref_table *, extern void caml_realloc_custom_table (struct caml_custom_table *); extern void caml_alloc_custom_table (struct caml_custom_table *, asize_t, asize_t); -struct caml_minor_tables* caml_alloc_minor_tables (void); +void caml_alloc_minor_tables (void); #define Oldify(p) do{ \ value __oldify__v__ = *p; \ diff --git a/runtime/caml/weak.h b/runtime/caml/weak.h index 73b6244482..668d51001a 100644 --- a/runtime/caml/weak.h +++ b/runtime/caml/weak.h @@ -184,7 +184,7 @@ static inline void caml_ephe_clean (value v){ }else{ Field (v, i) = child = f; if (Is_block (f) && Is_young (f)) - add_to_ephe_ref_table(&Caml_state->minor_tables->ephe_ref, v, i); + add_to_ephe_ref_table(Caml_state->ephe_ref_table, v, i); goto ephemeron_again; } } diff --git a/runtime/compact.c b/runtime/compact.c index 3291c28807..eb64db42f5 100644 --- a/runtime/compact.c +++ b/runtime/compact.c @@ -430,12 +430,12 @@ void caml_compact_heap (void) CAML_INSTR_SETUP(tmr, "compact"); CAMLassert (Caml_state->young_ptr == Caml_state->young_alloc_end); - CAMLassert (Caml_state->minor_tables->ref.ptr == - Caml_state->minor_tables->ref.base); - CAMLassert (Caml_state->minor_tables->ephe_ref.ptr == - Caml_state->minor_tables->ephe_ref.base); - CAMLassert (Caml_state->minor_tables->custom.ptr == - Caml_state->minor_tables->custom.base); + CAMLassert (Caml_state->ref_table->ptr == + Caml_state->ref_table->base); + CAMLassert (Caml_state->ephe_ref_table->ptr == + Caml_state->ephe_ref_table->base); + CAMLassert (Caml_state->custom_table->ptr == + Caml_state->custom_table->base); do_compaction (); CAML_INSTR_TIME (tmr, "compact/main"); diff --git a/runtime/custom.c b/runtime/custom.c index 5342b5678e..970ed3bd1a 100644 --- a/runtime/custom.c +++ b/runtime/custom.c @@ -54,7 +54,7 @@ static value alloc_custom_gen (struct custom_operations * ops, } /* The remaining [mem_minor] will be counted if the block survives a minor GC */ - add_to_custom_table (&Caml_state->minor_tables->custom, result, + add_to_custom_table (Caml_state->custom_table, result, mem_minor, max_major); /* Keep track of extra resources held by custom block in minor heap. */ diff --git a/runtime/domain.c b/runtime/domain.c index 4ea7be6536..f1bc08e3dc 100644 --- a/runtime/domain.c +++ b/runtime/domain.c @@ -45,7 +45,7 @@ void caml_init_domain () Caml_state->minor_heap_wsz = 0; Caml_state->in_minor_collection = 0; Caml_state->extra_heap_resources_minor = 0; - Caml_state->minor_tables = caml_alloc_minor_tables(); + caml_alloc_minor_tables(); Caml_state->stack_low = NULL; Caml_state->stack_high = NULL; diff --git a/runtime/intern.c b/runtime/intern.c index dd3b512ffd..9f83cdda9f 100644 --- a/runtime/intern.c +++ b/runtime/intern.c @@ -573,7 +573,7 @@ static void intern_rec(value *dest) if (ops->finalize != NULL && Is_young(v)) { /* Remember that the block has a finalizer. */ - add_to_custom_table (&Caml_state->minor_tables->custom, v, 0, 1); + add_to_custom_table (Caml_state->custom_table, v, 0, 1); } intern_dest += 1 + size; diff --git a/runtime/major_gc.c b/runtime/major_gc.c index c557661784..3c7976a945 100644 --- a/runtime/major_gc.c +++ b/runtime/major_gc.c @@ -271,9 +271,9 @@ static inline value* mark_slice_darken(value *gray_vals_ptr, Field (v, i) = f; if (Is_block (f) && Is_young (f) && !Is_young (child)){ if(in_ephemeron) { - add_to_ephe_ref_table (&Caml_state->minor_tables->ephe_ref, v, i); + add_to_ephe_ref_table (Caml_state->ephe_ref_table, v, i); } else { - add_to_ref_table (&Caml_state->minor_tables->ref, &Field (v, i)); + add_to_ref_table (Caml_state->ref_table, &Field (v, i)); } } } diff --git a/runtime/memory.c b/runtime/memory.c index 424d597e04..62b8dcf78c 100644 --- a/runtime/memory.c +++ b/runtime/memory.c @@ -648,7 +648,7 @@ CAMLexport CAMLweakdef void caml_initialize (value *fp, value val) CAMLassert(Is_in_heap_or_young(fp)); *fp = val; if (!Is_young((value)fp) && Is_block (val) && Is_young (val)) { - add_to_ref_table (&Caml_state->minor_tables->ref, fp); + add_to_ref_table (Caml_state->ref_table, fp); } } @@ -701,7 +701,7 @@ CAMLexport CAMLweakdef void caml_modify (value *fp, value val) } /* Check for condition 1. */ if (Is_block(val) && Is_young(val)) { - add_to_ref_table (&Caml_state->minor_tables->ref, fp); + add_to_ref_table (Caml_state->ref_table, fp); } } } diff --git a/runtime/minor_gc.c b/runtime/minor_gc.c index cba3ac21f4..1a3953d02d 100644 --- a/runtime/minor_gc.c +++ b/runtime/minor_gc.c @@ -59,14 +59,25 @@ struct generic_table CAML_TABLE_STRUCT(char); -struct caml_minor_tables* caml_alloc_minor_tables () +void caml_alloc_minor_tables () { - struct caml_minor_tables* t = - caml_stat_alloc_noexc(sizeof(struct caml_minor_tables)); - if (t == NULL) + Caml_state->ref_table = + caml_stat_alloc_noexc(sizeof(struct caml_ref_table)); + if (Caml_state->ref_table == NULL) caml_fatal_error ("cannot initialize minor heap"); - memset(t, 0, sizeof(*t)); - return t; + memset(Caml_state->ref_table, 0, sizeof(struct caml_ref_table)); + + Caml_state->ephe_ref_table = + caml_stat_alloc_noexc(sizeof(struct caml_ephe_ref_table)); + if (Caml_state->ephe_ref_table == NULL) + caml_fatal_error ("cannot initialize minor heap"); + memset(Caml_state->ephe_ref_table, 0, sizeof(struct caml_ephe_ref_table)); + + Caml_state->custom_table = + caml_stat_alloc_noexc(sizeof(struct caml_custom_table)); + if (Caml_state->custom_table == NULL) + caml_fatal_error ("cannot initialize minor heap"); + memset(Caml_state->custom_table, 0, sizeof(struct caml_custom_table)); } /* [sz] and [rsv] are numbers of entries */ @@ -160,9 +171,9 @@ void caml_set_minor_heap_size (asize_t bsz) Caml_state->minor_heap_wsz = Wsize_bsize (bsz); caml_memprof_renew_minor_sample(); - reset_table ((struct generic_table *) &Caml_state->minor_tables->ref); - reset_table ((struct generic_table *) &Caml_state->minor_tables->ephe_ref); - reset_table ((struct generic_table *) &Caml_state->minor_tables->custom); + reset_table ((struct generic_table *) Caml_state->ref_table); + reset_table ((struct generic_table *) Caml_state->ephe_ref_table); + reset_table ((struct generic_table *) Caml_state->custom_table); } static value oldify_todo_list = 0; @@ -305,8 +316,8 @@ void caml_oldify_mopup (void) /* Oldify the data in the minor heap of alive ephemeron During minor collection keys outside the minor heap are considered alive */ - for (re = Caml_state->minor_tables->ephe_ref.base; - re < Caml_state->minor_tables->ephe_ref.ptr; re++){ + for (re = Caml_state->ephe_ref_table->base; + re < Caml_state->ephe_ref_table->ptr; re++){ /* look only at ephemeron with data in the minor heap */ if (re->offset == 1){ value *data = &Field(re->ephe,1); @@ -344,16 +355,16 @@ void caml_empty_minor_heap (void) caml_gc_message (0x02, "<"); caml_oldify_local_roots(); CAML_INSTR_TIME (tmr, "minor/local_roots"); - for (r = Caml_state->minor_tables->ref.base; - r < Caml_state->minor_tables->ref.ptr; r++) { + for (r = Caml_state->ref_table->base; + r < Caml_state->ref_table->ptr; r++) { caml_oldify_one (**r, *r); } CAML_INSTR_TIME (tmr, "minor/ref_table"); caml_oldify_mopup (); CAML_INSTR_TIME (tmr, "minor/copy"); /* Update the ephemerons */ - for (re = Caml_state->minor_tables->ephe_ref.base; - re < Caml_state->minor_tables->ephe_ref.ptr; re++){ + for (re = Caml_state->ephe_ref_table->base; + re < Caml_state->ephe_ref_table->ptr; re++){ if(re->offset < Wosize_val(re->ephe)){ /* If it is not the case, the ephemeron has been truncated */ value *key = &Field(re->ephe,re->offset); @@ -371,8 +382,8 @@ void caml_empty_minor_heap (void) /* Update the OCaml finalise_last values */ caml_final_update_minor_roots(); /* Run custom block finalisation of dead minor values */ - for (elt = Caml_state->minor_tables->custom.base; - elt < Caml_state->minor_tables->custom.ptr; elt++){ + for (elt = Caml_state->custom_table->base; + elt < Caml_state->custom_table->ptr; elt++){ value v = elt->block; if (Hd_val (v) == 0){ /* Block was copied to the major heap: adjust GC speed numbers. */ @@ -390,9 +401,9 @@ void caml_empty_minor_heap (void) (double) (Caml_state->young_alloc_end - Caml_state->young_ptr) / Caml_state->minor_heap_wsz; Caml_state->young_ptr = Caml_state->young_alloc_end; - clear_table ((struct generic_table *) &Caml_state->minor_tables->ref); - clear_table ((struct generic_table *) &Caml_state->minor_tables->ephe_ref); - clear_table ((struct generic_table *) &Caml_state->minor_tables->custom); + clear_table ((struct generic_table *) Caml_state->ref_table); + clear_table ((struct generic_table *) Caml_state->ephe_ref_table); + clear_table ((struct generic_table *) Caml_state->custom_table); Caml_state->extra_heap_resources_minor = 0; caml_gc_message (0x02, ">"); Caml_state->in_minor_collection = 0; diff --git a/runtime/weak.c b/runtime/weak.c index 54ee5842b1..d5349f96f5 100644 --- a/runtime/weak.c +++ b/runtime/weak.c @@ -189,7 +189,7 @@ static void do_set (value ar, mlsize_t offset, value v) value old = Field (ar, offset); Field (ar, offset) = v; if (!(Is_block (old) && Is_young (old))){ - add_to_ephe_ref_table (&Caml_state->minor_tables->ephe_ref, ar, offset); + add_to_ephe_ref_table (Caml_state->ephe_ref_table, ar, offset); } }else{ Field (ar, offset) = v; |