1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-13 17:20:21 +02:00

Refactor pop_handle to not take the handle

This commit is contained in:
Andy Wingo 2022-03-16 21:36:21 +01:00
parent 32ddaa7624
commit 7dda5b992d
4 changed files with 16 additions and 16 deletions

View file

@ -4,4 +4,4 @@ struct handle { void *unused; };
#define HANDLE_REF(h) h.v #define HANDLE_REF(h) h.v
#define HANDLE_SET(h,val) do { h.v = val; } while (0) #define HANDLE_SET(h,val) do { h.v = val; } while (0)
#define PUSH_HANDLE(cx, h) do { (void) &h; } 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)

View file

@ -145,9 +145,9 @@ static void Populate(struct context *cx, int iDepth, Node *node) {
set_field((void**)&HANDLE_REF(self)->right, HANDLE_REF(r)); set_field((void**)&HANDLE_REF(self)->right, HANDLE_REF(r));
Populate (cx, iDepth, HANDLE_REF(self)->left); Populate (cx, iDepth, HANDLE_REF(self)->left);
Populate (cx, iDepth, HANDLE_REF(self)->right); Populate (cx, iDepth, HANDLE_REF(self)->right);
POP_HANDLE(cx, r); POP_HANDLE(cx);
POP_HANDLE(cx, l); POP_HANDLE(cx);
POP_HANDLE(cx, self); POP_HANDLE(cx);
} }
} }
@ -162,8 +162,8 @@ static Node* MakeTree(struct context *cx, int iDepth) {
PUSH_HANDLE(cx, right); PUSH_HANDLE(cx, right);
Node *result = allocate_node(cx); Node *result = allocate_node(cx);
init_Node(result, HANDLE_REF(left), HANDLE_REF(right)); init_Node(result, HANDLE_REF(left), HANDLE_REF(right));
POP_HANDLE(cx, right); POP_HANDLE(cx);
POP_HANDLE(cx, left); POP_HANDLE(cx);
return result; return result;
} }
} }
@ -216,7 +216,7 @@ static void TimeConstruction(struct context *cx, int depth) {
tFinish - tStart); tFinish - tStart);
} }
POP_HANDLE(cx, tempTree); POP_HANDLE(cx);
} }
int main() { int main() {
@ -294,9 +294,9 @@ int main() {
printf("Completed in %ld msec\n", tElapsed); printf("Completed in %ld msec\n", tElapsed);
print_end_gc_stats(cx); print_end_gc_stats(cx);
POP_HANDLE(cx, array); POP_HANDLE(cx);
POP_HANDLE(cx, tempTree); POP_HANDLE(cx);
POP_HANDLE(cx, longLivedTree); POP_HANDLE(cx);
POP_HANDLE(cx, root); POP_HANDLE(cx);
} }

View file

@ -7,13 +7,13 @@ struct handle {
#define HANDLE_REF(h) h.v #define HANDLE_REF(h) h.v
#define HANDLE_SET(h,val) do { h.v = val; } while (0) #define HANDLE_SET(h,val) do { h.v = val; } while (0)
#define PUSH_HANDLE(cx, h) push_handle(&cx->roots, &h.handle) #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) { static inline void push_handle(struct handle **roots, struct handle *handle) {
handle->next = *roots; handle->next = *roots;
*roots = handle; *roots = handle;
} }
static inline void pop_handle(struct handle **roots, struct handle *handle) { static inline void pop_handle(struct handle **roots) {
*roots = handle->next; *roots = (*roots)->next;
} }

View file

@ -52,7 +52,7 @@ static Quad* make_tree(struct context *cx, int depth) {
init_field((void**)&result->kids[i], HANDLE_REF(kids[i])); init_field((void**)&result->kids[i], HANDLE_REF(kids[i]));
for (size_t i = 0; i < 4; i++) for (size_t i = 0; i < 4; i++)
POP_HANDLE(cx, kids[3 - i]); POP_HANDLE(cx);
return result; return result;
} }
@ -162,7 +162,7 @@ int main(int argc, char *argv[]) {
print_end_gc_stats(cx); print_end_gc_stats(cx);
POP_HANDLE(cx, quad); POP_HANDLE(cx);
return 0; return 0;
} }