github-actions · GitHub

@hudson-ayers

@bradjc bradjc changed the title move as much kernel code as possible out of monomorphized functions Move kernel code out of monomorphized functions

Jul 2, 2021

@hudson-ayers

@hudson-ayers

@bradjc bradjc added the blocked

Waiting on something, like a different PR or a dependency.

label

Jul 6, 2021

@hudson-ayers

@hudson-ayers

@hudson-ayers

bradjc

bradjc

This commit applies the non-generic-inner-functions approach
(https://www.possiblerust.com/pattern/non-generic-inner-functions)
to several functions in grant.rs and sched.rs. None of these changes
should impact functionality in any way (assuming I got these changes
right). At the expense of the code being a little less readable,
these changes reduce the size of Imix by 6528 bytes.

@hudson-ayers

@bors

@bors

bors Bot deleted the less-generic-grants branch

July 8, 2021 14:42

Merged

2 tasks

hudson-ayers added a commit that referenced this pull request

Mar 7, 2022
For large functions with generic parameters that are called with
many different generic parameters, move as much code as possible within those
functions into separate, non-generic functions. This ensures that when
Rust monomorphizes those functions, only the portions of code which
actually need to be duplicated are duplicated. The approach here
is similar to that described in
https://www.possiblerust.com/pattern/non-generic-inner-functions,
except that it is applied to methods rather than functions.
This change reduces code size by 4016 bytes, most of which comes from
the changes to Grant::enter().
A corresponding PR has been sent to upstream Tock:
#2648 . That PR is for the Tock 2.0
version of grant.rs, and thus makes some different decisions based on
the updated grant design.
BUG=None,
TEST=make build;
Change-Id: I5fc0a360c9a37852746ebb32e83de2a03dc1e957
Reviewed-on: https://chrome-internal-review.googlesource.com/c/ti50/third_party/tock/tock/+/3947379
Reviewed-by: Andrey Pronin <apronin@google.com>
Reviewed-by: Jett Rink <jettrink@google.com>
Commit-Queue: Hudson Ayers <hudsonayers@google.com>
Tested-by: Hudson Ayers <hudsonayers@google.com>

sirchnik pushed a commit to sirchnik/tock that referenced this pull request

May 12, 2026
2648: Move kernel code out of monomorphized functions r=bradjc a=hudson-ayers
### Pull Request Overview
This commit applies the non-generic-inner-functions approach
(https://www.possiblerust.com/pattern/non-generic-inner-functions)
to several functions in grant.rs and sched.rs. None of these changes
should impact functionality in any way (assuming I got these changes
right). At the expense of the code being a little less readable,
these changes reduce the code size of Imix by 6528 (!) bytes.
### Testing Strategy
This pull request was tested by compiling.
### TODO or Help Wanted
N/A
### Documentation Updated
- [x] Updated the relevant files in `/docs`, or no updates are required.
### Formatting
- [x] Ran `make prepush`.
Co-authored-by: Hudson Ayers <hudsonayers@google.com>

Read the original on github.com ↗