lua-users home
lua-l archive

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

Roberto Ierusalimschy <> 于2020年12月23日周三 上午3:52写道:
> This seems doable; Lua could white this list incrementally, too.
> Certainly these transitions between modes could be improved.

You may consider entergen(), I think it also can be improved to avoid
stop-the-world problem.

luaC_runtilstate(L, bitmask(GCSpause));  /* prepare to start a new cycle */
luaC_runtilstate(L, bitmask(GCSpropagate));  /* start new cycle */
numobjs = atomic(L);  /* propagates all and then do the atomic stuff */

These can be incrementally, too.

> Besides this fixed-size headers, the allocator still would have
> to deal with the variable-size contents. And the waste would
> probably be larger than 4/8 bytes, because each extra memory block
> aslo wastes some bytes in its header. Or not?


But I think it can be optimized in the user-defined allocator (maybe) ,
and a separate string content may be easier to move during the GC to
avoid memory fragments.

We may add a flexible mechanism for long strings, too.
For example,  a user-defined long string free function to avoid memcpy
while pushing long strings into VM.