summaryrefslogtreecommitdiff
path: root/byterun/minor_gc.c
diff options
context:
space:
mode:
authorMark Shinwell <mshinwell@janestreet.com>2016-02-29 12:17:45 +0000
committerMark Shinwell <mshinwell@janestreet.com>2016-03-03 08:56:16 +0000
commitfb84058720f8f73006720e4ab489f300dc767a3d (patch)
tree1692f6bbd9b3e42318e98efe0827f8e7b9f99737 /byterun/minor_gc.c
parente14e85b992de285ec8ad35c0a6a261bcaa383dd0 (diff)
downloadocaml-fb84058720f8f73006720e4ab489f300dc767a3d.tar.gz
Fix PR7157 (too many minor collections)
Diffstat (limited to 'byterun/minor_gc.c')
-rw-r--r--byterun/minor_gc.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/byterun/minor_gc.c b/byterun/minor_gc.c
index 548a350e5c..ef75bc0f38 100644
--- a/byterun/minor_gc.c
+++ b/byterun/minor_gc.c
@@ -85,9 +85,9 @@ static void alloc_generic_table (struct generic_table *tbl, asize_t sz,
if (tbl->base != NULL) caml_stat_free (tbl->base);
tbl->base = new_table;
tbl->ptr = tbl->base;
- tbl->threshold = tbl->base + tbl->size;
+ tbl->threshold = tbl->base + tbl->size * element_size;
tbl->limit = tbl->threshold;
- tbl->end = tbl->base + tbl->size + tbl->reserve;
+ tbl->end = tbl->base + (tbl->size + tbl->reserve) * element_size;
}
void caml_alloc_table (struct caml_ref_table *tbl, asize_t sz, asize_t rsv)
@@ -280,7 +280,7 @@ void caml_oldify_one (value v, value *p)
static inline int ephe_check_alive_data(struct caml_ephe_ref_elt *re){
mlsize_t i;
value child;
- for (i = 2; i < Wosize_val(re->ephe); i++){
+ for (i = CAML_EPHE_FIRST_KEY; i < Wosize_val(re->ephe); i++){
child = Field (re->ephe, i);
if(child != caml_ephe_none
&& Is_block (child) && Is_young (child)
@@ -371,18 +371,21 @@ void caml_empty_minor_heap (void)
/* Update the ephemerons */
for (re = caml_ephe_ref_table.base;
re < caml_ephe_ref_table.ptr; re++){
- value *key = &Field(re->ephe,re->offset);
- if (*key != caml_ephe_none && Is_block (*key) && Is_young (*key)){
- if (Hd_val (*key) == 0){ /* Value copied to major heap */
- *key = Field (*key, 0);
- }else{ /* Value not copied so it's dead */
- Assert(!ephe_check_alive_data(re));
- *key = caml_ephe_none;
- Field(re->ephe,1) = caml_ephe_none;
+ 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);
+ if (*key != caml_ephe_none && Is_block (*key) && Is_young (*key)){
+ if (Hd_val (*key) == 0){ /* Value copied to major heap */
+ *key = Field (*key, 0);
+ }else{ /* Value not copied so it's dead */
+ Assert(!ephe_check_alive_data(re));
+ *key = caml_ephe_none;
+ Field(re->ephe,1) = caml_ephe_none;
+ }
}
}
}
- /* Run custom block finalisation of dead minor value */
+ /* Run custom block finalisation of dead minor values */
for (r = caml_finalize_table.base; r < caml_finalize_table.ptr; r++){
int hd = Hd_val ((value)*r);
if (hd != 0){ /* If not oldified the finalizer must be called */
@@ -520,8 +523,8 @@ static void realloc_generic_table
if (tbl->base == NULL){
caml_fatal_error (msg_error);
}
- tbl->end = tbl->base + tbl->size + tbl->reserve;
- tbl->threshold = tbl->base + tbl->size;
+ tbl->end = tbl->base + (tbl->size + tbl->reserve) * element_size;
+ tbl->threshold = tbl->base + tbl->size * element_size;
tbl->ptr = tbl->base + cur_ptr;
tbl->limit = tbl->end;
}