Skip to content

Commit

Permalink
kernel: fix Julia GC code
Browse files Browse the repository at this point in the history
  • Loading branch information
fingolfin committed Sep 8, 2018
1 parent d48bd64 commit 40c9c4c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
14 changes: 14 additions & 0 deletions src/julia_gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ static inline Bag * DATA(BagHeader * bag)
}


static TNumExtraMarkFuncBags ExtraMarkFuncBags;
void SetExtraMarkFuncBags(TNumExtraMarkFuncBags func)
{
ExtraMarkFuncBags = func;
}


/****************************************************************************
**
*F InitFreeFuncBag(<type>,<free-func>)
Expand Down Expand Up @@ -498,6 +505,13 @@ void GapRootScanner(int full)
// types, which thus also will not be collected prematurely)
JMark(Module);

// allow installing a custom marking function. This is used for
// integrating GAP (possibly linked as a shared library) with other code
// bases which use their own form of garbage collection. For example,
// with Python (for SageMath).
if (ExtraMarkFuncBags)
(*ExtraMarkFuncBags)();

// scan the stack for further object references, and mark them
syJmp_buf registers;
sySetjmp(registers);
Expand Down
4 changes: 2 additions & 2 deletions src/weakptr.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,12 @@ static inline void SET_ELM_WPOBJ(Obj list, UInt pos, Obj val)
ptr[pos] = val;
return;
}
jl_weakref_t * wref = (jl_weakref_t *)(ptr[pos]);
if (!IS_BAG_REF(wref)) {
if (!IS_BAG_REF(ptr[pos])) {
ptr[pos] = (Bag)jl_gc_new_weakref((jl_value_t *)val);
jl_gc_wb_back(BAG_HEADER(list));
}
else {
jl_weakref_t * wref = (jl_weakref_t *)(ptr[pos]);
wref->value = (jl_value_t *)val;
jl_gc_wb(wref, BAG_HEADER(val));
}
Expand Down

0 comments on commit 40c9c4c

Please sign in to comment.