From jurojon at gmail.com Thu Jun 12 04:18:37 2008 From: jurojon at gmail.com (Juro Jon) Date: Thu, 12 Jun 2008 01:18:37 -0700 (PDT) Subject: [Mono-gc-list] GC and multiple inheritance as in C++ Message-ID: <17769541.post@talk.nabble.com> Hello, I have a question concerning implementation of multiple inheritance in CIL. For a C++ MI object, a pointer can points to inside the object body instead of the its head. eg. struct A : B, C { }; C* c = new A; While Boehm GC detects this kind of reference, is it a supported feature of Mono? If not, what is the suggested way to implement it (eg. what is the C++/CLI way) ? Thanks you -- View this message in context: http://www.nabble.com/GC-and-multiple-inheritance-as-in-C%2B%2B-tp17769541p17769541.html Sent from the Mono - Garbage Collection mailing list archive at Nabble.com. From jurojon at gmail.com Thu Jun 12 21:36:22 2008 From: jurojon at gmail.com (Juro Jon) Date: Fri, 13 Jun 2008 11:36:22 +1000 Subject: [Mono-gc-list] GC and multiple inheritance as in C++ In-Reply-To: References: <17769541.post@talk.nabble.com> Message-ID: <3ca2f2b20806121836p29a4b5dfv27b186dd54a9a52d@mail.gmail.com> I don't know much of CLI specification so I may be missing something trivial. Java GC assumes that all pointers point to some "header" to identity the memory object. Since Java is single inheritance a pointer always points to the head of a full object, but for C++ multiple inheritance it may be pointing to an embedded part and need to be adjusted to find the full object. Are you saying that the CLI GC or typesystem has some way to do this adjustment? Thanks On Fri, Jun 13, 2008 at 3:50 AM, David Jeske wrote: > AFAIK, you don't need C++ MI to have a pointer to something inside an > object > body. This can happen if you take a ref of any instance data in C#. > > http://www.java2s.com/Code/CSharp/Language-Basics/CRefandOutParameters.htm > > -- Juro Jon wrote: > > Hello, I have a question concerning implementation of multiple > inheritance in > > CIL. For a C++ MI object, a pointer can points to inside the object body > > instead of the its head. eg. > > struct A : B, C { }; C* c = new A; > > While Boehm GC detects this kind of reference, is it a supported feature > of > > Mono? If not, what is the suggested way to implement it (eg. what is the > > C++/CLI way) ? > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.ximian.com/pipermail/mono-gc-list/attachments/20080613/41b4f4b4/attachment-0001.html From jasonw at develop.com Fri Jun 13 14:46:43 2008 From: jasonw at develop.com (Jason Whittington) Date: Fri, 13 Jun 2008 13:46:43 -0500 Subject: [Mono-gc-list] GC and multiple inheritance as in C++ In-Reply-To: <3ca2f2b20806121836p29a4b5dfv27b186dd54a9a52d@mail.gmail.com> References: <17769541.post@talk.nabble.com> <3ca2f2b20806121836p29a4b5dfv27b186dd54a9a52d@mail.gmail.com> Message-ID: <005501c8cd85$d4172450$7c456cf0$@com> I believe the answer here is: "no". MI languages have to find a way to fake it. Microsoft's C++/CLI fakes it by not allowing MI for managed types. MI classes are represented as value types in the CLI and thus don't behave with "true" polymorphism. They do in the sense that C++ code compiled together works correctly, but to other languages the inheritance is opaque - calling GetType().BaseType will just yield System.ValueType. The CLR port of Eiffel fakes it by using a [somewhat complex and arcane] scheme where inheritance in Eiffel is modeled with interfaces in .NET. Jason From: mono-gc-list-bounces at lists.ximian.com [mailto:mono-gc-list-bounces at lists.ximian.com] On Behalf Of Juro Jon Sent: Thursday, June 12, 2008 8:36 PM To: mono-gc-list at lists.ximian.com Subject: Re: [Mono-gc-list] GC and multiple inheritance as in C++ I don't know much of CLI specification so I may be missing something trivial. Java GC assumes that all pointers point to some "header" to identity the memory object. Since Java is single inheritance a pointer always points to the head of a full object, but for C++ multiple inheritance it may be pointing to an embedded part and need to be adjusted to find the full object. Are you saying that the CLI GC or typesystem has some way to do this adjustment? Thanks On Fri, Jun 13, 2008 at 3:50 AM, David Jeske wrote: AFAIK, you don't need C++ MI to have a pointer to something inside an object body. This can happen if you take a ref of any instance data in C#. http://www.java2s.com/Code/CSharp/Language-Basics/CRefandOutParameters.htm -- Juro Jon wrote: > Hello, I have a question concerning implementation of multiple inheritance in > CIL. For a C++ MI object, a pointer can points to inside the object body > instead of the its head. eg. > struct A : B, C { }; C* c = new A; > While Boehm GC detects this kind of reference, is it a supported feature of > Mono? If not, what is the suggested way to implement it (eg. what is the > C++/CLI way) ? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.ximian.com/pipermail/mono-gc-list/attachments/20080613/2e2e09ae/attachment.html From jeske at willowmail.com Thu Jun 12 13:50:56 2008 From: jeske at willowmail.com (David Jeske) Date: Thu, 12 Jun 2008 17:50:56 -0000 Subject: [Mono-gc-list] GC and multiple inheritance as in C++ In-Reply-To: <17769541.post@talk.nabble.com> References: <17769541.post@talk.nabble.com> Message-ID: AFAIK, you don't need C++ MI to have a pointer to something inside an object body. This can happen if you take a ref of any instance data in C#. http://www.java2s.com/Code/CSharp/Language-Basics/CRefandOutParameters.htm -- Juro Jon wrote: > Hello, I have a question concerning implementation of multiple inheritance in > CIL. For a C++ MI object, a pointer can points to inside the object body > instead of the its head. eg. > struct A : B, C { }; C* c = new A; > While Boehm GC detects this kind of reference, is it a supported feature of > Mono? If not, what is the suggested way to implement it (eg. what is the > C++/CLI way) ? From jeske at willowmail.com Thu Jun 12 21:40:42 2008 From: jeske at willowmail.com (David Jeske) Date: Fri, 13 Jun 2008 01:40:42 -0000 Subject: [Mono-gc-list] GC and multiple inheritance as in C++ In-Reply-To: <3ca2f2b20806121836p29a4b5dfv27b186dd54a9a52d@mail.gmail.com> References: <3ca2f2b20806121836p29a4b5dfv27b186dd54a9a52d@mail.gmail.com> Message-ID: I think my optimism may have got the better of me. The CLR has a mechanism to handle internal references, but I don't believe this answers your question or solves your issue. The CLI GC handles interior references to objects even in C# for "byref" paramaters, but only for interior references on the stack. Here are some potentially useful references: (see the bottom of this for comments on Rotor) http://blogs.msdn.com/joelpob/archive/2004/02/26/80776.aspx http://ksrenevasan.blogspot.com/2005/08/incomplete-rotor-gc-notes.html Partition I, section 12.4.1.5.2, it talks about byref and lifetimes. Partition II, section 12, it talks about interfaces and mentions MI. ---- However, it occurs to me that in C++ MI you may need interior pointers that are not on the stack. Your concern may be well-founded, as the snippets I can find only talk about Rotor tracing interior references which are on the stack. Perhaps someone with more knowledge can offer a more complete (or accurate) answer. -- Juro Jon wrote: > I don't know much of CLI specification so I may be missing something > trivial. Java GC assumes that all pointers point to some "header" to > identity the memory object. Since Java is single inheritance a pointer > always points to the head of a full object, but for C++ multiple inheritance > it may be pointing to an embedded part and need to be adjusted to find the > full object. Are you saying that the CLI GC or typesystem has some way to do > this adjustment?