Skip to content

Commit dece143

Browse files
authored
Create 'JL_GC_DECODE_NROOTS' macro to avoid writing explicit bitshifts in a few places (#58658)
See PR title. CC: @udesou, @qinsoon.
1 parent 3682c06 commit dece143

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/julia.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,6 +1139,7 @@ struct _jl_gcframe_t {
11391139

11401140
#define JL_GC_ENCODE_PUSHARGS(n) (((size_t)(n))<<2)
11411141
#define JL_GC_ENCODE_PUSH(n) ((((size_t)(n))<<2)|1)
1142+
#define JL_GC_DECODE_NROOTS(n) (n >> 2)
11421143

11431144
#ifdef __clang_gcanalyzer__
11441145

src/subtype.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ static void re_save_env(jl_stenv_t *e, jl_savedenv_t *se, int root)
274274
}
275275
else {
276276
roots = se->roots;
277-
nroots = se->gcframe.nroots >> 2;
277+
nroots = JL_GC_DECODE_NROOTS(se->gcframe.nroots);
278278
}
279279
}
280280
jl_varbinding_t *v = e->vars;
@@ -367,7 +367,7 @@ static void restore_env(jl_stenv_t *e, jl_savedenv_t *se, int root) JL_NOTSAFEPO
367367
}
368368
else {
369369
roots = se->roots;
370-
nroots = se->gcframe.nroots >> 2;
370+
nroots = JL_GC_DECODE_NROOTS(se->gcframe.nroots);
371371
}
372372
}
373373
jl_varbinding_t *v = e->vars;
@@ -4295,7 +4295,7 @@ static int merge_env(jl_stenv_t *e, jl_savedenv_t *me, jl_savedenv_t *se, int co
42954295
else {
42964296
saved = se->roots;
42974297
merged = me->roots;
4298-
nroots = se->gcframe.nroots >> 2;
4298+
nroots = JL_GC_DECODE_NROOTS(se->gcframe.nroots);
42994299
}
43004300
assert(nroots == current_env_length(e) * 3);
43014301
assert(nroots % 3 == 0);

0 commit comments

Comments
 (0)