Skip to content

Commit

Permalink
fix bug in rehashing typeToTypeId table. ref JuliaLang#5688
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Feb 11, 2014
1 parent 2d45d06 commit 20fb717
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/cgutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,9 @@ static bool is_tupletype_homogeneous(jl_tuple_t *t)
// --- scheme for tagging llvm values with julia types using metadata ---

static std::map<int, jl_value_t*> typeIdToType;
static jl_array_t *typeToTypeId;
extern "C" {
jl_array_t *typeToTypeId;
}
static int cur_type_id = 1;

static int jl_type_to_typeid(jl_value_t *t)
Expand All @@ -555,7 +557,7 @@ static int jl_type_to_typeid(jl_value_t *t)
jl_error("internal compiler error: too many bits types");
JL_GC_PUSH1(&id);
id = jl_box_long(mine);
jl_eqtable_put(typeToTypeId, t, id);
typeToTypeId = jl_eqtable_put(typeToTypeId, t, id);
typeIdToType[mine] = t;
JL_GC_POP();
return mine;
Expand Down
1 change: 0 additions & 1 deletion src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4143,7 +4143,6 @@ extern "C" void jl_init_codegen(void)
(void*)&restore_arg_area_loc);

typeToTypeId = jl_alloc_cell_1d(16);
jl_gc_preserve((jl_value_t*)typeToTypeId);
}

/*
Expand Down
2 changes: 2 additions & 0 deletions src/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,7 @@ static void gc_mark_uv_state(uv_loop_t *loop)
}

extern jl_module_t *jl_old_base_module;
extern jl_array_t *typeToTypeId;

static void gc_mark(void)
{
Expand All @@ -823,6 +824,7 @@ static void gc_mark(void)
gc_push_root(jl_bottom_func, 0);
gc_push_root(jl_typetype_type, 0);
gc_push_root(jl_tupletype_type, 0);
gc_push_root(typeToTypeId, 0);

// constants
gc_push_root(jl_null, 0);
Expand Down

0 comments on commit 20fb717

Please sign in to comment.