Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

bradjc
Copy link
Contributor

@bradjc bradjc commented Jun 26, 2023

Pull Request Overview

By outsourcing all of main() to a separate function (in this case start() other than running the kernel, we can minimize the stack frame size of main. This is important because the main stack frame is never popped since main does not return.

This is an alternative to doing this piecemeal for individual functions.

This PR is an alternative to #3499.

Testing Strategy

travis

TODO or Help Wanted

I only did this for one board. Thoughts? Naming? Is using Chip.unwrap() ok / is there a better option?

Documentation Updated

  • Updated the relevant files in /docs, or no updates are required.

Formatting

  • Ran make prepush.

By outsourcing all of `main()` to a separate function (in this case
`start()` other than running the kernel, we can minimize the stack frame
size of main. This is important because the main stack frame is never
popped since main does not return.

This is an alternative to doing this piecemeal for individual functions.
@bradjc bradjc added the rfc Issue designed for discussion and to solicit feedback. label Jun 26, 2023
@hudson-ayers
Copy link
Contributor

I think I would just return chip from start() so it can be used in main(), since I am not sure that Rust will optimize out that panicking branch with inlining prevented.

@hudson-ayers
Copy link
Contributor

This PR actually seems to reduce code size for the microbit, and gives us a much smaller main() stack frame (and worst-case stack depth, I am sure). I much prefer this to #3499, and advocate using it for all boards

alistair23 added a commit to alistair23/tock that referenced this pull request Jun 28, 2023
Update to use a helper function in main to reduce the stack usage. This
is to address the stack usage issue as described in
tock#3514.

This reverts commit eaffb31.

Signed-off-by: Alistair Francis <[email protected]>
@bradjc
Copy link
Contributor Author

bradjc commented Jun 28, 2023

Maybe setup() is a better name?

@hudson-ayers hudson-ayers changed the title boards: use helper function in main boards: microbitv2: use helper function in main Jul 10, 2023
Copy link
Member

@ppannuto ppannuto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bors r+ jk

@bors
Copy link
Contributor

bors bot commented Jul 13, 2023

Configuration problem:
bors.toml: not found

@ppannuto ppannuto added this pull request to the merge queue Jul 13, 2023
Merged via the queue into master with commit 29abb62 Jul 13, 2023
@ppannuto ppannuto deleted the board-start-fn branch July 13, 2023 01:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rfc Issue designed for discussion and to solicit feedback.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants