Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 3 additions & 0 deletions src/julia_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -1281,6 +1281,9 @@ JL_DLLEXPORT void jl_force_trace_compile_timing_disable(void);
JL_DLLEXPORT void jl_force_trace_dispatch_enable(void);
JL_DLLEXPORT void jl_force_trace_dispatch_disable(void);

JL_DLLEXPORT void jl_tag_newly_inferred_enable(void);
JL_DLLEXPORT void jl_tag_newly_inferred_disable(void);

uint32_t jl_module_next_counter(jl_module_t *m) JL_NOTSAFEPOINT;
jl_tupletype_t *arg_type_tuple(jl_value_t *arg1, jl_value_t **args, size_t nargs);

Expand Down
23 changes: 23 additions & 0 deletions src/staticdata_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,23 @@ static jl_array_t *newly_inferred JL_GLOBALLY_ROOTED /*FIXME*/;
// Mutex for newly_inferred
jl_mutex_t newly_inferred_mutex;
extern jl_mutex_t world_counter_lock;
static _Atomic(uint8_t) jl_tag_newly_inferred_enabled = 0;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could just be a UInt64 since we are using a whole cache line anyways


/**
* @brief Enable tagging of all newly inferred CodeInstances.
*/
JL_DLLEXPORT void jl_tag_newly_inferred_enable(void)
{
jl_atomic_fetch_add(&jl_tag_newly_inferred_enabled, 1); // FIXME overflow?
}
/**
* @brief Disable tagging of all newly inferred CodeInstances.
*/
JL_DLLEXPORT void jl_tag_newly_inferred_disable(void)
{
jl_atomic_fetch_add(&jl_tag_newly_inferred_enabled, -1); // FIXME underflow?
}


// Register array of newly-inferred MethodInstances
// This gets called as the first step of Base.include_package_for_output
Expand All @@ -101,6 +118,12 @@ JL_DLLEXPORT void jl_push_newly_inferred(jl_value_t* ci)
{
if (!newly_inferred)
return;
uint8_t tag_newly_inferred = jl_atomic_load_relaxed(&jl_tag_newly_inferred_enabled);
if (tag_newly_inferred) {
jl_method_instance_t *mi = jl_get_ci_mi((jl_code_instance_t*)ci);
uint8_t miflags = jl_atomic_load_relaxed(&mi->flags);
jl_atomic_store_relaxed(&mi->flags, miflags | JL_MI_FLAGS_MASK_PRECOMPILED);
}
JL_LOCK(&newly_inferred_mutex);
size_t end = jl_array_nrows(newly_inferred);
jl_array_grow_end(newly_inferred, 1);
Expand Down