Skip to content

Commit

Permalink
fix issues from #8745 (comments), incl. fixing #12208
Browse files Browse the repository at this point in the history
  • Loading branch information
vtjnash committed Jul 20, 2015
1 parent 198fd16 commit a93d1eb
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 20 deletions.
9 changes: 6 additions & 3 deletions doc/manual/modules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)

This comment has been minimized.

Copy link
@tkelman

tkelman Jul 20, 2015

Contributor

this still doesn't read quite right to me - "attempting to uniquely identify" would sound fine I think

Consider the following code snippet::

type UniquedById
Expand All @@ -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.

Expand Down Expand Up @@ -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:

Expand All @@ -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).
2 changes: 1 addition & 1 deletion doc/stdlib/base.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
12 changes: 6 additions & 6 deletions src/dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

This comment has been minimized.

Copy link
@tkelman

tkelman Jul 20, 2015

Contributor

thanks yeah it looks like msvc is okay with this

int32_t gv = jl_get_llvm_gv((jl_value_t*)p[i]);
if (gv != 0) {
write_int32(s, pos);
Expand Down Expand Up @@ -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);
}
Expand All @@ -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;
Expand Down Expand Up @@ -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;

Expand Down
21 changes: 11 additions & 10 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit a93d1eb

Please sign in to comment.