Skip to content

Commit 2d3d545

Browse files
committed
Changes to support moving and sticky Immix
1 parent 989b32b commit 2d3d545

22 files changed

+543
-10
lines changed

.github/workflows/StockBuild.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# This workflow does not exist upstream. DO NOT TRY TO UPSTREAM IT.
2+
# It is just a simple check to ensure that we do not break the stock build.
3+
4+
name: Test stock Julia build
5+
6+
on:
7+
pull_request:
8+
9+
concurrency:
10+
# Cancels pending runs when a PR gets updated.
11+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-22.04
17+
steps:
18+
- uses: actions/checkout@v4
19+
- name: Build
20+
run: |
21+
make

Make.inc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -844,6 +844,9 @@ MMTK_BUILD ?= release
844844
ifeq (${MMTK_PLAN},Immix)
845845
JCXXFLAGS += -DMMTK_PLAN_IMMIX
846846
JCFLAGS += -DMMTK_PLAN_IMMIX
847+
else ifeq (${MMTK_PLAN},StickyImmix)
848+
JCXXFLAGS += -DMMTK_PLAN_STICKYIMMIX
849+
JCFLAGS += -DMMTK_PLAN_STICKYIMMIX
847850
else
848851
$(error "Unsupported MMTk plan: $(MMTK_PLAN)")
849852
endif

src/ast.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -780,6 +780,7 @@ static value_t julia_to_list2_noalloc(fl_context_t *fl_ctx, jl_value_t *a, jl_va
780780

781781
static value_t julia_to_scm_(fl_context_t *fl_ctx, jl_value_t *v, int check_valid)
782782
{
783+
PTR_PIN(v);
783784
value_t retval;
784785
if (julia_to_scm_noalloc1(fl_ctx, v, &retval))
785786
return retval;

src/builtins.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,9 @@ static uintptr_t type_object_id_(jl_value_t *v, jl_varidx_t *env) JL_NOTSAFEPOIN
344344
i++;
345345
pe = pe->prev;
346346
}
347+
// FIXME: Pinning objects that get hashed
348+
// until we implement address space hashing.
349+
PTR_PIN(v);
347350
uintptr_t bits = jl_astaggedvalue(v)->header;
348351
if (bits & GC_IN_IMAGE)
349352
return ((uintptr_t*)v)[-2];
@@ -400,6 +403,10 @@ static uintptr_t immut_id_(jl_datatype_t *dt, jl_value_t *v, uintptr_t h) JL_NOT
400403
// a few select pointers (notably symbol) also have special hash values
401404
// which may affect the stability of the objectid hash, even though
402405
// they don't affect egal comparison
406+
407+
// FIXME: Pinning objects that get hashed
408+
// until we implement address space hashing.
409+
PTR_PIN(v);
403410
return bits_hash(v, sz) ^ h;
404411
}
405412
if (dt == jl_unionall_type)
@@ -460,6 +467,10 @@ static uintptr_t NOINLINE jl_object_id__cold(uintptr_t tv, jl_value_t *v) JL_NOT
460467
uintptr_t bits = jl_astaggedvalue(v)->header;
461468
if (bits & GC_IN_IMAGE)
462469
return ((uintptr_t*)v)[-2];
470+
471+
// FIXME: Pinning objects that get hashed
472+
// until we implement address space hashing.
473+
PTR_PIN(v);
463474
return inthash((uintptr_t)v);
464475
}
465476
return immut_id_(dt, v, dt->hash);

src/cgutils.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,7 @@ static Value *literal_pointer_val(jl_codectx_t &ctx, jl_value_t *p)
570570
{
571571
if (p == NULL)
572572
return Constant::getNullValue(ctx.types().T_pjlvalue);
573+
PTR_PIN(p);
573574
Value *pgv = literal_pointer_val_slot(ctx, p);
574575
jl_aliasinfo_t ai = jl_aliasinfo_t::fromTBAA(ctx, ctx.tbaa().tbaa_const);
575576
auto load = ai.decorateInst(maybe_mark_load_dereferenceable(

src/datatype.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ JL_DLLEXPORT jl_typename_t *jl_new_typename_in(jl_sym_t *name, jl_module_t *modu
6464
jl_typename_t *tn =
6565
(jl_typename_t*)jl_gc_alloc(ct->ptls, sizeof(jl_typename_t),
6666
jl_typename_type);
67+
// Typenames should be pinned since they are used as metadata, and are
68+
// read during scan_object
69+
PTR_PIN(tn);
6770
tn->name = name;
6871
tn->module = module;
6972
tn->wrapper = NULL;
@@ -96,6 +99,9 @@ jl_datatype_t *jl_new_uninitialized_datatype(void)
9699
{
97100
jl_task_t *ct = jl_current_task;
98101
jl_datatype_t *t = (jl_datatype_t*)jl_gc_alloc(ct->ptls, sizeof(jl_datatype_t), jl_datatype_type);
102+
// Types should be pinned since they are used as metadata, and are
103+
// read during scan_object
104+
PTR_PIN(t);
99105
jl_set_typetagof(t, jl_datatype_tag, 0);
100106
t->hash = 0;
101107
t->hasfreetypevars = 0;

src/interpreter.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,14 @@ extern void JL_GC_ENABLEFRAME(interpreter_state*) JL_NOTSAFEPOINT;
5252

5353
#else
5454

55+
#ifdef MMTK_GC
56+
#define JL_GC_ENCODE_PUSHFRAME(n) ((((size_t)(n))<<3)|2)
57+
// For roots that are not transitively pinned
58+
#define JL_GC_ENCODE_PUSHFRAME_NO_TPIN(n) ((((size_t)(n))<<3)|6)
59+
#else
5560
#define JL_GC_ENCODE_PUSHFRAME(n) ((((size_t)(n))<<2)|2)
61+
#define JL_GC_ENCODE_PUSHFRAME_NO_TPIN(n) JL_GC_ENCODE_PUSHFRAME(n)
62+
#endif
5663

5764
#define JL_GC_PUSHFRAME(frame,locals,n) \
5865
JL_CPPALLOCA(frame, sizeof(*frame)+(((n)+3)*sizeof(jl_value_t*))); \

src/ircode.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1661,12 +1661,15 @@ void jl_init_serializer(void)
16611661
assert(LAST_TAG+1+i < 256);
16621662

16631663
for (i = 2; i < 256; i++) {
1664-
if (deser_tag[i])
1664+
if (deser_tag[i]) {
1665+
PTRHASH_PIN(deser_tag[i])
16651666
ptrhash_put(&ser_tag, deser_tag[i], (void*)i);
1667+
}
16661668
}
16671669

16681670
i = 2;
16691671
while (common_symbols[i-2] != NULL) {
1672+
PTRHASH_PIN(common_symbols[i-2])
16701673
ptrhash_put(&common_symbol_tag, common_symbols[i-2], (void*)i);
16711674
deser_symbols[i] = (jl_value_t*)common_symbols[i-2];
16721675
i += 1;

src/jitlayers.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ void add_named_global(StringRef name, void *addr) JL_NOTSAFEPOINT;
310310

311311
static inline Constant *literal_static_pointer_val(const void *p, Type *T) JL_NOTSAFEPOINT
312312
{
313+
PTR_PIN((void*)p);
313314
// this function will emit a static pointer into the generated code
314315
// the generated code will only be valid during the current session,
315316
// and thus, this should typically be avoided in new API's

src/jl_exported_funcs.inc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,10 @@
170170
XX(jl_gc_small_alloc) \
171171
XX(jl_gc_queue_multiroot) \
172172
XX(jl_gc_queue_root) \
173+
XX(jl_gc_wb1_noinline) \
174+
XX(jl_gc_wb2_noinline) \
175+
XX(jl_gc_wb1_slow) \
176+
XX(jl_gc_wb2_slow) \
173177
XX(jl_gc_safepoint) \
174178
XX(jl_gc_schedule_foreign_sweepfunc) \
175179
XX(jl_gc_set_cb_notify_external_alloc) \
@@ -182,6 +186,8 @@
182186
XX(jl_gc_set_max_memory) \
183187
XX(jl_gc_sync_total_bytes) \
184188
XX(jl_gc_total_hrtime) \
189+
XX(jl_gc_preserve_begin_hook) \
190+
XX(jl_gc_preserve_end_hook) \
185191
XX(jl_gdblookup) \
186192
XX(jl_generating_output) \
187193
XX(jl_declare_const_gf) \

0 commit comments

Comments
 (0)