Skip to content

add boolean support #3

@jackdotink

Description

@jackdotink

There is currently no support for booleans. There is a lot of opportunity for easy size optimization with booleans. Bit-packing is trivial, especially in native mode (maybe it should only be enabled in native mode?). In my eyes there are some unanswered questions blocking this implementation:

Bit Packing

As booleans are a single bit, we can pack 8 of them into one byte. There are many ways to implement this, some of which are only really beneficial when Luau's native codegen is enabled. We should consider only doing bit packing when native codegen can be enabled.

Static Bit Packing

This is where booleans are written into buf in chunks that are at predictable locations. For example, in a struct we may decide to move all boolean fields in the struct to the header and pack them together. This approach certainly has limitations and would require more compiler code written to optimize different cases. This is my preferred implementation.

Dynamic Bit Packing

This is where booleans are written into a separate buffer in chunks in order, removing the need for predictable locations. The big downside of this is that it makes knowing the potential size of types ahead of time incredibly difficult. I am not sold on this implementation but I can be convinced.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions