Skip to content

Commit 9563961

Browse files
JeffBezansonKristofferC
authored andcommitted
add specialized codegen for jl_get_current_task (#32812)
1 parent e81635a commit 9563961

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/ccall.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1607,6 +1607,17 @@ static jl_cgval_t emit_ccall(jl_codectx_t &ctx, jl_value_t **args, size_t nargs)
16071607
tbaa_decorate(tbaa_const, ctx.builder.CreateLoad(ptid)),
16081608
retboxed, rt, unionall, static_rt);
16091609
}
1610+
else if (is_libjulia_func(jl_get_current_task)) {
1611+
assert(lrt == T_prjlvalue);
1612+
assert(!isVa && !llvmcall && nccallargs == 0);
1613+
JL_GC_POP();
1614+
Value *ptls_pv = emit_bitcast(ctx, ctx.ptlsStates, T_pprjlvalue);
1615+
const int ct_offset = offsetof(jl_tls_states_t, current_task);
1616+
Value *pct = ctx.builder.CreateGEP(ptls_pv, ConstantInt::get(T_size, ct_offset / sizeof(void*)));
1617+
return mark_or_box_ccall_result(ctx,
1618+
tbaa_decorate(tbaa_const, ctx.builder.CreateLoad(pct)),
1619+
retboxed, rt, unionall, static_rt);
1620+
}
16101621
else if (is_libjulia_func(jl_sigatomic_begin)) {
16111622
assert(lrt == T_void);
16121623
assert(!isVa && !llvmcall && nccallargs == 0);

src/julia_internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,6 +1014,7 @@ JL_DLLEXPORT jl_value_t *(jl_array_data_owner)(jl_array_t *a);
10141014
JL_DLLEXPORT int jl_array_isassigned(jl_array_t *a, size_t i);
10151015

10161016
JL_DLLEXPORT uintptr_t jl_object_id_(jl_value_t *tv, jl_value_t *v) JL_NOTSAFEPOINT;
1017+
JL_DLLEXPORT jl_value_t *jl_get_current_task(void);
10171018

10181019
// -- synchronization utilities -- //
10191020

0 commit comments

Comments
 (0)