diff --git a/src/codegen.cpp b/src/codegen.cpp index 93015c1bce834..a9f2e388787ce 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -3734,7 +3734,7 @@ static Function *emit_function(jl_lambda_info_t *lam, bool cstyle) ctx.f = f; // step 5. set up debug info context and create first basic block - bool in_user_code = !is_submodule(jl_base_module, lam->module); + bool in_user_code = !jl_is_submodule(lam->module, jl_base_module) && !jl_is_submodule(lam->module, jl_core_module); bool do_coverage = jl_compileropts.code_coverage == JL_LOG_ALL || (jl_compileropts.code_coverage == JL_LOG_USER && in_user_code); bool do_malloc_log = jl_compileropts.malloc_log == JL_LOG_ALL || (jl_compileropts.malloc_log == JL_LOG_USER && in_user_code); jl_value_t *stmt = jl_cellref(stmts,0); diff --git a/src/dump.c b/src/dump.c index f5de8e207fae0..ae220b78d9663 100644 --- a/src/dump.c +++ b/src/dump.c @@ -338,17 +338,6 @@ static void jl_update_all_fptrs() delayed_fptrs = NULL; } -int is_submodule(jl_module_t *parent, jl_module_t *child) -{ - while (1) { - if (parent == child) - return 1; - if (child == NULL || child == child->parent) - return 0; - child = child->parent; - } -} - // --- serialize --- static void jl_serialize_fptr(ios_t *s, void *fptr) @@ -367,7 +356,7 @@ static void jl_serialize_datatype(ios_t *s, jl_datatype_t *dt) tag = 6; // must use apply_type } else if (mode == MODE_MODULE) { - int internal = is_submodule(jl_current_module, dt->name->module); + int internal = jl_is_submodule(dt->name->module, jl_current_module); if (!internal && dt->name->primary == (jl_value_t*)dt) { tag = 6; // external primary type } @@ -440,11 +429,11 @@ static void jl_serialize_module(ios_t *s, jl_module_t *m) jl_serialize_value(s, m->name); int ref_only = 0; if (mode == MODE_MODULE_LAMBDAS) { - assert(!is_submodule(jl_current_module, m)); + assert(!jl_is_submodule(m, jl_current_module)); ref_only = 1; } if (mode == MODE_MODULE) { - if (!is_submodule(jl_current_module, m)) + if (!jl_is_submodule(m, jl_current_module)) ref_only = 1; write_int8(s, ref_only); } @@ -695,7 +684,7 @@ static void jl_serialize_value_(ios_t *s, jl_value_t *v) writetag(s, (jl_value_t*)jl_datatype_type); jl_serialize_value(s, t); if ((mode == MODE_MODULE || mode == MODE_MODULE_LAMBDAS) && t == jl_typename_type) { - if (is_submodule(jl_current_module, ((jl_typename_t*)v)->module)) { + if (jl_is_submodule(((jl_typename_t*)v)->module, jl_current_module)) { write_uint8(s, 0); } else { @@ -759,7 +748,7 @@ void jl_serialize_methtable_from_mod(ios_t *s, jl_module_t *m, jl_sym_t *name, j } *chain = NULL; jl_methlist_t *ml = mt->defs; while (ml != JL_NULL) { - if (is_submodule(jl_current_module, ml->func->linfo->module)) { + if (jl_is_submodule(ml->func->linfo->module, jl_current_module)) { struct _chain *link = (struct _chain*)alloca(sizeof(struct _chain)); link->ml = ml; link->next = chain; diff --git a/src/julia.h b/src/julia.h index 0c0b88fda03a5..c3879f7c1a696 100644 --- a/src/julia.h +++ b/src/julia.h @@ -806,7 +806,7 @@ STATIC_INLINE jl_function_t *jl_get_function(jl_module_t *m, const char *name) } DLLEXPORT void jl_module_run_initializer(jl_module_t *m); jl_function_t *jl_module_call_func(jl_module_t *m); -int is_submodule(jl_module_t *parent, jl_module_t *child); +int jl_is_submodule(jl_module_t *child, jl_module_t *parent); // eq hash tables DLLEXPORT jl_array_t *jl_eqtable_put(jl_array_t *h, void *key, void *val); diff --git a/src/module.c b/src/module.c index ade9972ed3087..28c7ba437085b 100644 --- a/src/module.c +++ b/src/module.c @@ -452,6 +452,17 @@ jl_function_t *jl_module_call_func(jl_module_t *m) return m->call_func; } +int jl_is_submodule(jl_module_t *child, jl_module_t *parent) +{ + while (1) { + if (parent == child) + return 1; + if (child == NULL || child == child->parent) + return 0; + child = child->parent; + } +} + #ifdef __cplusplus } #endif