From 217fe9aaa7d6e4c8a6cf7b39071a42439b68eeee Mon Sep 17 00:00:00 2001 From: Eduardo Souza Date: Wed, 18 Dec 2024 16:40:04 +1100 Subject: [PATCH] Pin pointer literals in literal_pointer_val and Julia pointers in julia_to_scm (#80) Backporting https://github.com/mmtk/julia/pull/63 to `dev`. Co-authored-by: Yi Lin --- src/ast.c | 1 + src/cgutils.cpp | 1 + src/jitlayers.h | 1 + 3 files changed, 3 insertions(+) diff --git a/src/ast.c b/src/ast.c index 0f24d96393f2f..d8af42757ff72 100644 --- a/src/ast.c +++ b/src/ast.c @@ -780,6 +780,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 98c5627578b80..cf8a32e74effa 100644 --- a/src/cgutils.cpp +++ b/src/cgutils.cpp @@ -570,6 +570,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 4637670ec588c..568ad4f0bccd0 100644 --- a/src/jitlayers.h +++ b/src/jitlayers.h @@ -310,6 +310,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