Skip to content

Commit 014d4f6

Browse files
committed
Adding support for MMTk (non-moving Immix)
1 parent 0d6bd8c commit 014d4f6

22 files changed

+1674
-210
lines changed

Make.inc

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ HAVE_SSP := 0
8080
WITH_GC_VERIFY := 0
8181
WITH_GC_DEBUG_ENV := 0
8282

83+
# Use stock if MMTK_PLAN hasn't been defined
84+
MMTK_PLAN ?= None
85+
8386
# Enable DTrace support
8487
WITH_DTRACE := 0
8588

@@ -833,6 +836,41 @@ JCXXFLAGS += -DGC_DEBUG_ENV
833836
JCFLAGS += -DGC_DEBUG_ENV
834837
endif
835838

839+
ifneq (${MMTK_PLAN},None)
840+
ifeq (${MMTK_JULIA_DIR},)
841+
$(error MMTK_JULIA_DIR must be set to use MMTk)
842+
endif
843+
JCXXFLAGS += -DMMTK_GC
844+
JCFLAGS += -DMMTK_GC
845+
ifeq (${MMTK_BUILD},)
846+
ifeq (debug,$(findstring debug,$(MAKECMDGOALS)))
847+
MMTK_BUILD = debug
848+
else
849+
MMTK_BUILD = release
850+
endif
851+
endif
852+
ifeq (${MMTK_PLAN},Immix)
853+
JCXXFLAGS += -DMMTK_PLAN_IMMIX
854+
JCFLAGS += -DMMTK_PLAN_IMMIX
855+
else
856+
$(error "Unsupported MMTk plan: $(MMTK_PLAN)")
857+
endif
858+
MMTK_DIR = ${MMTK_JULIA_DIR}/mmtk
859+
MMTK_API_INC = $(MMTK_DIR)/api
860+
ifeq ($(OS),Linux)
861+
MMTK_LIB_NAME := libmmtk_julia.so
862+
else
863+
$(error "Unsupported OS for MMTk")
864+
endif
865+
MMTK_LIB_SRC := $(MMTK_DIR)/target/$(MMTK_BUILD)/$(MMTK_LIB_NAME)
866+
MMTK_LIB_DST := $(BUILDROOT)/usr/lib/$(MMTK_LIB_NAME)
867+
MMTK_LIB := -lmmtk_julia
868+
LDFLAGS += -Wl,-rpath=$(MMTK_DIR)/target/$(MMTK_BUILD)/
869+
else
870+
MMTK_JULIA_INC :=
871+
MMTK_LIB :=
872+
endif
873+
836874
ifeq ($(WITH_DTRACE), 1)
837875
JCXXFLAGS += -DUSE_DTRACE
838876
JCFLAGS += -DUSE_DTRACE
@@ -1827,6 +1865,9 @@ PRINT_PERL = printf ' %b %b\n' $(PERLCOLOR)PERL$(ENDCOLOR) $(BINCOLOR)$(GOAL)
18271865
PRINT_FLISP = printf ' %b %b\n' $(FLISPCOLOR)FLISP$(ENDCOLOR) $(BINCOLOR)$(GOAL)$(ENDCOLOR); $(1)
18281866
PRINT_JULIA = printf ' %b %b\n' $(JULIACOLOR)JULIA$(ENDCOLOR) $(BINCOLOR)$(GOAL)$(ENDCOLOR); $(1)
18291867
PRINT_DTRACE = printf ' %b %b\n' $(DTRACECOLOR)DTRACE$(ENDCOLOR) $(BINCOLOR)$(GOAL)$(ENDCOLOR); $(1)
1868+
ifneq (${MMTK_PLAN},None)
1869+
PRINT_MMTK = printf ' %b %b\n' $(LINKCOLOR)MMTK$(ENDCOLOR) $(BINCOLOR)$(GOAL)$(ENDCOLOR); $(1)
1870+
endif
18301871

18311872
else
18321873
QUIET_MAKE =
@@ -1837,6 +1878,9 @@ PRINT_PERL = echo '$(subst ','\'',$(1))'; $(1)
18371878
PRINT_FLISP = echo '$(subst ','\'',$(1))'; $(1)
18381879
PRINT_JULIA = echo '$(subst ','\'',$(1))'; $(1)
18391880
PRINT_DTRACE = echo '$(subst ','\'',$(1))'; $(1)
1881+
ifneq (${MMTK_PLAN},None)
1882+
PRINT_MMTK = echo '$(subst ','\'',$(1))'; $(1)
1883+
endif
18401884

18411885
endif # VERBOSE
18421886

base/timing.jl

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,14 @@ function gc_page_utilization_data()
106106
return Base.unsafe_wrap(Array, page_utilization_raw, JL_GC_N_MAX_POOLS, own=false)
107107
end
108108

109+
110+
const USING_STOCK_GC = occursin("stock", unsafe_string(ccall(:jl_gc_active_impl, Ptr{UInt8}, ())))
111+
# Full sweep reasons are currently only available for the stock GC
112+
@static if USING_STOCK_GC
109113
# must be kept in sync with `src/gc-stock.h``
110114
const FULL_SWEEP_REASONS = [:FULL_SWEEP_REASON_SWEEP_ALWAYS_FULL, :FULL_SWEEP_REASON_FORCED_FULL_SWEEP,
111115
:FULL_SWEEP_REASON_USER_MAX_EXCEEDED, :FULL_SWEEP_REASON_LARGE_PROMOTION_RATE]
116+
end
112117

113118
"""
114119
Base.full_sweep_reasons()
@@ -124,11 +129,15 @@ The reasons are:
124129
Note that the set of reasons is not guaranteed to be stable across minor versions of Julia.
125130
"""
126131
function full_sweep_reasons()
127-
reason = cglobal(:jl_full_sweep_reasons, UInt64)
128-
reasons_as_array = Base.unsafe_wrap(Vector{UInt64}, reason, length(FULL_SWEEP_REASONS), own=false)
129132
d = Dict{Symbol, Int64}()
130-
for (i, r) in enumerate(FULL_SWEEP_REASONS)
131-
d[r] = reasons_as_array[i]
133+
# populate the dictionary according to the reasons above for the stock GC
134+
# otherwise return an empty dictionary for now
135+
@static if USING_STOCK_GC
136+
reason = cglobal(:jl_full_sweep_reasons, UInt64)
137+
reasons_as_array = Base.unsafe_wrap(Vector{UInt64}, reason, length(FULL_SWEEP_REASONS), own=false)
138+
for (i, r) in enumerate(FULL_SWEEP_REASONS)
139+
d[r] = reasons_as_array[i]
140+
end
132141
end
133142
return d
134143
end

src/Makefile

Lines changed: 45 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ ifeq ($(USECLANG),1)
2929
FLAGS += -Wno-return-type-c-linkage -Wno-atomic-alignment
3030
endif
3131

32+
ifeq ($(WITH_MMTK), 1)
33+
FLAGS += -I$(MMTK_API_INC)
34+
endif
35+
3236
FLAGS += -DJL_BUILD_ARCH='"$(ARCH)"'
3337
ifeq ($(OS),WINNT)
3438
FLAGS += -DJL_BUILD_UNAME='"NT"'
@@ -40,23 +44,41 @@ ifeq ($(OS),FreeBSD)
4044
FLAGS += -I$(LOCALBASE)/include
4145
endif
4246

47+
# GC source code. It depends on which GC implementation to use.
48+
GC_SRCS := gc-common gc-stacks gc-alloc-profiler gc-heap-snapshot
49+
ifneq (${MMTK_PLAN},None)
50+
GC_SRCS += gc-mmtk
51+
else
52+
GC_SRCS += gc-stock gc-debug gc-pages gc-page-profiler
53+
endif
54+
4355
SRCS := \
4456
jltypes gf typemap smallintset ast builtins module interpreter symbol \
4557
dlload sys init task array genericmemory staticdata toplevel jl_uv datatype \
4658
simplevector runtime_intrinsics precompile jloptions mtarraylist \
47-
threading scheduler stackwalk gc-common gc-stock gc-debug gc-pages gc-stacks gc-alloc-profiler gc-page-profiler method \
48-
jlapi signal-handling safepoint timing subtype rtutils gc-heap-snapshot \
49-
crc32c APInt-C processor ircode opaque_closure codegen-stubs coverage runtime_ccall engine
59+
threading scheduler stackwalk \
60+
method jlapi signal-handling safepoint timing subtype rtutils \
61+
crc32c APInt-C processor ircode opaque_closure codegen-stubs coverage runtime_ccall engine \
62+
$(GC_SRCS)
5063

5164
RT_LLVMLINK :=
5265
CG_LLVMLINK :=
5366

5467
ifeq ($(JULIACODEGEN),LLVM)
68+
# Currently these files are used by both GCs. But we should make the list specific to stock, and MMTk should have its own implementation.
69+
GC_CODEGEN_SRCS := llvm-final-gc-lowering llvm-late-gc-lowering llvm-gc-invariant-verifier
70+
ifneq (${MMTK_PLAN},None)
71+
FLAGS += -I$(MMTK_API_INC)
72+
GC_CODEGEN_SRCS += llvm-late-gc-lowering-mmtk
73+
else
74+
GC_CODEGEN_SRCS += llvm-late-gc-lowering-stock
75+
endif
5576
CODEGEN_SRCS := codegen jitlayers aotcompile debuginfo disasm llvm-simdloop \
56-
llvm-final-gc-lowering llvm-pass-helpers llvm-late-gc-lowering llvm-ptls \
57-
llvm-lower-handlers llvm-gc-invariant-verifier llvm-propagate-addrspaces \
77+
llvm-pass-helpers llvm-ptls \
78+
llvm-lower-handlers llvm-propagate-addrspaces \
5879
llvm-multiversioning llvm-alloc-opt llvm-alloc-helpers cgmemmgr llvm-remove-addrspaces \
59-
llvm-remove-ni llvm-julia-licm llvm-demote-float16 llvm-cpufeatures pipeline llvm_api
80+
llvm-remove-ni llvm-julia-licm llvm-demote-float16 llvm-cpufeatures pipeline llvm_api \
81+
$(GC_CODEGEN_SRCS)
6082
FLAGS += -I$(shell $(LLVM_CONFIG_HOST) --includedir)
6183
CG_LLVM_LIBS := all
6284
ifeq ($(USE_POLLY),1)
@@ -99,7 +121,12 @@ ifeq ($(USE_SYSTEM_LIBUV),0)
99121
UV_HEADERS += uv.h
100122
UV_HEADERS += uv/*.h
101123
endif
102-
PUBLIC_HEADERS := $(BUILDDIR)/julia_version.h $(wildcard $(SRCDIR)/support/*.h) $(addprefix $(SRCDIR)/,work-stealing-queue.h gc-interface.h gc-tls.h gc-tls-common.h julia.h julia_assert.h julia_threads.h julia_fasttls.h julia_locks.h julia_atomics.h jloptions.h)
124+
PUBLIC_HEADERS := $(BUILDDIR)/julia_version.h $(wildcard $(SRCDIR)/support/*.h) $(addprefix $(SRCDIR)/,work-stealing-queue.h gc-interface.h gc-tls-common.h julia.h julia_assert.h julia_threads.h julia_fasttls.h julia_locks.h julia_atomics.h jloptions.h)
125+
ifneq (${MMTK_PLAN},None)
126+
PUBLIC_HEADERS += $(addprefix $(SRCDIR)/,gc-tls-mmtk.h)
127+
else
128+
PUBLIC_HEADERS += $(addprefix $(SRCDIR)/,gc-tls-stock.h)
129+
endif
103130
ifeq ($(OS),WINNT)
104131
PUBLIC_HEADERS += $(addprefix $(SRCDIR)/,win32_ucontext.h)
105132
endif
@@ -164,8 +191,8 @@ LIBJULIA_PATH_REL := libjulia
164191
endif
165192

166193
COMMON_LIBPATHS := -L$(build_libdir) -L$(build_shlibdir)
167-
RT_LIBS := $(WHOLE_ARCHIVE) $(LIBUV) $(WHOLE_ARCHIVE) $(LIBUTF8PROC) $(NO_WHOLE_ARCHIVE) $(LIBUNWIND) $(RT_LLVMLINK) $(OSLIBS) $(LIBTRACYCLIENT) $(LIBITTAPI)
168-
CG_LIBS := $(LIBUNWIND) $(CG_LLVMLINK) $(OSLIBS) $(LIBTRACYCLIENT) $(LIBITTAPI)
194+
RT_LIBS := $(WHOLE_ARCHIVE) $(LIBUV) $(WHOLE_ARCHIVE) $(LIBUTF8PROC) $(NO_WHOLE_ARCHIVE) $(LIBUNWIND) $(RT_LLVMLINK) $(OSLIBS) $(LIBTRACYCLIENT) $(LIBITTAPI) $(MMTK_LIB)
195+
CG_LIBS := $(LIBUNWIND) $(CG_LLVMLINK) $(OSLIBS) $(LIBTRACYCLIENT) $(LIBITTAPI) $(MMTK_LIB)
169196
RT_DEBUG_LIBS := $(COMMON_LIBPATHS) $(WHOLE_ARCHIVE) $(BUILDDIR)/flisp/libflisp-debug.a $(WHOLE_ARCHIVE) $(BUILDDIR)/support/libsupport-debug.a -ljulia-debug $(RT_LIBS)
170197
CG_DEBUG_LIBS := $(COMMON_LIBPATHS) $(CG_LIBS) -ljulia-debug -ljulia-internal-debug
171198
RT_RELEASE_LIBS := $(COMMON_LIBPATHS) $(WHOLE_ARCHIVE) $(BUILDDIR)/flisp/libflisp.a $(WHOLE_ARCHIVE) $(BUILDDIR)/support/libsupport.a -ljulia $(RT_LIBS)
@@ -222,6 +249,12 @@ $(BUILDDIR)/%.h.gen : $(SRCDIR)/%.d
222249
sed 's/JULIA_/JL_PROBE_/' $@ > $@.tmp
223250
mv $@.tmp $@
224251

252+
# Compile files from the binding side and copy so file into lib folder
253+
ifneq (${MMTK_PLAN},None)
254+
$(MMTK_LIB_DST): $(MMTK_LIB_SRC)
255+
@$(call PRINT_MMTK, cp $< $@)
256+
endif
257+
225258
$(BUILDDIR)/jl_internal_funcs.inc: $(SRCDIR)/jl_exported_funcs.inc
226259
# Generate `.inc` file that contains a list of `#define` macros to rename functions defined in `libjulia-internal`
227260
# to have a `ijl_` prefix instead of `jl_`, to denote that they are coming from `libjulia-internal`. This avoids
@@ -314,6 +347,7 @@ $(BUILDDIR)/debuginfo.o $(BUILDDIR)/debuginfo.dbg.obj: $(addprefix $(SRCDIR)/,de
314347
$(BUILDDIR)/disasm.o $(BUILDDIR)/disasm.dbg.obj: $(SRCDIR)/debuginfo.h $(SRCDIR)/processor.h
315348
$(BUILDDIR)/gc-debug.o $(BUILDDIR)/gc-debug.dbg.obj: $(SRCDIR)/gc-common.h $(SRCDIR)/gc-stock.h
316349
$(BUILDDIR)/gc-pages.o $(BUILDDIR)/gc-pages.dbg.obj: $(SRCDIR)/gc-common.h $(SRCDIR)/gc-stock.h
350+
$(BUILDDIR)/gc-mmtk.o $(BUILDDIR)/gc-mmtk.dbg.obj: $(SRCDIR)/gc-common.h $(SRCDIR)/gc-heap-snapshot.h $(SRCDIR)/gc-alloc-profiler.h
317351
$(BUILDDIR)/gc-stacks.o $(BUILDDIR)/gc-stacks.dbg.obj: $(SRCDIR)/gc-common.h $(SRCDIR)/gc-stock.h
318352
$(BUILDDIR)/gc-stock.o $(BUILDDIR)/gc.dbg.obj: $(SRCDIR)/gc-common.h $(SRCDIR)/gc-stock.h $(SRCDIR)/gc-heap-snapshot.h $(SRCDIR)/gc-alloc-profiler.h $(SRCDIR)/gc-page-profiler.h
319353
$(BUILDDIR)/gc-heap-snapshot.o $(BUILDDIR)/gc-heap-snapshot.dbg.obj: $(SRCDIR)/gc-heap-snapshot.h
@@ -386,13 +420,13 @@ $(BUILDDIR)/julia.expmap: $(SRCDIR)/julia.expmap.in $(JULIAHOME)/VERSION $(LLVM_
386420
sed <'$<' >'$@' -e "s/@JULIA_SHLIB_SYMBOL_VERSION@/JL_LIBJULIA_$(SOMAJOR)/" \
387421
-e "s/@LLVM_SHLIB_SYMBOL_VERSION@/$(LLVM_SHLIB_SYMBOL_VERSION)/"
388422

389-
$(build_shlibdir)/libjulia-internal.$(JL_MAJOR_MINOR_SHLIB_EXT): $(BUILDDIR)/julia.expmap $(OBJS) $(BUILDDIR)/flisp/libflisp.a $(BUILDDIR)/support/libsupport.a $(LIBUV)
423+
$(build_shlibdir)/libjulia-internal.$(JL_MAJOR_MINOR_SHLIB_EXT): $(BUILDDIR)/julia.expmap $(OBJS) $(MMTK_LIB_DST) $(BUILDDIR)/flisp/libflisp.a $(BUILDDIR)/support/libsupport.a $(LIBUV)
390424
@$(call PRINT_LINK, $(CXXLD) $(call IMPLIB_FLAGS,$@) $(JCXXFLAGS) $(JL_CXXFLAGS) $(CXXLDFLAGS) $(SHIPFLAGS) $(OBJS) $(RPATH_LIB) -o $@ \
391425
$(JLDFLAGS) $(BOLT_LDFLAGS) $(JLIBLDFLAGS) $(RT_RELEASE_LIBS) $(call SONAME_FLAGS,libjulia-internal.$(JL_MAJOR_SHLIB_EXT)))
392426
@$(INSTALL_NAME_CMD)libjulia-internal.$(SHLIB_EXT) $@
393427
$(DSYMUTIL) $@
394428

395-
$(build_shlibdir)/libjulia-internal-debug.$(JL_MAJOR_MINOR_SHLIB_EXT): $(BUILDDIR)/julia.expmap $(DOBJS) $(BUILDDIR)/flisp/libflisp-debug.a $(BUILDDIR)/support/libsupport-debug.a $(LIBUV)
429+
$(build_shlibdir)/libjulia-internal-debug.$(JL_MAJOR_MINOR_SHLIB_EXT): $(BUILDDIR)/julia.expmap $(DOBJS) $(MMTK_LIB_DST) $(BUILDDIR)/flisp/libflisp-debug.a $(BUILDDIR)/support/libsupport-debug.a $(LIBUV)
396430
@$(call PRINT_LINK, $(CXXLD) $(call IMPLIB_FLAGS,$@) $(JCXXFLAGS) $(JL_CXXFLAGS) $(CXXLDFLAGS) $(DEBUGFLAGS) $(DOBJS) $(RPATH_LIB) -o $@ \
397431
$(JLDFLAGS) $(JLIBLDFLAGS) $(RT_DEBUG_LIBS) $(call SONAME_FLAGS,libjulia-internal-debug.$(JL_MAJOR_SHLIB_EXT)))
398432
@$(INSTALL_NAME_CMD)libjulia-internal-debug.$(SHLIB_EXT) $@

src/gc-common.c

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,38 @@ JL_DLLEXPORT jl_value_t *(jl_gc_alloc)(jl_ptls_t ptls, size_t sz, void *ty)
540540
return jl_gc_alloc_(ptls, sz, ty);
541541
}
542542

543+
JL_DLLEXPORT void *jl_malloc(size_t sz)
544+
{
545+
return jl_gc_counted_malloc(sz);
546+
}
547+
548+
//_unchecked_calloc does not check for potential overflow of nm*sz
549+
STATIC_INLINE void *_unchecked_calloc(size_t nm, size_t sz) {
550+
size_t nmsz = nm*sz;
551+
return jl_gc_counted_calloc(nmsz, 1);
552+
}
553+
554+
JL_DLLEXPORT void *jl_calloc(size_t nm, size_t sz)
555+
{
556+
if (nm > SSIZE_MAX/sz)
557+
return NULL;
558+
return _unchecked_calloc(nm, sz);
559+
}
560+
561+
JL_DLLEXPORT void jl_free(void *p)
562+
{
563+
if (p != NULL) {
564+
size_t sz = memory_block_usable_size(p, 0);
565+
return jl_gc_counted_free_with_size(p, sz);
566+
}
567+
}
568+
569+
JL_DLLEXPORT void *jl_realloc(void *p, size_t sz)
570+
{
571+
size_t old = p ? memory_block_usable_size(p, 0) : 0;
572+
return jl_gc_counted_realloc_with_old_size(p, old, sz);
573+
}
574+
543575
// =========================================================================== //
544576
// Generic Memory
545577
// =========================================================================== //
@@ -668,6 +700,24 @@ JL_DLLEXPORT void jl_throw_out_of_memory_error(void)
668700
jl_throw(jl_memory_exception);
669701
}
670702

703+
// Sweeping mtarraylist_buffers:
704+
// These buffers are made unreachable via `mtarraylist_resizeto` from mtarraylist.c
705+
// and are freed at the end of GC via jl_gc_sweep_stack_pools_and_mtarraylist_buffers
706+
void sweep_mtarraylist_buffers(void) JL_NOTSAFEPOINT
707+
{
708+
for (int i = 0; i < gc_n_threads; i++) {
709+
jl_ptls_t ptls = gc_all_tls_states[i];
710+
if (ptls == NULL) {
711+
continue;
712+
}
713+
small_arraylist_t *buffers = &ptls->lazily_freed_mtarraylist_buffers;
714+
void *buf;
715+
while ((buf = small_arraylist_pop(buffers)) != NULL) {
716+
free(buf);
717+
}
718+
}
719+
}
720+
671721
#ifdef __cplusplus
672722
}
673723
#endif

src/gc-common.h

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,31 @@
2424
extern "C" {
2525
#endif
2626

27+
// =========================================================================== //
28+
// GC Big objects
29+
// =========================================================================== //
30+
31+
JL_EXTENSION typedef struct _bigval_t {
32+
struct _bigval_t *next;
33+
struct _bigval_t *prev;
34+
size_t sz;
35+
#ifdef _P64 // Add padding so that the value is 64-byte aligned
36+
// (8 pointers of 8 bytes each) - (4 other pointers in struct)
37+
void *_padding[8 - 4];
38+
#else
39+
// (16 pointers of 4 bytes each) - (4 other pointers in struct)
40+
void *_padding[16 - 4];
41+
#endif
42+
//struct jl_taggedvalue_t <>;
43+
union {
44+
uintptr_t header;
45+
struct {
46+
uintptr_t gc:2;
47+
} bits;
48+
};
49+
// must be 64-byte aligned here, in 32 & 64 bit modes
50+
} bigval_t;
51+
2752
// =========================================================================== //
2853
// GC Callbacks
2954
// =========================================================================== //
@@ -187,4 +212,14 @@ extern jl_ptls_t* gc_all_tls_states;
187212

188213
extern int gc_logging_enabled;
189214

215+
// =========================================================================== //
216+
// MISC
217+
// =========================================================================== //
218+
219+
// number of stacks to always keep available per pool
220+
#define MIN_STACK_MAPPINGS_PER_POOL 5
221+
222+
void _jl_free_stack(jl_ptls_t ptls, void *stkbuf, size_t bufsz) JL_NOTSAFEPOINT;
223+
void sweep_mtarraylist_buffers(void) JL_NOTSAFEPOINT;
224+
190225
#endif // JL_GC_COMMON_H

src/gc-interface.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,13 @@ JL_DLLEXPORT void jl_gc_set_max_memory(uint64_t max_mem);
9898
JL_DLLEXPORT void jl_gc_collect(jl_gc_collection_t collection);
9999
// Returns whether the thread with `tid` is a collector thread
100100
JL_DLLEXPORT int gc_is_collector_thread(int tid) JL_NOTSAFEPOINT;
101+
// Returns which GC implementation is being used and possibly its version according to the list of supported GCs
102+
// NB: it should clearly identify the GC by including e.g. ‘stock’ or ‘mmtk’ as a substring.
103+
JL_DLLEXPORT const char* jl_gc_active_impl(void);
104+
// Sweep Julia's stack pools and mtarray buffers. Note that this function has been added to the interface as
105+
// each GC should implement it but it will most likely not be used by other code in the runtime.
106+
// It still needs to be annotated with JL_DLLEXPORT since it is called from Rust by MMTk.
107+
JL_DLLEXPORT void jl_gc_sweep_stack_pools_and_mtarraylist_buffers(jl_ptls_t ptls) JL_NOTSAFEPOINT;
101108

102109
// ========================================================================= //
103110
// Metrics
@@ -138,7 +145,6 @@ JL_DLLEXPORT uint64_t jl_gc_total_hrtime(void);
138145
// **must** also set the type of the returning object to be `ty`. The type `ty` may also be used to record
139146
// an allocation of that type in the allocation profiler.
140147
struct _jl_value_t *jl_gc_alloc_(struct _jl_tls_states_t * ptls, size_t sz, void *ty);
141-
142148
// Allocates small objects and increments Julia allocation counterst. Size of the object
143149
// header must be included in the object size. The (possibly unused in some implementations)
144150
// offset to the arena in which we're allocating is passed in the second parameter, and the
@@ -198,6 +204,10 @@ JL_DLLEXPORT void *jl_gc_perm_alloc(size_t sz, int zero, unsigned align,
198204
// the allocated object. All objects stored in fields of this object
199205
// must be either permanently allocated or have other roots.
200206
struct _jl_value_t *jl_gc_permobj(size_t sz, void *ty) JL_NOTSAFEPOINT;
207+
// This function notifies the GC about memory addresses that are set when loading the boot image.
208+
// The GC may use that information to, for instance, determine that such objects should
209+
// be treated as marked and belonged to the old generation in nursery collections.
210+
void jl_gc_notify_image_load(const char* img_data, size_t len);
201211

202212
// ========================================================================= //
203213
// Runtime Write-Barriers

0 commit comments

Comments
 (0)