From b5e7a9ddc28c145a025c38b41bc9492f4ad534e8 Mon Sep 17 00:00:00 2001 From: Eduardo Souza Date: Tue, 10 Dec 2024 04:51:49 +0000 Subject: [PATCH] Pin pointer literals in literal_pointer_val and Julia pointers in julia_to_scm --- src/ast.c | 1 + src/cgutils.cpp | 1 + src/jitlayers.h | 1 + src/julia.h | 2 ++ 4 files changed, 5 insertions(+) diff --git a/src/ast.c b/src/ast.c index 474c0661f5230..3d8a56c85600a 100644 --- a/src/ast.c +++ b/src/ast.c @@ -815,6 +815,7 @@ static value_t julia_to_list2_noalloc(fl_context_t *fl_ctx, jl_value_t *a, jl_va static value_t julia_to_scm_(fl_context_t *fl_ctx, jl_value_t *v, int check_valid) { + PTR_PIN(v); value_t retval; if (julia_to_scm_noalloc1(fl_ctx, v, &retval)) return retval; diff --git a/src/cgutils.cpp b/src/cgutils.cpp index 7d4bd917eff30..c81886d936e64 100644 --- a/src/cgutils.cpp +++ b/src/cgutils.cpp @@ -578,6 +578,7 @@ static Value *literal_pointer_val(jl_codectx_t &ctx, jl_value_t *p) { if (p == NULL) return Constant::getNullValue(ctx.types().T_pjlvalue); + PTR_PIN(p); Value *pgv = literal_pointer_val_slot(ctx, p); jl_aliasinfo_t ai = jl_aliasinfo_t::fromTBAA(ctx, ctx.tbaa().tbaa_const); auto load = ai.decorateInst(maybe_mark_load_dereferenceable( diff --git a/src/jitlayers.h b/src/jitlayers.h index baba5412226e3..f18ee2d0af98e 100644 --- a/src/jitlayers.h +++ b/src/jitlayers.h @@ -308,6 +308,7 @@ void add_named_global(StringRef name, void *addr) JL_NOTSAFEPOINT; static inline Constant *literal_static_pointer_val(const void *p, Type *T) JL_NOTSAFEPOINT { + PTR_PIN((void*)p); // this function will emit a static pointer into the generated code // the generated code will only be valid during the current session, // and thus, this should typically be avoided in new API's diff --git a/src/julia.h b/src/julia.h index 71bef19ed450b..6e8ff6fda91c7 100644 --- a/src/julia.h +++ b/src/julia.h @@ -2755,6 +2755,8 @@ extern void mmtk_object_reference_write_slow(void* mutator, const void* parent, #define MMTK_IMMORTAL_BUMP_ALLOCATOR (0) // VO bit is required to support conservative stack scanning and moving. +// NB: We have to set VO bit even if this is a non_moving build. Otherwise, assertions in mmtk-core +// will complain about seeing objects without VO bit. #define MMTK_NEEDS_VO_BIT (1) void mmtk_immortal_post_alloc_fast(MMTkMutatorContext* mutator, void* obj, size_t size);