An Exploration of SBCL Internals (2020)

# · 🔥 131 · 💬 106 · 11 days ago · simonsafar.com · v9v · 📷
It's also an experiment in "Learning in the public"; at the point of starting to write this, I don't actually know a lot about how SBCL works either. SBCL provides a way for creating pointer values from integers: sb-sys:int-sap does exactly this, which then we can read by invoking CL-USER> 0) 66. If parameter 1, coming in a register as per the relevant calling convention, is a 64-bit integer, we can treat it as such; if it's a pointer to a struct, different code gets generated. The rest of the pointer is, well, an actual pointer. This is the point where having compiled SBCL for yourself becomes fairly useful. SBCL stores fixnums in the exact same registers as pointers; to keep the most precision possible, we just interpret anything ending with a 0 bit as a number. If the last bit is 1, we can look at the rest of the final 4 bits to figure out what kind of pointer we're dealing with.
An Exploration of SBCL Internals (2020)



Send Feedback | WebAssembly Version (beta)