Skip to content

Instantly share code, notes, and snippets.

@yuyichao
Created May 22, 2015 15:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuyichao/fd5f2780c0b4b3651c06 to your computer and use it in GitHub Desktop.
Save yuyichao/fd5f2780c0b4b3651c06 to your computer and use it in GitHub Desktop.
diff --git a/src/alloc.c b/src/alloc.c
index 913982d..60bc49e 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -842,6 +842,7 @@ jl_expr_t *jl_exprn(jl_sym_t *head, size_t n)
jl_set_typeof(ex, jl_expr_type);
ex->head = head;
ex->args = ar;
+ gc_wb(ex, ar);
ex->etype = (jl_value_t*)jl_any_type;
JL_GC_POP();
return ex;
@@ -859,6 +860,7 @@ JL_CALLABLE(jl_f_new_expr)
jl_set_typeof(ex, jl_expr_type);
ex->head = (jl_sym_t*)args[0];
ex->args = ar;
+ gc_wb(ex, ar);
ex->etype = (jl_value_t*)jl_any_type;
JL_GC_POP();
return (jl_value_t*)ex;
diff --git a/src/dump.c b/src/dump.c
index fed1d7b..6774612 100644
--- a/src/dump.c
+++ b/src/dump.c
@@ -1122,6 +1122,7 @@ static jl_value_t *jl_deserialize_value_(ios_t *s, jl_value_t *vtag, jl_value_t
if (usetable)
arraylist_push(&backref_list, NULL);
jl_expr_t *e = jl_exprn((jl_sym_t*)jl_deserialize_value(s, NULL), len);
+ JL_GC_PUSH1(&e);
if (usetable)
backref_list.items[pos] = e;
e->etype = jl_deserialize_value(s, &e->etype);
@@ -1130,6 +1131,7 @@ static jl_value_t *jl_deserialize_value_(ios_t *s, jl_value_t *vtag, jl_value_t
for(i=0; i < len; i++) {
data[i] = jl_deserialize_value(s, &data[i]);
}
+ JL_GC_POP();
return (jl_value_t*)e;
}
else if (vtag == (jl_value_t*)jl_tvar_type) {
@@ -1221,6 +1223,7 @@ static jl_value_t *jl_deserialize_value_(ios_t *s, jl_value_t *vtag, jl_value_t
return m_ref;
}
jl_module_t *m = jl_new_module(mname);
+ JL_GC_PUSH1(&m);
if (usetable)
backref_list.items[pos] = m;
m->parent = (jl_module_t*)jl_deserialize_value(s, (jl_value_t**)&m->parent);
@@ -1256,6 +1259,7 @@ static jl_value_t *jl_deserialize_value_(ios_t *s, jl_value_t *vtag, jl_value_t
if (m->constant_table != NULL) gc_wb(m, m->constant_table);
m->istopmod = read_uint8(s);
m->uuid = read_uint64(s);
+ JL_GC_POP();
return (jl_value_t*)m;
}
else if (vtag == (jl_value_t*)SmallInt64_tag) {
diff --git a/src/module.c b/src/module.c
index d4e3b50..fb81477 100644
--- a/src/module.c
+++ b/src/module.c
@@ -44,9 +44,11 @@ jl_module_t *jl_new_module(jl_sym_t *name)
DLLEXPORT jl_value_t *jl_f_new_module(jl_sym_t *name, uint8_t std_imports)
{
jl_module_t *m = jl_new_module(name);
+ JL_GC_PUSH1(&m);
m->parent = jl_main_module;
gc_wb(m, m->parent);
if (std_imports) jl_add_standard_imports(m);
+ JL_GC_POP();
return (jl_value_t*)m;
}
diff --git a/src/options.h b/src/options.h
index 91015f0..291d31f 100644
--- a/src/options.h
+++ b/src/options.h
@@ -47,7 +47,7 @@
// GC_VERIFY force a full verification gc along with every quick gc to ensure no
// reachable memory is freed
-//#define GC_VERIFY
+#define GC_VERIFY
// profiling options
diff --git a/src/toplevel.c b/src/toplevel.c
index 3abe931..d3ccccb 100644
--- a/src/toplevel.c
+++ b/src/toplevel.c
@@ -114,9 +114,11 @@ jl_value_t *jl_eval_module_expr(jl_expr_t *ex)
jl_printf(JL_STDERR, "Warning: replacing module %s\n", name->name);
}
jl_module_t *newm = jl_new_module(name);
+ JL_GC_PUSH2(&newm, &parent_module);
+ {
newm->parent = parent_module;
b->value = (jl_value_t*)newm;
-
+ gc_wb(b, newm);
gc_wb(parent_module, newm);
if (parent_module == jl_main_module && name == jl_symbol("Base")) {
@@ -191,7 +193,8 @@ jl_value_t *jl_eval_module_expr(jl_expr_t *ex)
jl_module_load_time_initialize((jl_module_t *) arraylist_pop(&module_stack));
}
}
-
+}
+ JL_GC_POP();
return jl_nothing;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment