core: register the finalizer immedietely after allocation

Previously we've registered the finalizer when a symbol was dynamically bound
for the first time; this commit changes that to remove a dependency on GC when
binding special variables.
This commit is contained in:
Daniel Kochmański 2024-04-23 09:42:54 +02:00
parent fdbff61f51
commit d4c20918b9
3 changed files with 5 additions and 4 deletions

View file

@ -889,9 +889,10 @@ standard_finalizer(cl_object o)
break;
}
case t_symbol: {
ecl_atomic_push(&cl_core.reused_indices,
ecl_make_fixnum(o->symbol.binding));
o->symbol.binding = ECL_MISSING_SPECIAL_BINDING;
if (o->symbol.binding != ECL_MISSING_SPECIAL_BINDING) {
ecl_atomic_push(&cl_core.reused_indices, ecl_make_fixnum(o->symbol.binding));
o->symbol.binding = ECL_MISSING_SPECIAL_BINDING;
}
}
#endif /* ECL_THREADS */
default:;

View file

@ -435,7 +435,6 @@ ecl_new_binding_index(cl_env_ptr env, cl_object symbol)
}
symbol->symbol.binding = new_index;
}
ecl_set_finalizer_unprotected(symbol, ECL_T);
return new_index;
}

View file

@ -112,6 +112,7 @@ cl_make_symbol(cl_object str)
x->symbol.plist = ECL_NIL;
x->symbol.hpack = ECL_NIL;
x->symbol.stype = ecl_stp_ordinary;
ecl_set_finalizer_unprotected(x, ECL_T);
@(return x);
}