diff options
Diffstat (limited to 'notes/250210-nan.md')
| -rw-r--r-- | notes/250210-nan.md | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/notes/250210-nan.md b/notes/250210-nan.md index 107bdf7..adc939f 100644 --- a/notes/250210-nan.md +++ b/notes/250210-nan.md @@ -116,9 +116,9 @@ as unused, giving us another `2^52 - 2` bit patterns. In total, this gives us `2^53 - 4` definitely-unused NaN bit patterns. -## Representing Zisp values and pointers as unused NaN bit patterns +## Representing Xisp values and pointers as unused NaN bit patterns -Zisp wants to store two different things in unused NaN patterns: +Xisp wants to store two different things in unused NaN patterns: 1. Pointers (to anything in principle) @@ -252,7 +252,7 @@ that much play room, we can do some crazy things. ### Foreign pointers Firstly, let's introduce the concept of a "foreign" pointer. This means the -pointer doesn't necessarily point to a Zisp object, and may not be 8-byte +pointer doesn't necessarily point to a Xisp object, and may not be 8-byte aligned. As it may point to anything, there's no point in defining further bits as tagging additional information, so we have all 50 bits available. @@ -272,16 +272,16 @@ essentially defined another fixnum range of 50 bits. This can include the value zero, since the foreign bit being set ensures we don't step on the forbidden all-zero payload value. -### Zisp pointers +### Xisp pointers -Now let's look at what we can do with "native" Zisp pointers. +Now let's look at what we can do with "native" Xisp pointers. Wouldn't it be nice if our language had an explicit "pointer" data type and it didn't require any additional heap allocation? So let's decide that one bit is dedicated to distinguishing between an explicit pointer object, and regular pointers that stand in for the object being pointed to. -Perhaps it would be good to show some Zisp pseudo-code to explain what that +Perhaps it would be good to show some Xisp pseudo-code to explain what that means, since it may be a strange concept: ;; In memory, vec is represented as a regular/direct vector pointer. @@ -311,7 +311,7 @@ immediate value like an integer or double as well. A box would necessarily need heap allocation, whereas a pointer doesn't. It's *also not* the same thing as a foreign pointer, because those can be -anything, whereas these pointer objects definitely point to Zisp objects. +anything, whereas these pointer objects definitely point to Xisp objects. Pointers may or may not be mutable; I've not made up my mind yet. It may seem like a pointless data type, but it adds a little bit of expressive @@ -332,7 +332,7 @@ would fit perfectly since they can contain null. Direct or indirect makes no difference to the fact that the pointer value will be 8-byte aligned, so we still have 4 bits for more information about what's being pointed to. Also, since the actual pointer value can never be -zero (all non-foreign pointers must point to a valid Zisp object), we avoid +zero (all non-foreign pointers must point to a valid Xisp object), we avoid the forbidden zero pattern. Thus, we can indicate 16 different values with our 4 remaining bits. @@ -352,14 +352,14 @@ of an operation, after all.) The tag can be used to tell us what we're pointing to, so that type checks often don't require following the pointer. The memory location that's being pointed to may duplicate this information, since we may want to ensure that -any Zisp object on the heap carries its type information within itself, but +any Xisp object on the heap carries its type information within itself, but I'm not yet decided on that. In any case, let's list some common heap data types that our 4-bit tag can represent, making sure to have an "other" wildcard for future extensions. The right side shows the value of the type tag when it's acquired by masking -the 49-bit Zisp pointer payload. +the 49-bit Xisp pointer payload. 0. String (Symbol) ... 0x0000000000000 1. Pair (List) 0x0000000000001 @@ -408,12 +408,12 @@ missing, so we automatically avoid the forbidden zero payload. ### What the heck is a "short string"? -Remember that [strings are immutable](250210-symbols.html) in Zisp. This +Remember that [strings are immutable](250210-symbols.html) in Xisp. This allows us to use an amazing optimization where short strings can be represented as immediate values. We can't get to 56 bits (7 bytes), but 48 bits (6 bytes) fits perfectly into -our payload! So any interned string (equivalent to a Scheme symbol) in Zisp +our payload! So any interned string (equivalent to a Scheme symbol) in Xisp will in fact be an immediate value if 6 bytes or shorter, and doesn't need any heap allocation. Awesome! @@ -451,7 +451,7 @@ claim that you must avoid signaling NaNs or quiet NaNs, or they take a naive approach to the subdivision of the available bit patterns and end up wasting tons of bit real estate. -Stay tuned for the development of Zisp, because this is getting serious! +Stay tuned for the development of Xisp, because this is getting serious! <!-- ;; Local Variables: |
