mirror of
https://github.com/janet-lang/janet
synced 2024-11-19 07:04:48 +00:00
Fix gc mark function in compiler.
GNU readline is not valgrind clean or it is being used incorrectly.
This commit is contained in:
parent
f817610d4a
commit
d47ee18b1a
2
Makefile
2
Makefile
@ -41,7 +41,7 @@ debug: $(GST_TARGET)
|
||||
gdb $(GST_TARGET)
|
||||
|
||||
valgrind: $(GST_TARGET)
|
||||
valgrind ./$(GST_TARGET)
|
||||
valgrind --leak-check=full ./$(GST_TARGET)
|
||||
|
||||
clean:
|
||||
rm $(GST_TARGET) || true
|
||||
|
@ -1140,7 +1140,7 @@ GstFunction *gst_compiler_compile(GstCompiler *c, GstValue form) {
|
||||
/* Stl */
|
||||
/***/
|
||||
|
||||
/* GC mark mark all memory used by the compiler */
|
||||
/* GC mark all memory used by the compiler */
|
||||
static void gst_compiler_mark(Gst *vm, void *data, uint32_t len) {
|
||||
SlotTracker *st;
|
||||
GstScope *scope;
|
||||
@ -1149,16 +1149,19 @@ static void gst_compiler_mark(Gst *vm, void *data, uint32_t len) {
|
||||
return;
|
||||
/* Mark compiler */
|
||||
gst_mark_value(vm, gst_wrap_buffer(c->buffer));
|
||||
/* Mark trackers */
|
||||
/* Mark trackers - the trackers themselves are all on the stack. */
|
||||
st = (SlotTracker *) c->trackers;
|
||||
while (st) {
|
||||
gst_mark_mem(vm, st->slots);
|
||||
if (st->slots)
|
||||
gst_mark_mem(vm, st->slots);
|
||||
st = st->next;
|
||||
}
|
||||
/* Mark scopes */
|
||||
scope = c->tail;
|
||||
while (scope) {
|
||||
gst_mark_mem(vm, scope->freeHeap);
|
||||
gst_mark_mem(vm, scope);
|
||||
if (scope->freeHeap)
|
||||
gst_mark_mem(vm, scope->freeHeap);
|
||||
gst_mark_value(vm, gst_wrap_array(scope->literalsArray));
|
||||
gst_mark_value(vm, gst_wrap_table(scope->locals));
|
||||
gst_mark_value(vm, gst_wrap_table(scope->literals));
|
||||
@ -1173,7 +1176,7 @@ static const GstUserType gst_stl_compilertype = {
|
||||
"std.compiler",
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&gst_compiler_mark
|
||||
};
|
||||
|
||||
|
@ -176,8 +176,8 @@ void gst_mark(Gst *vm, GstValueUnion x, GstType type) {
|
||||
break;
|
||||
|
||||
case GST_USERDATA:
|
||||
if (gc_header(x.string - sizeof(GstUserdataHeader))->color != vm->black) {
|
||||
GstUserdataHeader *h = (GstUserdataHeader *)x.pointer - 1;
|
||||
if (gc_header(gst_udata_header(x.pointer))->color != vm->black) {
|
||||
GstUserdataHeader *h = gst_udata_header(x.pointer);
|
||||
gc_header(h)->color = vm->black;
|
||||
if (h->type->gcmark)
|
||||
h->type->gcmark(vm, x.pointer, h->size);
|
||||
|
@ -79,7 +79,7 @@ void *gst_check_userdata(Gst *vm, uint32_t i, const GstUserType *type) {
|
||||
GstValue x = gst_arg(vm, i);
|
||||
GstUserdataHeader *h;
|
||||
if (x.type != GST_USERDATA) return NULL;
|
||||
h = ((GstUserdataHeader *)x.data.pointer) - 1;
|
||||
h = gst_udata_header(x.data.pointer);
|
||||
if (h->type != type) return NULL;
|
||||
return x.data.pointer;
|
||||
}
|
||||
@ -111,7 +111,6 @@ GstValue gst_cmodule_struct(Gst *vm, const GstModuleItem *mod) {
|
||||
++m;
|
||||
}
|
||||
return gst_wrap_struct(gst_struct_end(vm, st));
|
||||
|
||||
}
|
||||
|
||||
void gst_module_put(Gst *vm, const char *packagename, GstValue mod) {
|
||||
|
Loading…
Reference in New Issue
Block a user