Re: GC and multiple inheritance as in C++
"Jason Whittington" <[email protected]> Fri, 13 Jun 2008 13:46:43 -0500
| Newsgroups | gmane.comp.gnome.mono.garbage-collection |
|---|---|
| Message-ID | <005501c8cd85$d4172450$7c456cf0$@com> |
This is a multipart message in MIME format. --===============0207160247== Content-Type: multipart/alternative; boundary="----=_NextPart_000_0056_01C8CD5B.EB411C50" Content-Language: en-us This is a multipart message in MIME format. ------=_NextPart_000_0056_01C8CD5B.EB411C50 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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: [email protected] [mailto:[email protected]] On Behalf Of Juro Jon Sent: Thursday, June 12, 2008 8:36 PM To: [email protected] 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 <[email protected]> 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) ? ------=_NextPart_000_0056_01C8CD5B.EB411C50 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable <html xmlns:v=3D"urn:schemas-microsoft-com:vml" = xmlns:o=3D"urn:schemas-microsoft-com:office:office" = xmlns:w=3D"urn:schemas-microsoft-com:office:word" = xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" = xmlns=3D"http://www.w3.org/TR/REC-html40"> <head> <meta http-equiv=3DContent-Type content=3D"text/html; = charset=3Dus-ascii"> <meta name=3DGenerator content=3D"Microsoft Word 12 (filtered medium)"> <style> <!-- /* Font Definitions */ @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4;} @font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4;} @font-face {font-family:Tahoma; panose-1:2 11 6 4 3 5 4 4 2 4;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {margin:0in; margin-bottom:.0001pt; font-size:12.0pt; font-family:"Times New Roman","serif";} a:link, span.MsoHyperlink {mso-style-priority:99; color:blue; text-decoration:underline;} a:visited, span.MsoHyperlinkFollowed {mso-style-priority:99; color:purple; text-decoration:underline;} span.EmailStyle17 {mso-style-type:personal-reply; font-family:"Calibri","sans-serif"; color:#1F497D;} .MsoChpDefault {mso-style-type:export-only;} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.0in 1.0in 1.0in;} div.Section1 {page:Section1;} --> </style> <!--[if gte mso 9]><xml> <o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" /> </xml><![endif]--><!--[if gte mso 9]><xml> <o:shapelayout v:ext=3D"edit"> <o:idmap v:ext=3D"edit" data=3D"1" /> </o:shapelayout></xml><![endif]--> </head> <body lang=3DEN-US link=3Dblue vlink=3Dpurple> <div class=3DSection1> <p class=3DMsoNormal><span = style=3D'font-size:11.0pt;font-family:"Calibri","sans-serif"; color:#1F497D'>I believe the answer here is: “no”. = MI languages have to find a way to fake it.<o:p></o:p></span></p> <p class=3DMsoNormal><span = style=3D'font-size:11.0pt;font-family:"Calibri","sans-serif"; color:#1F497D'><o:p> </o:p></span></p> <p class=3DMsoNormal><span = style=3D'font-size:11.0pt;font-family:"Calibri","sans-serif"; color:#1F497D'>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.<o:p></o:p></span></p> <p class=3DMsoNormal><span = style=3D'font-size:11.0pt;font-family:"Calibri","sans-serif"; color:#1F497D'><o:p> </o:p></span></p> <p class=3DMsoNormal><span = style=3D'font-size:11.0pt;font-family:"Calibri","sans-serif"; color:#1F497D'>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.<o:p></o:p></span></p> <p class=3DMsoNormal><span = style=3D'font-size:11.0pt;font-family:"Calibri","sans-serif"; color:#1F497D'><o:p> </o:p></span></p> <p class=3DMsoNormal><span = style=3D'font-size:11.0pt;font-family:"Calibri","sans-serif"; color:#1F497D'>Jason<o:p></o:p></span></p> <p class=3DMsoNormal><span = style=3D'font-size:11.0pt;font-family:"Calibri","sans-serif"; color:#1F497D'><o:p> </o:p></span></p> <p class=3DMsoNormal><span = style=3D'font-size:11.0pt;font-family:"Calibri","sans-serif"; color:#1F497D'><o:p> </o:p></span></p> <div style=3D'border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt = 0in 0in 0in'> <p class=3DMsoNormal><b><span = style=3D'font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span>= </b><span style=3D'font-size:10.0pt;font-family:"Tahoma","sans-serif"'> [email protected] [mailto:[email protected]] <b>On Behalf Of </b>Juro = Jon<br> <b>Sent:</b> Thursday, June 12, 2008 8:36 PM<br> <b>To:</b> [email protected]<br> <b>Subject:</b> Re: [Mono-gc-list] GC and multiple inheritance as in = C++<o:p></o:p></span></p> </div> <p class=3DMsoNormal><o:p> </o:p></p> <p class=3DMsoNormal style=3D'margin-bottom:12.0pt'>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?<br> <br> Thanks<o:p></o:p></p> <div> <p class=3DMsoNormal>On Fri, Jun 13, 2008 at 3:50 AM, David Jeske <<a href=3D"mailto:[email protected]">[email protected]</a>> = wrote:<o:p></o:p></p> <p class=3DMsoNormal>AFAIK, you don't need C++ MI to have a pointer to = something inside an object<br> body. This can happen if you take a ref of any instance data in C#.<br> <br> <a href=3D"http://www.java2s.com/Code/CSharp/Language-Basics/CRefandOutParam= eters.htm" target=3D"_blank">http://www.java2s.com/Code/CSharp/Language-Basics/CRefa= ndOutParameters.htm</a><o:p></o:p></p> <div> <div> <p class=3DMsoNormal><br> -- Juro Jon wrote:<br> > Hello, I have a question concerning implementation of multiple = inheritance in<br> > CIL. For a C++ MI object, a pointer can points to inside the object = body<br> > instead of the its head. eg.<br> > struct A : B, C { }; C* c =3D new A;<br> > While Boehm GC detects this kind of reference, is it a supported = feature of<br> > Mono? If not, what is the suggested way to implement it (eg. what = is the<br> > C++/CLI way) ?<o:p></o:p></p> </div> </div> </div> <p class=3DMsoNormal><o:p> </o:p></p> </div> </body> </html> ------=_NextPart_000_0056_01C8CD5B.EB411C50-- --===============0207160247== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Mono-gc-list maillist - [email protected] http://lists.ximian.com/mailman/listinfo/mono-gc-list --===============0207160247==--