Skip to content

Commit c6ceac2

Browse files
committed
Merge pull request #11741 from ScottPJones/spj/fixnames
Fix exported names from gc.c to have jl_gc_ prefix
2 parents 42806c2 + a89f203 commit c6ceac2

21 files changed

+227
-214
lines changed

NEWS.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,21 @@ Deprecated or removed
409409

410410
* `start_timer` and `stop_timer` are replaced by `Timer` and `close`.
411411

412+
* The following internal julia C functions have been renamed, in order to prevent
413+
potential naming conflicts with C libraries: ([#11741])
414+
415+
* `gc_wb*` -> `jl_gc_wb*`
416+
417+
* `gc_queue_root` -> `jl_gc_queue_root`
418+
419+
* `allocobj` -> `jl_gc_allocobj`
420+
421+
* `alloc_[0-3]w` -> `jl_gc_alloc_*w`
422+
423+
* `diff_gc_total_bytes` -> `jl_gc_diff_total_bytes`
424+
425+
* `sync_gc_total_bytes` -> `jl_gc_sync_total_bytes`
426+
412427
Julia v0.3.0 Release Notes
413428
==========================
414429

@@ -1462,3 +1477,4 @@ Too numerous to mention.
14621477
[#11347]: https://github.com/JuliaLang/julia/issues/11347
14631478
[#11379]: https://github.com/JuliaLang/julia/issues/11379
14641479
[#11432]: https://github.com/JuliaLang/julia/issues/11432
1480+
[#11741]: https://github.com/JuliaLang/julia/issues/11741

doc/devdocs/object.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ The mutability property of a value can be queried for with::
7272

7373
If the object being stored is a :c:type:`jl_value_t`, the Julia garbage collector must be notified also::
7474

75-
void gc_wb(jl_value_t *parent, jl_value_t *ptr);
75+
void jl_gc_wb(jl_value_t *parent, jl_value_t *ptr);
7676

7777
However, the :ref:`man-embedding` section of the manual is also required reading at this point,
7878

@@ -163,7 +163,7 @@ Internal to Julia, storage is typically allocated by :c:func:`newstruct` (or :fu
163163
And at the lowest level, memory is getting allocated by a call to the garbage collector (in ``gc.c``),
164164
then tagged with its type::
165165

166-
jl_value_t *allocobj(size_t nbytes);
166+
jl_value_t *jl_gc_allocobj(size_t nbytes);
167167
void jl_set_typeof(jl_value_t *v, jl_datatype_t *type);
168168

169169
.. sidebar:: :ref:`man-singleton-types`

doc/manual/embedding.rst

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,11 @@ Several Julia values can be pushed at once using the ``JL_GC_PUSH2`` , ``JL_GC_P
172172
// Do something with args (e.g. call jl_... functions)
173173
JL_GC_POP();
174174

175-
The garbage collector also operates under the assumption that it is aware of every old-generation object pointing to a young-generation one. Any time a pointer is updated breaking that assumption, it must be signaled to the collector with the ``gc_wb`` (write barrier) function like so::
175+
The garbage collector also operates under the assumption that it is aware of every old-generation object pointing to a young-generation one. Any time a pointer is updated breaking that assumption, it must be signaled to the collector with the ``jl_gc_wb`` (write barrier) function like so::
176176

177177
jl_value_t *parent = some_old_value, *child = some_young_value;
178178
((some_specific_type*)parent)->field = child;
179-
gc_wb(parent, child);
179+
jl_gc_wb(parent, child);
180180

181181
It is in general impossible to predict which values will be old at runtime, so the write barrier must be inserted after all explicit stores. One notable exception is if the ``parent`` object was just allocated and garbage collection was not run since then. Remember that most ``jl_...`` functions can sometimes invoke garbage collection.
182182

@@ -186,19 +186,20 @@ The write barrier is also necessary for arrays of pointers when updating their d
186186
void **data = (void**)jl_array_data(some_array);
187187
jl_value_t *some_value = ...;
188188
data[0] = some_value;
189-
gc_wb(some_array, some_value);
189+
jl_gc_wb(some_array, some_value);
190190

191191

192192
Manipulating the Garbage Collector
193193
---------------------------------------------------
194194

195195
There are some functions to control the GC. In normal use cases, these should not be necessary.
196196

197-
========================= ==============================================================================
198-
``void jl_gc_collect()`` Force a GC run
199-
``void jl_gc_disable()`` Disable the GC
200-
``void jl_gc_enable()`` Enable the GC
201-
========================= ==============================================================================
197+
======================= =====================================================
198+
``jl_gc_collect()`` Force a GC run
199+
``jl_gc_enable(0)`` Disable the GC, return previous state as int
200+
``jl_gc_enable(1)`` Enable the GC, return previous state as int
201+
``jl_gc_is_enabled()`` Return current state as int
202+
======================= =====================================================
202203

203204
Working with Arrays
204205
========================

src/alloc.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ void jl_set_nth_field(jl_value_t *v, size_t i, jl_value_t *rhs)
257257
size_t offs = jl_field_offset(st,i);
258258
if (jl_field_isptr(st,i)) {
259259
*(jl_value_t**)((char*)v + offs) = rhs;
260-
if (rhs != NULL) gc_wb(v, rhs);
260+
if (rhs != NULL) jl_gc_wb(v, rhs);
261261
}
262262
else {
263263
jl_assign_bits((char*)v + offs, rhs);
@@ -315,7 +315,7 @@ DLLEXPORT jl_value_t *jl_new_struct_uninit(jl_datatype_t *type)
315315
DLLEXPORT jl_function_t *jl_new_closure(jl_fptr_t fptr, jl_value_t *env,
316316
jl_lambda_info_t *linfo)
317317
{
318-
jl_function_t *f = (jl_function_t*)alloc_3w(); assert(NWORDS(sizeof(jl_function_t))==3);
318+
jl_function_t *f = (jl_function_t*)jl_gc_alloc_3w(); assert(NWORDS(sizeof(jl_function_t))==3);
319319
jl_set_typeof(f, jl_function_type);
320320
f->fptr = (fptr!=NULL ? fptr : linfo->fptr);
321321
f->env = env;
@@ -445,7 +445,7 @@ jl_sym_t *jl_symbol(const char *str)
445445
if (*pnode == NULL) {
446446
*pnode = mk_symbol(str);
447447
if (parent != NULL)
448-
gc_wb(parent, *pnode);
448+
jl_gc_wb(parent, *pnode);
449449
}
450450
return *pnode;
451451
}
@@ -594,11 +594,11 @@ jl_datatype_t *jl_new_datatype(jl_sym_t *name, jl_datatype_t *super,
594594
tn = t->name;
595595
// init before possibly calling jl_new_typename
596596
t->super = super;
597-
if (super != NULL) gc_wb(t, t->super);
597+
if (super != NULL) jl_gc_wb(t, t->super);
598598
t->parameters = parameters;
599-
gc_wb(t, t->parameters);
599+
jl_gc_wb(t, t->parameters);
600600
t->types = ftypes;
601-
if (ftypes != NULL) gc_wb(t, t->types);
601+
if (ftypes != NULL) jl_gc_wb(t, t->types);
602602
t->abstract = abstract;
603603
t->mutabl = mutabl;
604604
t->pointerfree = 0;
@@ -616,14 +616,14 @@ jl_datatype_t *jl_new_datatype(jl_sym_t *name, jl_datatype_t *super,
616616
else
617617
tn = jl_new_typename((jl_sym_t*)name);
618618
t->name = tn;
619-
gc_wb(t, t->name);
619+
jl_gc_wb(t, t->name);
620620
}
621621
t->name->names = fnames;
622-
gc_wb(t->name, t->name->names);
622+
jl_gc_wb(t->name, t->name->names);
623623

624624
if (t->name->primary == NULL) {
625625
t->name->primary = (jl_value_t*)t;
626-
gc_wb(t->name, t);
626+
jl_gc_wb(t->name, t);
627627
}
628628

629629
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) \
668668
{ \
669669
assert(jl_isbits(t)); \
670670
assert(jl_datatype_size(t) == sizeof(x)); \
671-
jl_value_t *v = (jl_value_t*)alloc_##nw##w(); \
671+
jl_value_t *v = (jl_value_t*)jl_gc_alloc_##nw##w(); \
672672
jl_set_typeof(v, t); \
673673
*(int##nb##_t*)jl_data_ptr(v) = x; \
674674
return v; \
@@ -706,7 +706,7 @@ UNBOX_FUNC(gensym, ssize_t)
706706
#define BOX_FUNC(typ,c_type,pfx,nw) \
707707
jl_value_t *pfx##_##typ(c_type x) \
708708
{ \
709-
jl_value_t *v = (jl_value_t*)alloc_##nw##w(); \
709+
jl_value_t *v = (jl_value_t*)jl_gc_alloc_##nw##w(); \
710710
jl_set_typeof(v, jl_##typ##_type); \
711711
*(c_type*)jl_data_ptr(v) = x; \
712712
return v; \
@@ -728,7 +728,7 @@ jl_value_t *jl_box_##typ(c_type x) \
728728
c_type idx = x+NBOX_C/2; \
729729
if ((u##c_type)idx < (u##c_type)NBOX_C) \
730730
return boxed_##typ##_cache[idx]; \
731-
jl_value_t *v = (jl_value_t*)alloc_##nw##w(); \
731+
jl_value_t *v = (jl_value_t*)jl_gc_alloc_##nw##w(); \
732732
jl_set_typeof(v, jl_##typ##_type); \
733733
*(c_type*)jl_data_ptr(v) = x; \
734734
return v; \
@@ -739,7 +739,7 @@ jl_value_t *jl_box_##typ(c_type x) \
739739
{ \
740740
if (x < NBOX_C) \
741741
return boxed_##typ##_cache[x]; \
742-
jl_value_t *v = (jl_value_t*)alloc_##nw##w(); \
742+
jl_value_t *v = (jl_value_t*)jl_gc_alloc_##nw##w(); \
743743
jl_set_typeof(v, jl_##typ##_type); \
744744
*(c_type*)jl_data_ptr(v) = x; \
745745
return v; \
@@ -833,7 +833,7 @@ jl_expr_t *jl_exprn(jl_sym_t *head, size_t n)
833833
{
834834
jl_array_t *ar = n==0 ? (jl_array_t*)jl_an_empty_cell : jl_alloc_cell_1d(n);
835835
JL_GC_PUSH1(&ar);
836-
jl_expr_t *ex = (jl_expr_t*)alloc_3w(); assert(NWORDS(sizeof(jl_expr_t))==3);
836+
jl_expr_t *ex = (jl_expr_t*)jl_gc_alloc_3w(); assert(NWORDS(sizeof(jl_expr_t))==3);
837837
jl_set_typeof(ex, jl_expr_type);
838838
ex->head = head;
839839
ex->args = ar;
@@ -850,7 +850,7 @@ JL_CALLABLE(jl_f_new_expr)
850850
JL_GC_PUSH1(&ar);
851851
for(size_t i=0; i < nargs-1; i++)
852852
jl_cellset(ar, i, args[i+1]);
853-
jl_expr_t *ex = (jl_expr_t*)alloc_3w(); assert(NWORDS(sizeof(jl_expr_t))==3);
853+
jl_expr_t *ex = (jl_expr_t*)jl_gc_alloc_3w(); assert(NWORDS(sizeof(jl_expr_t))==3);
854854
jl_set_typeof(ex, jl_expr_type);
855855
ex->head = (jl_sym_t*)args[0];
856856
ex->args = ar;

src/array.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ static jl_array_t *_new_array_(jl_value_t *atype, uint32_t ndims, size_t *dims,
8181
size_t doffs = tsz;
8282
tsz += tot;
8383
tsz = JL_ARRAY_ALIGN(tsz, 16); // align whole object 16
84-
a = (jl_array_t*)allocobj(tsz);
84+
a = (jl_array_t*)jl_gc_allocobj(tsz);
8585
jl_set_typeof(a, atype);
8686
a->how = 0;
8787
data = (char*)a + doffs;
@@ -91,7 +91,7 @@ static jl_array_t *_new_array_(jl_value_t *atype, uint32_t ndims, size_t *dims,
9191
}
9292
else {
9393
tsz = JL_ARRAY_ALIGN(tsz, 16); // align whole object 16
94-
a = (jl_array_t*)allocobj(tsz);
94+
a = (jl_array_t*)jl_gc_allocobj(tsz);
9595
JL_GC_PUSH1(&a);
9696
jl_set_typeof(a, atype);
9797
// 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
153153

154154
int ndimwords = jl_array_ndimwords(ndims);
155155
int tsz = JL_ARRAY_ALIGN(sizeof(jl_array_t) + ndimwords*sizeof(size_t) + sizeof(void*), 16);
156-
a = (jl_array_t*)allocobj(tsz);
156+
a = (jl_array_t*)jl_gc_allocobj(tsz);
157157
jl_set_typeof(a, atype);
158158
a->pooled = tsz <= GC_MAX_SZCLASS;
159159
a->ndims = ndims;
@@ -229,7 +229,7 @@ jl_array_t *jl_ptr_to_array_1d(jl_value_t *atype, void *data, size_t nel,
229229

230230
int ndimwords = jl_array_ndimwords(1);
231231
int tsz = JL_ARRAY_ALIGN(sizeof(jl_array_t) + ndimwords*sizeof(size_t), 16);
232-
a = (jl_array_t*)allocobj(tsz);
232+
a = (jl_array_t*)jl_gc_allocobj(tsz);
233233
jl_set_typeof(a, atype);
234234
a->pooled = tsz <= GC_MAX_SZCLASS;
235235
a->data = data;
@@ -280,7 +280,7 @@ jl_array_t *jl_ptr_to_array(jl_value_t *atype, void *data, jl_value_t *dims,
280280

281281
int ndimwords = jl_array_ndimwords(ndims);
282282
int tsz = JL_ARRAY_ALIGN(sizeof(jl_array_t) + ndimwords*sizeof(size_t), 16);
283-
a = (jl_array_t*)allocobj(tsz);
283+
a = (jl_array_t*)jl_gc_allocobj(tsz);
284284
jl_set_typeof(a, atype);
285285
a->pooled = tsz <= GC_MAX_SZCLASS;
286286
a->data = data;
@@ -354,7 +354,7 @@ jl_value_t *jl_array_to_string(jl_array_t *a)
354354
// TODO: check type of array?
355355
jl_datatype_t *string_type = u8_isvalid((char*)a->data, jl_array_len(a)) == 1 ? // ASCII
356356
jl_ascii_string_type : jl_utf8_string_type;
357-
jl_value_t *s = (jl_value_t*)alloc_1w();
357+
jl_value_t *s = (jl_value_t*)jl_gc_alloc_1w();
358358
jl_set_typeof(s, string_type);
359359
jl_set_nth_field(s, 0, (jl_value_t*)a);
360360
return s;
@@ -524,7 +524,7 @@ void jl_arrayset(jl_array_t *a, jl_value_t *rhs, size_t i)
524524
if (a->how == 3) {
525525
owner = jl_array_data_owner(a);
526526
}
527-
gc_wb(owner, rhs);
527+
jl_gc_wb(owner, rhs);
528528
}
529529
}
530530

@@ -598,7 +598,7 @@ static void array_resize_buffer(jl_array_t *a, size_t newlen, size_t oldlen, siz
598598
if (a->ptrarray || es==1)
599599
memset(newdata+offsnb+oldnbytes, 0, nbytes-oldnbytes-offsnb);
600600
if (a->how == 1)
601-
gc_wb_buf(a, newdata);
601+
jl_gc_wb_buf(a, newdata);
602602
a->maxsize = newlen;
603603
}
604604

src/ast.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ static jl_value_t *copy_ast(jl_value_t *expr, jl_svec_t *sp, int do_sp)
770770
// of a top-level thunk that gets type inferred.
771771
li->def = li;
772772
li->ast = jl_prepare_ast(li, li->sparams);
773-
gc_wb(li, li->ast);
773+
jl_gc_wb(li, li->ast);
774774
JL_GC_POP();
775775
return (jl_value_t*)li;
776776
}
@@ -821,7 +821,7 @@ DLLEXPORT jl_value_t *jl_copy_ast(jl_value_t *expr)
821821
ne = jl_exprn(e->head, l);
822822
if (l == 0) {
823823
ne->args = jl_alloc_cell_1d(0);
824-
gc_wb(ne, ne->args);
824+
jl_gc_wb(ne, ne->args);
825825
}
826826
else {
827827
for(i=0; i < l; i++) {

src/builtins.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -945,7 +945,7 @@ void jl_trampoline_compile_function(jl_function_t *f, int always_infer, jl_tuple
945945
if (!jl_in_inference) {
946946
if (!jl_is_expr(f->linfo->ast)) {
947947
f->linfo->ast = jl_uncompress_ast(f->linfo, f->linfo->ast);
948-
gc_wb(f->linfo, f->linfo->ast);
948+
jl_gc_wb(f->linfo, f->linfo->ast);
949949
}
950950
if (always_infer || jl_eval_with_compiler_p(jl_lam_body((jl_expr_t*)f->linfo->ast),1,f->linfo->module)) {
951951
jl_type_infer(f->linfo, sig, f->linfo);
@@ -959,7 +959,7 @@ void jl_trampoline_compile_function(jl_function_t *f, int always_infer, jl_tuple
959959
jl_generate_fptr(f);
960960
if (jl_boot_file_loaded && jl_is_expr(f->linfo->ast)) {
961961
f->linfo->ast = jl_compress_ast(f->linfo, f->linfo->ast);
962-
gc_wb(f->linfo, f->linfo->ast);
962+
jl_gc_wb(f->linfo, f->linfo->ast);
963963
}
964964
}
965965

0 commit comments

Comments
 (0)