You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SR-13570 UnsafeMutable*Pointer should stack-promote allocations (like malloc)
Issue Description:
often times you just need an allocation for a single frame and dont need to actually heap allocate. alloca or stack allocation is considerably faster than malloc/heap allocation. There should be a way to indicate either by inference of usage or by explicit call that the compiler should be able to emit a stack allocated memory buffer.
Often times as a work-around a tuple is used to accommodate stack allocation but this is not very ergonomic and can cause some severe cargo-cult-ed patterns to be used. We should have a cleaner and better answer than this.
The text was updated successfully, but these errors were encountered:
at least on Darwin and linux based platforms the main thread has additional stack space available so a limit on the allocation can be conditional on determination of the main thread.
Here is an example of something similar that is used in CoreFoundation
I mocked up an implementation of this and posted it on Twitter a few weeks ago. If we were to really do it we'd probably want to add a new builtin instead of relying on C, so we could optimize it.
the problem with that approach (which is currently used in Foundation's overlay via the _withStackOrHeapBuffer helper function is that we cannot rethrow...
Additional Detail from JIRA
md5: 6857a631645c8afe8fb362159661c0eb
relates to:
Issue Description:
often times you just need an allocation for a single frame and dont need to actually heap allocate. alloca or stack allocation is considerably faster than malloc/heap allocation. There should be a way to indicate either by inference of usage or by explicit call that the compiler should be able to emit a stack allocated memory buffer.
Often times as a work-around a tuple is used to accommodate stack allocation but this is not very ergonomic and can cause some severe cargo-cult-ed patterns to be used. We should have a cleaner and better answer than this.
The text was updated successfully, but these errors were encountered: