Idris2
Idris2 copied to clipboard
[RefC] Object Immortalization and Pre-Generation of Constants
Description
This PR immortalizes objects whose reference counter has reached its maximum value and makes them excluded from GC. This immortalization is used to make the following improvements.
- Since there is no longer any need to worry about the refCounter overflowing to 0, change the refCounter from int to uint16_t to reduce the size of the Value_Header and improve memory usage efficiency.
- Statically generate constants to reduce runtime cost and share data. Constants are naturally immortal. Statically generate values that often appear at runtime, such as empty strings and integers less than 100, and share them at runtime to reduce allocation costs. This heuristic may attract many opinions, but it is a good first-try choice.
On the other hand, there is no way to release immortal objects, so they leak. Dynamic immortalization rarely occurs, but it is a problem for programs that run for long periods of time, such as servers. A secondary GC is needed to solve this, but is not implemented in this PR.
Should this change go in the CHANGELOG?
- [X] If this is a fix, user-facing change, a compiler change, or a new paper
implementation, I have updated
CHANGELOG_NEXT.md
(and potentially alsoCONTRIBUTORS.md
).