D Programming Debris beneficiary Thoughts about bigger GC implementations

 07 August 10:27   

    It should be accessible to accept altered GC Implementations. E.g.

    This leads to added accurate requirements

    A absolute GC should alone mark that memory, that is referenced from a pointer. It should not mark anamnesis referenced from non-pointer types. A affective GC aswell needs to adapt arrow values, if an item was relocated.

    If a arrow is scanned, the alpha abode of an item should be know. So it should be accessible to get the PLI (pointer area information), which is bare to go on.

    In concurrent/incremental GC implementation, the affective advertence is a problem.

     Item refa = new Object;

     Item refb = null;

    # alpha of gc accession cycle

    # gc scans refb, which is null

    # gc pauses or is disconnected from addition thread

    # about else: refb = refa; refa = null;

    # gc continues (thinking refb is null)

    # gc scans refa, which is now absent also

    # GC: Oh, no ref to obj, I can chargeless it!

    # the appl tries to advertence refb which is not absent and crashes

    This is the couldcause for the charge of a address barrier. In a concurrent/incremental GC, every address to a advertence needs to invalidate the scans of the old ambition advertence value.

    Since scanning the assemblage absolutely could be a harder problem (especially if considerign C interfaces, i.e. callbacks from C cipher to D code), one could artlessly conservatively browse the assemblage and pin all altar that are possibly referenced from the stack. The new

    [http://www.mono-project.com/Compacting_GC Address GC] does this.

    See area Bourgeois Scanning. The assemblage is advised in a agnate way like the accepted mark & ambit algorithm does it.

    In adjustment to support

     Object.toHash()

    in attendance of a affective GC, one needs to abundance the assortment cipher in the item itsself. The assortment cipher can be taken from the altar address, but back its abode can be changed, it needs to be stored.

    It should be advised to abutment anemic pointers, which are a potentially advantageous and an generally requested feature. A anemic arrow is set to null, if there are no added non-weak pointers to an object. Java and C# aswell abutment anemic pointers.

    Pointer to built-in types should be accessible by the language,

    but should not be GC relevant. This means, they should should not anticipate the GC

    from deleting an object, and they are not apparent as pointers.

    So the GC does not charge to acquisition the item start. The programmer just needs

    to be sure, that he does not create references to member, that reside best than

    the complete object.

    A specific GC accomplishing ability be implemented added calmly if it is accessible to abundance a bound bulk of GC data central the item (i.e. flags). But agenda that alotof managment data can be stored in the anamnesis block which contains the object.

    Brain affronted what accurate item layouts (only wrt. to GC) would be possible:

    The first 4 bytes would accommodate a typeinfo pointer, and the blazon advice contains the blueprint advice for the object. This blueprint advice would is as a bitmap or

    a arena account (a account of (offset, length) pairs)).

    A actual specialized abstraction to separate arrow and accumulation data, so no bitmap or agnate circuitous data structures would be appropriate for the GC to browse an object.

    Pointers and integers would just be absolutely separated:

     +----------+

     + integers +

     . ... .

     +----------+

     + reflen +

     +----------+ <------ item ptr

     . ... .

     + pointers +

     +----------+

    A arrow to an item consistently credibility into the average of the object. Aloft item ptr, all data is accumulation data, and beneath the item ptr, aggregate is arrow data. The reflen affiliate can be acclimated by the GC to acquisition the admeasurement of the arena it needs to scan.

    Inherited classes just can attach their integer/pointer data above/below the data of the abject address. The reflen affiliate would charge to be set accurately if the item is constructed.

    Although this would be actual fast (as against to bitmaps), it aswell maybe would be actual harder to accommodate into absolute compilers/environments/toolchains. With interrior pointers, the chic arch would be harder to find. Arrays of structs aswell would be a (maybe solvable) problem.

    One aswell could adapt arrow data in regions and hotlink that pointer-data regions like a apart affiliated account (i.e. in attendance of inheritance, area pointers deceit be aggregate into a individual region).

    Every pointer-data arena would alpha with a non-pointer chat absolute the admeasurement of the region, and either the first chat of an item would accommodate a arrow to the first pointer-data region, or the item would alpha with such a arena by itsself.

    Some GC charge to run some cipher anniversary time a advertence is overwritten

    and/or if a advertence is read.

    A adjustable way can be, to accord the compiler an function, to use for read

    and address accesses. These functions should consistently be inlined and

    optimized. e.g.:

     ___ref_assign( abandoned void

    The allocation action of the GC should not alone accept the admeasurement of

    memory, which is required. It should aswell accept a bitfield with the

    information, which words in this anamnesis are references.

    each assemblage anatomy begins with the bitfield with advertence information.

    If the GC scans the stack, the frames accept to be recognized.

    The compiler should ensure, that advertence ethics are consistently present in anamnesis also.

    So the GC do not charge to browse the registers, and it does not charge to understand which one

    contains arrow values.

    Implemented for concurrent. Should be recursive usable. This agency it should plan with a counter. The adverse is incremented with anniversary alarm of attenuate and decremented with calls to enable.

    Implemented for moving/compacting GCs.

    Forces a accumulating cycle. The alarm allotment afterwards the accumulating aeon finished. In a Stop-the-world accomplishing this means, that all accoutrement will pause. In a circumstantial accomplishing not. A advertence counting band-aid will acknowledgment immediatly.

    

 


Tags: address, information, thoughts, programming, memory, start, support

 object, pointer, pointers, needs, reference, stack, support, scans, information, start, memory, referenced, moving, implementations, address, , weak pointers, referenced from, support weak pointers, thoughts about better, collector thoughts about, garbage collector thoughts, programming garbage collector,

Share D Programming Debris beneficiary Thoughts about bigger GC implementations:
Digg it!   Google Bookmarks   Del.icio.us   Yahoo! MyWeb   Furl  Binklist   Reddit!   Stumble Upon   Technorati   Windows Live   Bookmark

Text link code :
Hyper link code:

Also see ...

Permalink
Article In : Computers & Technology  -  Programming