From d3a6418b0b4e15f8f9f2c14151f49040dff5958a Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Mon, 9 Nov 2015 23:04:56 -0500 Subject: [PATCH] WIP --- gc.c | 49 +++++++++++++++++++++++------------------ include/cyclone/types.h | 2 +- 2 files changed, 29 insertions(+), 22 deletions(-) diff --git a/gc.c b/gc.c index 17fc7124..2c369457 100644 --- a/gc.c +++ b/gc.c @@ -665,27 +665,34 @@ void gc_wait_handshake() // GC Collection cycle // TODO: -//void gc_collector() -//{ -// clear : stage clear-or-marking -// exchange values of markColor and clearColor -// weakRefsList:clear() -// Handshake(sync1) -// mark: Handshake(sync2) -// stage tracing -// postHandshake(async) -// mark global roots -// waitHandshake -// trace : CollectorTrace() -// stage refProcessing -// processRefs() -// stage sweeping -// sweep : For each object x in the heap: -// if (color(x) = clearColor) -// free free [ x -// color(x) blue -// stage resting -//} +void gc_collector() +{ + int tmp; + // TODO: what kind of sync is required here? + + //clear + gc_stage = STAGE_CLEAR_OR_MARKING; + // exchange values of markColor and clearColor + tmp = gc_color_clear; + gc_color_clear = gc_color_mark; + gc_color_mark = tmp; + gc_handshake(STATUS_SYNC1); + //mark: + gc_handshake(STATUS_SYNC2) + gc_stage = STAGE_TRACING; + gc_post_handshake(STATUS_ASYNC); + TODO: mark global roots + gc_wait_handshake(); + //trace : + CollectorTrace() + gc_stage = STAGE_SWEEPING; + //sweep : + For each object x in the heap: + if (color(x) = clearColor) + free free [ x + color(x) blue + gc_stage = STAGE_RESTING; +} ///////////////////////////////////////////// // END tri-color marking section diff --git a/include/cyclone/types.h b/include/cyclone/types.h index 5de7d56c..69f2466e 100644 --- a/include/cyclone/types.h +++ b/include/cyclone/types.h @@ -108,7 +108,7 @@ typedef enum { STATUS_ASYNC typedef enum { STAGE_CLEAR_OR_MARKING , STAGE_TRACING - , STAGE_REF_PROCESSING + //, STAGE_REF_PROCESSING , STAGE_SWEEPING , STAGE_RESTING } gc_stage_type;