From 9f5aa98ac1034030788ae24c9df506c88216c907 Mon Sep 17 00:00:00 2001 From: Taylan Kammer Date: Tue, 25 Aug 2026 21:53:24 +0200 Subject: Addition to last note. --- notes/260825-code-gc.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'notes/260825-code-gc.md') diff --git a/notes/260825-code-gc.md b/notes/260825-code-gc.md index 9593d15..b2736af 100644 --- a/notes/260825-code-gc.md +++ b/notes/260825-code-gc.md @@ -309,3 +309,33 @@ I'll call it quits here. I think a simple little mark & sweep of a global modules list would be quite fine though. To be clear I don't mean going into the modules; just the modules themselves. So this would be a very quick and easy operation. + + +## Wait... + +I've made a crucial mistake: If statically linking a module means +having direct pointers to its data, and the linking module is frozen, +that would mean the recursive free goes into the other module. Ugh! + +We really need a better way to detect boundaries between modules. + +OK, here's an idea: Given that we have a bunch of as of yet barely +defined bits in our heap pointer NaN types, we could have one bit +meaning "pointer to another module's data" or more generally some +"foreign" data indicator. + +For example, heap NaN pointers all have 8 bits currently reserved for +indeterminate purposes. (Probably tri-color marking & generations.) +One of these could be sacrificed for this purpose. + +Would be used in two ways: + +1. Intra-module references to private bindings: Copy the value into + the code, set the foreign bit if it's a pointer; recursive free + won't touch it. + +2. References to statically linked modules: Copy the value of the + binding into the code of this module, set foreign bit if pointer; + recursive free won't touch it. + +Something like that would work, I think. -- cgit v1.2.3