Skip to content

subsecond: Typed HotFn pointer #4153

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

Merged
merged 4 commits into from
May 22, 2025

Conversation

mockersf
Copy link
Contributor

  • Type the pointer you can get from ptr_address
  • Add a method to reuse a saved pointer instead of checking the jump table

@jkelleyrtp
Copy link
Member

try_call_with_ptr should be unsafe if HotFnPtr is craftable outside Subsecond since you'd be able to pass arbitrary u64s in, so either we make it so HotFnPtr can only originate inside this crate or mark the method unsafe. I think I like marking the method unsafe more, but up to you.

@janhohenheim
Copy link

janhohenheim commented May 21, 2025

I think the cleaner API would be to make the HotFnPtr only craftable externally via an unsafe constructor, that way we don't need to mark things that are de-facto safe as unsafe :)

@mockersf
Copy link
Contributor Author

I went with @janhohenheim suggestion!

@jkelleyrtp
Copy link
Member

Also - if a HotFnPtr is around, it might be unsafe to use it if the framework has migrated structs. IE the layout of a function's argument changed, the old one is going to cause a segfault. It might be worth marking the call method unsafe too.

@jkelleyrtp jkelleyrtp merged commit f557fd4 into DioxusLabs:main May 22, 2025
AnteDeliria pushed a commit to AnteDeliria/dioxus that referenced this pull request Jun 2, 2025
* type the HotFn pointer

* can reuse a HotFnPtr to run a hot patched function

* unsafe constructor

* try_call_with_ptr is unsafe
github-merge-queue bot pushed a commit to bevyengine/bevy that referenced this pull request Jun 3, 2025
# Objective

- Enable hot patching systems with subsecond
- Fixes #19296 

## Solution

- First commit is the naive thin layer
- Second commit only check the jump table when the code is hot patched
instead of on every system execution
- Depends on DioxusLabs/dioxus#4153 for a nicer
API, but could be done without
- Everything in second commit is feature gated, it has no impact when
the feature is not enabled

## Testing

- Check dependencies without the feature enabled: nothing dioxus in tree
- Run the new example: text and color can be changed

---------

Co-authored-by: Jan Hohenheim <[email protected]>
Co-authored-by: JMS55 <[email protected]>
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

Successfully merging this pull request may close these issues.

3 participants