Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kernel: fix Julia GC code #2793

Merged
merged 1 commit into from
Sep 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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