Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce instruction size #14

Open
pjhades opened this issue Mar 26, 2018 · 0 comments
Open

Reduce instruction size #14

pjhades opened this issue Mar 26, 2018 · 0 comments
Labels
enhancement New feature or request

Comments

@pjhades
Copy link
Owner

pjhades commented Mar 26, 2018

We will soon need to introduce character set like [a-zA-Z] and \w or even [\w\d\s] so there might be a new variant Inst::Char(CharKind::Charset(...)) which will definitely bloat the size of struct Inst.

The size of this struct should be kept as small as possible to reduce the overall memory consumption for the compiled program. So it may be helpful to have a CharKind::Charset(Box<HashSet<char>>) instead of CharKind::Charset(HashSet<char>).

Also, we can compile to bytecode so that each Inst variant takes 2 bytes. A trick could be played on the Split instructions. Since we're using i32 to represent an instruction address, the valid range is 0x00000000 - 0x7fffffff. So we can use the sign bit to record whether the next instruction is preferred. In this way we only need to record one Iaddr on a Split. Also 2 bytes is enough for holding a Box<HashSet<char>>.

@pjhades pjhades added the enhancement New feature or request label Mar 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant