diff --git a/doc/manual/modules.rst b/doc/manual/modules.rst index aa47052141b31..85118d9f8df4c 100644 --- a/doc/manual/modules.rst +++ b/doc/manual/modules.rst @@ -340,7 +340,7 @@ not a standalone interpreter that also generates compiled code. Other known potential failure scenarios include: -1. Global counters (for example, for uniquely identify objects) +1. Global counters (for example, for attempting to unique identifying objects) Consider the following code snippet:: type UniquedById @@ -355,6 +355,9 @@ Other known potential failure scenarios include: All subsequent usages of this incrementally compiled module will start from that same counter value. + Note that ``object_id`` (which works by hashing the memory pointer) + has similar issues (see notes on Dict usage below). + One alternative is to store both ``current_module()`` and the current ``counter`` value, however, it may be better to redesign the code to not depend on this global state. @@ -384,7 +387,7 @@ to help the user avoid other wrong-behavior situations: 2. ``global const`` statements from local scope after ``__init__()`` has been started (see issue #12010 for plans to add an error for this) -3. Replacing a module (or calling ``workspace()`` is a runtime error while doing an incremental compile. +3. Replacing a module (or calling ``workspace()``) is a runtime error while doing an incremental compile. A few other points to be aware of: @@ -399,5 +402,5 @@ A few other points to be aware of: However, when possible, it can be good practice to copy resources into the module at compile-time so they won't need to be found at runtime. -4. WeakRef objects and finalizers are not captured by currently handled by the serializer +4. WeakRef objects and finalizers are not currently handled properly by the serializer (this will be fixed in an upcoming release). diff --git a/doc/stdlib/base.rst b/doc/stdlib/base.rst index 5ce55500c1167..4c297bcf8719b 100644 --- a/doc/stdlib/base.rst +++ b/doc/stdlib/base.rst @@ -86,7 +86,7 @@ Getting Around When searching for files, ``require`` first looks in the current working directory, then looks for package code under ``Pkg.dir()``, then tries paths in the global array ``LOAD_PATH``. -.. function:: compile(module::String) +.. function:: compile(module::Symbol) Creates a precompiled cache file for module (see help for ``require``) and all of its dependencies. This can be used to reduce package load times. Cache files are stored in LOAD_CACHE_PATH[1], which defaults to `~/.julia/lib/VERSION`. See the manual section `Module initialization and precompilation` (under `Modules`) for important notes. diff --git a/src/dump.c b/src/dump.c index 6586a95585bf0..49408591b8dee 100644 --- a/src/dump.c +++ b/src/dump.c @@ -288,9 +288,9 @@ static void jl_serialize_globalvals(ios_t *s) size_t i, len = backref_table.size; void **p = backref_table.table; for(i=0; i < len; i+=2) { - void *offs = p[i+1]; + char *offs = (char*)p[i+1]; if (offs != HT_NOTFOUND) { - uintptr_t pos = offs - HT_NOTFOUND - 1; + uintptr_t pos = offs - (char*)HT_NOTFOUND - 1; int32_t gv = jl_get_llvm_gv((jl_value_t*)p[i]); if (gv != 0) { write_int32(s, pos); @@ -604,8 +604,8 @@ static void jl_serialize_value_(ios_t *s, jl_value_t *v) else { bp = ptrhash_bp(&backref_table, v); if (*bp != HT_NOTFOUND) { - uintptr_t pos = *bp - HT_NOTFOUND - 1; - if ((uptrint_t)*bp < 65536) { + uintptr_t pos = (char*)*bp - (char*)HT_NOTFOUND - 1; + if (pos < 65536) { write_uint8(s, ShortBackRef_tag); write_uint16(s, pos); } @@ -631,7 +631,7 @@ static void jl_serialize_value_(ios_t *s, jl_value_t *v) } if (mode == MODE_MODULE || mode == MODE_MODULE_POSTWORK) pos <<= 1; - ptrhash_put(&backref_table, v, HT_NOTFOUND + pos + 1); + ptrhash_put(&backref_table, v, (char*)HT_NOTFOUND + pos + 1); } size_t i; @@ -1896,7 +1896,7 @@ DLLEXPORT int jl_save_incremental(const char *fname, jl_array_t *worklist) JL_SIGATOMIC_BEGIN(); arraylist_new(&reinit_list, 0); htable_new(&backref_table, 5000); - ptrhash_put(&backref_table, jl_main_module, HT_NOTFOUND + 1); + ptrhash_put(&backref_table, jl_main_module, (char*)HT_NOTFOUND + 1); backref_table_numel = 1; jl_idtable_type = jl_base_module ? jl_get_global(jl_base_module, jl_symbol("ObjectIdDict")) : NULL; diff --git a/test/runtests.jl b/test/runtests.jl index edd1a572296e7..3c61edfbf62b4 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -2,16 +2,17 @@ include("choosetests.jl") tests, net_on = choosetests(ARGS) -n = 1 -if net_on - n = min(8, CPU_CORES, length(tests)) - n > 1 && addprocs(n; exeflags=`--check-bounds=yes --depwarn=error`) - blas_set_num_threads(1) -end +let n = 1 + if net_on + n = min(8, CPU_CORES, length(tests)) + n > 1 && addprocs(n; exeflags=`--check-bounds=yes --depwarn=error`) + blas_set_num_threads(1) + end -@everywhere include("testdefs.jl") + @everywhere include("testdefs.jl") -reduce(propagate_errors, nothing, pmap(test->runtests(test), tests; err_retry=false, err_stop=true)) + reduce(propagate_errors, nothing, pmap(test->runtests(test), tests; err_retry=false, err_stop=true)) -@unix_only n > 1 && rmprocs(workers(), waitfor=5.0) -println(" \033[32;1mSUCCESS\033[0m") + @unix_only n > 1 && rmprocs(workers(), waitfor=5.0) + println(" \033[32;1mSUCCESS\033[0m") +end