From 94d63722a0ea3f1381ec400bae50f27ec76e8c32 Mon Sep 17 00:00:00 2001 From: Luis Eduardo de Souza Amorim Date: Tue, 19 Mar 2024 00:12:03 +0000 Subject: [PATCH 1/4] Adding macros to push roots that are not transitively pinned (only pinned) --- src/interpreter.c | 7 +++++ src/julia.h | 77 ++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 83 insertions(+), 1 deletion(-) diff --git a/src/interpreter.c b/src/interpreter.c index a7bea95a7e762..aaef1dfe7286b 100644 --- a/src/interpreter.c +++ b/src/interpreter.c @@ -51,7 +51,14 @@ extern void JL_GC_ENABLEFRAME(interpreter_state*) JL_NOTSAFEPOINT; #else +#ifdef MMTK_GC +#define JL_GC_ENCODE_PUSHFRAME(n) ((((size_t)(n))<<3)|2) +// For roots that are not transitively pinned +#define JL_GC_ENCODE_PUSHFRAME_RELAXED(n) ((((size_t)(n))<<3)|6) +#else #define JL_GC_ENCODE_PUSHFRAME(n) ((((size_t)(n))<<2)|2) +#define JL_GC_ENCODE_PUSHFRAME_RELAXED(n) JL_GC_ENCODE_PUSHFRAME(n) +#endif #define JL_GC_PUSHFRAME(frame,locals,n) \ JL_CPPALLOCA(frame, sizeof(*frame)+(((n)+3)*sizeof(jl_value_t*))); \ diff --git a/src/julia.h b/src/julia.h index 2961e7997bb7c..f805c41a98a66 100644 --- a/src/julia.h +++ b/src/julia.h @@ -852,9 +852,22 @@ struct _jl_gcframe_t { #define jl_pgcstack (jl_current_task->gcstack) +#ifndef MMTK_GC #define JL_GC_ENCODE_PUSHARGS(n) (((size_t)(n))<<2) #define JL_GC_ENCODE_PUSH(n) ((((size_t)(n))<<2)|1) +#define JL_GC_ENCODE_PUSHARGS_RELAXED(n) JL_GC_ENCODE_PUSHARGS(n) +#define JL_GC_ENCODE_PUSH_RELAXED(n) JL_GC_ENCODE_PUSH_RELAXED(n) +#else +// 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_RELAXED(n) (((size_t)(n))<<3|4) +#define JL_GC_ENCODE_PUSH_RELAXED(n) ((((size_t)(n))<<3)|5) +#endif + #ifdef __clang_gcanalyzer__ // When running with the analyzer make these real function calls, that are @@ -905,11 +918,11 @@ extern void JL_GC_POP() JL_NOTSAFEPOINT; #define JL_GC_PUSH7(arg1, arg2, arg3, arg4, arg5, arg6, arg7) \ void *__gc_stkf[] = {(void*)JL_GC_ENCODE_PUSH(7), jl_pgcstack, arg1, arg2, arg3, arg4, arg5, arg6, arg7}; \ jl_pgcstack = (jl_gcframe_t*)__gc_stkf; + #define JL_GC_PUSH8(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) \ void *__gc_stkf[] = {(void*)JL_GC_ENCODE_PUSH(8), jl_pgcstack, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8}; \ jl_pgcstack = (jl_gcframe_t*)__gc_stkf; - #define JL_GC_PUSHARGS(rts_var,n) \ rts_var = ((jl_value_t**)alloca(((n)+2)*sizeof(jl_value_t*)))+2; \ ((void**)rts_var)[-2] = (void*)JL_GC_ENCODE_PUSHARGS(n); \ @@ -921,6 +934,68 @@ extern void JL_GC_POP() JL_NOTSAFEPOINT; #endif +#ifdef MMTK_GC +// these are pinning roots: only the root object needs to be pinned as opposed to +// the functions above which are transitively pinning +#define JL_GC_PUSH1_RELAXED(arg1) \ + void *__gc_stkf[] = {(void*)JL_GC_ENCODE_PUSH_RELAXED(1), jl_pgcstack, arg1}; \ + jl_pgcstack = (jl_gcframe_t*)__gc_stkf; + +#define JL_GC_PUSH2_RELAXED(arg1, arg2) \ + void *__gc_stkf[] = {(void*)JL_GC_ENCODE_PUSH_RELAXED(2), jl_pgcstack, arg1, arg2}; \ + jl_pgcstack = (jl_gcframe_t*)__gc_stkf; + +#define JL_GC_PUSH3_RELAXED(arg1, arg2, arg3) \ + void *__gc_stkf[] = {(void*)JL_GC_ENCODE_PUSH_RELAXED(3), jl_pgcstack, arg1, arg2, arg3}; \ + jl_pgcstack = (jl_gcframe_t*)__gc_stkf; + +#define JL_GC_PUSH4_RELAXED(arg1, arg2, arg3, arg4) \ + void *__gc_stkf[] = {(void*)JL_GC_ENCODE_PUSH_RELAXED(4), jl_pgcstack, arg1, arg2, arg3, arg4}; \ + jl_pgcstack = (jl_gcframe_t*)__gc_stkf; + +#define JL_GC_PUSH5_RELAXED(arg1, arg2, arg3, arg4, arg5) \ + void *__gc_stkf[] = {(void*)JL_GC_ENCODE_PUSH_RELAXED(5), jl_pgcstack, arg1, arg2, arg3, arg4, arg5}; \ + jl_pgcstack = (jl_gcframe_t*)__gc_stkf; + +#define JL_GC_PUSH6_RELAXED(arg1, arg2, arg3, arg4, arg5, arg6) \ + void *__gc_stkf[] = {(void*)JL_GC_ENCODE_PUSH_RELAXED(6), jl_pgcstack, arg1, arg2, arg3, arg4, arg5, arg6}; \ + jl_pgcstack = (jl_gcframe_t*)__gc_stkf; + +#define JL_GC_PUSH7_RELAXED(arg1, arg2, arg3, arg4, arg5, arg6, arg7) \ + void *__gc_stkf[] = {(void*)JL_GC_ENCODE_PUSH_RELAXED(7), jl_pgcstack, arg1, arg2, arg3, arg4, arg5, arg6, arg7}; \ + jl_pgcstack = (jl_gcframe_t*)__gc_stkf; + +#define JL_GC_PUSH8_RELAXED(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) \ + void *__gc_stkf[] = {(void*)JL_GC_ENCODE_PUSH_RELAXED(8), jl_pgcstack, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8}; \ + jl_pgcstack = (jl_gcframe_t*)__gc_stkf; + +#define JL_GC_PUSHARGS_RELAXED(rts_var,n) \ + rts_var = ((jl_value_t**)alloca(((n)+2)*sizeof(jl_value_t*)))+2; \ + ((void**)rts_var)[-2] = (void*)JL_GC_ENCODE_PUSHARGS_RELAXED(n); \ + ((void**)rts_var)[-1] = jl_pgcstack; \ + memset((void*)rts_var, 0, (n)*sizeof(jl_value_t*)); \ + jl_pgcstack = (jl_gcframe_t*)&(((void**)rts_var)[-2]) +#else +// When not using MMTk, default to the stock functions +#define JL_GC_PUSH1_RELAXED(arg1) JL_GC_PUSH1(arg1) + +#define JL_GC_PUSH2_RELAXED(arg1, arg2) JL_GC_PUSH2(arg1, arg2) + +#define JL_GC_PUSH3_RELAXED(arg1, arg2, arg3) JL_GC_PUSH3(arg1, arg2, arg3) + +#define JL_GC_PUSH4_RELAXED(arg1, arg2, arg3, arg4) JL_GC_PUSH4(arg1, arg2, arg3, arg4) + +#define JL_GC_PUSH5_RELAXED(arg1, arg2, arg3, arg4, arg5) JL_GC_PUSH5(arg1, arg2, arg3, arg4, arg5) + +#define JL_GC_PUSH6_RELAXED(arg1, arg2, arg3, arg4, arg5, arg6) JL_GC_PUSH6(arg1, arg2, arg3, arg4, arg5, arg6) + +#define JL_GC_PUSH7_RELAXED(arg1, arg2, arg3, arg4, arg5, arg6, arg7) JL_GC_PUSH7(arg1, arg2, arg3, arg4, arg5, arg6, arg7) + +#define JL_GC_PUSH8_RELAXED(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) JL_GC_PUSH8(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) + +#define JL_GC_PUSHARGS_RELAXED(rts_var,n) JL_GC_PUSHARGS(rts_var,n) +#endif + JL_DLLEXPORT int jl_gc_enable(int on); JL_DLLEXPORT int jl_gc_is_enabled(void); From 9a8d8ec4bc65697da3401602dc5e165c1d6227ae Mon Sep 17 00:00:00 2001 From: Luis Eduardo de Souza Amorim Date: Tue, 19 Mar 2024 01:22:25 +0000 Subject: [PATCH 2/4] Renaming _RELAXED => _NO_TPIN --- src/interpreter.c | 4 +-- src/julia.h | 62 +++++++++++++++++++++++------------------------ 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/src/interpreter.c b/src/interpreter.c index aaef1dfe7286b..76416d379de88 100644 --- a/src/interpreter.c +++ b/src/interpreter.c @@ -54,10 +54,10 @@ extern void JL_GC_ENABLEFRAME(interpreter_state*) JL_NOTSAFEPOINT; #ifdef MMTK_GC #define JL_GC_ENCODE_PUSHFRAME(n) ((((size_t)(n))<<3)|2) // For roots that are not transitively pinned -#define JL_GC_ENCODE_PUSHFRAME_RELAXED(n) ((((size_t)(n))<<3)|6) +#define JL_GC_ENCODE_PUSHFRAME_NO_TPIN(n) ((((size_t)(n))<<3)|6) #else #define JL_GC_ENCODE_PUSHFRAME(n) ((((size_t)(n))<<2)|2) -#define JL_GC_ENCODE_PUSHFRAME_RELAXED(n) JL_GC_ENCODE_PUSHFRAME(n) +#define JL_GC_ENCODE_PUSHFRAME_NO_TPIN(n) JL_GC_ENCODE_PUSHFRAME(n) #endif #define JL_GC_PUSHFRAME(frame,locals,n) \ diff --git a/src/julia.h b/src/julia.h index f805c41a98a66..62ac19217e56a 100644 --- a/src/julia.h +++ b/src/julia.h @@ -856,16 +856,16 @@ struct _jl_gcframe_t { #define JL_GC_ENCODE_PUSHARGS(n) (((size_t)(n))<<2) #define JL_GC_ENCODE_PUSH(n) ((((size_t)(n))<<2)|1) -#define JL_GC_ENCODE_PUSHARGS_RELAXED(n) JL_GC_ENCODE_PUSHARGS(n) -#define JL_GC_ENCODE_PUSH_RELAXED(n) JL_GC_ENCODE_PUSH_RELAXED(n) +#define JL_GC_ENCODE_PUSHARGS_NO_TPIN(n) JL_GC_ENCODE_PUSHARGS(n) +#define JL_GC_ENCODE_PUSH_NO_TPIN(n) JL_GC_ENCODE_PUSH(n) #else // 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_RELAXED(n) (((size_t)(n))<<3|4) -#define JL_GC_ENCODE_PUSH_RELAXED(n) ((((size_t)(n))<<3)|5) +#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) #endif #ifdef __clang_gcanalyzer__ @@ -937,63 +937,63 @@ extern void JL_GC_POP() JL_NOTSAFEPOINT; #ifdef MMTK_GC // these are pinning roots: only the root object needs to be pinned as opposed to // the functions above which are transitively pinning -#define JL_GC_PUSH1_RELAXED(arg1) \ - void *__gc_stkf[] = {(void*)JL_GC_ENCODE_PUSH_RELAXED(1), jl_pgcstack, arg1}; \ +#define JL_GC_PUSH1_NO_TPIN(arg1) \ + void *__gc_stkf[] = {(void*)JL_GC_ENCODE_PUSH_NO_TPIN(1), jl_pgcstack, arg1}; \ jl_pgcstack = (jl_gcframe_t*)__gc_stkf; -#define JL_GC_PUSH2_RELAXED(arg1, arg2) \ - void *__gc_stkf[] = {(void*)JL_GC_ENCODE_PUSH_RELAXED(2), jl_pgcstack, arg1, arg2}; \ +#define JL_GC_PUSH2_NO_TPIN(arg1, arg2) \ + void *__gc_stkf[] = {(void*)JL_GC_ENCODE_PUSH_NO_TPIN(2), jl_pgcstack, arg1, arg2}; \ jl_pgcstack = (jl_gcframe_t*)__gc_stkf; -#define JL_GC_PUSH3_RELAXED(arg1, arg2, arg3) \ - void *__gc_stkf[] = {(void*)JL_GC_ENCODE_PUSH_RELAXED(3), jl_pgcstack, arg1, arg2, arg3}; \ +#define JL_GC_PUSH3_NO_TPIN(arg1, arg2, arg3) \ + void *__gc_stkf[] = {(void*)JL_GC_ENCODE_PUSH_NO_TPIN(3), jl_pgcstack, arg1, arg2, arg3}; \ jl_pgcstack = (jl_gcframe_t*)__gc_stkf; -#define JL_GC_PUSH4_RELAXED(arg1, arg2, arg3, arg4) \ - void *__gc_stkf[] = {(void*)JL_GC_ENCODE_PUSH_RELAXED(4), jl_pgcstack, arg1, arg2, arg3, arg4}; \ +#define JL_GC_PUSH4_NO_TPIN(arg1, arg2, arg3, arg4) \ + void *__gc_stkf[] = {(void*)JL_GC_ENCODE_PUSH_NO_TPIN(4), jl_pgcstack, arg1, arg2, arg3, arg4}; \ jl_pgcstack = (jl_gcframe_t*)__gc_stkf; -#define JL_GC_PUSH5_RELAXED(arg1, arg2, arg3, arg4, arg5) \ - void *__gc_stkf[] = {(void*)JL_GC_ENCODE_PUSH_RELAXED(5), jl_pgcstack, arg1, arg2, arg3, arg4, arg5}; \ +#define JL_GC_PUSH5_NO_TPIN(arg1, arg2, arg3, arg4, arg5) \ + void *__gc_stkf[] = {(void*)JL_GC_ENCODE_PUSH_NO_TPIN(5), jl_pgcstack, arg1, arg2, arg3, arg4, arg5}; \ jl_pgcstack = (jl_gcframe_t*)__gc_stkf; -#define JL_GC_PUSH6_RELAXED(arg1, arg2, arg3, arg4, arg5, arg6) \ - void *__gc_stkf[] = {(void*)JL_GC_ENCODE_PUSH_RELAXED(6), jl_pgcstack, arg1, arg2, arg3, arg4, arg5, arg6}; \ +#define JL_GC_PUSH6_NO_TPIN(arg1, arg2, arg3, arg4, arg5, arg6) \ + void *__gc_stkf[] = {(void*)JL_GC_ENCODE_PUSH_NO_TPIN(6), jl_pgcstack, arg1, arg2, arg3, arg4, arg5, arg6}; \ jl_pgcstack = (jl_gcframe_t*)__gc_stkf; -#define JL_GC_PUSH7_RELAXED(arg1, arg2, arg3, arg4, arg5, arg6, arg7) \ - void *__gc_stkf[] = {(void*)JL_GC_ENCODE_PUSH_RELAXED(7), jl_pgcstack, arg1, arg2, arg3, arg4, arg5, arg6, arg7}; \ +#define JL_GC_PUSH7_NO_TPIN(arg1, arg2, arg3, arg4, arg5, arg6, arg7) \ + void *__gc_stkf[] = {(void*)JL_GC_ENCODE_PUSH_NO_TPIN(7), jl_pgcstack, arg1, arg2, arg3, arg4, arg5, arg6, arg7}; \ jl_pgcstack = (jl_gcframe_t*)__gc_stkf; -#define JL_GC_PUSH8_RELAXED(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) \ - void *__gc_stkf[] = {(void*)JL_GC_ENCODE_PUSH_RELAXED(8), jl_pgcstack, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8}; \ +#define JL_GC_PUSH8_NO_TPIN(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) \ + void *__gc_stkf[] = {(void*)JL_GC_ENCODE_PUSH_NO_TPIN(8), jl_pgcstack, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8}; \ jl_pgcstack = (jl_gcframe_t*)__gc_stkf; -#define JL_GC_PUSHARGS_RELAXED(rts_var,n) \ +#define JL_GC_PUSHARGS_NO_TPIN(rts_var,n) \ rts_var = ((jl_value_t**)alloca(((n)+2)*sizeof(jl_value_t*)))+2; \ - ((void**)rts_var)[-2] = (void*)JL_GC_ENCODE_PUSHARGS_RELAXED(n); \ + ((void**)rts_var)[-2] = (void*)JL_GC_ENCODE_PUSHARGS_NO_TPIN(n); \ ((void**)rts_var)[-1] = jl_pgcstack; \ memset((void*)rts_var, 0, (n)*sizeof(jl_value_t*)); \ jl_pgcstack = (jl_gcframe_t*)&(((void**)rts_var)[-2]) #else // When not using MMTk, default to the stock functions -#define JL_GC_PUSH1_RELAXED(arg1) JL_GC_PUSH1(arg1) +#define JL_GC_PUSH1_NO_TPIN(arg1) JL_GC_PUSH1(arg1) -#define JL_GC_PUSH2_RELAXED(arg1, arg2) JL_GC_PUSH2(arg1, arg2) +#define JL_GC_PUSH2_NO_TPIN(arg1, arg2) JL_GC_PUSH2(arg1, arg2) -#define JL_GC_PUSH3_RELAXED(arg1, arg2, arg3) JL_GC_PUSH3(arg1, arg2, arg3) +#define JL_GC_PUSH3_NO_TPIN(arg1, arg2, arg3) JL_GC_PUSH3(arg1, arg2, arg3) -#define JL_GC_PUSH4_RELAXED(arg1, arg2, arg3, arg4) JL_GC_PUSH4(arg1, arg2, arg3, arg4) +#define JL_GC_PUSH4_NO_TPIN(arg1, arg2, arg3, arg4) JL_GC_PUSH4(arg1, arg2, arg3, arg4) -#define JL_GC_PUSH5_RELAXED(arg1, arg2, arg3, arg4, arg5) JL_GC_PUSH5(arg1, arg2, arg3, arg4, arg5) +#define JL_GC_PUSH5_NO_TPIN(arg1, arg2, arg3, arg4, arg5) JL_GC_PUSH5(arg1, arg2, arg3, arg4, arg5) -#define JL_GC_PUSH6_RELAXED(arg1, arg2, arg3, arg4, arg5, arg6) JL_GC_PUSH6(arg1, arg2, arg3, arg4, arg5, arg6) +#define JL_GC_PUSH6_NO_TPIN(arg1, arg2, arg3, arg4, arg5, arg6) JL_GC_PUSH6(arg1, arg2, arg3, arg4, arg5, arg6) -#define JL_GC_PUSH7_RELAXED(arg1, arg2, arg3, arg4, arg5, arg6, arg7) JL_GC_PUSH7(arg1, arg2, arg3, arg4, arg5, arg6, arg7) +#define JL_GC_PUSH7_NO_TPIN(arg1, arg2, arg3, arg4, arg5, arg6, arg7) JL_GC_PUSH7(arg1, arg2, arg3, arg4, arg5, arg6, arg7) -#define JL_GC_PUSH8_RELAXED(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) JL_GC_PUSH8(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) +#define JL_GC_PUSH8_NO_TPIN(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) JL_GC_PUSH8(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) -#define JL_GC_PUSHARGS_RELAXED(rts_var,n) JL_GC_PUSHARGS(rts_var,n) +#define JL_GC_PUSHARGS_NO_TPIN(rts_var,n) JL_GC_PUSHARGS(rts_var,n) #endif JL_DLLEXPORT int jl_gc_enable(int on); From 5f2b75e93742646cd74ff502624652e56336e2da Mon Sep 17 00:00:00 2001 From: Luis Eduardo de Souza Amorim Date: Tue, 19 Mar 2024 03:18:44 +0000 Subject: [PATCH 3/4] Removing whitespace issues --- src/julia.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/julia.h b/src/julia.h index 62ac19217e56a..541fa7e7a4adb 100644 --- a/src/julia.h +++ b/src/julia.h @@ -977,19 +977,19 @@ extern void JL_GC_POP() JL_NOTSAFEPOINT; jl_pgcstack = (jl_gcframe_t*)&(((void**)rts_var)[-2]) #else // When not using MMTk, default to the stock functions -#define JL_GC_PUSH1_NO_TPIN(arg1) JL_GC_PUSH1(arg1) +#define JL_GC_PUSH1_NO_TPIN(arg1) JL_GC_PUSH1(arg1) #define JL_GC_PUSH2_NO_TPIN(arg1, arg2) JL_GC_PUSH2(arg1, arg2) -#define JL_GC_PUSH3_NO_TPIN(arg1, arg2, arg3) JL_GC_PUSH3(arg1, arg2, arg3) +#define JL_GC_PUSH3_NO_TPIN(arg1, arg2, arg3) JL_GC_PUSH3(arg1, arg2, arg3) #define JL_GC_PUSH4_NO_TPIN(arg1, arg2, arg3, arg4) JL_GC_PUSH4(arg1, arg2, arg3, arg4) #define JL_GC_PUSH5_NO_TPIN(arg1, arg2, arg3, arg4, arg5) JL_GC_PUSH5(arg1, arg2, arg3, arg4, arg5) -#define JL_GC_PUSH6_NO_TPIN(arg1, arg2, arg3, arg4, arg5, arg6) JL_GC_PUSH6(arg1, arg2, arg3, arg4, arg5, arg6) +#define JL_GC_PUSH6_NO_TPIN(arg1, arg2, arg3, arg4, arg5, arg6) JL_GC_PUSH6(arg1, arg2, arg3, arg4, arg5, arg6) -#define JL_GC_PUSH7_NO_TPIN(arg1, arg2, arg3, arg4, arg5, arg6, arg7) JL_GC_PUSH7(arg1, arg2, arg3, arg4, arg5, arg6, arg7) +#define JL_GC_PUSH7_NO_TPIN(arg1, arg2, arg3, arg4, arg5, arg6, arg7) JL_GC_PUSH7(arg1, arg2, arg3, arg4, arg5, arg6, arg7) #define JL_GC_PUSH8_NO_TPIN(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) JL_GC_PUSH8(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) From e5e0bdcf8c63e6cd6cfa7e08acdcaffa66896593 Mon Sep 17 00:00:00 2001 From: Luis Eduardo de Souza Amorim Date: Wed, 24 Apr 2024 02:16:15 +0000 Subject: [PATCH 4/4] Adding comment that explains how to push roots on the shadow stack that are/are not transitively pinning --- src/julia.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/julia.h b/src/julia.h index 541fa7e7a4adb..404a26ea453c8 100644 --- a/src/julia.h +++ b/src/julia.h @@ -859,6 +859,24 @@ struct _jl_gcframe_t { #define JL_GC_ENCODE_PUSHARGS_NO_TPIN(n) JL_GC_ENCODE_PUSHARGS(n) #define JL_GC_ENCODE_PUSH_NO_TPIN(n) JL_GC_ENCODE_PUSH(n) #else + +// We use an extra bit (100) in the nroots value from the frame to indicate that the roots +// in the frame are/are not transitively pinning. +// There are currently 3 macros that encode passing nroots to the gcframe +// and they use the two lowest bits to encode information about what is in the frame (as below). +// To support the distinction between transtively pinning roots and non transitively pinning roots +// on the stack, we take another bit from nroots to encode information about whether or not to +// transitively pin the roots in the frame. +// +// So the ones that transitively pin look like: +// #define JL_GC_ENCODE_PUSHARGS(n) (((size_t)(n))<<3) +// #define JL_GC_ENCODE_PUSH(n) ((((size_t)(n))<<3)|1) +// #define JL_GC_ENCODE_PUSHFRAME(n) ((((size_t)(n))<<3)|2) +// and the ones that do not look like: +// #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_PUSHFRAME_NO_TPIN(n) ((((size_t)(n))<<3)|6) + // 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)