Modified global state format to work with new tag format

The main difference here is a change from encoding "hasorphans" and
"hasmove" bits in the tag itself. This worked with the old format, but
in the new format the space these bits take up must be consistent for
each tag type. The tradeoff is that the new tag format allows for up to
256 different global states which may be useful in the future (for
example, a global free list).

The new format encodes this info in the data blob, using an additional
word of storage. This word is actually formatted the same as though it
was a tag, which simplified internal handling and may allow other tag
types in the future.

Format for global state:
[----                          96 bits                         ----]
[1|- 11 -|- 10 -|- 10 -|---                 64                  ---]
 ^    ^      ^      ^                        ^- move dir pair
 |    |      |      \-------------------------- unused, must be 0s
 |    |      \--------------------------------- move id
 |    \---------------------------------------- type, 0xfff for move
 \--------------------------------------------- has orphans

This also included another iteration over globals (renamed to gstate)
with some simplifications to how globals are handled.
This commit is contained in:
Christopher Haster
2019-01-04 17:23:36 -06:00
parent b989b4a89f
commit 66d751544d
3 changed files with 209 additions and 240 deletions

8
lfs.h
View File

@@ -381,12 +381,10 @@ typedef struct lfs {
} *mlist;
uint32_t seed;
struct lfs_globals {
struct lfs_gstate {
uint32_t tag;
lfs_block_t pair[2];
uint16_t id;
bool hasmove;
uint8_t orphans;
} globals, locals;
} gstate, gpending, gdelta;
struct lfs_free {
lfs_block_t off;