Skip to content

Commit

Permalink
add jl_ prefix to is_submodule and switch argument order
Browse files Browse the repository at this point in the history
also exclude Core module from user code in coverage
  • Loading branch information
JeffBezanson committed Jan 4, 2015
1 parent 2447f79 commit 3576665
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
21 changes: 5 additions & 16 deletions src/dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/julia.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
11 changes: 11 additions & 0 deletions src/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 3576665

Please sign in to comment.