lua-users home
lua-l archive

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


Jim <djvaios@gmail.com> 于2019年4月14日周日 下午6:41写道:
>
> how about making it possible to manage certain objects
> provided by C code by reference counting instead of
> garbage collection when the programmer indicates so ?
>


I'm working on a modified lua vm these days. It implements a
thread-safe mixed gc , which
mix a deferred reference counting and mark-sweep gc.

My goal is to share constant GCObject (such as TString and TProto)
with in multiple lua vm.
We can copy a GCObject to another lua vm by reference instead of deep-copy.

The main idea is :

1. Add a SHARED bit in marked of GCObject. When this bit is set, Its
life span is managed by a deferred reference counting system.
2. Shared GCObjects are always white, in the stage GCSpropagate, put
its pointer into a MARKED set instead of touching the marked bits.
3. in the stage GCScallfin , send this MARKED set to the GC thread ,
and GC thread will decease the reference counts of GCObject that is
not in this set but was in the vm.

-- 
http://blog.codingnow.com