This repository has been archived by the owner on Jun 27, 2022. It is now read-only.
[Lang Enhancement Proposal] Use alloca()
and implement stack-based variable storage for small values
#68
Labels
Milestone
Affected area by change:
Short Introduction and Summary
Currently, the implementation of memory is handled through datatypes which are allocated purely on the heap, as they use
void* PblMalloc(size_t)
, though for better optimisations the allocations should happen preferably on the stack, and if possible with stack overflow checking, to avoid undefined behaviour.Is your request related to a problem? Please describe.
At the moment, the allocation of memory is rather inefficient, as even small data-types are allocated on the stack, causing slow-downs, which could be easily fixed with additional implementation of something like
void* PblAlloca(size_t)
.Describe the solution you'd like
pbl-mem.h
with the following signaturevoid* PblAlloca(size_t)
.PBL_ALLOCA_DECLARATION
andPBL_ALLOCA_DEFINITION
, which should usePblAlloca()
PBL_ALLOC_DEFINITION
toPBL_MALLOC_DEFINITION
,PBL_ALLOC_DECLARATION
toPBL_MALLOC_DECLARATION
andPBL_ALLOC_ARRAY_DEFINITION
toPBL_MALLOC_ARRAY_DEFINITION
for clearer signalisation that the heap is used.Describe alternatives you've considered
Perhaps revert to the old usage of actual finished types, though this would create issues with the current pointer implementations, so re-creating the stack usage is preferable.
Additional context
alloca
(The GNU C Library)The text was updated successfully, but these errors were encountered: