diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2018-07-01 16:53:15 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2018-07-01 16:53:15 +0300 |
commit | 2e7daad62ee243556b67109535ddfacfb11a0160 (patch) | |
tree | cfaaf493c0fe2642721f0b7ec1e8eae9fa8d1f62 /cord | |
parent | c6107dca026f023f96af3f66f465a0727389ff7c (diff) | |
download | bdwgc-2e7daad62ee243556b67109535ddfacfb11a0160.tar.gz |
New public API (PTR_STORE_AND_DIRTY) to simplify store-and-dirty operation
* cord/cordbscs.c (CORD_cat_char_star, CORD_cat, CORD_from_fn_inner,
CORD_substr_closure): Replace the last store to the heap-allocated
object, GC_END_STUBBORN_CHANGE() and GC_reachable_here() with
GC_PTR_STORE_AND_DIRTY() call.
* cord/tests/de.c (prune_map, add_map, replace_line): Likewise.
* include/gc_inline.h (GC_CONS): Likewise.
* tests/disclaim_test.c (pair_dct, pair_new): Likewise.
* tests/test.c [!VERY_SMALL_CONFIG] (cons): Likewise.
* tests/test.c (small_cons, small_cons_uncollectable,
reverse_test_inner, mktree): Likewise.
* tests/test.c [GC_GCJ_SUPPORT] (gcj_cons): Likewise.
* tests/test.c [GC_PTHREADS && !SMALL_CONFIG && !GC_DEBUG]
(alloc8bytes): Likewise.
* tests/test.c [!NO_TYPED_TEST] (typed_test): Likewise.
* tests/test_cpp.cc (main): Likewise.
* dbg_mlc.c (GC_debug_ptr_store_and_dirty): Implement.
* mallocx.c (GC_ptr_store_and_dirty): Likewise.
* include/gc.h (GC_PTR_STORE_AND_DIRTY): New public macro.
* include/gc.h (GC_debug_ptr_store_and_dirty, GC_ptr_store_and_dirty):
Declare new public API function; add comment.
* tests/test.c (reverse_test_inner): Remove tmp local variable.
* tests/test.c (mktree): Remove right_left local variable.
Diffstat (limited to 'cord')
-rw-r--r-- | cord/cordbscs.c | 16 | ||||
-rw-r--r-- | cord/tests/de.c | 12 |
2 files changed, 7 insertions, 21 deletions
diff --git a/cord/cordbscs.c b/cord/cordbscs.c index 7979ff74..117dd9f3 100644 --- a/cord/cordbscs.c +++ b/cord/cordbscs.c @@ -231,10 +231,8 @@ CORD CORD_cat_char_star(CORD x, const char * y, size_t leny) result->left_len = (unsigned char)lenx; result->len = (word)result_len; result->left = x; - result->right = y; - GC_END_STUBBORN_CHANGE(result); + GC_PTR_STORE_AND_DIRTY(&result->right, y); GC_reachable_here(x); - GC_reachable_here(y); if (depth >= MAX_DEPTH) { return(CORD_balance((CORD)result)); } else { @@ -275,10 +273,8 @@ CORD CORD_cat(CORD x, CORD y) result->left_len = (unsigned char)lenx; result->len = (word)result_len; result->left = x; - result->right = y; - GC_END_STUBBORN_CHANGE(result); + GC_PTR_STORE_AND_DIRTY(&result->right, y); GC_reachable_here(x); - GC_reachable_here(y); if (depth >= MAX_DEPTH) { return(CORD_balance((CORD)result)); } else { @@ -318,9 +314,7 @@ static CordRep *CORD_from_fn_inner(CORD_fn fn, void * client_data, size_t len) /* depth is already 0 */ result->len = (word)len; result->fn = fn; - result->client_data = client_data; - GC_END_STUBBORN_CHANGE(result); - GC_reachable_here(client_data); + GC_PTR_STORE_AND_DIRTY(&result->client_data, client_data); return (CordRep *)result; } } @@ -369,10 +363,8 @@ CORD CORD_substr_closure(CORD x, size_t i, size_t n, CORD_fn f) CordRep * result; if (sa == 0) OUT_OF_MEMORY; - sa->sa_cord = (CordRep *)x; sa->sa_index = i; - GC_END_STUBBORN_CHANGE(sa); - GC_reachable_here(x); + GC_PTR_STORE_AND_DIRTY(&sa->sa_cord, x); result = CORD_from_fn_inner(f, (void *)sa, n); if ((CORD)result != CORD_EMPTY && 0 == result -> function.null) result -> function.header = SUBSTR_HDR; diff --git a/cord/tests/de.c b/cord/tests/de.c index 522da919..2fd8c487 100644 --- a/cord/tests/de.c +++ b/cord/tests/de.c @@ -139,9 +139,7 @@ void prune_map(void) if (map -> line < start_line - LINES && map -> previous != 0) { line_map pred = map -> previous -> previous; - map -> previous = pred; - GC_END_STUBBORN_CHANGE(map); - GC_reachable_here(pred); + GC_PTR_STORE_AND_DIRTY(&map->previous, pred); } map = map -> previous; } while (map != 0); @@ -158,9 +156,7 @@ void add_map(int line_arg, size_t pos) new_map -> line = line_arg; new_map -> pos = pos; cur_map = current_map; - new_map -> previous = cur_map; - GC_END_STUBBORN_CHANGE(new_map); - GC_reachable_here(cur_map); + GC_PTR_STORE_AND_DIRTY(&new_map->previous, cur_map); current_map = new_map; current_map_size++; } @@ -260,9 +256,7 @@ void replace_line(int i, CORD s) addch(c); } } - screen[i] = s; - GC_END_STUBBORN_CHANGE(screen + i); - GC_reachable_here(s); + GC_PTR_STORE_AND_DIRTY(screen + i, s); } } #else |