Skip to content

Commit 48d7e42

Browse files
authored
Fix build with stock GC: mmtk_pin_object is conditionaly compiled (#42)
1 parent 09e025b commit 48d7e42

File tree

5 files changed

+30
-11
lines changed

5 files changed

+30
-11
lines changed

src/array.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ JL_DLLEXPORT jl_array_t *jl_reshape_array(jl_value_t *atype, jl_array_t *data,
243243
// introspect the object to update the a->data field. To avoid doing that and
244244
// making scan_object much more complex we simply enforce that both owner and
245245
// buffers are always pinned
246-
mmtk_pin_object(owner);
246+
PTR_PIN(owner);
247247
a->flags.how = 3;
248248
a->data = data->data;
249249
a->flags.isshared = 1;
@@ -296,7 +296,7 @@ JL_DLLEXPORT jl_array_t *jl_string_to_array(jl_value_t *str)
296296
// introspect the object to update the a->data field. To avoid doing that and
297297
// making scan_object much more complex we simply enforce that both owner and
298298
// buffers are always pinned
299-
mmtk_pin_object(str);
299+
PTR_PIN(str);
300300
a->flags.how = 3;
301301
a->flags.isshared = 1;
302302
size_t l = jl_string_len(str);
@@ -695,7 +695,7 @@ static int NOINLINE array_resize_buffer(jl_array_t *a, size_t newlen)
695695
// introspect the object to update the a->data field. To avoid doing that and
696696
// making scan_object much more complex we simply enforce that both owner and
697697
// buffers are always pinned
698-
mmtk_pin_object(s);
698+
PTR_PIN(s);
699699
jl_array_data_owner(a) = s;
700700
jl_gc_wb(a, s);
701701
a->data = jl_string_data(s);

src/builtins.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ static uintptr_t type_object_id_(jl_value_t *v, jl_varidx_t *env) JL_NOTSAFEPOIN
314314
}
315315
// FIXME: Pinning objects that get hashed
316316
// until we implement address space hashing.
317-
mmtk_pin_object(v);
317+
PTR_PIN(v);
318318
return inthash((uintptr_t)v);
319319
}
320320
if (tv == jl_uniontype_type) {
@@ -364,7 +364,7 @@ static uintptr_t immut_id_(jl_datatype_t *dt, jl_value_t *v, uintptr_t h) JL_NOT
364364

365365
// FIXME: Pinning objects that get hashed
366366
// until we implement address space hashing.
367-
mmtk_pin_object(v);
367+
PTR_PIN(v);
368368
// operate element-wise if there are unused bits inside,
369369
// otherwise just take the whole data block at once
370370
// a few select pointers (notably symbol) also have special hash values
@@ -424,7 +424,7 @@ static uintptr_t NOINLINE jl_object_id__cold(jl_datatype_t *dt, jl_value_t *v) J
424424
if (dt->name->mutabl) {
425425
// FIXME: Pinning objects that get hashed
426426
// until we implement address space hashing.
427-
mmtk_pin_object(v);
427+
PTR_PIN(v);
428428
return inthash((uintptr_t)v);
429429
}
430430
return immut_id_(dt, v, dt->hash);

src/datatype.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ JL_DLLEXPORT jl_typename_t *jl_new_typename_in(jl_sym_t *name, jl_module_t *modu
6767
jl_typename_type);
6868
// Typenames should be pinned since they are used as metadata, and are
6969
// read during scan_object
70-
mmtk_pin_object(tn);
70+
PTR_PIN(tn);
7171
tn->name = name;
7272
tn->module = module;
7373
tn->wrapper = NULL;
@@ -101,7 +101,7 @@ jl_datatype_t *jl_new_uninitialized_datatype(void)
101101
jl_datatype_t *t = (jl_datatype_t*)jl_gc_alloc(ct->ptls, sizeof(jl_datatype_t), jl_datatype_type);
102102
// Types should be pinned since they are used as metadata, and are
103103
// read during scan_object
104-
mmtk_pin_object(t);
104+
PTR_PIN(t);
105105
t->hash = 0;
106106
t->hasfreetypevars = 0;
107107
t->isdispatchtuple = 0;

src/julia.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@ extern int mmtk_object_is_managed_by_mmtk(void* addr);
1313
extern unsigned char mmtk_pin_object(void* obj);
1414
// FIXME: Pinning objects that get hashed in the ptrhash table
1515
// until we implement address space hashing.
16-
#define PTRHASH_PIN(key) \
17-
mmtk_pin_object(key); \
16+
#ifdef MMTK_GC
17+
#define PTRHASH_PIN(key) mmtk_pin_object(key);
18+
#else
19+
#define PTRHASH_PIN(key)
20+
#endif
1821

1922
#ifdef __cplusplus
2023
}

src/julia_internal.h

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,22 @@
33
#ifndef JL_INTERNAL_H
44
#define JL_INTERNAL_H
55

6+
#ifdef __cplusplus
7+
extern "C" {
8+
#endif
9+
10+
extern int mmtk_object_is_managed_by_mmtk(void* addr);
11+
extern unsigned char mmtk_pin_object(void* obj);
12+
#ifdef MMTK_GC
13+
#define PTR_PIN(key) mmtk_pin_object(key);
14+
#else
15+
#define PTR_PIN(key)
16+
#endif
17+
18+
#ifdef __cplusplus
19+
}
20+
#endif
21+
622
#include "options.h"
723
#include "julia_locks.h"
824
#include "julia_threads.h"
@@ -532,7 +548,7 @@ STATIC_INLINE jl_gc_tracked_buffer_t *jl_gc_alloc_buf(jl_ptls_t ptls, size_t sz)
532548
// introspect the object to update the a->data field. To avoid doing that and
533549
// making scan_object much more complex we simply enforce that both owner and
534550
// buffers are always pinned
535-
mmtk_pin_object(buf);
551+
PTR_PIN(buf);
536552
return buf;
537553
}
538554

0 commit comments

Comments
 (0)