Skip to content
New issue

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

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

Already on GitHub? # to your account

Add clox patch #3

Merged
merged 2 commits into from
Jun 27, 2023
Merged

Add clox patch #3

merged 2 commits into from
Jun 27, 2023

Conversation

gloria-mundi
Copy link
Contributor

This adds a patch to allow LoxLox to run on clox. clox is modified to support up to 32768 constants per chunk, by encoding larger constant indices in two bytes. In addition, the stack size has been doubled to allow LoxLox to parse itself without overflowing the stack.

Performance

Command Mean [ms] Min [ms] Max [ms] Relative
./clox sum.lox 20.6 ± 2.0 14.4 23.9 1.00
./jlox sum.lox 205.9 ± 18.3 180.0 264.5 10.02 ± 1.31
./clox lox.lox < sum.lox 1356.4 ± 20.8 1327.4 1426.8 65.99 ± 6.44
./jlox lox.lox < sum.lox 8276.7 ± 168.6 8010.6 8695.5 402.69 ± 39.67

LoxLox under clox is only about 6.5 times slower than jlox! (on this specific benchmark, on my machine)

@benhoyt
Copy link
Owner

benhoyt commented Jun 27, 2023

This is brilliant -- thank you! I've added a note about running under CLox to the README and will merge this. Really well done. :-) I like the variable-sized int encoding, too.

@benhoyt benhoyt merged commit 78949f7 into benhoyt:master Jun 27, 2023
@benhoyt
Copy link
Owner

benhoyt commented Jun 27, 2023

I also added an "Update: ..." note to my article about LoxLox.

@gloria-mundi gloria-mundi deleted the clox branch June 27, 2023 14:02
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants