This week was spent on bug fixes, and enhancing memory tightness of the core VM.
There were many places in the VM where the following construction was used:
It was unfortunate, since this construction can lead to memory leaks if an exception is thrown
between the construction of new
the moment it becomes guarded by the
Viua strives to correctly manage its memory, and account for every resource it allocates, so this
was clearly unacceptable.
The solution came in the form of
This function safely allocates memory, constructs an object, and wraps it in a
It also leads to shorter code and less repetition:
Bits in Boolean context
An embarrassing omission managed to slip past tests: bit strings always evaluated to false when used a Boolean values. This obviously incorrect behaviour was fixed. Bit strings containing at least one enabled bit evaluate to true, bit strings with all zeroes evaluate to false.
All-zero bit string literals
Another bug managed to sneak into the assembler: literal bit strings that were all zeroes were reduced to zero-width strings. This is fixed now, and literal all-zero bit strings are (correctly) reduced to one-zero strings. Examples:
After stripping leading zeroes the width of the literal bit string is expanded to the nearest multiple of 8. This behaviour did not change.
Register set specifiers in assembler and disassembler
Disassembly was fixed for
Their target registers were not disassembled with register set specifiers, which could change the meaning of the program being
if instruction also did not support register set specifiers in source code at all.
This is now fixed.