From 7dda5b992dec1b1350db1747bd34c92423625c18 Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Wed, 16 Mar 2022 21:36:21 +0100 Subject: [PATCH] Refactor pop_handle to not take the handle --- conservative-roots.h | 2 +- gcbench.c | 20 ++++++++++---------- precise-roots.h | 6 +++--- quads.c | 4 ++-- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/conservative-roots.h b/conservative-roots.h index 7f2db0abd..f5b1a5708 100644 --- a/conservative-roots.h +++ b/conservative-roots.h @@ -4,4 +4,4 @@ struct handle { void *unused; }; #define HANDLE_REF(h) h.v #define HANDLE_SET(h,val) do { h.v = val; } while (0) #define PUSH_HANDLE(cx, h) do { (void) &h; } while (0) -#define POP_HANDLE(cx, h) do { (void) &h; } while (0) +#define POP_HANDLE(cx) do { } while (0) diff --git a/gcbench.c b/gcbench.c index 90e85a5fa..d57258ccc 100644 --- a/gcbench.c +++ b/gcbench.c @@ -145,9 +145,9 @@ static void Populate(struct context *cx, int iDepth, Node *node) { set_field((void**)&HANDLE_REF(self)->right, HANDLE_REF(r)); Populate (cx, iDepth, HANDLE_REF(self)->left); Populate (cx, iDepth, HANDLE_REF(self)->right); - POP_HANDLE(cx, r); - POP_HANDLE(cx, l); - POP_HANDLE(cx, self); + POP_HANDLE(cx); + POP_HANDLE(cx); + POP_HANDLE(cx); } } @@ -162,8 +162,8 @@ static Node* MakeTree(struct context *cx, int iDepth) { PUSH_HANDLE(cx, right); Node *result = allocate_node(cx); init_Node(result, HANDLE_REF(left), HANDLE_REF(right)); - POP_HANDLE(cx, right); - POP_HANDLE(cx, left); + POP_HANDLE(cx); + POP_HANDLE(cx); return result; } } @@ -216,7 +216,7 @@ static void TimeConstruction(struct context *cx, int depth) { tFinish - tStart); } - POP_HANDLE(cx, tempTree); + POP_HANDLE(cx); } int main() { @@ -294,9 +294,9 @@ int main() { printf("Completed in %ld msec\n", tElapsed); print_end_gc_stats(cx); - POP_HANDLE(cx, array); - POP_HANDLE(cx, tempTree); - POP_HANDLE(cx, longLivedTree); - POP_HANDLE(cx, root); + POP_HANDLE(cx); + POP_HANDLE(cx); + POP_HANDLE(cx); + POP_HANDLE(cx); } diff --git a/precise-roots.h b/precise-roots.h index 919154b99..0465083b9 100644 --- a/precise-roots.h +++ b/precise-roots.h @@ -7,13 +7,13 @@ struct handle { #define HANDLE_REF(h) h.v #define HANDLE_SET(h,val) do { h.v = val; } while (0) #define PUSH_HANDLE(cx, h) push_handle(&cx->roots, &h.handle) -#define POP_HANDLE(cx, h) pop_handle(&cx->roots, &h.handle) +#define POP_HANDLE(cx) pop_handle(&cx->roots) static inline void push_handle(struct handle **roots, struct handle *handle) { handle->next = *roots; *roots = handle; } -static inline void pop_handle(struct handle **roots, struct handle *handle) { - *roots = handle->next; +static inline void pop_handle(struct handle **roots) { + *roots = (*roots)->next; } diff --git a/quads.c b/quads.c index 5b311b9fd..b6853d5ba 100644 --- a/quads.c +++ b/quads.c @@ -52,7 +52,7 @@ static Quad* make_tree(struct context *cx, int depth) { init_field((void**)&result->kids[i], HANDLE_REF(kids[i])); for (size_t i = 0; i < 4; i++) - POP_HANDLE(cx, kids[3 - i]); + POP_HANDLE(cx); return result; } @@ -162,7 +162,7 @@ int main(int argc, char *argv[]) { print_end_gc_stats(cx); - POP_HANDLE(cx, quad); + POP_HANDLE(cx); return 0; }