Skip to content

Instantly share code, notes, and snippets.

@matthew-levan
Last active August 31, 2023 19:58
Show Gist options
  • Save matthew-levan/5b957864b2e08d42e1cd242a7ade14c7 to your computer and use it in GitHub Desktop.
Save matthew-levan/5b957864b2e08d42e1cd242a7ade14c7 to your computer and use it in GitHub Desktop.
Loom Migrations

Loom Migration Refactor

I am undertaking a refactor of the pointer compression loom migration. Refactoring this migration (the only "loom migration" we currently have in the repository) will also serve as scaffolding for future loom migrations.

Motivation

Currently, pointer compression is implemented as a feature which depends on a "virtual bits" flag, u3C.vits_w. This flag is set at runtime based on the loom's version and is subsequently used by memory management functions.

Using a runtime flag for this feature means that many of these functions were modified to support both compressed and uncompressed pointers (again, based on the runtime flag). While this prevented much code duplication, it also makes future loom migrations (like the one I am trying to write for persistent Nock caching) more difficult. It also adds at least a little bit of performance overhead to the runtime.

Goals

  1. Decouple the pointer compression migration from the runtime flag u3C.vits_w and all functions which were modified to support it.
  2. Make the pointer compression migration a compile-time feature.
  3. Version any functions and structures which are modified by the migration.
  4. Provide a framework for future loom migrations.

Approach

Here, I will maintain a working list of functions and structures which will need to be versioned, categorized by "package". Most of the "old" versions of these will go into pkg/noun/{v1|v2|v3|...}, or similar.

pkg/noun

allocate.h:

  • u3a_to_off(c3_w som) -- uses u3C.vits_w
    • u3a_to_ptr(c3_w som) -- calls u3a_to_off()
    • u3a_north_is_senior(r, dog) -- calls u3a_to_off()
    • u3a_north_is_junior(r, dog) -- calls u3a_to_off()
    • u3a_north_is_normal(r, dog) -- calls u3a_north_is_senior(),u3a_north_is_junior()
    • u3a_south_is_senior(r, dog) -- calls u3a_to_off()
    • u3a_south_is_junior(r, dog) -- calls u3a_to_off()
    • u3a_south_is_normal(r, dog) -- calls u3a_south_is_senior(),u3a_south_is_junior()
    • u3a_is_junior(r, som) -- calls u3a_north_is_junior(),u3a_south_is_junior()
    • u3a_is_senior(r, som) -- calls u3a_north_is_senior(),u3a_south_is_senior()
    • u3a_is_mutable(r, som) -- calls u3a_is_junior(),u3a_is_senior()
  • u3a_to_pug(c3_w off) -- uses u3C.vits_w
  • u3a_to_pom(c3_w off) -- uses u3C.vits_w

More later...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment