]> granicus.if.org Git - gc/commitdiff
Fix cords for MANUAL_VDB
authorIvan Maidanski <ivmai@mail.ru>
Wed, 23 May 2018 08:43:04 +0000 (11:43 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Tue, 10 Jul 2018 07:37:34 +0000 (10:37 +0300)
(a cherry-pick of commits e12e820f3e8e76b5d8 from 'master')

* cord/cordbscs.c (CORD_cat_char_star, CORD CORD_cat,
CORD_from_fn_inner, CORD_substr_closure): Call GC_END_STUBBORN_CHANGE.
* cord/cordxtra.c (refill_cache): Likewise.
* cord/tests/de.c (prune_map, add_map, add_hist, replace_line,
generic_init): Likewise.
* cord/cordbscs.c (CORD_cat_char_star, CORD_cat): Mark x and y as
reachable after GC_END_STUBBORN_CHANGE(result).
* cord/cordbscs.c (CORD_from_fn_inner): Mark client_data as reachable
after GC_END_STUBBORN_CHANGE(result).
* cord/cordbscs.c (CORD_substr_closure): Mark x as reachable after
GC_END_STUBBORN_CHANGE(sa).
* cord/tests/de.c (prune_map): Mark saved map->previous->previous as
reachable after GC_END_STUBBORN_CHANGE(map).
* cord/tests/de.c (add_map): Mark saved current_map as reachable after
GC_END_STUBBORN_CHANGE(new_map).
* cord/tests/de.c (replace_line): Mark s as reachable after
GC_END_STUBBORN_CHANGE(screen+i).

cord/cordbscs.c
cord/cordxtra.c
cord/tests/de.c

index 032c4fbae6c70ea377a252d49d4a3e3b45279f28..7fe241153f501737442641ab78de87278dc29d60 100644 (file)
@@ -227,6 +227,9 @@ CORD CORD_cat_char_star(CORD x, const char * y, size_t leny)
         result->len = (word)result_len;
         result->left = x;
         result->right = y;
+        GC_END_STUBBORN_CHANGE(result);
+        GC_reachable_here(x);
+        GC_reachable_here(y);
         if (depth >= MAX_DEPTH) {
             return(CORD_balance((CORD)result));
         } else {
@@ -269,6 +272,9 @@ CORD CORD_cat(CORD x, CORD y)
         result->len = (word)result_len;
         result->left = x;
         result->right = y;
+        GC_END_STUBBORN_CHANGE(result);
+        GC_reachable_here(x);
+        GC_reachable_here(y);
         if (depth >= MAX_DEPTH) {
             return(CORD_balance((CORD)result));
         } else {
@@ -310,6 +316,8 @@ static CordRep *CORD_from_fn_inner(CORD_fn fn, void * client_data, size_t len)
         result->len = (word)len;
         result->fn = fn;
         result->client_data = client_data;
+        GC_END_STUBBORN_CHANGE(result);
+        GC_reachable_here(client_data);
         return (CordRep *)result;
     }
 }
@@ -360,6 +368,8 @@ CORD CORD_substr_closure(CORD x, size_t i, size_t n, CORD_fn f)
     if (sa == 0) OUT_OF_MEMORY;
     sa->sa_cord = (CordRep *)x;
     sa->sa_index = i;
+    GC_END_STUBBORN_CHANGE(sa);
+    GC_reachable_here(x);
     result = CORD_from_fn_inner(f, (void *)sa, n);
     if ((CORD)result != CORD_EMPTY && 0 == result -> function.null)
         result -> function.header = SUBSTR_HDR;
index b89f1a30746a73dc2392c2b372ce29af08fea301..9f3e10005e86cada933d5351acd6ec26ddfcd579 100644 (file)
@@ -546,6 +546,8 @@ static void * GC_CALLBACK refill_cache(void * client_data)
     new_cache -> tag = DIV_LINE_SZ(file_pos);
     /* Store barrier goes here. */
     ATOMIC_WRITE(state -> lf_cache[line_no], new_cache);
+    GC_END_STUBBORN_CHANGE((/* no volatile */ void *)(state -> lf_cache
+                                                      + line_no));
     state -> lf_current = line_start + LINE_SZ;
     return (void *)((GC_word)new_cache->data[MOD_LINE_SZ(file_pos)]);
 }
index 7fb355212aa5268a9184834846e440b1bbfd9f85..61ee72fb6b34ee8492efc0e72eabb0d6d32de01b 100644 (file)
@@ -133,7 +133,11 @@ void prune_map(void)
     do {
         current_map_size++;
         if (map -> line < start_line - LINES && map -> previous != 0) {
-            map -> previous = map -> previous -> previous;
+            line_map pred = map -> previous -> previous;
+
+            map -> previous = pred;
+            GC_END_STUBBORN_CHANGE(map);
+            GC_reachable_here(pred);
         }
         map = map -> previous;
     } while (map != 0);
@@ -143,12 +147,16 @@ void prune_map(void)
 void add_map(int line_arg, size_t pos)
 {
     line_map new_map = GC_NEW(struct LineMapRep);
+    line_map cur_map;
 
     if (NULL == new_map) OUT_OF_MEMORY;
     if (current_map_size >= MAX_MAP_SIZE) prune_map();
     new_map -> line = line_arg;
     new_map -> pos = pos;
-    new_map -> previous = current_map;
+    cur_map = current_map;
+    new_map -> previous = cur_map;
+    GC_END_STUBBORN_CHANGE(new_map);
+    GC_reachable_here(cur_map);
     current_map = new_map;
     current_map_size++;
 }
@@ -194,7 +202,11 @@ void add_hist(CORD s)
     new_file -> file_contents = current = s;
     current_len = CORD_len(s);
     new_file -> previous = now;
-    if (now != 0) now -> map = current_map;
+    GC_END_STUBBORN_CHANGE(new_file);
+    if (now != NULL) {
+        now -> map = current_map;
+        GC_END_STUBBORN_CHANGE(now);
+    }
     now = new_file;
 }
 
@@ -245,6 +257,8 @@ void replace_line(int i, CORD s)
             }
         }
         screen[i] = s;
+        GC_END_STUBBORN_CHANGE(screen + i);
+        GC_reachable_here(s);
     }
 }
 #else
@@ -566,6 +580,7 @@ void generic_init(void)
     add_hist(initial);
     now -> map = current_map;
     now -> previous = now;  /* Can't back up further: beginning of the world */
+    GC_END_STUBBORN_CHANGE(now);
     need_redisplay = ALL;
     fix_cursor();
 }