Skip to content

Commit

Permalink
use extra bir in specsigflags
Browse files Browse the repository at this point in the history
  • Loading branch information
vchuravy committed Feb 22, 2023
1 parent ae77ba2 commit 15d936b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 2 additions & 4 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4305,10 +4305,8 @@ static jl_cgval_t emit_invoke(jl_codectx_t &ctx, const jl_cgval_t &lival, const
protoname = jl_ExecutionEngine->getFunctionAtAddress((uintptr_t)fptr, codeinst);
if (ctx.external_linkage) {
// TODO: Add !specsig support to aotcompile.cpp
// FIXME: Need to guard against CI being allocated in image,
// but not filled in. If `fptr` non-null due to JIT compilation
// of this image, we will during loading find an empty CI.
if (specsig && jl_object_in_image((jl_value_t*)codeinst)) {
// Check that the codeinst is containing native code
if (specsig && jl_atomic_load_relaxed(&codeinst->specsigflags) & 0b100) {
external = true;
need_to_emit = false;
}
Expand Down
4 changes: 3 additions & 1 deletion src/julia.h
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,9 @@ typedef struct _jl_code_instance_t {
jl_value_t *argescapes; // escape information of call arguments

// compilation state cache
_Atomic(uint8_t) specsigflags; // & 0b1 == specptr is a specialized function signature for specTypes->rettype, &0b10 == invokeptr matches specptr
_Atomic(uint8_t) specsigflags; // & 0b001 == specptr is a specialized function signature for specTypes->rettype
// & 0b010 == invokeptr matches specptr
// & 0b100 == From image
_Atomic(uint8_t) precompile; // if set, this will be added to the output system image
uint8_t relocatability; // nonzero if all roots are built into sysimg or tagged by module key
_Atomic(jl_callptr_t) invoke; // jlcall entry point
Expand Down
6 changes: 3 additions & 3 deletions src/staticdata.c
Original file line number Diff line number Diff line change
Expand Up @@ -1077,7 +1077,7 @@ static void record_external_fns(jl_serializer_state *s, arraylist_t *external_fn
#ifndef JL_NDEBUG
for (size_t i = 0; i < external_fns->len; i++) {
jl_code_instance_t *ci = (jl_code_instance_t*)external_fns->items[i];
assert(jl_object_in_image((jl_value_t*)ci));
assert(jl_atomic_load_relaxed(&ci->specsigflags) & 0b100);
}
#endif
}
Expand Down Expand Up @@ -1889,7 +1889,7 @@ static void jl_update_all_fptrs(jl_serializer_state *s, jl_image_t *image)
void *fptr = (void*)(base + offset);
if (specfunc) {
codeinst->specptr.fptr = fptr;
codeinst->specsigflags = 0b11; // TODO: set only if confirmed to be true
codeinst->specsigflags = 0b111; // TODO: set only if confirmed to be true
}
else {
codeinst->invoke = (jl_callptr_t)fptr;
Expand All @@ -1913,7 +1913,7 @@ static uint32_t write_gvars(jl_serializer_state *s, arraylist_t *globals, arrayl
}
for (size_t i = 0; i < external_fns->len; i++) {
jl_code_instance_t *ci = (jl_code_instance_t*)external_fns->items[i];
assert(ci && ci->isspecsig);
assert(ci && (jl_atomic_load_relaxed(&ci->specsigflags) & 0b001));
uintptr_t item = backref_id(s, (void*)ci, s->link_ids_external_fnvars);
uintptr_t reloc = get_reloc_for_item(item, 0);
write_reloc_t(s->gvar_record, reloc);
Expand Down

0 comments on commit 15d936b

Please sign in to comment.