lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Francisco Olarte wrote:

This might be a problem for the SSO since it would need to create a heap
string whenever a C function tries to get a pointer to the string since
it could be moved to a different stack index and the pointer still needs
to be valid.
It is, a show stopper for me. Thanks.

I did think a bit more about this problem. It could be solved by a second "stack". This stack would need to be implemented by a linked list of pages to ensure pointer stability. When a string pointer to a small string in the stack is requested the string is allocated in a page and the pointer is returned. The amount of allocated strings for a function frame is bounded by the amount of stack slots this function uses since only the used stack slots can have their strings allocated. If there are to many strings allocated for a function frame the strings which are already removed from the lua stack can be searched and the 16 byte buckets reused for another string allocation. This would require a search and copy of small strings, however, the heap allocation is removed.

Regards,
Xmilia