Skip to content

Commit

Permalink
Merge pull request #13325 from JuliaLang/yyc/get_field_gc
Browse files Browse the repository at this point in the history
Fix many GC related bugs
  • Loading branch information
yuyichao committed Sep 28, 2015
2 parents 2d82167 + d8f5bf2 commit 5acbcc6
Show file tree
Hide file tree
Showing 9 changed files with 168 additions and 124 deletions.
4 changes: 2 additions & 2 deletions src/alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,8 @@ jl_lambda_info_t *jl_new_lambda_info(jl_value_t *ast, jl_svec_t *sparams, jl_mod
if (ast != NULL && jl_is_expr(ast)) {
jl_value_t *body1 = skip_meta(jl_lam_body((jl_expr_t*)ast)->args);
if (jl_is_linenode(body1)) {
li->file = (jl_sym_t*)jl_fieldref(body1, 0);
li->line = jl_unbox_long(jl_fieldref(body1, 1));
li->file = jl_linenode_file(body1);
li->line = jl_linenode_line(body1);
} else if (jl_is_expr(body1) && ((jl_expr_t*)body1)->head == line_sym) {
li->file = (jl_sym_t*)jl_exprarg(body1, 1);
li->line = jl_unbox_long(jl_exprarg(body1, 0));
Expand Down
3 changes: 3 additions & 0 deletions src/array.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,12 @@ jl_array_t *jl_ptr_to_array(jl_value_t *atype, void *data, jl_value_t *dims,
}
else {
size_t *adims = &a->nrows;
// jl_fieldref can allocate
JL_GC_PUSH1(&a);
for(i=0; i < ndims; i++) {
adims[i] = jl_unbox_long(jl_fieldref(dims, i));
}
JL_GC_POP();
}
return a;
}
Expand Down
5 changes: 5 additions & 0 deletions src/ast.c
Original file line number Diff line number Diff line change
Expand Up @@ -482,13 +482,18 @@ static value_t julia_to_scm_(jl_value_t *v)
return scmv;
}
if (jl_typeis(v, jl_linenumbernode_type)) {
// GC Note: jl_fieldref(v, 1) allocates but neither jl_fieldref(v, 0)
// or julia_to_list2 should allocate here
value_t args = julia_to_list2(jl_fieldref(v,1), jl_fieldref(v,0));
fl_gc_handle(&args);
value_t hd = julia_to_scm_((jl_value_t*)line_sym);
value_t scmv = fl_cons(hd, args);
fl_free_gc_handles(1);
return scmv;
}
// GC Note: jl_fieldref(v, 0) allocate for LabelNode, GotoNode
// but we don't need a GC root here because julia_to_list2
// shouldn't allocate in this case.
if (jl_typeis(v, jl_labelnode_type))
return julia_to_list2((jl_value_t*)label_sym, jl_fieldref(v,0));
if (jl_typeis(v, jl_gotonode_type))
Expand Down
Loading

0 comments on commit 5acbcc6

Please sign in to comment.