Dropped lfsr_mptr_t as a struct

This replaces the lfsr_mptr_t struct with simple arrays.

The main motivation for this is C99's strict aliasing. It saves a
decent amount of stack to reference the mdir's internal block array as
an mptr directly, but we were only able to accomplish this in
lfsr_mdir_mptr by violating C99's strict aliasing rules.

The main downside of this is C's wonderful array-to-pointer decay
resulting in more implicit references and chances for things to get
clobbered (the original motivation for lfsr_mptr_t was due to bugs
introduced this way).

If I know one thing about C99's strict aliasing it's that it sure loves
to make code less safe.

No significant code changes, which is probably a good thing:

                     code          stack
  default before:   36436           2672
  default after:    36432 (-0.0%)   2672 (+0.0%)

  ckfetches before: 36674           2704
  ckfetches after:  36666 (-0.0%)   2704 (+0.0%)
This commit is contained in:
Christopher Haster
2024-08-14 16:00:37 -05:00
parent 770578d221
commit 2cefcbdddc
4 changed files with 69 additions and 73 deletions
+1 -1
View File
@@ -4326,7 +4326,7 @@ code = '''
lfsr_mdir_commit(&lfs, &lfs.mroot, LFSR_ATTRS(
LFSR_ATTR(
LFSR_TAG_MROOT, 0,
LFSR_DATA_MPTR(&LFSR_MPTR_MROOTANCHOR())))) => 0;
LFSR_DATA_MPTR(LFSR_MPTR_MROOTANCHOR())))) => 0;
// technically, cycle detection only needs to work when we're validating
lfsr_traversal_t t = LFSR_TRAVERSAL(
+3 -3
View File
@@ -5429,7 +5429,7 @@ code = '''
// we need internals to check this
lfsr_mdir_t mrootanchor;
lfsr_mdir_fetch(&lfs, &mrootanchor,
-1, &LFSR_MPTR_MROOTANCHOR()) => 0;
-1, LFSR_MPTR_MROOTANCHOR()) => 0;
if (lfsr_rbyd_eoff(&mrootanchor.rbyd) > GC_COMPACT_THRESH) {
break;
}
@@ -5474,7 +5474,7 @@ code = '''
// mrootanchor should have been compacted
lfsr_mdir_t mrootanchor;
lfsr_mdir_fetch(&lfs, &mrootanchor,
-1, &LFSR_MPTR_MROOTANCHOR()) => 0;
-1, LFSR_MPTR_MROOTANCHOR()) => 0;
assert(lfsr_rbyd_eoff(&mrootanchor.rbyd) <= GC_COMPACT_THRESH);
// but because we mutated, we're still marked as uncompacted
@@ -5496,7 +5496,7 @@ code = '''
// mrootanchor should have been compacted
lfsr_mdir_fetch(&lfs, &mrootanchor,
-1, &LFSR_MPTR_MROOTANCHOR()) => 0;
-1, LFSR_MPTR_MROOTANCHOR()) => 0;
assert(lfsr_rbyd_eoff(&mrootanchor.rbyd) <= GC_COMPACT_THRESH);
// uncompacted flag should have been cleared