1
0
mirror of https://github.com/janet-lang/janet synced 2024-11-10 10:49:54 +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:
Calvin Rose 2017-05-05 23:33:36 -04:00
parent f817610d4a
commit d47ee18b1a
4 changed files with 12 additions and 10 deletions

View File

@ -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

View File

@ -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,15 +1149,18 @@ 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) {
if (st->slots)
gst_mark_mem(vm, st->slots);
st = st->next;
}
/* Mark scopes */
scope = c->tail;
while (scope) {
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));

View File

@ -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);

View File

@ -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) {