Parcourir la source

Made the garbage collector preserve object whose only reference are statically defined in function code #2

main
Ludovic 'Archivist' Lagouardette il y a 1 semaine
Parent
révision
acc5e366ad
1 fichiers modifiés avec 12 ajouts et 2 suppressions
  1. +12
    -2
      lib.c

+ 12
- 2
lib.c Voir le fichier

@ -1300,6 +1300,7 @@ void ink_gc(struct context* ctx) {
int i, j, k;
int marked;
struct element_slab* v;
struct elem* thing;
for(i = 0; i < ctx->types_top; ++i) {
for(j = 0; j < ctx->types[i].elements_top; ++j) {
@ -1329,11 +1330,20 @@ void ink_gc(struct context* ctx) {
continue;
} else for(j = 0; j < ctx->routines[i].top; ++j) {
v = ink_get_value_link(ctx, ctx->routines[i].stack[j]);
if(v != NULL) ++v->uses;
if(v != NULL && !v->uses) ++v->uses;
}
}
/* TODO: Mark objects contained within function code */
for(i = 0; i < ctx->native_words_top; ++i) {
struct fn* function = ctx->words + i;
for(j = 0; j < function->size; ++j) {
thing = function->things + j;
v = ink_get_value_link(ctx, *thing);
if (v != NULL && !v->uses) {
++v->uses;
}
}
}
/* Mark the rest of the data */
do {

Chargement…
Annuler
Enregistrer