Skip to content

Commit

Permalink
Various updates for the Julia integration
Browse files Browse the repository at this point in the history
1. test against Julia 1.4.2 instead of 1.2.0
2. fix compiler constness warnings in weakptr.c
3. use `jl_threadid()` and `jl_get_current_task()` helpers to avoid access to
   `JuliaTLS` members

Point 3 is important because the layout of the `jl_ptls_t` struct  keeps
changing between Julia versions, meaning that one has to recompile GAP when
updating Julia. With this patch, we avoid accessing the `tid` and `current_task`
members.

However, we still access `root_task` and `safe_restore`. More work will be needed
to deal with those.
  • Loading branch information
fingolfin committed May 28, 2020
1 parent f9e7e4b commit 27e4a5e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion etc/ci-prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ fi
if [[ $JULIA = yes ]]
then
pushd extern
wget https://julialang-s3.julialang.org/bin/linux/x64/1.2/julia-1.2.0-linux-x86_64.tar.gz
wget https://julialang-s3.julialang.org/bin/linux/x64/1.4/julia-1.4.2-linux-x86_64.tar.gz
tar xvf julia-*.tar.gz
rm julia-*.tar.gz
cd julia-*
Expand Down
15 changes: 9 additions & 6 deletions src/julia_gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
#include <julia.h>
#include <julia_gcext.h>

// import jl_get_current_task from julia_internal.h, which unfortunately
// isn't installed as part of a typical Julia installation
JL_DLLEXPORT jl_value_t *jl_get_current_task(void);

/****************************************************************************
**
Expand Down Expand Up @@ -554,9 +557,9 @@ static void GapRootScanner(int full)
// Module is a valid Julia object at this point, so further checks
// in JMark() can be skipped.
jl_gc_mark_queue_obj(JuliaTLS, (jl_value_t *)Module);
jl_task_t * task = JuliaTLS->current_task;
jl_task_t * task = (jl_task_t *)jl_get_current_task();
size_t size;
int tid;
int tid; // unused
// We figure out the end of the stack from the current task. While
// `stack_bottom` is passed to InitBags(), we cannot use that if
// current_task != root_task.
Expand All @@ -567,13 +570,13 @@ static void GapRootScanner(int full)
//
// 1. GAP is not being used as a library, but is the main program
// and in charge of the main() function.
// 2. The stack of the current task is that of the main task of the
// main thread.
// 2. The stack of the current task is that of the root task of the
// main thread (which has thread id 0).
//
// The reason is that if Julia is being initialized from GAP, it
// cannot always reliably find the top of the stack for that task,
// so we have to fall back to GAP for that.
if (!IsUsingLibGap() && JuliaTLS->tid == 0 &&
if (!IsUsingLibGap() && jl_threadid() == 0 &&
JuliaTLS->root_task == task) {
stackend = (char *)GapStackBottom;
}
Expand Down Expand Up @@ -607,7 +610,7 @@ static void GapTaskScanner(jl_task_t * task, int root_task)
char * stack = (char *)jl_task_stack_buffer(task, &size, &tid);
// If it is the current task, it has been scanned by GapRootScanner()
// already.
if (task == JuliaTLS->current_task)
if (task == (jl_task_t *)jl_get_current_task())
return;
int rescan = 1;
if (!FullGC) {
Expand Down

0 comments on commit 27e4a5e

Please sign in to comment.