lua-users home
lua-l archive

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

> thank you for your answer very much! but i'm still missing for the first
> question.
> i found luaC_barrierback is only used when the black object is a table,
> while luaC_barrierf is for the other type.
> why can't we simply mark the white object to grey as what luaC_barrierf do?
> if we turn the parent table back to grey, it means all of its son objects
> will be traversed again, what's the reason we have to do this? is there any
> special characters of  table type?

As I said, we could mark the white object to gray. It is just a matter
of (expected) performance.

When you assign to a table, there is a good chance that you will assign
many other values to that same table. If we use barrierf here, all
these objects will be marked: that means a call to barrier for each
assignment, and also means that none of these objects will be collected
in this cycle. By changing the table back to gray, the following
assignments do not trigger the barrier (so they become faster) and the
assigned objects may still be collected in that cycle (if they are
overwritten before the table is traversed again).

(All this is highly speculative, of course. It depends on the program
behavior. Currently we have no strong results to support this option.
Actually, we do not have a good set of programs to test the behavior
of the garbage collection in "real" situations. It would be very
useful to have such a set.)

-- Roberto