@@ -1053,8 +1053,41 @@ struct _jl_gcframe_t {
10531053
10541054#define jl_pgcstack (jl_current_task->gcstack)
10551055
1056+ #ifndef MMTK_GC
10561057#define JL_GC_ENCODE_PUSHARGS (n ) (((size_t)(n))<<2)
10571058#define JL_GC_ENCODE_PUSH (n ) ((((size_t)(n))<<2)|1)
1059+ #define JL_GC_DECODE_NROOTS (n ) (n >> 2)
1060+
1061+ #define JL_GC_ENCODE_PUSHARGS_NO_TPIN (n ) JL_GC_ENCODE_PUSHARGS(n)
1062+ #define JL_GC_ENCODE_PUSH_NO_TPIN (n ) JL_GC_ENCODE_PUSH(n)
1063+ #else
1064+
1065+ // We use an extra bit (100) in the nroots value from the frame to indicate that the roots
1066+ // in the frame are/are not transitively pinning.
1067+ // There are currently 3 macros that encode passing nroots to the gcframe
1068+ // and they use the two lowest bits to encode information about what is in the frame (as below).
1069+ // To support the distinction between transtively pinning roots and non transitively pinning roots
1070+ // on the stack, we take another bit from nroots to encode information about whether or not to
1071+ // transitively pin the roots in the frame.
1072+ //
1073+ // So the ones that transitively pin look like:
1074+ // #define JL_GC_ENCODE_PUSHARGS(n) (((size_t)(n))<<3)
1075+ // #define JL_GC_ENCODE_PUSH(n) ((((size_t)(n))<<3)|1)
1076+ // #define JL_GC_ENCODE_PUSHFRAME(n) ((((size_t)(n))<<3)|2)
1077+ // and the ones that do not look like:
1078+ // #define JL_GC_ENCODE_PUSHARGS_NO_TPIN(n) (((size_t)(n))<<3|4)
1079+ // #define JL_GC_ENCODE_PUSH_NO_TPIN(n) ((((size_t)(n))<<3)|5)
1080+ // #define JL_GC_ENCODE_PUSHFRAME_NO_TPIN(n) ((((size_t)(n))<<3)|6)
1081+
1082+ // these are transitively pinning
1083+ #define JL_GC_ENCODE_PUSHARGS (n ) (((size_t)(n))<<3)
1084+ #define JL_GC_ENCODE_PUSH (n ) ((((size_t)(n))<<3)|1)
1085+ #define JL_GC_DECODE_NROOTS (n ) (n >> 3)
1086+
1087+ // these only pin the root object itself
1088+ #define JL_GC_ENCODE_PUSHARGS_NO_TPIN (n ) (((size_t)(n))<<3|4)
1089+ #define JL_GC_ENCODE_PUSH_NO_TPIN (n ) ((((size_t)(n))<<3)|5)
1090+ #endif
10581091
10591092#ifdef __clang_gcanalyzer__
10601093
0 commit comments