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

Add an build-time flag to transitively pin roots #60

Merged
merged 8 commits into from
Jul 24, 2024
Merged
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
13 changes: 13 additions & 0 deletions Make.inc
Original file line number Diff line number Diff line change
Expand Up @@ -747,22 +747,27 @@ JCFLAGS += -DGC_FIXED_HEAP
endif

ifeq ($(WITH_MMTK), 1)

ifeq (${MMTK_JULIA_DIR},)
$(error MMTK_JULIA_DIR must be set to use MMTk)
endif

JCXXFLAGS += -DMMTK_GC
JCFLAGS += -DMMTK_GC

ifeq (${MMTK_BUILD},)
ifeq (debug,$(findstring debug,$(MAKECMDGOALS)))
MMTK_BUILD = debug
else
MMTK_BUILD = release
endif
endif

ifeq (${MMTK_PLAN},Immix)
JCXXFLAGS += -DMMTK_PLAN_IMMIX
JCFLAGS += -DMMTK_PLAN_IMMIX
endif

ifeq (${MMTK_PLAN},StickyImmix)
JCXXFLAGS += -DMMTK_PLAN_STICKYIMMIX
JCFLAGS += -DMMTK_PLAN_STICKYIMMIX
Expand All @@ -774,15 +779,23 @@ endif
MMTK_DIR = ${MMTK_JULIA_DIR}/mmtk
MMTK_API_INC = $(MMTK_DIR)/api
MMTK_JULIA_INC = ${MMTK_JULIA_DIR}/julia

ifeq ($(OS),Linux)
MMTK_LIB_NAME := libmmtk_julia.so
else
$(error "Unsupported OS for MMTk")
endif

MMTK_LIB_SRC := $(MMTK_DIR)/target/$(MMTK_BUILD)/$(MMTK_LIB_NAME)
MMTK_LIB_DST := $(BUILDROOT)/usr/lib/$(MMTK_LIB_NAME)
MMTK_LIB := -lmmtk_julia
LDFLAGS += -Wl,-rpath=$(BUILDROOT)/usr/lib/ -L$(BUILDROOT)/usr/lib/

ifeq (${MMTK_TPIN_ROOTS}, 1)
JCXXFLAGS += -DMMTK_TPIN_ROOTS
JCFLAGS += -DMMTK_TPIN_ROOTS
endif

else
MMTK_JULIA_INC :=
MMTK_LIB :=
Expand Down
4 changes: 4 additions & 0 deletions src/interpreter.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ extern void JL_GC_ENABLEFRAME(interpreter_state*) JL_NOTSAFEPOINT;
#else

#ifdef MMTK_GC
#ifdef MMTK_TPIN_ROOTS
#define JL_GC_ENCODE_PUSHFRAME(n) ((((size_t)(n))<<3)|2)
#else
#define JL_GC_ENCODE_PUSHFRAME(n) JL_GC_ENCODE_PUSHFRAME_NO_TPIN(n)
#endif
// For roots that are not transitively pinned
#define JL_GC_ENCODE_PUSHFRAME_NO_TPIN(n) ((((size_t)(n))<<3)|6)
#else
Expand Down
9 changes: 8 additions & 1 deletion src/julia.h
Original file line number Diff line number Diff line change
Expand Up @@ -885,13 +885,20 @@ struct _jl_gcframe_t {
// #define JL_GC_ENCODE_PUSH_NO_TPIN(n) ((((size_t)(n))<<3)|5)
// #define JL_GC_ENCODE_PUSHFRAME_NO_TPIN(n) ((((size_t)(n))<<3)|6)

#ifdef MMTK_TPIN_ROOTS
// these are transitively pinning
#define JL_GC_ENCODE_PUSHARGS(n) (((size_t)(n))<<3)
#define JL_GC_ENCODE_PUSH(n) ((((size_t)(n))<<3)|1)

// these only pin the root object itself
#define JL_GC_ENCODE_PUSHARGS_NO_TPIN(n) (((size_t)(n))<<3|4)
#define JL_GC_ENCODE_PUSH_NO_TPIN(n) ((((size_t)(n))<<3)|5)
#else
// No transitive pin
#define JL_GC_ENCODE_PUSHARGS_NO_TPIN(n) (((size_t)(n))<<3|4)
#define JL_GC_ENCODE_PUSH_NO_TPIN(n) ((((size_t)(n))<<3)|5)
#define JL_GC_ENCODE_PUSHARGS(n) JL_GC_ENCODE_PUSHARGS_NO_TPIN(n)
#define JL_GC_ENCODE_PUSH(n) JL_GC_ENCODE_PUSH_NO_TPIN(n)
#endif
#endif

#ifdef __clang_gcanalyzer__
Expand Down