[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: GC Barriers
- From: Roberto Ierusalimschy <roberto@...>
- Date: Wed, 13 Nov 2013 09:28:01 -0200
> There is a comment above luaH_set that says:
>
> "beware: when using this function you probably need to check a GC barrier and invalidate the TM cache"
>
> I have a function which is called from luaV_execute, it creates a Table object, which may or may not have nested Table objects, which is eventually assigned to 'ra'.
>
> As I am creating this table entirely during the call to my function from luaV_execute do I need to worry about creating GC barriers? The tables have no metamethods so I do not need to invalidate any caches.
>
> I am setting the array part of the table every time and potentially the hash part if needed. These values are being set to Lua strings via luaS_new. Right now I do not have any barrier calls in place, I do have lua_assert defined and I do not get any assertions during the execution of my code, nor when the Lua state is torn down, which leads me to believe I probably don't need a barrier call.
>
> I just thought I would double-check here to be sure! :)
If your entire operation never calls the garbage collector (e.g.,
'luaC_checkGC'), then you do not need barriers. The tables you are
creating are all white (not visited yet); the problem is a black object
refering to a white one. If you are using Lua 5.2, remember also that
you have to anchor your objects while creating them, or an emergency
collection can collect them.
-- Roberto