Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port to master: Fix build with stock GC: mmtk_pin_object is conditionaly compiled (#42) #45

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/array.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ JL_DLLEXPORT jl_array_t *jl_reshape_array(jl_value_t *atype, jl_array_t *data,
// introspect the object to update the a->data field. To avoid doing that and
// making scan_object much more complex we simply enforce that both owner and
// buffers are always pinned
mmtk_pin_object(owner);
PTR_PIN(owner);
a->flags.how = 3;
a->data = data->data;
a->flags.isshared = 1;
Expand Down Expand Up @@ -296,7 +296,7 @@ JL_DLLEXPORT jl_array_t *jl_string_to_array(jl_value_t *str)
// introspect the object to update the a->data field. To avoid doing that and
// making scan_object much more complex we simply enforce that both owner and
// buffers are always pinned
mmtk_pin_object(str);
PTR_PIN(str);
a->flags.how = 3;
a->flags.isshared = 1;
size_t l = jl_string_len(str);
Expand Down Expand Up @@ -695,7 +695,7 @@ static int NOINLINE array_resize_buffer(jl_array_t *a, size_t newlen)
// introspect the object to update the a->data field. To avoid doing that and
// making scan_object much more complex we simply enforce that both owner and
// buffers are always pinned
mmtk_pin_object(s);
PTR_PIN(s);
jl_array_data_owner(a) = s;
jl_gc_wb(a, s);
a->data = jl_string_data(s);
Expand Down
6 changes: 3 additions & 3 deletions src/builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ static uintptr_t type_object_id_(jl_value_t *v, jl_varidx_t *env) JL_NOTSAFEPOIN
}
// FIXME: Pinning objects that get hashed
// until we implement address space hashing.
mmtk_pin_object(v);
PTR_PIN(v);
return inthash((uintptr_t)v);
}
if (tv == jl_uniontype_type) {
Expand Down Expand Up @@ -398,7 +398,7 @@ static uintptr_t immut_id_(jl_datatype_t *dt, jl_value_t *v, uintptr_t h) JL_NOT

// FIXME: Pinning objects that get hashed
// until we implement address space hashing.
mmtk_pin_object(v);
PTR_PIN(v);
// operate element-wise if there are unused bits inside,
// otherwise just take the whole data block at once
// a few select pointers (notably symbol) also have special hash values
Expand Down Expand Up @@ -462,7 +462,7 @@ static uintptr_t NOINLINE jl_object_id__cold(jl_datatype_t *dt, jl_value_t *v) J
if (dt->name->mutabl) {
// FIXME: Pinning objects that get hashed
// until we implement address space hashing.
mmtk_pin_object(v);
PTR_PIN(v);
return inthash((uintptr_t)v);
}
return immut_id_(dt, v, dt->hash);
Expand Down
4 changes: 2 additions & 2 deletions src/datatype.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ JL_DLLEXPORT jl_typename_t *jl_new_typename_in(jl_sym_t *name, jl_module_t *modu
jl_typename_type);
// Typenames should be pinned since they are used as metadata, and are
// read during scan_object
mmtk_pin_object(tn);
PTR_PIN(tn);
tn->name = name;
tn->module = module;
tn->wrapper = NULL;
Expand Down Expand Up @@ -101,7 +101,7 @@ jl_datatype_t *jl_new_uninitialized_datatype(void)
jl_datatype_t *t = (jl_datatype_t*)jl_gc_alloc(ct->ptls, sizeof(jl_datatype_t), jl_datatype_type);
// Types should be pinned since they are used as metadata, and are
// read during scan_object
mmtk_pin_object(t);
PTR_PIN(t);
jl_set_typetagof(t, jl_datatype_tag, 0);
t->hash = 0;
t->hasfreetypevars = 0;
Expand Down
7 changes: 5 additions & 2 deletions src/julia.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ extern int mmtk_object_is_managed_by_mmtk(void* addr);
extern unsigned char mmtk_pin_object(void* obj);
// FIXME: Pinning objects that get hashed in the ptrhash table
// until we implement address space hashing.
#define PTRHASH_PIN(key) \
mmtk_pin_object(key); \
#ifdef MMTK_GC
#define PTRHASH_PIN(key) mmtk_pin_object(key);
#else
#define PTRHASH_PIN(key)
#endif

#ifdef __cplusplus
}
Expand Down
18 changes: 17 additions & 1 deletion src/julia_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@
#ifndef JL_INTERNAL_H
#define JL_INTERNAL_H

#ifdef __cplusplus
extern "C" {
#endif

extern int mmtk_object_is_managed_by_mmtk(void* addr);
extern unsigned char mmtk_pin_object(void* obj);
#ifdef MMTK_GC
#define PTR_PIN(key) mmtk_pin_object(key);
#else
#define PTR_PIN(key)
#endif

#ifdef __cplusplus
}
#endif

#include "options.h"
#include "julia_assert.h"
#include "julia_locks.h"
Expand Down Expand Up @@ -535,7 +551,7 @@ STATIC_INLINE jl_gc_tracked_buffer_t *jl_gc_alloc_buf(jl_ptls_t ptls, size_t sz)
// introspect the object to update the a->data field. To avoid doing that and
// making scan_object much more complex we simply enforce that both owner and
// buffers are always pinned
mmtk_pin_object(buf);
PTR_PIN(buf);
return buf;
}

Expand Down