Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

better module initialization order: init inner modules after outer mo…

…dules

are complete and initialized.
  • Loading branch information...
commit b5df426923fc350276d1fe370dcf28a5564fa49c 1 parent 58867fc
@JeffBezanson JeffBezanson authored
View
1  base/client.jl
@@ -349,7 +349,6 @@ end
function _start()
- global const CPU_CORES = Sys.CPU_CORES
if CPU_CORES > 8 && !("OPENBLAS_NUM_THREADS" in keys(ENV)) && !("OMP_NUM_THREADS" in keys(ENV))
# Prevent openblas from stating to many threads, unless/until specifically requested
ENV["OPENBLAS_NUM_THREADS"] = 8
View
1  base/sysimg.jl
@@ -188,6 +188,7 @@ include("sharedarray.jl")
# utilities - version, timing, help, edit, metaprogramming
include("sysinfo.jl")
+import .Sys.CPU_CORES
include("version.jl")
include("datafmt.jl")
include("deepcopy.jl")
View
2  base/sysinfo.jl
@@ -19,6 +19,8 @@ export CPU_CORES,
import ..Base: WORD_SIZE, OS_NAME, ARCH, MACHINE
import ..Base: show, uv_error
+global CPU_CORES
+
function __init__()
# set CPU core count
global const CPU_CORES = int(
View
3  src/dump.c
@@ -1081,8 +1081,7 @@ void jl_restore_system_image(char *fname)
void jl_init_restored_modules()
{
while (modules_to_init.len > 0) {
- jl_module_t *m = arraylist_pop(&modules_to_init);
- jl_module_run_initializer(m);
+ jl_module_run_initializer(arraylist_pop(&modules_to_init));
}
}
View
14 src/toplevel.c
@@ -63,6 +63,12 @@ extern void jl_get_uv_hooks(int);
extern int base_module_conflict;
jl_value_t *jl_eval_module_expr(jl_expr_t *ex)
{
+ static arraylist_t module_stack;
+ static int initialized=0;
+ if (!initialized) {
+ arraylist_new(&module_stack, 0);
+ initialized = 1;
+ }
assert(ex->head == module_sym);
jl_module_t *last_module = jl_current_module;
if (jl_array_len(ex->args) != 3 || !jl_is_expr(jl_exprarg(ex,2))) {
@@ -151,7 +157,13 @@ jl_value_t *jl_eval_module_expr(jl_expr_t *ex)
}
#endif
- jl_module_run_initializer(newm);
+ arraylist_push(&module_stack, newm);
+
+ if (jl_current_module == jl_main_module) {
+ while (module_stack.len > 0) {
+ jl_module_run_initializer(arraylist_pop(&module_stack));
+ }
+ }
return jl_nothing;
}
Please sign in to comment.
Something went wrong with that request. Please try again.