more gc track support
@@ -1115,18 +1115,23 @@ static int tracked_max = 0;
static void hl_gc_check_track() {
int i;
+ vdynamic p;
+ vdynamic *pptr = &p;
+ p.t = &hlt_bool;
for(i=0;i<tracked_count;i++) {
hl_track *tr = tracked + i;
if( !tr->value ) continue;
if( !hl_is_gc_ptr((void*)hide_ptr(tr->obj)) /*GC'ed!*/ ) {
hl_is_gc_ptr((void*)hide_ptr(tr->obj));
tr->value = NULL;
+ p.v.b = true;
} else {
int_val v = hide_ptr(*tr->value);
if( v == tr->old_value ) continue;
tr->old_value = v;
+ p.v.b = false;
}
- hl_dyn_call(tr->callb,NULL,0);
+ hl_dyn_call(tr->callb,&pptr,1);
}
}
@@ -1145,6 +1150,20 @@ HL_API bool hl_gc_track( vdynamic *dobj, int fid, vclosure *callb ) {
value = (void**)((char*)obj + c->offsets[fid]);
}
break;
+ case HOBJ:
+ {
+ hl_runtime_obj *rt = dobj->t->obj->rt;
+ hl_field_lookup *f = NULL;
+ while( rt ) {
+ f = hl_lookup_find(rt->lookup,rt->nlookup,fid);
+ if( f ) break;
+ rt = rt->parent;
+ }
+ if( !f || f->field_index < 0 ) return false;
+ obj = dobj;
+ value = (void**)((char*)obj + f->field_index);
+ }
+ break;
default:
return false;
}
@@ -1203,7 +1222,7 @@ HL_API int hl_gc_track_count() {
return tracked_count;
}
-DEFINE_PRIM(_BOOL, gc_track, _DYN _I32 _FUN(_VOID, _NO_ARG));
+DEFINE_PRIM(_BOOL, gc_track, _DYN _I32 _FUN(_VOID, _BOOL));
DEFINE_PRIM(_BOOL, gc_untrack, _DYN);
DEFINE_PRIM(_VOID, gc_untrack_all, _NO_ARG);
DEFINE_PRIM(_I32, gc_track_count, _NO_ARG);
