From patchwork Fri Aug 10 16:14:09 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Diego Novillo X-Patchwork-Id: 176522 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 932842C0084 for ; Sat, 11 Aug 2012 02:14:45 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1345220085; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Message-ID:Date:From:User-Agent:MIME-Version: To:CC:Subject:References:In-Reply-To:Content-Type: Content-Transfer-Encoding:Mailing-List:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=tk25aXtvccsCsk8R0ZwLbEX7f5c=; b=awKzQ7WvfEYC0c2 qhbfjBMm5TvpDRjeAX63HgMPRjpwH4iddaJFolO0vdvUr+xXhHGhthwW9Ev3gOPx bchaYI80C/r2DhAcjg8NZgYlRBcTa/MacDXJ2g2TANLY+1BMYjc2cQm+SnlElepm I2JHL55JgSfOqi+CJbA6xigEV/Aw= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:X-Google-DKIM-Signature:Received:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject:References:In-Reply-To:Content-Type:Content-Transfer-Encoding:X-Gm-Message-State:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=JPwonlSlCrkWA7cxFQFTVyWOZWtzH+BWhNQHs5Y+NrRRlouPB/+CM0GAMj1pBi JLFtFgub1qaaP2EexUO6vvvx8TWXGWUf8nhUfTDyWliqRuR4Jz5KY8zMdwH0E8Ie AiT3Tt/61gg1Pa/Zzog4Oy3ZsTJqutIzj1cv1R/Y+NHh0=; Received: (qmail 4845 invoked by alias); 10 Aug 2012 16:14:30 -0000 Received: (qmail 4796 invoked by uid 22791); 10 Aug 2012 16:14:26 -0000 X-SWARE-Spam-Status: No, hits=-5.7 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, KHOP_RCVD_TRUST, KHOP_THREADED, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail-vc0-f175.google.com (HELO mail-vc0-f175.google.com) (209.85.220.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 10 Aug 2012 16:14:13 +0000 Received: by vcbfy27 with SMTP id fy27so1792331vcb.20 for ; Fri, 10 Aug 2012 09:14:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:organization:user-agent:mime-version:to:cc :subject:references:in-reply-to:content-type :content-transfer-encoding:x-gm-message-state; bh=Iblgeqbs6IROho1komgQC/RGk9vSxAuEb2aj45K/fEo=; b=Gyly84n6D08S8ff+D0kVcuEk/s6tlNZ8/tbEQ+oUyURbzb8yQKPCmh7cUBINh80k+/ qBiJjsjNHJCO3QG3ecudmL09xw3IjJf6c4T6qdsUX8HsVqAJo74emYMFZTR+OMge/FrG uvw8PXzL23evwYOjK1BytxT/nriNWmNjokdCF6Xxpa3vIwREnrFEgLTG4aqQV8fWgYZs Aac403g7OS/UFSoRtIhT5bv8XX6coyqbCXpELIKD6aMIhXWfTVCq6k+sqFlxzkpmmNa+ zXMhPyhODTiQIFPKnanm8I1NqjbBMrDk4mp1h4yvgRhvb8SPB9V79oIgiVUZ0WPlhMqr 6e/Q== Received: by 10.220.153.7 with SMTP id i7mr2843550vcw.34.1344615252139; Fri, 10 Aug 2012 09:14:12 -0700 (PDT) Received: by 10.220.153.7 with SMTP id i7mr2843545vcw.34.1344615252038; Fri, 10 Aug 2012 09:14:12 -0700 (PDT) Received: from dnovillo-macbookpro.local ([172.26.45.69]) by mx.google.com with ESMTPS id n12sm3596394vdu.1.2012.08.10.09.14.10 (version=SSLv3 cipher=OTHER); Fri, 10 Aug 2012 09:14:11 -0700 (PDT) Message-ID: <50253351.1030309@google.com> Date: Fri, 10 Aug 2012 12:14:09 -0400 From: Diego Novillo User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:14.0) Gecko/20120713 Thunderbird/14.0 MIME-Version: 1.0 To: Laurynas Biveinis CC: gcc-patches@gcc.gnu.org, Lawrence Crowl Subject: Re: [cxx-conversion] Support garbage-collected C++ templates References: <20120808195258.GA30576@google.com> In-Reply-To: X-Gm-Message-State: ALoCoQnBFANGCMQequxF7PFRiTc1TZpGzfmQfYTklIkOTCfvbslSSZ//W/OOUWWfOzyJv0igyoaMifOZeQ66WsmZ/HLzgaQz0RtHgIy2Ktq8+WRCGklRJr6HQwgcUrYj7uE36DSnMccVAUUooliTqmspcY0hc6/f/snEE9qxwEKaS7r4KEhCewD20ql0KJtgdVSPG0+Uroo5 X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org On 12-08-09 03:12 , Laurynas Biveinis wrote: > Might be also interesting to try valgrind. Good to hear the zone > collector hasn't bitrotten once again. Well, it seems it has now. I just tried --with-gc=zone in trunk and it failed. I have not merged trunk for 2-3 weeks, so something may have broken it in the meantime. > >> * doc/gty.texi: Document support for C++ templates and >> user-provided markers. > > The 1st node in this doc file needs s/C/C++/g and perhaps some more > explanation with an eye on C++. Sorry. I'm not sure what you are trying to say here. I'm adding more details on the user-provided GTY keyword below. Diego. The following code snippets represent all the functions that need to be provided. Note that type @code{TP} may reference to more than one @@ -509,8 +543,6 @@ will, in turn, walk all the pointers inside fields of @code{T}). In the case of @code{TP}, references to @code{T *} must be handled by calling the @code{op} function on the address of the pointer (see the code snippets above). - -@item Only template structures are supported at this time. @end enumerate @node GGC Roots diff --git a/gcc/doc/gty.texi b/gcc/doc/gty.texi index 472738e..2210441 100644 --- a/gcc/doc/gty.texi +++ b/gcc/doc/gty.texi @@ -68,6 +68,7 @@ These don't need to be marked. @menu * GTY Options:: What goes inside a @code{GTY(())}. * GGC Roots:: Making global variables GGC roots. +* User GC:: Adding user-provided GC marking routines. * Files:: How the generated files work. * Invoking the garbage collector:: How to invoke the garbage collector. * Troubleshooting:: When something does not work as expected. @@ -435,20 +436,53 @@ The @code{special} option is used to mark types that have to be dealt with by special case machinery. The parameter is the name of the special case. See @file{gengtype.c} for further details. Avoid adding new special cases unless there is no other alternative. + +@findex user +@item user + +The @code{user} option indicates that the code to mark structure +fields is completely handled by user-provided routines. Section +@ref{User GC} for details on what functions need to be provided. @end table +@node User GC @section Support for user-provided GC marking routines +@cindex user gc The garbage collector supports types for which no automatic marking code is generated. For these types, the user is required to provide four functions: one to act as a marker for garbage collection, and -three functions to act as marker and pointer walking for pre-compiled +two functions to act as marker and pointer walking for pre-compiled headers. -User-provided types are currently supported for C++ template -structures. When a template type @code{TP} is marked with @code{GTY}, -all instances of that type are considered user-provided types. As -such, the user needs to provide template functions to mark all the -fields of the type. +Given a structure @code{struct GTY((user)) my_struct}, the following functions +should be defined to mark @code{my_struct} + +@smallexample +void gt_ggc_mx (my_struct *p) +@{ + /* This marks field 'fld'. */ + gt_ggc_mx (p->fld); +@} + +void gt_pch_nx (my_struct *p) +@{ + /* This marks field 'fld'. */ + gt_pch_nx (tp->fld); +@} + +void gt_pch_nx (my_struct *p, gt_pointer_operator op, void *cookie) +@{ + /* For every field 'fld', call the given pointer operator. */ + op (&(tp->fld), cookie); +@} +@end smallexample + +@section User-provided marking routines for template types +When a template type @code{TP} is marked with @code{GTY}, all +instances of that type are considered user-provided types. This means +that the individual instances of @code{TP} do not need to marked with +@code{GTY}. The user needs to provide template functions to mark all +the fields of the type.