Branch: Tag:

2014-12-04

2014-12-04 19:26:38 by Henrik Grubbström (Grubba) <grubba@grubba.org>

GC: Added visit_{enter,leave}() API.

Make it easier to keep track of state in the visit_*() API
by tracking when we start and stop visiting things.

4399:   /* Visit things API */      PMOD_EXPORT visit_ref_cb *visit_ref = NULL; + PMOD_EXPORT visit_enter_cb *visit_enter = NULL; + PMOD_EXPORT visit_leave_cb *visit_leave = NULL;      /* Be careful if extending this with internal types like    * T_MAPPING_DATA and T_MULTISET_DATA; there's code that assumes
5283:    }   }    + static void ignore_visit_enter(void *thing, int type, void *extra) + { + } +  + static void ignore_visit_leave(void *thing, int type, void *extra) + { + } +    PMOD_EXPORT int mc_count_bytes (void *thing)   {    if (mc_pass == MC_PASS_LOOKAHEAD) {
5608:    mc_wq_used = 1;       assert (!mc_pass); +  assert (visit_enter == NULL);    assert (visit_ref == NULL); -  +  assert (visit_leave == NULL);       free_svalue (&throw_value);    mark_free_svalue (&throw_value);
5693:    count_internal = count_cyclic = count_visited = 0;    count_visits = count_revisits = count_rounds = 0;    +  visit_enter = ignore_visit_enter;    visit_ref = mc_lookahead < 0 ?    current_only_visit_ref : pass_lookahead_visit_ref; -  +  visit_leave = ignore_visit_leave;       do {    count_rounds++;
6014:    }       mc_pass = 0; +  visit_enter = NULL;    visit_ref = NULL; -  +  visit_leave = NULL;       DL_MAKE_EMPTY (mc_incomplete);    DL_MAKE_EMPTY (mc_indirect);