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 heap usage #11

Open
1 of 4 tasks
Kroc opened this issue Jul 3, 2024 · 3 comments
Open
1 of 4 tasks

Reduce heap usage #11

Kroc opened this issue Jul 3, 2024 · 3 comments
Milestone

Comments

@Kroc
Copy link
Owner

Kroc commented Jul 3, 2024

Both in general, and specifically when assembling v80, which uses roughly 25KB of heap space. This would make assembling v80 a major squeeze on even a 48K system, if even possible. v80 is 8KB + 256B buffers, + 256B stack. v80's heap usage whilst assembling itself needs to be reduced to at least 20KB. There are general strategies, such as just using less labels, but this issue will focus on code changes that can help.

  • Do not store the first char of symbols (consts & labels). Since there's specific routines for accessing constants and labels, we can assume the first char and reconstruct it where necessary. Saves 1 byte for every symbol
  • When a deferred expression is a relative jump, store the virtual program-counter in the expr-byte code so that it doesn't need to be included in the record of every deferred expression
  • Store the parameter & rel-flag byte in the first reserved byte in the code-segment, rather than in the deferred record. Saves 1 byte every record
  • Store numbers that fit into 1 byte in a special 1-byte number token. This complicates the parser / evaluator a little more, but is an easy way to save bytes
@Kroc Kroc added this to the v1.x milestone Jul 3, 2024
@Kroc
Copy link
Owner Author

Kroc commented Jul 5, 2024

Not heap related, but I don't have a good place to put this idea yet -- there's a lot of once-off initialisation routines we could move into the code-segment, so that they get overwritten when assembly begins. Things like parameter parsing, the no-parameters help message. The most difficult part is simply deciding how best to split the files and include them in such a way that's going to scale for multiple supported platforms/OSes besides just CP/M.

@Kroc
Copy link
Owner Author

Kroc commented Sep 30, 2024

The switch to v2-ISA-parser has massively reduced heap usage by doing away with all the forward references in the ISA definition. Heap usage has halved to just 12KB!

@Kroc
Copy link
Owner Author

Kroc commented Nov 29, 2024

Not directly releated to heap usage, but we can save more RAM by moving the start of :main to an :init routine inside the code-segment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant