Skip to content

Commit

Permalink
add a uuid to each Module that is stable across serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
vtjnash committed Oct 21, 2014
1 parent e3a74ee commit 8abce49
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,8 @@ static void jl_serialize_module(ios_t *s, jl_module_t *m)
}
}
jl_serialize_value(s, m->constant_table);
write_int32(s, (uint32_t)m->uuid);
write_int32(s, (uint32_t)(m->uuid>>32));
}

static int is_ast_node(jl_value_t *v)
Expand Down Expand Up @@ -1088,6 +1090,8 @@ static jl_value_t *jl_deserialize_value_(ios_t *s, int pos, jl_value_t *vtag, jl
i++;
}
m->constant_table = (jl_array_t*)jl_deserialize_value(s, (jl_value_t**)&m->constant_table);
m->uuid = read_int32(s);
m->uuid |= ((uint64_t)read_int32(s))<<32;
return (jl_value_t*)m;
}
else if (vtag == (jl_value_t*)SmallInt64_tag) {
Expand Down
1 change: 1 addition & 0 deletions src/julia.h
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ typedef struct _jl_module_t {
htable_t bindings;
arraylist_t usings; // modules with all bindings potentially imported
jl_array_t *constant_table;
uint64_t uuid;
} jl_module_t;

typedef struct _jl_methlist_t {
Expand Down
2 changes: 2 additions & 0 deletions src/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jl_module_t *jl_new_module(jl_sym_t *name)
assert(jl_is_symbol(name));
m->name = name;
m->constant_table = NULL;
m->uuid = uv_now(uv_default_loop());
htable_new(&m->bindings, 0);
arraylist_new(&m->usings, 0);
if (jl_core_module) {
Expand Down Expand Up @@ -425,6 +426,7 @@ DLLEXPORT jl_value_t *jl_module_names(jl_module_t *m, int all, int imported)

DLLEXPORT jl_sym_t *jl_module_name(jl_module_t *m) { return m->name; }
DLLEXPORT jl_module_t *jl_module_parent(jl_module_t *m) { return m->parent; }
DLLEXPORT uint64_t jl_module_uuid(jl_module_t *m) { return m->uuid; }

int jl_module_has_initializer(jl_module_t *m)
{
Expand Down

0 comments on commit 8abce49

Please sign in to comment.