Optimize flash storage of properties #6337
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In-flash properties with only a getter or only get+set are organized into two specific memory regions, so that it's possible to tell by their address whether they have 1, 2, or 3 proxy slots available. When accessing a property slot, code is added to check if the desired slot is available -- this affects setter & deleter paths, adding some additional conditional branching, so it probably has a minor negative performance effect as well (which I didn't attempt to measure)
A property with only a getter shrinks from 16 byte (type pointer + 3 proxy slots) to 8 bytes (type pointer + 1 proxy slot); a get+set property shrinks to 12 bytes (type pointer + 2 proxy slots). However, new tests are added in some fast paths, apparently costing ~120 bytes on samd21. Net, 96 bytes are saved on the trinket_m0 build.
Closes: #4899 (except for enabling it on all ports)