digitalmars.D - GC API: What can change for precise scanning?
- dsimcha (27/27) Apr 17 2012 Now that the compiler infrastructure has been implemented, I've
- deadalnix (5/30) Apr 18 2012 I guess that the flag to indicate if some piece of memory may have
- =?UTF-8?B?QWxleCBSw7hubmUgUGV0ZXJzZW4=?= (4/37) Apr 18 2012 --
- Walter Bright (3/5) Apr 18 2012 The purpose of the indirection is so that DLLs in Windows can share a gc...
- Sean Kelly (5/7) Apr 18 2012 wonder why most of theses functions are extern(C).
- deadalnix (3/7) Apr 18 2012 I know, but this is now impossible anyway because of the modification of...
- Sean Kelly (7/15) Apr 18 2012 at link-time. Similar to how the compiler runtime code hides behind a =
- deadalnix (5/15) Apr 18 2012 No it doesn't break GC behind C functions. It break the possibility of
- Timon Gehr (2/25) Apr 18 2012 The indirection is there for better shared library support.
- =?UTF-8?B?QWxleCBSw7hubmUgUGV0ZXJzZW4=?= (13/38) Apr 18 2012 This is not specifically an answer to your question, but my opinion on
- Walter Bright (7/30) Apr 18 2012 1. I would not try to redesign everything and do precise gc at the same ...
- Sean Kelly (29/62) Apr 18 2012 I think I'm
- dsimcha (7/8) Apr 18 2012 Or, failing that, I can look at it to get ideas about how to handle
- Sean Kelly (5/7) Apr 18 2012 TypeInfo into the guts of the GC where they can be acted on?
Now that the compiler infrastructure has been implemented, I've gotten busy figuring out how to make D's default GC precise. As a first attempt, I think I'm going to adapt my original solution from http://d.puremagic.com/issues/show_bug.cgi?id=3463 since it's simple and it works except that there previously was no clean way to get the offset info into the GC. As Walter pointed out in another thread, the GCInfo template is allowed to instantiate to data instead of a function. IMHO unless/until major architectural changes to the GC are made that require a function pointer, there's no point in adding this indirection. I started working on this and I ran into a roadblock. I need to know what parts of the GC API are allowed to change, and discuss how to abstract away the implementation of it from the GC API. I assume the stuff in core.memory needs to stay mostly the same, though I guess we would need to add a setType() function that takes a pointer into a block of memory and a TypeInfo object and changes how the GC interprets the bits in the block. In gc.d, we define a bunch of extern(C) functions and the proxy thing. Since we've given up on the idea of swapping precise GCs at link time, can I just rip out all this unnecesary indirection? If not, is it ok to change some of these signatures? I definitely want to avoid allocating (requiring the GC lock) and then calling a function to set the type (requiring another lock acquisition) so the signature of malloc(), etc. needs to change somewhere. More generally, what is the intended way to get GCInfo pointers from TypeInfo into the guts of the GC where they can be acted on?
Apr 17 2012
Le 18/04/2012 02:36, dsimcha a écrit :Now that the compiler infrastructure has been implemented, I've gotten busy figuring out how to make D's default GC precise. As a first attempt, I think I'm going to adapt my original solution from http://d.puremagic.com/issues/show_bug.cgi?id=3463 since it's simple and it works except that there previously was no clean way to get the offset info into the GC. As Walter pointed out in another thread, the GCInfo template is allowed to instantiate to data instead of a function. IMHO unless/until major architectural changes to the GC are made that require a function pointer, there's no point in adding this indirection. I started working on this and I ran into a roadblock. I need to know what parts of the GC API are allowed to change, and discuss how to abstract away the implementation of it from the GC API. I assume the stuff in core.memory needs to stay mostly the same, though I guess we would need to add a setType() function that takes a pointer into a block of memory and a TypeInfo object and changes how the GC interprets the bits in the block. In gc.d, we define a bunch of extern(C) functions and the proxy thing. Since we've given up on the idea of swapping precise GCs at link time, can I just rip out all this unnecesary indirection? If not, is it ok to change some of these signatures? I definitely want to avoid allocating (requiring the GC lock) and then calling a function to set the type (requiring another lock acquisition) so the signature of malloc(), etc. needs to change somewhere. More generally, what is the intended way to get GCInfo pointers from TypeInfo into the guts of the GC where they can be acted on?I guess that the flag to indicate if some piece of memory may have pointer can go away. I think you certainly can remove all indirection. Additionally, I wonder why most of theses functions are extern(C).
Apr 18 2012
On 18-04-2012 11:56, deadalnix wrote:Le 18/04/2012 02:36, dsimcha a écrit :+1. This is useless if we're going to use bitmaps or similar.Now that the compiler infrastructure has been implemented, I've gotten busy figuring out how to make D's default GC precise. As a first attempt, I think I'm going to adapt my original solution from http://d.puremagic.com/issues/show_bug.cgi?id=3463 since it's simple and it works except that there previously was no clean way to get the offset info into the GC. As Walter pointed out in another thread, the GCInfo template is allowed to instantiate to data instead of a function. IMHO unless/until major architectural changes to the GC are made that require a function pointer, there's no point in adding this indirection. I started working on this and I ran into a roadblock. I need to know what parts of the GC API are allowed to change, and discuss how to abstract away the implementation of it from the GC API. I assume the stuff in core.memory needs to stay mostly the same, though I guess we would need to add a setType() function that takes a pointer into a block of memory and a TypeInfo object and changes how the GC interprets the bits in the block. In gc.d, we define a bunch of extern(C) functions and the proxy thing. Since we've given up on the idea of swapping precise GCs at link time, can I just rip out all this unnecesary indirection? If not, is it ok to change some of these signatures? I definitely want to avoid allocating (requiring the GC lock) and then calling a function to set the type (requiring another lock acquisition) so the signature of malloc(), etc. needs to change somewhere. More generally, what is the intended way to get GCInfo pointers from TypeInfo into the guts of the GC where they can be acted on?I guess that the flag to indicate if some piece of memory may have pointer can go away.I think you certainly can remove all indirection. Additionally, I wonder why most of theses functions are extern(C).-- - Alex
Apr 18 2012
On 4/18/2012 2:56 AM, deadalnix wrote:I think you certainly can remove all indirection. Additionally, I wonder why most of theses functions are extern(C).The purpose of the indirection is so that DLLs in Windows can share a gc instance, rather than having two instances fight each other.
Apr 18 2012
On Apr 18, 2012, at 2:56 AM, deadalnix wrote:=20 I think you certainly can remove all indirection. Additionally, I =wonder why most of theses functions are extern(C). So the GC implementation is opaque and the GC can therefore be chosen at = link-time. Similar to how the compiler runtime code hides behind a raft = of extern=A9 functions.=
Apr 18 2012
Le 18/04/2012 20:53, Sean Kelly a écrit :On Apr 18, 2012, at 2:56 AM, deadalnix wrote:I know, but this is now impossible anyway because of the modification of TypeInfo anyway.I think you certainly can remove all indirection. Additionally, I wonder why most of theses functions are extern(C).So the GC implementation is opaque and the GC can therefore be chosen at link-time. Similar to how the compiler runtime code hides behind a raft of extern© functions.
Apr 18 2012
On Apr 18, 2012, at 4:02 PM, deadalnix wrote:Le 18/04/2012 20:53, Sean Kelly a =E9crit :wonder why most of theses functions are extern(C).On Apr 18, 2012, at 2:56 AM, deadalnix wrote:=20 I think you certainly can remove all indirection. Additionally, I =at link-time. Similar to how the compiler runtime code hides behind a = raft of extern=A9 functions.=20 So the GC implementation is opaque and the GC can therefore be chosen ==20 I know, but this is now impossible anyway because of the modification =of TypeInfo anyway. I'm not sure I follow. Are you saying the change breaks having the GC = behind extern C functions? How?
Apr 18 2012
Le 19/04/2012 02:08, Sean Kelly a écrit :On Apr 18, 2012, at 4:02 PM, deadalnix wrote:No it doesn't break GC behind C functions. It break the possibility of changing GC at link time, because different GC needs different data generated in TypeInfo. So the indirection become useless.Le 18/04/2012 20:53, Sean Kelly a écrit :I'm not sure I follow. Are you saying the change breaks having the GC behind extern C functions? How?On Apr 18, 2012, at 2:56 AM, deadalnix wrote:I know, but this is now impossible anyway because of the modification of TypeInfo anyway.I think you certainly can remove all indirection. Additionally, I wonder why most of theses functions are extern(C).So the GC implementation is opaque and the GC can therefore be chosen at link-time. Similar to how the compiler runtime code hides behind a raft of extern© functions.
Apr 18 2012
On 04/19/2012 02:21 AM, deadalnix wrote:Le 19/04/2012 02:08, Sean Kelly a écrit :The indirection is there for better shared library support.On Apr 18, 2012, at 4:02 PM, deadalnix wrote:No it doesn't break GC behind C functions. It break the possibility of changing GC at link time, because different GC needs different data generated in TypeInfo. So the indirection become useless.Le 18/04/2012 20:53, Sean Kelly a écrit :I'm not sure I follow. Are you saying the change breaks having the GC behind extern C functions? How?On Apr 18, 2012, at 2:56 AM, deadalnix wrote:I know, but this is now impossible anyway because of the modification of TypeInfo anyway.I think you certainly can remove all indirection. Additionally, I wonder why most of theses functions are extern(C).So the GC implementation is opaque and the GC can therefore be chosen at link-time. Similar to how the compiler runtime code hides behind a raft of extern© functions.
Apr 18 2012
On 18-04-2012 02:36, dsimcha wrote:Now that the compiler infrastructure has been implemented, I've gotten busy figuring out how to make D's default GC precise. As a first attempt, I think I'm going to adapt my original solution from http://d.puremagic.com/issues/show_bug.cgi?id=3463 since it's simple and it works except that there previously was no clean way to get the offset info into the GC. As Walter pointed out in another thread, the GCInfo template is allowed to instantiate to data instead of a function. IMHO unless/until major architectural changes to the GC are made that require a function pointer, there's no point in adding this indirection. I started working on this and I ran into a roadblock. I need to know what parts of the GC API are allowed to change, and discuss how to abstract away the implementation of it from the GC API. I assume the stuff in core.memory needs to stay mostly the same, though I guess we would need to add a setType() function that takes a pointer into a block of memory and a TypeInfo object and changes how the GC interprets the bits in the block. In gc.d, we define a bunch of extern(C) functions and the proxy thing. Since we've given up on the idea of swapping precise GCs at link time, can I just rip out all this unnecesary indirection? If not, is it ok to change some of these signatures? I definitely want to avoid allocating (requiring the GC lock) and then calling a function to set the type (requiring another lock acquisition) so the signature of malloc(), etc. needs to change somewhere. More generally, what is the intended way to get GCInfo pointers from TypeInfo into the guts of the GC where they can be acted on?This is not specifically an answer to your question, but my opinion on this subject is that altering the GC API without a deprecation process or similar is fine. This is a core component of the runtime, and I don't think expecting a stable API for something like a garbage collector of all things is reasonable in the first place. That said, I do think functionality has to be maintained. That is, if the GC can do something in a previous version, it should be able to do it in the subsequent version too. *How* that something is achieved in the subsequent version isn't so important, as long as the functionality is *there* in some way. -- - Alex
Apr 18 2012
On 4/17/2012 5:36 PM, dsimcha wrote:Now that the compiler infrastructure has been implemented, I've gotten busy figuring out how to make D's default GC precise. As a first attempt, I think I'm going to adapt my original solution from http://d.puremagic.com/issues/show_bug.cgi?id=3463 since it's simple and it works except that there previously was no clean way to get the offset info into the GC. As Walter pointed out in another thread, the GCInfo template is allowed to instantiate to data instead of a function. IMHO unless/until major architectural changes to the GC are made that require a function pointer, there's no point in adding this indirection. I started working on this and I ran into a roadblock. I need to know what parts of the GC API are allowed to change, and discuss how to abstract away the implementation of it from the GC API. I assume the stuff in core.memory needs to stay mostly the same, though I guess we would need to add a setType() function that takes a pointer into a block of memory and a TypeInfo object and changes how the GC interprets the bits in the block. In gc.d, we define a bunch of extern(C) functions and the proxy thing. Since we've given up on the idea of swapping precise GCs at link time, can I just rip out all this unnecesary indirection? If not, is it ok to change some of these signatures? I definitely want to avoid allocating (requiring the GC lock) and then calling a function to set the type (requiring another lock acquisition) so the signature of malloc(), etc. needs to change somewhere. More generally, what is the intended way to get GCInfo pointers from TypeInfo into the guts of the GC where they can be acted on?1. I would not try to redesign everything and do precise gc at the same time. 2. The purpose of the indirection is to support DLLs so that the different DLLs can share an instance. 3. The reason for function pointers for marking is so that the marking code can be customized and directly inlined, rather than decoding a table. It costs one code indirection, but after that it cannot be beaten for speed.
Apr 18 2012
On Apr 18, 2012, at 1:13 PM, Walter Bright wrote:On 4/17/2012 5:36 PM, dsimcha wrote:gotten busyNow that the compiler infrastructure has been implemented, I've =I think I'mfiguring out how to make D's default GC precise. As a first attempt, =simple and itgoing to adapt my original solution from http://d.puremagic.com/issues/show_bug.cgi?id=3D3463 since it's =info intoworks except that there previously was no clean way to get the offset =is allowedthe GC. As Walter pointed out in another thread, the GCInfo template =pointer,to instantiate to data instead of a function. IMHO unless/until major architectural changes to the GC are made that require a function =what partsthere's no point in adding this indirection. =20 I started working on this and I ran into a roadblock. I need to know =theof the GC API are allowed to change, and discuss how to abstract away =core.memory needs toimplementation of it from the GC API. I assume the stuff in =functionstay mostly the same, though I guess we would need to add a setType() =changesthat takes a pointer into a block of memory and a TypeInfo object and =thing. Sincehow the GC interprets the bits in the block. =20 In gc.d, we define a bunch of extern(C) functions and the proxy =I just ripwe've given up on the idea of swapping precise GCs at link time, can =of theseout all this unnecesary indirection? If not, is it ok to change some =lock) andsignatures? I definitely want to avoid allocating (requiring the GC =acquisition) sothen calling a function to set the type (requiring another lock =TypeInfothe signature of malloc(), etc. needs to change somewhere. =20 More generally, what is the intended way to get GCInfo pointers from =same time.into the guts of the GC where they can be acted on?=20 1. I would not try to redesign everything and do precise gc at the ==20 2. The purpose of the indirection is to support DLLs so that the =different DLLs can share an instance.=20 3. The reason for function pointers for marking is so that the marking =code can be customized and directly inlined, rather than decoding a = table. It costs one code indirection, but after that it cannot be beaten = for speed. Leandro's GC (CDGC) is already set up to support precise scanning. It's = in the Druntime git repository, but lacks the features added to the = Druntime GC compared to the Tango GC on which CDGC is based. Still, it = may be easier to update CDGC based on a diff between the Druntime and = Tango GC than it would to add precise scanning to the GC Druntime = currently uses. Worth a look if anyone is interested anyway.
Apr 18 2012
On 4/18/2012 6:46 PM, Sean Kelly wrote:Leandro's GC (CDGC) is already set up to support precise scanning. It's in the Druntime git repository, but lacks the features added to the Druntime GC compared to the Tango GC on which CDGC is based. Still, it may be easier to update CDGC based on a diff between the Druntime and Tango GC than it would to add precise scanning to the GC Druntime currently uses. Worth a look if anyone is interested anyway.Or, failing that, I can look at it to get ideas about how to handle various annoying plumbing issues. The plumbing issues (i.e. getting the GCInfo pointers from the allocation routines into the guts of the GC) are actually the hard part of this project. Once the GC has the the GCInfo pointer, making it use that for precise scanning is trivial in that I've done it before and remember roughly how I did it.
Apr 18 2012
On Apr 17, 2012, at 5:36 PM, dsimcha wrote:=20 More generally, what is the intended way to get GCInfo pointers from =TypeInfo into the guts of the GC where they can be acted on? I just resurrected an old thread titled "Proposed changes to the GC = interface" in the Druntime mailing list. Perhaps we could pick up = discussion there?
Apr 18 2012