diff --git a/src/alloc.c b/src/alloc.c index 4fb1181d219e0..bea34d5bcdc40 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -257,7 +257,7 @@ void jl_set_nth_field(jl_value_t *v, size_t i, jl_value_t *rhs) size_t offs = jl_field_offset(st,i); if (jl_field_isptr(st,i)) { *(jl_value_t**)((char*)v + offs) = rhs; - if (rhs != NULL) gc_wb(v, rhs); + if (rhs != NULL) jl_gc_wb(v, rhs); } else { jl_assign_bits((char*)v + offs, rhs); @@ -315,7 +315,7 @@ DLLEXPORT jl_value_t *jl_new_struct_uninit(jl_datatype_t *type) DLLEXPORT jl_function_t *jl_new_closure(jl_fptr_t fptr, jl_value_t *env, jl_lambda_info_t *linfo) { - jl_function_t *f = (jl_function_t*)alloc_3w(); assert(NWORDS(sizeof(jl_function_t))==3); + jl_function_t *f = (jl_function_t*)jl_gc_alloc_3w(); assert(NWORDS(sizeof(jl_function_t))==3); jl_set_typeof(f, jl_function_type); f->fptr = (fptr!=NULL ? fptr : linfo->fptr); f->env = env; @@ -445,7 +445,7 @@ jl_sym_t *jl_symbol(const char *str) if (*pnode == NULL) { *pnode = mk_symbol(str); if (parent != NULL) - gc_wb(parent, *pnode); + jl_gc_wb(parent, *pnode); } return *pnode; } @@ -594,11 +594,11 @@ jl_datatype_t *jl_new_datatype(jl_sym_t *name, jl_datatype_t *super, tn = t->name; // init before possibly calling jl_new_typename t->super = super; - if (super != NULL) gc_wb(t, t->super); + if (super != NULL) jl_gc_wb(t, t->super); t->parameters = parameters; - gc_wb(t, t->parameters); + jl_gc_wb(t, t->parameters); t->types = ftypes; - if (ftypes != NULL) gc_wb(t, t->types); + if (ftypes != NULL) jl_gc_wb(t, t->types); t->abstract = abstract; t->mutabl = mutabl; t->pointerfree = 0; @@ -616,14 +616,14 @@ jl_datatype_t *jl_new_datatype(jl_sym_t *name, jl_datatype_t *super, else tn = jl_new_typename((jl_sym_t*)name); t->name = tn; - gc_wb(t, t->name); + jl_gc_wb(t, t->name); } t->name->names = fnames; - gc_wb(t->name, t->name->names); + jl_gc_wb(t->name, t->name->names); if (t->name->primary == NULL) { t->name->primary = (jl_value_t*)t; - gc_wb(t->name, t); + jl_gc_wb(t->name, t); } if (abstract || jl_svec_len(parameters) > 0) { @@ -668,7 +668,7 @@ jl_value_t *jl_box##nb(jl_datatype_t *t, int##nb##_t x) \ { \ assert(jl_isbits(t)); \ assert(jl_datatype_size(t) == sizeof(x)); \ - jl_value_t *v = (jl_value_t*)alloc_##nw##w(); \ + jl_value_t *v = (jl_value_t*)jl_gc_alloc_##nw##w(); \ jl_set_typeof(v, t); \ *(int##nb##_t*)jl_data_ptr(v) = x; \ return v; \ @@ -706,7 +706,7 @@ UNBOX_FUNC(gensym, ssize_t) #define BOX_FUNC(typ,c_type,pfx,nw) \ jl_value_t *pfx##_##typ(c_type x) \ { \ - jl_value_t *v = (jl_value_t*)alloc_##nw##w(); \ + jl_value_t *v = (jl_value_t*)jl_gc_alloc_##nw##w(); \ jl_set_typeof(v, jl_##typ##_type); \ *(c_type*)jl_data_ptr(v) = x; \ return v; \ @@ -728,7 +728,7 @@ jl_value_t *jl_box_##typ(c_type x) \ c_type idx = x+NBOX_C/2; \ if ((u##c_type)idx < (u##c_type)NBOX_C) \ return boxed_##typ##_cache[idx]; \ - jl_value_t *v = (jl_value_t*)alloc_##nw##w(); \ + jl_value_t *v = (jl_value_t*)jl_gc_alloc_##nw##w(); \ jl_set_typeof(v, jl_##typ##_type); \ *(c_type*)jl_data_ptr(v) = x; \ return v; \ @@ -739,7 +739,7 @@ jl_value_t *jl_box_##typ(c_type x) \ { \ if (x < NBOX_C) \ return boxed_##typ##_cache[x]; \ - jl_value_t *v = (jl_value_t*)alloc_##nw##w(); \ + jl_value_t *v = (jl_value_t*)jl_gc_alloc_##nw##w(); \ jl_set_typeof(v, jl_##typ##_type); \ *(c_type*)jl_data_ptr(v) = x; \ return v; \ @@ -833,7 +833,7 @@ jl_expr_t *jl_exprn(jl_sym_t *head, size_t n) { jl_array_t *ar = n==0 ? (jl_array_t*)jl_an_empty_cell : jl_alloc_cell_1d(n); JL_GC_PUSH1(&ar); - jl_expr_t *ex = (jl_expr_t*)alloc_3w(); assert(NWORDS(sizeof(jl_expr_t))==3); + jl_expr_t *ex = (jl_expr_t*)jl_gc_alloc_3w(); assert(NWORDS(sizeof(jl_expr_t))==3); jl_set_typeof(ex, jl_expr_type); ex->head = head; ex->args = ar; @@ -850,7 +850,7 @@ JL_CALLABLE(jl_f_new_expr) JL_GC_PUSH1(&ar); for(size_t i=0; i < nargs-1; i++) jl_cellset(ar, i, args[i+1]); - jl_expr_t *ex = (jl_expr_t*)alloc_3w(); assert(NWORDS(sizeof(jl_expr_t))==3); + jl_expr_t *ex = (jl_expr_t*)jl_gc_alloc_3w(); assert(NWORDS(sizeof(jl_expr_t))==3); jl_set_typeof(ex, jl_expr_type); ex->head = (jl_sym_t*)args[0]; ex->args = ar; diff --git a/src/array.c b/src/array.c index 350cfd76085c0..2f129fd22709e 100644 --- a/src/array.c +++ b/src/array.c @@ -81,7 +81,7 @@ static jl_array_t *_new_array_(jl_value_t *atype, uint32_t ndims, size_t *dims, size_t doffs = tsz; tsz += tot; tsz = JL_ARRAY_ALIGN(tsz, 16); // align whole object 16 - a = (jl_array_t*)allocobj(tsz); + a = (jl_array_t*)jl_gc_allocobj(tsz); jl_set_typeof(a, atype); a->how = 0; data = (char*)a + doffs; @@ -91,7 +91,7 @@ static jl_array_t *_new_array_(jl_value_t *atype, uint32_t ndims, size_t *dims, } else { tsz = JL_ARRAY_ALIGN(tsz, 16); // align whole object 16 - a = (jl_array_t*)allocobj(tsz); + a = (jl_array_t*)jl_gc_allocobj(tsz); JL_GC_PUSH1(&a); jl_set_typeof(a, atype); // temporarily initialize to make gc-safe @@ -153,7 +153,7 @@ jl_array_t *jl_reshape_array(jl_value_t *atype, jl_array_t *data, jl_value_t *di int ndimwords = jl_array_ndimwords(ndims); int tsz = JL_ARRAY_ALIGN(sizeof(jl_array_t) + ndimwords*sizeof(size_t) + sizeof(void*), 16); - a = (jl_array_t*)allocobj(tsz); + a = (jl_array_t*)jl_gc_allocobj(tsz); jl_set_typeof(a, atype); a->pooled = tsz <= GC_MAX_SZCLASS; a->ndims = ndims; @@ -229,7 +229,7 @@ jl_array_t *jl_ptr_to_array_1d(jl_value_t *atype, void *data, size_t nel, int ndimwords = jl_array_ndimwords(1); int tsz = JL_ARRAY_ALIGN(sizeof(jl_array_t) + ndimwords*sizeof(size_t), 16); - a = (jl_array_t*)allocobj(tsz); + a = (jl_array_t*)jl_gc_allocobj(tsz); jl_set_typeof(a, atype); a->pooled = tsz <= GC_MAX_SZCLASS; a->data = data; @@ -280,7 +280,7 @@ jl_array_t *jl_ptr_to_array(jl_value_t *atype, void *data, jl_value_t *dims, int ndimwords = jl_array_ndimwords(ndims); int tsz = JL_ARRAY_ALIGN(sizeof(jl_array_t) + ndimwords*sizeof(size_t), 16); - a = (jl_array_t*)allocobj(tsz); + a = (jl_array_t*)jl_gc_allocobj(tsz); jl_set_typeof(a, atype); a->pooled = tsz <= GC_MAX_SZCLASS; a->data = data; @@ -354,7 +354,7 @@ jl_value_t *jl_array_to_string(jl_array_t *a) // TODO: check type of array? jl_datatype_t *string_type = u8_isvalid((char*)a->data, jl_array_len(a)) == 1 ? // ASCII jl_ascii_string_type : jl_utf8_string_type; - jl_value_t *s = (jl_value_t*)alloc_1w(); + jl_value_t *s = (jl_value_t*)jl_gc_alloc_1w(); jl_set_typeof(s, string_type); jl_set_nth_field(s, 0, (jl_value_t*)a); return s; @@ -524,7 +524,7 @@ void jl_arrayset(jl_array_t *a, jl_value_t *rhs, size_t i) if (a->how == 3) { owner = jl_array_data_owner(a); } - gc_wb(owner, rhs); + jl_gc_wb(owner, rhs); } } @@ -598,7 +598,7 @@ static void array_resize_buffer(jl_array_t *a, size_t newlen, size_t oldlen, siz if (a->ptrarray || es==1) memset(newdata+offsnb+oldnbytes, 0, nbytes-oldnbytes-offsnb); if (a->how == 1) - gc_wb_buf(a, newdata); + jl_gc_wb_buf(a, newdata); a->maxsize = newlen; } diff --git a/src/ast.c b/src/ast.c index 9cd837046dff0..dda1752f55751 100644 --- a/src/ast.c +++ b/src/ast.c @@ -770,7 +770,7 @@ static jl_value_t *copy_ast(jl_value_t *expr, jl_svec_t *sp, int do_sp) // of a top-level thunk that gets type inferred. li->def = li; li->ast = jl_prepare_ast(li, li->sparams); - gc_wb(li, li->ast); + jl_gc_wb(li, li->ast); JL_GC_POP(); return (jl_value_t*)li; } @@ -821,7 +821,7 @@ DLLEXPORT jl_value_t *jl_copy_ast(jl_value_t *expr) ne = jl_exprn(e->head, l); if (l == 0) { ne->args = jl_alloc_cell_1d(0); - gc_wb(ne, ne->args); + jl_gc_wb(ne, ne->args); } else { for(i=0; i < l; i++) { diff --git a/src/builtins.c b/src/builtins.c index 76f4ca94f3a72..750f8f604aa9b 100644 --- a/src/builtins.c +++ b/src/builtins.c @@ -938,7 +938,7 @@ void jl_trampoline_compile_function(jl_function_t *f, int always_infer, jl_tuple if (!jl_in_inference) { if (!jl_is_expr(f->linfo->ast)) { f->linfo->ast = jl_uncompress_ast(f->linfo, f->linfo->ast); - gc_wb(f->linfo, f->linfo->ast); + jl_gc_wb(f->linfo, f->linfo->ast); } if (always_infer || jl_eval_with_compiler_p(jl_lam_body((jl_expr_t*)f->linfo->ast),1,f->linfo->module)) { jl_type_infer(f->linfo, sig, f->linfo); @@ -952,7 +952,7 @@ void jl_trampoline_compile_function(jl_function_t *f, int always_infer, jl_tuple jl_generate_fptr(f); if (jl_boot_file_loaded && jl_is_expr(f->linfo->ast)) { f->linfo->ast = jl_compress_ast(f->linfo, f->linfo->ast); - gc_wb(f->linfo, f->linfo->ast); + jl_gc_wb(f->linfo, f->linfo->ast); } } diff --git a/src/codegen.cpp b/src/codegen.cpp index 9d0683568ee08..6d795a58ed614 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -355,9 +355,9 @@ static std::vector three_pvalue_llvmt; static std::map builtin_func_map; -extern "C" DLLEXPORT void gc_wb_slow(jl_value_t* parent, jl_value_t* ptr) +extern "C" DLLEXPORT void jl_gc_wb_slow(jl_value_t* parent, jl_value_t* ptr) { - gc_wb(parent, ptr); + jl_gc_wb(parent, ptr); } // --- code generation --- @@ -1229,7 +1229,7 @@ static logdata_t mallocData; static void mallocVisitLine(std::string filename, int line) { if (filename == "" || filename == "none" || filename == "no file") { - sync_gc_total_bytes(); + jl_gc_sync_total_bytes(); return; } logdata_t::iterator it = mallocData.find(filename); @@ -1273,7 +1273,7 @@ extern "C" DLLEXPORT void jl_clear_malloc_data(void) } } } - sync_gc_total_bytes(); + jl_gc_sync_total_bytes(); } extern "C" void jl_write_malloc_log(void) @@ -1749,7 +1749,7 @@ static void jl_add_linfo_root(jl_lambda_info_t *li, jl_value_t *val) li = li->def; if (li->roots == NULL) { li->roots = jl_alloc_cell_1d(1); - gc_wb(li, li->roots); + jl_gc_wb(li, li->roots); jl_cellset(li->roots, 0, val); } else { @@ -4966,9 +4966,9 @@ extern "C" void jl_fptr_to_llvm(void *fptr, jl_lambda_info_t *lam, int specsig) extern "C" DLLEXPORT jl_value_t *jl_new_box(jl_value_t *v) { - jl_value_t *box = (jl_value_t*)alloc_1w(); + jl_value_t *box = (jl_value_t*)jl_gc_alloc_1w(); jl_set_typeof(box, jl_box_any_type); - // if (v) gc_wb(box, v); // write block not needed: box was just allocated + // if (v) jl_gc_wb(box, v); // write block not needed: box was just allocated box->fieldptr[0] = v; return box; } @@ -5341,16 +5341,16 @@ static void init_julia_llvm_env(Module *m) #ifdef JL_GC_MARKSWEEP queuerootfun = Function::Create(FunctionType::get(T_void, args_1ptr, false), Function::ExternalLinkage, - "gc_queue_root", m); - add_named_global(queuerootfun, (void*)&gc_queue_root); + "jl_gc_queue_root", m); + add_named_global(queuerootfun, (void*)&jl_gc_queue_root); std::vector wbargs(0); wbargs.push_back(jl_pvalue_llvmt); wbargs.push_back(jl_pvalue_llvmt); wbfunc = Function::Create(FunctionType::get(T_void, wbargs, false), Function::ExternalLinkage, - "gc_wb_slow", m); - add_named_global(wbfunc, (void*)&gc_wb_slow); + "jl_gc_wb_slow", m); + add_named_global(wbfunc, (void*)&jl_gc_wb_slow); #endif std::vector exp_args(0); @@ -5489,27 +5489,27 @@ static void init_julia_llvm_env(Module *m) jlallocobj_func = Function::Create(FunctionType::get(jl_pvalue_llvmt, aoargs, false), Function::ExternalLinkage, - "allocobj", m); - add_named_global(jlallocobj_func, (void*)&allocobj); + "jl_gc_allocobj", m); + add_named_global(jlallocobj_func, (void*)&jl_gc_allocobj); std::vector empty_args(0); jlalloc1w_func = Function::Create(FunctionType::get(jl_pvalue_llvmt, empty_args, false), Function::ExternalLinkage, - "alloc_1w", m); - add_named_global(jlalloc1w_func, (void*)&alloc_1w); + "jl_gc_alloc_1w", m); + add_named_global(jlalloc1w_func, (void*)&jl_gc_alloc_1w); jlalloc2w_func = Function::Create(FunctionType::get(jl_pvalue_llvmt, empty_args, false), Function::ExternalLinkage, - "alloc_2w", m); - add_named_global(jlalloc2w_func, (void*)&alloc_2w); + "jl_gc_alloc_2w", m); + add_named_global(jlalloc2w_func, (void*)&jl_gc_alloc_2w); jlalloc3w_func = Function::Create(FunctionType::get(jl_pvalue_llvmt, empty_args, false), Function::ExternalLinkage, - "alloc_3w", m); - add_named_global(jlalloc3w_func, (void*)&alloc_3w); + "jl_gc_alloc_3w", m); + add_named_global(jlalloc3w_func, (void*)&jl_gc_alloc_3w); std::vector atargs(0); atargs.push_back(T_size); @@ -5550,8 +5550,8 @@ static void init_julia_llvm_env(Module *m) diff_gc_total_bytes_func = Function::Create(FunctionType::get(T_int64, false), Function::ExternalLinkage, - "diff_gc_total_bytes", m); - add_named_global(diff_gc_total_bytes_func, (void*)*diff_gc_total_bytes); + "jl_gc_diff_total_bytes", m); + add_named_global(diff_gc_total_bytes_func, (void*)*jl_gc_diff_total_bytes); std::vector execpoint_args(0); execpoint_args.push_back(T_pint8); diff --git a/src/dump.c b/src/dump.c index cdb753e2ed550..109ee03d5ca1e 100644 --- a/src/dump.c +++ b/src/dump.c @@ -519,7 +519,7 @@ static int is_ast_node(jl_value_t *v) jl_lambda_info_t *li = (jl_lambda_info_t*)v; if (jl_is_expr(li->ast)) { li->ast = jl_compress_ast(li, li->ast); - gc_wb(li, li->ast); + jl_gc_wb(li, li->ast); } return 0; } @@ -960,7 +960,7 @@ static jl_value_t *jl_deserialize_datatype(ios_t *s, int pos, jl_value_t **loc) dt->alignment = read_int32(s); ios_read(s, (char*)&dt->fields[0], nf*sizeof(jl_fielddesc_t)); dt->types = (jl_svec_t*)jl_deserialize_value(s, (jl_value_t**)&dt->types); - gc_wb(dt, dt->types); + jl_gc_wb(dt, dt->types); } else { dt->alignment = dt->size; @@ -969,11 +969,11 @@ static jl_value_t *jl_deserialize_datatype(ios_t *s, int pos, jl_value_t **loc) dt->types = jl_emptysvec; } dt->parameters = (jl_svec_t*)jl_deserialize_value(s, (jl_value_t**)&dt->parameters); - gc_wb(dt, dt->parameters); + jl_gc_wb(dt, dt->parameters); dt->name = (jl_typename_t*)jl_deserialize_value(s, (jl_value_t**)&dt->name); - gc_wb(dt, dt->name); + jl_gc_wb(dt, dt->name); dt->super = (jl_datatype_t*)jl_deserialize_value(s, (jl_value_t**)&dt->super); - gc_wb(dt, dt->super); + jl_gc_wb(dt, dt->super); if (datatype_list) { if (dt->name == jl_array_type->name || dt->name == jl_ref_type->name || dt->name == jl_pointer_type->name || dt->name == jl_type_type->name || @@ -1109,7 +1109,7 @@ static jl_value_t *jl_deserialize_value_(ios_t *s, jl_value_t *vtag, jl_value_t jl_value_t** data = (jl_value_t**)jl_array_data(a); for(i=0; i < jl_array_len(a); i++) { data[i] = jl_deserialize_value(s, &data[i]); - if (data[i]) gc_wb(a, data[i]); + if (data[i]) jl_gc_wb(a, data[i]); } } if (mode == MODE_MODULE) { @@ -1132,7 +1132,7 @@ static jl_value_t *jl_deserialize_value_(ios_t *s, jl_value_t *vtag, jl_value_t if (usetable) backref_list.items[pos] = e; e->etype = jl_deserialize_value(s, &e->etype); - gc_wb(e, e->etype); + jl_gc_wb(e, e->etype); jl_value_t **data = (jl_value_t**)(e->args->data); for(i=0; i < len; i++) { data[i] = jl_deserialize_value(s, &data[i]); @@ -1144,11 +1144,11 @@ static jl_value_t *jl_deserialize_value_(ios_t *s, jl_value_t *vtag, jl_value_t if (usetable) arraylist_push(&backref_list, tv); tv->name = (jl_sym_t*)jl_deserialize_value(s, NULL); - gc_wb(tv, tv->name); + jl_gc_wb(tv, tv->name); tv->lb = jl_deserialize_value(s, &tv->lb); - gc_wb(tv, tv->lb); + jl_gc_wb(tv, tv->lb); tv->ub = jl_deserialize_value(s, &tv->ub); - gc_wb(tv, tv->ub); + jl_gc_wb(tv, tv->ub); tv->bound = read_int8(s); return (jl_value_t*)tv; } @@ -1158,9 +1158,9 @@ static jl_value_t *jl_deserialize_value_(ios_t *s, jl_value_t *vtag, jl_value_t if (usetable) arraylist_push(&backref_list, f); f->linfo = (jl_lambda_info_t*)jl_deserialize_value(s, (jl_value_t**)&f->linfo); - if (f->linfo != NULL) gc_wb(f, f->linfo); + if (f->linfo != NULL) jl_gc_wb(f, f->linfo); f->env = jl_deserialize_value(s, &f->env); - gc_wb(f, f->env); + jl_gc_wb(f, f->env); f->fptr = jl_deserialize_fptr(s); return (jl_value_t*)f; } @@ -1171,29 +1171,29 @@ static jl_value_t *jl_deserialize_value_(ios_t *s, jl_value_t *vtag, jl_value_t if (usetable) arraylist_push(&backref_list, li); li->ast = jl_deserialize_value(s, &li->ast); - gc_wb(li, li->ast); + jl_gc_wb(li, li->ast); li->sparams = (jl_svec_t*)jl_deserialize_value(s, (jl_value_t**)&li->sparams); - gc_wb(li, li->sparams); + jl_gc_wb(li, li->sparams); li->tfunc = jl_deserialize_value(s, (jl_value_t**)&li->tfunc); - gc_wb(li, li->tfunc); + jl_gc_wb(li, li->tfunc); li->name = (jl_sym_t*)jl_deserialize_value(s, NULL); - gc_wb(li, li->name); + jl_gc_wb(li, li->name); li->specTypes = (jl_tupletype_t*)jl_deserialize_value(s, (jl_value_t**)&li->specTypes); - if (li->specTypes) gc_wb(li, li->specTypes); + if (li->specTypes) jl_gc_wb(li, li->specTypes); li->specializations = (jl_array_t*)jl_deserialize_value(s, (jl_value_t**)&li->specializations); - if (li->specializations) gc_wb(li, li->specializations); + if (li->specializations) jl_gc_wb(li, li->specializations); li->inferred = read_int8(s); li->file = (jl_sym_t*)jl_deserialize_value(s, NULL); - gc_wb(li, li->file); + jl_gc_wb(li, li->file); li->line = read_int32(s); li->module = (jl_module_t*)jl_deserialize_value(s, (jl_value_t**)&li->module); - gc_wb(li, li->module); + jl_gc_wb(li, li->module); li->roots = (jl_array_t*)jl_deserialize_value(s, (jl_value_t**)&li->roots); - if (li->roots) gc_wb(li, li->roots); + if (li->roots) jl_gc_wb(li, li->roots); li->def = (jl_lambda_info_t*)jl_deserialize_value(s, (jl_value_t**)&li->def); - gc_wb(li, li->def); + jl_gc_wb(li, li->def); li->capt = jl_deserialize_value(s, &li->capt); - if (li->capt) gc_wb(li, li->capt); + if (li->capt) jl_gc_wb(li, li->capt); li->fptr = &jl_trampoline; li->functionObject = NULL; li->cFunctionList = NULL; @@ -1231,7 +1231,7 @@ static jl_value_t *jl_deserialize_value_(ios_t *s, jl_value_t *vtag, jl_value_t if (usetable) backref_list.items[pos] = m; m->parent = (jl_module_t*)jl_deserialize_value(s, (jl_value_t**)&m->parent); - gc_wb(m, m->parent); + jl_gc_wb(m, m->parent); while (1) { jl_sym_t *name = (jl_sym_t*)jl_deserialize_value(s, NULL); @@ -1239,12 +1239,12 @@ static jl_value_t *jl_deserialize_value_(ios_t *s, jl_value_t *vtag, jl_value_t break; jl_binding_t *b = jl_get_binding_wr(m, name); b->value = jl_deserialize_value(s, &b->value); - gc_wb_buf(m, b); - if (b->value != NULL) gc_wb(m, b->value); + jl_gc_wb_buf(m, b); + if (b->value != NULL) jl_gc_wb(m, b->value); b->type = jl_deserialize_value(s, &b->type); - gc_wb(m, b->type); + jl_gc_wb(m, b->type); b->owner = (jl_module_t*)jl_deserialize_value(s, (jl_value_t**)&b->owner); - if (b->owner != NULL) gc_wb(m, b->owner); + if (b->owner != NULL) jl_gc_wb(m, b->owner); int8_t flags = read_int8(s); b->constp = (flags>>2) & 1; b->exportp = (flags>>1) & 1; @@ -1260,7 +1260,7 @@ static jl_value_t *jl_deserialize_value_(ios_t *s, jl_value_t *vtag, jl_value_t i++; } m->constant_table = (jl_array_t*)jl_deserialize_value(s, (jl_value_t**)&m->constant_table); - if (m->constant_table != NULL) gc_wb(m, m->constant_table); + if (m->constant_table != NULL) jl_gc_wb(m, m->constant_table); m->istopmod = read_uint8(s); m->uuid = read_uint64(s); return (jl_value_t*)m; @@ -1317,7 +1317,7 @@ static jl_value_t *jl_deserialize_value_(ios_t *s, jl_value_t *vtag, jl_value_t case 4: v = jl_box32(dt, *(int32_t*)data); break; case 8: v = jl_box64(dt, *(int64_t*)data); break; default: - v = (jl_value_t*)allocobj(nby); + v = (jl_value_t*)jl_gc_allocobj(nby); jl_set_typeof(v, dt); memcpy(jl_data_ptr(v), data, nby); } @@ -1346,7 +1346,7 @@ static jl_value_t *jl_deserialize_value_(ios_t *s, jl_value_t *vtag, jl_value_t } else if (vtag == (jl_value_t*)Singleton_tag) { assert(mode != MODE_MODULE_LAMBDAS); - jl_value_t *v = (jl_value_t*)alloc_0w(); + jl_value_t *v = (jl_value_t*)jl_gc_alloc_0w(); if (usetable) { uptrint_t pos = backref_list.len; arraylist_push(&backref_list, (void*)v); @@ -1579,7 +1579,7 @@ void jl_restore_system_image_from_stream(ios_t *f) case 1: { jl_array_t **a = (jl_array_t**)&v->fieldptr[0]; jl_idtable_rehash(a, jl_array_len(*a)); - gc_wb(v, *a); + jl_gc_wb(v, *a); break; } default: @@ -1676,11 +1676,11 @@ jl_value_t *jl_compress_ast(jl_lambda_info_t *li, jl_value_t *ast) if (li->module->constant_table == NULL) { li->module->constant_table = jl_alloc_cell_1d(0); - gc_wb(li->module, li->module->constant_table); + jl_gc_wb(li->module, li->module->constant_table); } tree_literal_values = li->module->constant_table; li->capt = (jl_value_t*)jl_lam_capt((jl_expr_t*)ast); - gc_wb(li, li->capt); + jl_gc_wb(li, li->capt); if (jl_array_len(li->capt) == 0) li->capt = NULL; jl_serialize_value(&dest, jl_lam_body((jl_expr_t*)ast)->etype); diff --git a/src/gc.c b/src/gc.c index 02e2485bda4c8..40d022fe3f300 100644 --- a/src/gc.c +++ b/src/gc.c @@ -785,21 +785,21 @@ static inline int maybe_collect(void) // preserved values -DLLEXPORT int jl_gc_n_preserved_values(void) +int jl_gc_n_preserved_values(void) { FOR_CURRENT_HEAP return preserved_values.len; END } -DLLEXPORT void jl_gc_preserve(jl_value_t *v) +void jl_gc_preserve(jl_value_t *v) { FOR_CURRENT_HEAP arraylist_push(&preserved_values, (void*)v); END } -DLLEXPORT void jl_gc_unpreserve(void) +void jl_gc_unpreserve(void) { FOR_CURRENT_HEAP (void)arraylist_pop(&preserved_values); @@ -810,7 +810,7 @@ DLLEXPORT void jl_gc_unpreserve(void) DLLEXPORT jl_weakref_t *jl_gc_new_weakref(jl_value_t *value) { - jl_weakref_t *wr = (jl_weakref_t*)alloc_1w(); + jl_weakref_t *wr = (jl_weakref_t*)jl_gc_alloc_1w(); jl_set_typeof(wr, jl_weakref_type); wr->value = value; FOR_CURRENT_HEAP @@ -1451,7 +1451,7 @@ static void reset_remset(void) END } -DLLEXPORT void gc_queue_root(jl_value_t *ptr) +DLLEXPORT void jl_gc_queue_root(jl_value_t *ptr) { FOR_CURRENT_HEAP jl_taggedvalue_t *o = jl_astaggedvalue(ptr); @@ -1926,7 +1926,7 @@ static void post_mark(arraylist_t *list, int dryrun) is rare enough this may not be straightforward. If the backtracking goes well you should know which object and which of its slots was written to without being caught by the write barrier. Most times this allows you to take a guess. If this type of object is modified - by C code directly, look for missing gc_wb() on pointer updates. Be aware that there are + by C code directly, look for missing jl_gc_wb() on pointer updates. Be aware that there are innocent looking functions which allocate (and thus trigger marking) only on special cases. If you cant find it, you can try the following : @@ -2095,14 +2095,14 @@ DLLEXPORT int64_t jl_gc_total_bytes(void) { return total_allocd_bytes + allocd_b DLLEXPORT uint64_t jl_gc_total_hrtime(void) { return total_gc_time; } DLLEXPORT GC_Num jl_gc_num(void) { return gc_num; } -int64_t diff_gc_total_bytes(void) +int64_t jl_gc_diff_total_bytes(void) { int64_t oldtb = last_gc_total_bytes; int64_t newtb = jl_gc_total_bytes(); last_gc_total_bytes = newtb; return newtb - oldtb; } -void sync_gc_total_bytes(void) {last_gc_total_bytes = jl_gc_total_bytes();} +void jl_gc_sync_total_bytes(void) {last_gc_total_bytes = jl_gc_total_bytes();} #if defined(MEMPROFILE) static void all_pool_stats(void); @@ -2436,7 +2436,7 @@ void *reallocb(void *b, size_t sz) } */ -DLLEXPORT jl_value_t *allocobj(size_t sz) +DLLEXPORT jl_value_t *jl_gc_allocobj(size_t sz) { size_t allocsz = sz + sizeof(jl_taggedvalue_t); if (allocsz < sz) // overflow in adding offs, size was "negative" @@ -2450,7 +2450,7 @@ DLLEXPORT jl_value_t *allocobj(size_t sz) return jl_valueof(alloc_big(allocsz)); } -DLLEXPORT jl_value_t *alloc_0w(void) +DLLEXPORT jl_value_t *jl_gc_alloc_0w(void) { const int sz = sizeof(jl_taggedvalue_t); #ifdef MEMDEBUG @@ -2459,7 +2459,7 @@ DLLEXPORT jl_value_t *alloc_0w(void) return jl_valueof(_pool_alloc(&pools[szclass(sz)], sz)); } -DLLEXPORT jl_value_t *alloc_1w(void) +DLLEXPORT jl_value_t *jl_gc_alloc_1w(void) { const int sz = LLT_ALIGN(sizeof(jl_taggedvalue_t) + sizeof(void*), 16); #ifdef MEMDEBUG @@ -2468,7 +2468,7 @@ DLLEXPORT jl_value_t *alloc_1w(void) return jl_valueof(_pool_alloc(&pools[szclass(sz)], sz)); } -DLLEXPORT jl_value_t *alloc_2w(void) +DLLEXPORT jl_value_t *jl_gc_alloc_2w(void) { const int sz = LLT_ALIGN(sizeof(jl_taggedvalue_t) + sizeof(void*) * 2, 16); #ifdef MEMDEBUG @@ -2477,7 +2477,7 @@ DLLEXPORT jl_value_t *alloc_2w(void) return jl_valueof(_pool_alloc(&pools[szclass(sz)], sz)); } -DLLEXPORT jl_value_t *alloc_3w(void) +DLLEXPORT jl_value_t *jl_gc_alloc_3w(void) { const int sz = LLT_ALIGN(sizeof(jl_taggedvalue_t) + sizeof(void*) * 3, 16); #ifdef MEMDEBUG @@ -2679,7 +2679,7 @@ static void big_obj_stats(void) #endif //MEMPROFILE #else //JL_GC_MARKSWEEP -DLLEXPORT jl_value_t *allocobj(size_t sz) +DLLEXPORT jl_value_t *jl_gc_allocobj(size_t sz) { size_t allocsz = sz + sizeof(jl_taggedvalue_t); if (allocsz < sz) // overflow in adding offs, size was "negative" @@ -2688,13 +2688,13 @@ DLLEXPORT jl_value_t *allocobj(size_t sz) gc_num.alloc++; return jl_valueof(malloc(allocsz)); } -int64_t diff_gc_total_bytes(void) +int64_t jl_gc_diff_total_bytes(void) { return 0; } DLLEXPORT jl_weakref_t *jl_gc_new_weakref(jl_value_t *value) { - jl_weakref_t *wr = (jl_weakref_t*)alloc_1w(); + jl_weakref_t *wr = (jl_weakref_t*)jl_gc_alloc_1w(); jl_set_typeof(wr, jl_weakref_type); wr->value = value; return wr; diff --git a/src/gf.c b/src/gf.c index de6a27193ffed..7fd7a3859f6ad 100644 --- a/src/gf.c +++ b/src/gf.c @@ -40,7 +40,7 @@ static jl_value_t *jl_apply_unspecialized(jl_function_t *meth, jl_value_t **args static jl_methtable_t *new_method_table(jl_sym_t *name) { - jl_methtable_t *mt = (jl_methtable_t*)allocobj(sizeof(jl_methtable_t)); + jl_methtable_t *mt = (jl_methtable_t*)jl_gc_allocobj(sizeof(jl_methtable_t)); jl_set_typeof(mt, jl_methtable_type); mt->name = name; mt->defs = (jl_methlist_t*)jl_nothing; @@ -176,7 +176,7 @@ static void mtcache_rehash(jl_array_t **pa, jl_value_t* parent) nd[uid & (len*2-1)] = (jl_value_t*)ml; } } - gc_wb(parent, n); + jl_gc_wb(parent, n); *pa = n; } @@ -311,7 +311,7 @@ jl_function_t *jl_instantiate_method(jl_function_t *f, jl_svec_t *sp) jl_function_t *nf = jl_new_closure(f->fptr, f->env, NULL); JL_GC_PUSH1(&nf); nf->linfo = jl_add_static_parameters(f->linfo, sp); - gc_wb(nf, nf->linfo); + jl_gc_wb(nf, nf->linfo); JL_GC_POP(); return nf; } @@ -362,7 +362,7 @@ jl_function_t *jl_method_cache_insert(jl_methtable_t *mt, jl_tupletype_t *type, if (uid > 0) { if (mt->cache_targ == (void*)jl_nothing) { mt->cache_targ = jl_alloc_cell_1d(16); - gc_wb(mt, mt->cache_targ); + jl_gc_wb(mt, mt->cache_targ); } pml = mtcache_hash_bp(&mt->cache_targ, a0, 1, (jl_value_t*)mt); cache_array = (jl_value_t*)mt->cache_targ; @@ -374,7 +374,7 @@ jl_function_t *jl_method_cache_insert(jl_methtable_t *mt, jl_tupletype_t *type, if (uid > 0) { if (mt->cache_arg1 == (void*)jl_nothing) { mt->cache_arg1 = jl_alloc_cell_1d(16); - gc_wb(mt, mt->cache_arg1); + jl_gc_wb(mt, mt->cache_arg1); } pml = mtcache_hash_bp(&mt->cache_arg1, t0, 0, (jl_value_t*)mt); cache_array = (jl_value_t*)mt->cache_arg1; @@ -413,7 +413,7 @@ void jl_type_infer(jl_lambda_info_t *li, jl_tupletype_t *argtypes, jl_lambda_inf #ifdef ENABLE_INFERENCE jl_value_t *newast = jl_apply(jl_typeinf_func, fargs, 4); li->ast = jl_fieldref(newast, 0); - gc_wb(li, li->ast); + jl_gc_wb(li, li->ast); li->inferred = 1; #endif li->inInference = 0; @@ -803,15 +803,15 @@ static jl_function_t *cache_method(jl_methtable_t *mt, jl_tupletype_t *type, jl_instantiate_method(method, jl_emptysvec); if (method->env != (jl_value_t*)jl_emptysvec) method->linfo->unspecialized->env = NULL; - gc_wb(method->linfo, method->linfo->unspecialized); + jl_gc_wb(method->linfo, method->linfo->unspecialized); } newmeth->linfo->unspecialized = method->linfo->unspecialized; - gc_wb(newmeth->linfo, newmeth->linfo->unspecialized); + jl_gc_wb(newmeth->linfo, newmeth->linfo->unspecialized); } if (newmeth->linfo != NULL && newmeth->linfo->ast != NULL) { newmeth->linfo->specTypes = type; - gc_wb(newmeth->linfo, type); + jl_gc_wb(newmeth->linfo, type); jl_array_t *spe = method->linfo->specializations; if (spe == NULL) { spe = jl_alloc_cell_1d(1); @@ -821,7 +821,7 @@ static jl_function_t *cache_method(jl_methtable_t *mt, jl_tupletype_t *type, jl_cell_1d_push(spe, (jl_value_t*)newmeth->linfo); } method->linfo->specializations = spe; - gc_wb(method->linfo, method->linfo->specializations); + jl_gc_wb(method->linfo, method->linfo->specializations); jl_type_infer(newmeth->linfo, type, method->linfo); } JL_GC_POP(); @@ -1160,14 +1160,14 @@ jl_methlist_t *jl_method_list_insert(jl_methlist_t **pml, jl_tupletype_t *type, } JL_SIGATOMIC_BEGIN(); l->sig = type; - gc_wb(l, l->sig); + jl_gc_wb(l, l->sig); l->tvars = tvars; - gc_wb(l, l->tvars); + jl_gc_wb(l, l->tvars); l->va = jl_is_va_tuple(type); l->isstaged = isstaged; l->invokes = (struct _jl_methtable_t *)jl_nothing; l->func = method; - gc_wb(l, l->func); + jl_gc_wb(l, l->func); JL_SIGATOMIC_END(); return l; } @@ -1188,7 +1188,7 @@ jl_methlist_t *jl_method_list_insert(jl_methlist_t **pml, jl_tupletype_t *type, pa = (jl_value_t*)l; l = l->next; } - jl_methlist_t *newrec = (jl_methlist_t*)allocobj(sizeof(jl_methlist_t)); + jl_methlist_t *newrec = (jl_methlist_t*)jl_gc_allocobj(sizeof(jl_methlist_t)); jl_set_typeof(newrec, jl_method_type); newrec->sig = type; newrec->tvars = tvars; @@ -1200,7 +1200,7 @@ jl_methlist_t *jl_method_list_insert(jl_methlist_t **pml, jl_tupletype_t *type, JL_SIGATOMIC_BEGIN(); JL_GC_PUSH1(&newrec); *pl = newrec; - gc_wb(pa, newrec); + jl_gc_wb(pa, newrec); // if this contains Union types, methods after it might actually be // more specific than it. we need to re-sort them. if (has_unions(type)) { @@ -1220,11 +1220,11 @@ jl_methlist_t *jl_method_list_insert(jl_methlist_t **pml, jl_tupletype_t *type, (jl_value_t*)l->sig)) { // reinsert item earlier in the list *pitem = next; - gc_wb(item_parent, next); + jl_gc_wb(item_parent, next); item->next = l; - gc_wb(item, item->next); + jl_gc_wb(item, item->next); *pl = item; - gc_wb(pa, item); + jl_gc_wb(pa, item); pnext = pitem; next_parent = item_parent; break; @@ -1277,13 +1277,13 @@ jl_methlist_t *jl_method_table_insert(jl_methtable_t *mt, jl_tupletype_t *type, jl_methlist_t *ml = jl_method_list_insert(&mt->defs,type,method,tvars,1,isstaged,(jl_value_t*)mt); // invalidate cached methods that overlap this definition remove_conflicting(&mt->cache, (jl_value_t*)type); - gc_wb(mt, mt->cache); + jl_gc_wb(mt, mt->cache); if (mt->cache_arg1 != (void*)jl_nothing) { for(int i=0; i < jl_array_len(mt->cache_arg1); i++) { jl_methlist_t **pl = &((jl_methlist_t**)jl_array_data(mt->cache_arg1))[i]; if (*pl && *pl != (void*)jl_nothing) { remove_conflicting(pl, (jl_value_t*)type); - gc_wb(mt->cache_arg1, jl_cellref(mt->cache_arg1,i)); + jl_gc_wb(mt->cache_arg1, jl_cellref(mt->cache_arg1,i)); } } } @@ -1292,7 +1292,7 @@ jl_methlist_t *jl_method_table_insert(jl_methtable_t *mt, jl_tupletype_t *type, jl_methlist_t **pl = &((jl_methlist_t**)jl_array_data(mt->cache_targ))[i]; if (*pl && *pl != (void*)jl_nothing) { remove_conflicting(pl, (jl_value_t*)type); - gc_wb(mt->cache_targ, jl_cellref(mt->cache_targ,i)); + jl_gc_wb(mt->cache_targ, jl_cellref(mt->cache_targ,i)); } } } @@ -1462,7 +1462,7 @@ static void all_p2c(jl_value_t *ast, jl_svec_t *tvars) if (jl_is_lambda_info(ast)) { jl_lambda_info_t *li = (jl_lambda_info_t*)ast; li->ast = jl_prepare_ast(li, jl_emptysvec); - gc_wb(li, li->ast); + jl_gc_wb(li, li->ast); parameters_to_closureenv(li->ast, tvars); all_p2c(li->ast, tvars); } @@ -1476,7 +1476,7 @@ static void all_p2c(jl_value_t *ast, jl_svec_t *tvars) static void precompile_unspecialized(jl_function_t *func, jl_tupletype_t *sig, jl_svec_t *tvars) { func->linfo->specTypes = sig; - gc_wb(func->linfo, sig); + jl_gc_wb(func->linfo, sig); if (tvars != jl_emptysvec) { // add static parameter names to end of closure env; compile // assuming they are there. method cache will fill them in when @@ -1504,7 +1504,7 @@ void jl_compile_all_defs(jl_function_t *gf) if (func->env != (jl_value_t*)jl_emptysvec) func->env = NULL; m->func->linfo->unspecialized = func; - gc_wb(m->func->linfo, func); + jl_gc_wb(m->func->linfo, func); precompile_unspecialized(func, m->sig, m->tvars); } m = m->next; @@ -1546,7 +1546,7 @@ static void _compile_all(jl_module_t *m, htable_t *h) if (func == NULL) { func = jl_new_closure(li->fptr, (jl_value_t*)jl_emptysvec, li); li->unspecialized = func; - gc_wb(li, func); + jl_gc_wb(li, func); } precompile_unspecialized(func, NULL, jl_emptysvec); } @@ -1617,7 +1617,7 @@ JL_CALLABLE(jl_apply_generic) li->unspecialized = jl_instantiate_method(mfunc, li->sparams); if (mfunc->env != (jl_value_t*)jl_emptysvec) li->unspecialized->env = NULL; - gc_wb(li, li->unspecialized); + jl_gc_wb(li, li->unspecialized); } return jl_apply_unspecialized(mfunc, args, nargs); } @@ -1715,7 +1715,7 @@ jl_value_t *jl_gf_invoke(jl_function_t *gf, jl_tupletype_t *types, li->unspecialized = jl_instantiate_method(mfunc, li->sparams); if (mfunc->env != (jl_value_t*)jl_emptysvec) li->unspecialized->env = NULL; - gc_wb(li, li->unspecialized); + jl_gc_wb(li, li->unspecialized); } return jl_apply_unspecialized(mfunc, args, nargs); } @@ -1728,7 +1728,7 @@ jl_value_t *jl_gf_invoke(jl_function_t *gf, jl_tupletype_t *types, tt = arg_type_tuple(args, nargs); if (m->invokes == (void*)jl_nothing) { m->invokes = new_method_table(mt->name); - gc_wb(m, m->invokes); + jl_gc_wb(m, m->invokes); update_max_args(m->invokes, tt); // this private method table has just this one definition jl_method_list_insert(&m->invokes->defs,m->sig,m->func,m->tvars,0,0,(jl_value_t*)m->invokes); @@ -1772,7 +1772,7 @@ void jl_initialize_generic_function(jl_function_t *f, jl_sym_t *name) { f->fptr = jl_apply_generic; f->env = (jl_value_t*)new_method_table(name); - gc_wb(f, f->env); + jl_gc_wb(f, f->env); } jl_function_t *jl_new_generic_function(jl_sym_t *name) diff --git a/src/interpreter.c b/src/interpreter.c index ff18d3f896cb4..78d06c3ba0812 100644 --- a/src/interpreter.c +++ b/src/interpreter.c @@ -152,7 +152,7 @@ static jl_value_t *eval(jl_value_t *e, jl_value_t **locals, size_t nl, size_t ng jl_lambda_info_t *li = (jl_lambda_info_t*)e; if (jl_boot_file_loaded && li->ast && jl_is_expr(li->ast)) { li->ast = jl_compress_ast(li, li->ast); - gc_wb(li, li->ast); + jl_gc_wb(li, li->ast); } return (jl_value_t*)jl_new_closure(NULL, (jl_value_t*)jl_emptysvec, li); } @@ -192,7 +192,7 @@ static jl_value_t *eval(jl_value_t *e, jl_value_t **locals, size_t nl, size_t ng JL_GC_PUSHARGS(ar, na*2); for(int i=0; i < na; i++) { ar[i*2+1] = eval(args[i+1], locals, nl, ngensym); - gc_wb(ex->args, ar[i*2+1]); + jl_gc_wb(ex->args, ar[i*2+1]); } if (na != nreq) { jl_error("wrong number of arguments"); @@ -350,7 +350,7 @@ static jl_value_t *eval(jl_value_t *e, jl_value_t **locals, size_t nl, size_t ng temp = b->value; check_can_assign_type(b); b->value = (jl_value_t*)dt; - gc_wb_binding(b, dt); + jl_gc_wb_binding(b, dt); super = eval(args[2], locals, nl, ngensym); jl_set_datatype_super(dt, super); b->value = temp; @@ -380,7 +380,7 @@ static jl_value_t *eval(jl_value_t *e, jl_value_t **locals, size_t nl, size_t ng temp = b->value; check_can_assign_type(b); b->value = (jl_value_t*)dt; - gc_wb_binding(b, dt); + jl_gc_wb_binding(b, dt); super = eval(args[3], locals, nl, ngensym); jl_set_datatype_super(dt, super); b->value = temp; @@ -409,13 +409,13 @@ static jl_value_t *eval(jl_value_t *e, jl_value_t **locals, size_t nl, size_t ng // temporarily assign so binding is available for field types check_can_assign_type(b); b->value = (jl_value_t*)dt; - gc_wb_binding(b,dt); + jl_gc_wb_binding(b,dt); JL_TRY { // operations that can fail inside_typedef = 1; dt->types = (jl_svec_t*)eval(args[4], locals, nl, ngensym); - gc_wb(dt, dt->types); + jl_gc_wb(dt, dt->types); inside_typedef = 0; for(size_t i=0; i < jl_svec_len(dt->types); i++) { jl_value_t *elt = jl_svecref(dt->types, i); @@ -435,7 +435,7 @@ static jl_value_t *eval(jl_value_t *e, jl_value_t **locals, size_t nl, size_t ng jl_compute_field_offsets(dt); if (para == (jl_value_t*)jl_emptysvec && jl_is_datatype_singleton(dt)) { dt->instance = newstruct(dt); - gc_wb(dt, dt->instance); + jl_gc_wb(dt, dt->instance); } b->value = temp; @@ -459,7 +459,7 @@ static jl_value_t *eval(jl_value_t *e, jl_value_t **locals, size_t nl, size_t ng f->linfo && f->linfo->ast && jl_is_expr(f->linfo->ast)) { jl_lambda_info_t *li = f->linfo; li->ast = jl_compress_ast(li, li->ast); - gc_wb(li, li->ast); + jl_gc_wb(li, li->ast); li->name = nm; } jl_set_global(jl_current_module, nm, (jl_value_t*)f); diff --git a/src/jltypes.c b/src/jltypes.c index eeba8c3272866..4e8b31c609a46 100644 --- a/src/jltypes.c +++ b/src/jltypes.c @@ -275,7 +275,7 @@ jl_value_t *jl_type_union_v(jl_value_t **ts, size_t n) JL_GC_PUSH1(&types); jl_uniontype_t *tu = (jl_uniontype_t*)newobj((jl_value_t*)jl_uniontype_type,NWORDS(sizeof(jl_uniontype_t))); tu->types = types; - gc_wb(tu, types); + jl_gc_wb(tu, types); JL_GC_POP(); return (jl_value_t*)tu; } @@ -1922,7 +1922,7 @@ static void cache_insert_type(jl_value_t *type, ssize_t insert_at, int ordered) ((jl_datatype_t*)type)->name->cache = nc; else ((jl_datatype_t*)type)->name->linearcache = nc; - gc_wb(((jl_datatype_t*)type)->name, nc); + jl_gc_wb(((jl_datatype_t*)type)->name, nc); cache = nc; n = jl_svec_len(nc); } @@ -2026,10 +2026,10 @@ static jl_value_t *inst_datatype(jl_datatype_t *dt, jl_svec_t *p, jl_value_t **i top.prev = stack; stack = ⊤ ndt->name = tn; - gc_wb(ndt, ndt->name); + jl_gc_wb(ndt, ndt->name); ndt->super = jl_any_type; ndt->parameters = p; - gc_wb(ndt, ndt->parameters); + jl_gc_wb(ndt, ndt->parameters); ndt->types = istuple ? p : jl_emptysvec; // to be filled in below ndt->mutabl = dt->mutabl; ndt->abstract = dt->abstract; @@ -2048,13 +2048,13 @@ static jl_value_t *inst_datatype(jl_datatype_t *dt, jl_svec_t *p, jl_value_t **i ndt->super = jl_any_type; else ndt->super = (jl_datatype_t*)inst_type_w_((jl_value_t*)dt->super, env,n,stack, 1); - gc_wb(ndt, ndt->super); + jl_gc_wb(ndt, ndt->super); ftypes = dt->types; if (ftypes != NULL) { if (!istuple) { // recursively instantiate the types of the fields ndt->types = inst_all(ftypes, env, n, stack, 1); - gc_wb(ndt, ndt->types); + jl_gc_wb(ndt, ndt->types); } if (!isabstract) { if (jl_svec_len(ftypes) == 0) { @@ -2067,7 +2067,7 @@ static jl_value_t *inst_datatype(jl_datatype_t *dt, jl_svec_t *p, jl_value_t **i } if (jl_is_datatype_singleton(ndt)) { ndt->instance = newstruct(ndt); - gc_wb(ndt, ndt->instance); + jl_gc_wb(ndt, ndt->instance); } } else { @@ -2286,9 +2286,9 @@ void jl_reinstantiate_inner_types(jl_datatype_t *t) env[i*2+1] = env[i*2]; } t->super = (jl_datatype_t*)inst_type_w_((jl_value_t*)t->super, env, n, &top, 1); - gc_wb(t, t->super); + jl_gc_wb(t, t->super); t->types = inst_all(t->types, env, n, &top, 1); - gc_wb(t, t->types); + jl_gc_wb(t, t->types); } // subtype comparison diff --git a/src/julia.expmap b/src/julia.expmap index f6c1f587c9a8c..c3ccb299bbb86 100644 --- a/src/julia.expmap +++ b/src/julia.expmap @@ -2,8 +2,6 @@ global: __asan*; __stack_chk_guard; - alloc_*w; - allocobj; asprintf; bitvector_*; clock_now; @@ -32,8 +30,6 @@ uv_*; add_library_mapping; utf8proc_*; - gc_queue_root; - gc_wb_slow; jlbacktrace; _IO_stdin_used; diff --git a/src/julia.h b/src/julia.h index cf7b3725160fe..28b69933158e8 100644 --- a/src/julia.h +++ b/src/julia.h @@ -546,13 +546,13 @@ DLLEXPORT int jl_gc_enable(int on); DLLEXPORT int jl_gc_is_enabled(void); DLLEXPORT int64_t jl_gc_total_bytes(void); DLLEXPORT uint64_t jl_gc_total_hrtime(void); -int64_t diff_gc_total_bytes(void); -void sync_gc_total_bytes(void); +int64_t jl_gc_diff_total_bytes(void); +void jl_gc_sync_total_bytes(void); DLLEXPORT void jl_gc_collect(int); -DLLEXPORT void jl_gc_preserve(jl_value_t *v); -DLLEXPORT void jl_gc_unpreserve(void); -DLLEXPORT int jl_gc_n_preserved_values(void); +void jl_gc_preserve(jl_value_t *v); +void jl_gc_unpreserve(void); +int jl_gc_n_preserved_values(void); DLLEXPORT void jl_gc_add_finalizer(jl_value_t *v, jl_function_t *f); DLLEXPORT void jl_finalize(jl_value_t *o); @@ -561,37 +561,37 @@ void jl_gc_free_array(jl_array_t *a); void jl_gc_track_malloced_array(jl_array_t *a); void jl_gc_count_allocd(size_t sz); void jl_gc_run_all_finalizers(void); -DLLEXPORT jl_value_t *alloc_0w(void); -DLLEXPORT jl_value_t *alloc_1w(void); -DLLEXPORT jl_value_t *alloc_2w(void); -DLLEXPORT jl_value_t *alloc_3w(void); +DLLEXPORT jl_value_t *jl_gc_alloc_0w(void); +DLLEXPORT jl_value_t *jl_gc_alloc_1w(void); +DLLEXPORT jl_value_t *jl_gc_alloc_2w(void); +DLLEXPORT jl_value_t *jl_gc_alloc_3w(void); void *allocb(size_t sz); void *reallocb(void*, size_t); -DLLEXPORT jl_value_t *allocobj(size_t sz); +DLLEXPORT jl_value_t *jl_gc_allocobj(size_t sz); DLLEXPORT void jl_clear_malloc_data(void); DLLEXPORT int64_t jl_gc_num_pause(void); DLLEXPORT int64_t jl_gc_num_full_sweep(void); // GC write barriers -DLLEXPORT void gc_queue_root(jl_value_t *root); // root isa jl_value_t* +DLLEXPORT void jl_gc_queue_root(jl_value_t *root); // root isa jl_value_t* void gc_queue_binding(jl_binding_t *bnd); void gc_setmark_buf(void *buf, int); -static inline void gc_wb_binding(jl_binding_t *bnd, void *val) // val isa jl_value_t* +static inline void jl_gc_wb_binding(jl_binding_t *bnd, void *val) // val isa jl_value_t* { if (__unlikely((*((uintptr_t*)bnd-1) & 1) == 1 && (*(uintptr_t*)jl_astaggedvalue(val) & 1) == 0)) gc_queue_binding(bnd); } -static inline void gc_wb(void *parent, void *ptr) // parent and ptr isa jl_value_t* +static inline void jl_gc_wb(void *parent, void *ptr) // parent and ptr isa jl_value_t* { if (__unlikely((*((uintptr_t*)jl_astaggedvalue(parent)) & 1) == 1 && (*((uintptr_t*)jl_astaggedvalue(ptr)) & 1) == 0)) - gc_queue_root((jl_value_t*)parent); + jl_gc_queue_root((jl_value_t*)parent); } -static inline void gc_wb_buf(void *parent, void *bufptr) // parent isa jl_value_t* +static inline void jl_gc_wb_buf(void *parent, void *bufptr) // parent isa jl_value_t* { // if parent is marked and buf is not if (__unlikely((*((uintptr_t*)jl_astaggedvalue(parent)) & 1) == 1)) @@ -599,11 +599,11 @@ static inline void gc_wb_buf(void *parent, void *bufptr) // parent isa jl_value_ gc_setmark_buf(bufptr, *(uintptr_t*)jl_astaggedvalue(parent) & 3); } -static inline void gc_wb_back(void *ptr) // ptr isa jl_value_t* +static inline void jl_gc_wb_back(void *ptr) // ptr isa jl_value_t* { // if ptr is marked if(__unlikely((*((uintptr_t*)jl_astaggedvalue(ptr)) & 1) == 1)) { - gc_queue_root((jl_value_t*)ptr); + jl_gc_queue_root((jl_value_t*)ptr); } } @@ -623,30 +623,30 @@ static inline void gc_wb_back(void *ptr) // ptr isa jl_value_t* #define jl_gc_n_preserved_values() (0) #define allocb(nb) malloc(nb) -DLLEXPORT jl_value_t *allocobj(size_t sz); -STATIC_INLINE jl_value_t *alloc_1w() { return allocobj(1*sizeof(void*)); } -STATIC_INLINE jl_value_t *alloc_2w() { return allocobj(2*sizeof(void*)); } -STATIC_INLINE jl_value_t *alloc_3w() { return allocobj(3*sizeof(void*)); } +DLLEXPORT jl_value_t *jl_gc_allocobj(size_t sz); +STATIC_INLINE jl_value_t *jl_gc_alloc_1w() { return jl_gc_allocobj(1*sizeof(void*)); } +STATIC_INLINE jl_value_t *jl_gc_alloc_2w() { return jl_gc_allocobj(2*sizeof(void*)); } +STATIC_INLINE jl_value_t *jl_gc_alloc_3w() { return jl_gc_allocobj(3*sizeof(void*)); } DLLEXPORT void jl_gc_add_finalizer(jl_value_t *v, jl_function_t *f); -int64_t diff_gc_total_bytes(void); -#define sync_gc_total_bytes() +int64_t jl_gc_diff_total_bytes(void); +#define jl_gc_sync_total_bytes() #define jl_gc_collect(arg); #define jl_gc_enable(on) (0) #define jl_gc_is_enabled() (0) #define jl_gc_track_malloced_array(a) #define jl_gc_count_allocd(sz) -#define gc_wb_binding(bnd, val) -#define gc_wb(parent, ptr) -#define gc_wb_buf(parent, bufptr) -#define gc_wb_back(ptr) +#define jl_gc_wb_binding(bnd, val) +#define jl_gc_wb(parent, ptr) +#define jl_gc_wb_buf(parent, bufptr) +#define jl_gc_wb_back(ptr) #endif -DLLEXPORT void *jl_gc_managed_malloc(size_t sz); -DLLEXPORT void *jl_gc_managed_realloc(void *d, size_t sz, size_t oldsz, int isaligned, jl_value_t* owner); +void *jl_gc_managed_malloc(size_t sz); +void *jl_gc_managed_realloc(void *d, size_t sz, size_t oldsz, int isaligned, jl_value_t* owner); // object accessors ----------------------------------------------------------- @@ -667,7 +667,7 @@ STATIC_INLINE jl_value_t *jl_svecset(void *t, size_t i, void *x) assert(jl_typeis(t,jl_simplevector_type)); assert(i < jl_svec_len(t)); jl_svec_data(t)[i] = (jl_value_t*)x; - if (x) gc_wb(t, x); + if (x) jl_gc_wb(t, x); return (jl_value_t*)x; } @@ -698,7 +698,7 @@ STATIC_INLINE jl_value_t *jl_cellset(void *a, size_t i, void *x) if (((jl_array_t*)a)->how == 3) { a = jl_array_data_owner(a); } - gc_wb(a, x); + jl_gc_wb(a, x); } return (jl_value_t*)x; } diff --git a/src/julia_internal.h b/src/julia_internal.h index 1d3aef7cc63c8..a53cc4fe3c26b 100644 --- a/src/julia_internal.h +++ b/src/julia_internal.h @@ -18,15 +18,15 @@ STATIC_INLINE jl_value_t *newobj(jl_value_t *type, size_t nfields) jl_value_t *jv = NULL; switch (nfields) { case 0: - jv = (jl_value_t*)alloc_0w(); break; + jv = (jl_value_t*)jl_gc_alloc_0w(); break; case 1: - jv = (jl_value_t*)alloc_1w(); break; + jv = (jl_value_t*)jl_gc_alloc_1w(); break; case 2: - jv = (jl_value_t*)alloc_2w(); break; + jv = (jl_value_t*)jl_gc_alloc_2w(); break; case 3: - jv = (jl_value_t*)alloc_3w(); break; + jv = (jl_value_t*)jl_gc_alloc_3w(); break; default: - jv = (jl_value_t*)allocobj(nfields * sizeof(void*)); + jv = (jl_value_t*)jl_gc_allocobj(nfields * sizeof(void*)); } jl_set_typeof(jv, type); return jv; @@ -34,7 +34,7 @@ STATIC_INLINE jl_value_t *newobj(jl_value_t *type, size_t nfields) STATIC_INLINE jl_value_t *newstruct(jl_datatype_t *type) { - jl_value_t *jv = (jl_value_t*)allocobj(type->size); + jl_value_t *jv = (jl_value_t*)jl_gc_allocobj(type->size); jl_set_typeof(jv, type); return jv; } diff --git a/src/module.c b/src/module.c index a86eb5a166cdc..cd3eec77a795f 100644 --- a/src/module.c +++ b/src/module.c @@ -19,7 +19,7 @@ jl_module_t *jl_current_module=NULL; jl_module_t *jl_new_module(jl_sym_t *name) { - jl_module_t *m = (jl_module_t*)allocobj(sizeof(jl_module_t)); + jl_module_t *m = (jl_module_t*)jl_gc_allocobj(sizeof(jl_module_t)); jl_set_typeof(m, jl_module_type); JL_GC_PUSH1(&m); assert(jl_is_symbol(name)); @@ -46,7 +46,7 @@ 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); + jl_gc_wb(m, m->parent); if (std_imports) jl_add_standard_imports(m); JL_GC_POP(); return (jl_value_t*)m; @@ -102,7 +102,7 @@ DLLEXPORT jl_binding_t *jl_get_binding_wr(jl_module_t *m, jl_sym_t *var) b = new_binding(var); b->owner = m; *bp = b; - gc_wb_buf(m, b); + jl_gc_wb_buf(m, b); return *bp; } @@ -145,7 +145,7 @@ DLLEXPORT jl_binding_t *jl_get_binding_for_method_def(jl_module_t *m, jl_sym_t * b = new_binding(var); b->owner = m; *bp = b; - gc_wb_buf(m, b); + jl_gc_wb_buf(m, b); return *bp; } @@ -292,7 +292,7 @@ static void module_import_(jl_module_t *to, jl_module_t *from, jl_sym_t *s, nb->owner = b->owner; nb->imported = (explici!=0); *bp = nb; - gc_wb_buf(to, nb); + jl_gc_wb_buf(to, nb); } } } @@ -361,7 +361,7 @@ void jl_module_export(jl_module_t *from, jl_sym_t *s) // don't yet know who the owner is b->owner = NULL; *bp = b; - gc_wb_buf(from, b); + jl_gc_wb_buf(from, b); } assert(*bp != HT_NOTFOUND); (*bp)->exportp = 1; @@ -399,7 +399,7 @@ void jl_set_global(jl_module_t *m, jl_sym_t *var, jl_value_t *val) jl_binding_t *bp = jl_get_binding_wr(m, var); if (!bp->constp) { bp->value = val; - gc_wb(m, val); + jl_gc_wb(m, val); } } @@ -409,7 +409,7 @@ void jl_set_const(jl_module_t *m, jl_sym_t *var, jl_value_t *val) if (!bp->constp) { bp->value = val; bp->constp = 1; - gc_wb(m, val); + jl_gc_wb(m, val); } } @@ -432,7 +432,7 @@ DLLEXPORT void jl_checked_assignment(jl_binding_t *b, jl_value_t *rhs) } } b->value = rhs; - gc_wb_binding(b, rhs); + jl_gc_wb_binding(b, rhs); } DLLEXPORT void jl_declare_constant(jl_binding_t *b) diff --git a/src/simplevector.c b/src/simplevector.c index 908181dabf3fb..69a0ed28dcf52 100644 --- a/src/simplevector.c +++ b/src/simplevector.c @@ -23,9 +23,9 @@ DLLEXPORT jl_svec_t *jl_svec(size_t n, ...) jl_svec_t *jl_svec1(void *a) { #ifdef OVERLAP_SVEC_LEN - jl_svec_t *v = (jl_svec_t*)alloc_1w(); + jl_svec_t *v = (jl_svec_t*)jl_gc_alloc_1w(); #else - jl_svec_t *v = (jl_svec_t*)alloc_2w(); + jl_svec_t *v = (jl_svec_t*)jl_gc_alloc_2w(); #endif jl_set_typeof(v, jl_simplevector_type); jl_svec_set_len_unsafe(v, 1); @@ -36,9 +36,9 @@ jl_svec_t *jl_svec1(void *a) jl_svec_t *jl_svec2(void *a, void *b) { #ifdef OVERLAP_SVEC_LEN - jl_svec_t *v = (jl_svec_t*)alloc_2w(); + jl_svec_t *v = (jl_svec_t*)jl_gc_alloc_2w(); #else - jl_svec_t *v = (jl_svec_t*)alloc_3w(); + jl_svec_t *v = (jl_svec_t*)jl_gc_alloc_3w(); #endif jl_set_typeof(v, jl_simplevector_type); jl_svec_set_len_unsafe(v, 2); diff --git a/src/table.c b/src/table.c index 9283b90fe941c..eb15018c34f36 100644 --- a/src/table.c +++ b/src/table.c @@ -23,7 +23,7 @@ void jl_idtable_rehash(jl_array_t **pa, size_t newsz) for(i=0; i < sz; i+=2) { if (ol[i+1] != NULL) { (*jl_table_lookup_bp(pa, ol[i])) = ol[i+1]; - gc_wb(*pa, ol[i+1]); + jl_gc_wb(*pa, ol[i+1]); // it is however necessary here because allocation // can (and will) occur in a recursive call inside table_lookup_bp } @@ -49,7 +49,7 @@ static void **jl_table_lookup_bp(jl_array_t **pa, void *key) do { if (tab[index+1] == NULL) { tab[index] = key; - gc_wb(a, key); + jl_gc_wb(a, key); return &tab[index+1]; } @@ -118,7 +118,7 @@ jl_array_t *jl_eqtable_put(jl_array_t *h, void *key, void *val) { void **bp = jl_table_lookup_bp(&h, key); *bp = val; - gc_wb(h, val); + jl_gc_wb(h, val); return h; } diff --git a/src/task.c b/src/task.c index 6b6800fa6fb45..e0e6044b97437 100644 --- a/src/task.c +++ b/src/task.c @@ -182,7 +182,7 @@ static void NOINLINE save_stack(jl_task_t *t) // this task's stack could have been modified after // it was marked by an incremental collection // move the barrier back instead of walking it again here - gc_wb_back(t); + jl_gc_wb_back(t); } void NOINLINE restore_stack(jl_task_t *t, jl_jmp_buf *where, char *p) @@ -317,7 +317,7 @@ static void ctx_switch(jl_task_t *t, jl_jmp_buf *where) } t->last = jl_current_task; - gc_wb(t, t->last); + jl_gc_wb(t, t->last); jl_current_task = t; #ifdef COPY_STACKS @@ -825,7 +825,7 @@ DLLEXPORT void jl_throw_with_superfluous_argument(jl_value_t *e, int line) DLLEXPORT jl_task_t *jl_new_task(jl_function_t *start, size_t ssize) { size_t pagesz = jl_page_size; - jl_task_t *t = (jl_task_t*)allocobj(sizeof(jl_task_t)); + jl_task_t *t = (jl_task_t*)jl_gc_allocobj(sizeof(jl_task_t)); jl_set_typeof(t, jl_task_type); ssize = LLT_ALIGN(ssize, pagesz); t->ssize = ssize; @@ -853,7 +853,7 @@ DLLEXPORT jl_task_t *jl_new_task(jl_function_t *start, size_t ssize) char *stk = allocb(ssize+pagesz+(pagesz-1)); t->stkbuf = stk; - gc_wb_buf(t, t->stkbuf); + jl_gc_wb_buf(t, t->stkbuf); stk = (char*)LLT_ALIGN((uptrint_t)stk, pagesz); // add a guard page to detect stack overflow // the GC might read this area, which is ok, just prevent writes @@ -922,7 +922,7 @@ void jl_init_tasks(void) // Initialize a root task using the given stack. void jl_init_root_task(void *stack, size_t ssize) { - jl_current_task = (jl_task_t*)allocobj(sizeof(jl_task_t)); + jl_current_task = (jl_task_t*)jl_gc_allocobj(sizeof(jl_task_t)); jl_set_typeof(jl_current_task, jl_task_type); #ifdef COPY_STACKS jl_current_task->ssize = 0; // size of saved piece diff --git a/src/toplevel.c b/src/toplevel.c index 4eb57252d7600..80e1f2962b9d5 100644 --- a/src/toplevel.c +++ b/src/toplevel.c @@ -117,7 +117,7 @@ jl_value_t *jl_eval_module_expr(jl_expr_t *ex) jl_module_t *newm = jl_new_module(name); newm->parent = parent_module; b->value = (jl_value_t*)newm; - gc_wb_binding(b, newm); + jl_gc_wb_binding(b, newm); if (parent_module == jl_main_module && name == jl_symbol("Base")) { // pick up Base module during bootstrap @@ -635,7 +635,7 @@ void jl_set_datatype_super(jl_datatype_t *tt, jl_value_t *super) jl_errorf("invalid subtyping in definition of %s",tt->name->name->name); } tt->super = (jl_datatype_t*)super; - gc_wb(tt, tt->super); + jl_gc_wb(tt, tt->super); if (jl_svec_len(tt->parameters) > 0) { tt->name->cache = jl_emptysvec; tt->name->linearcache = jl_emptysvec; @@ -691,7 +691,7 @@ DLLEXPORT jl_value_t *jl_generic_function_def(jl_sym_t *name, jl_value_t **bp, j if (*bp == NULL) { gf = (jl_value_t*)jl_new_generic_function(name); *bp = gf; - if (bp_owner) gc_wb(bp_owner, gf); + if (bp_owner) jl_gc_wb(bp_owner, gf); } return gf; } @@ -740,7 +740,7 @@ DLLEXPORT jl_value_t *jl_method_def(jl_sym_t *name, jl_value_t **bp, jl_value_t // edit args, insert type first if (!jl_is_expr(f->linfo->ast)) { f->linfo->ast = jl_uncompress_ast(f->linfo, f->linfo->ast); - gc_wb(f->linfo, f->linfo->ast); + jl_gc_wb(f->linfo, f->linfo->ast); } jl_array_t *al = jl_lam_args((jl_expr_t*)f->linfo->ast); if (jl_array_len(al) == 0) { @@ -799,7 +799,7 @@ DLLEXPORT jl_value_t *jl_method_def(jl_sym_t *name, jl_value_t **bp, jl_value_t if (*bp == NULL) { gf = (jl_value_t*)jl_new_generic_function(name); *bp = gf; - if (bp_owner) gc_wb(bp_owner, gf); + if (bp_owner) jl_gc_wb(bp_owner, gf); } assert(jl_is_function(f)); assert(jl_is_tuple_type(argtypes)); @@ -810,7 +810,7 @@ DLLEXPORT jl_value_t *jl_method_def(jl_sym_t *name, jl_value_t **bp, jl_value_t f->linfo && f->linfo->ast && jl_is_expr(f->linfo->ast)) { jl_lambda_info_t *li = f->linfo; li->ast = jl_compress_ast(li, li->ast); - gc_wb(li, li->ast); + jl_gc_wb(li, li->ast); } JL_GC_POP(); return gf;