digitalmars.D - Does the spec preclude objects being movable by the GC?
- Ben Davis (7/7) Feb 25 2013 Unless I'm mistaken, this page:
- Ben Davis (3/10) Feb 25 2013 Actually I suppose it's possible for any object affected by that union
- Vladimir Panteleev (8/26) Feb 25 2013 As I understand it, there will always be uncertain references,
Unless I'm mistaken, this page: http://dlang.org/garbage.html states that it's safe to use a union to share storage with a pointer, e.g. union U { void* ptr; int value } But that wouldn't be safe if the GC ever moved objects. Should the page be tweaked? Especially as further down on that page, it says that a moving garbage collector can be implemented if one follows the rules.
Feb 25 2013
On 25/02/2013 23:15, Ben Davis wrote:Unless I'm mistaken, this page: http://dlang.org/garbage.html states that it's safe to use a union to share storage with a pointer, e.g. union U { void* ptr; int value } But that wouldn't be safe if the GC ever moved objects. Should the page be tweaked? Especially as further down on that page, it says that a moving garbage collector can be implemented if one follows the rules.Actually I suppose it's possible for any object affected by that union to be pinned. Is that the intention?
Feb 25 2013
On Monday, 25 February 2013 at 23:17:16 UTC, Ben Davis wrote:On 25/02/2013 23:15, Ben Davis wrote:As I understand it, there will always be uncertain references, such as those found on the stack (esp. stack of C functions) and data segment. Such uncertain references will pin objects they point at, however ideally this would only apply to a small percentage of heap objects. A moving GC in D would only move those objects for which it can be certain that it knows how to safely update all existing references to the object.Unless I'm mistaken, this page: http://dlang.org/garbage.html states that it's safe to use a union to share storage with a pointer, e.g. union U { void* ptr; int value } But that wouldn't be safe if the GC ever moved objects. Should the page be tweaked? Especially as further down on that page, it says that a moving garbage collector can be implemented if one follows the rules.Actually I suppose it's possible for any object affected by that union to be pinned. Is that the intention?
Feb 25 2013