From patchwork Tue Jun 12 11:09:37 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 164391 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 6A1AEB6FB6 for ; Tue, 12 Jun 2012 21:10:06 +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=1340104206; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Date:From:To:Cc:Subject:Message-ID: MIME-Version:Content-Type:Content-Disposition:User-Agent: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=PhKPFAx1p3wIc852DZHG q0YnzMs=; b=efcyLSe16N+kZL5KZmoLZNu2i02+gviDBTjgl85HayK995XRe0O8 9CjsmIT+aBdyAxcGQwFLG3Ob0qhlQO1Ie+eFXx9WCP26bVMQsPais4P+Y/iMk+r/ c3urqFA+QfTeq958pG3B5wIfhpvTopZd8XmgIxdo6rkszWpSnLE4qBM= 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:Received:Received:Received:Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type:Content-Disposition:User-Agent:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=c2ombYGVattFj/fMUg6YnYk5Ho9bUnPH9xZlWhr5VjmIRLq+AVYxWv7hLC359Q 14eN4LR3Fn3RkFe8hiF7Jf0lwuTPJ+xISrc5nCpt5x3+R4MRB05JHHPwGG5nyxIx ITRbxcSmyRQFQ3Nv+6zkUaMNozs3yH67yDIVXz6e4y0k8=; Received: (qmail 11982 invoked by alias); 12 Jun 2012 11:09:52 -0000 Received: (qmail 11753 invoked by uid 22791); 12 Jun 2012 11:09:50 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_HOSTKARMA_NO X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 12 Jun 2012 11:09:38 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 757211C6E42; Tue, 12 Jun 2012 07:09:37 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id Pf3Beunx4lwr; Tue, 12 Jun 2012 07:09:37 -0400 (EDT) Received: from kwai.gnat.com (kwai.gnat.com [205.232.38.4]) by rock.gnat.com (Postfix) with ESMTP id 5363A1C6E3E; Tue, 12 Jun 2012 07:09:37 -0400 (EDT) Received: by kwai.gnat.com (Postfix, from userid 4192) id 5101D3FEE8; Tue, 12 Jun 2012 07:09:37 -0400 (EDT) Date: Tue, 12 Jun 2012 07:09:37 -0400 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Vincent Celier Subject: [Ada] Avoid memory exhaustion when using gnatmake -m Message-ID: <20120612110937.GA5402@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) 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 In large systems, gnatmake may crash when invoked with -m (minimal recompilation) when there are many sources that have been modified but have kept the same checksum. This patch fixes this. There is no simple test. Tested on x86_64-pc-linux-gnu, committed on trunk 2012-06-12 Vincent Celier * ali-util.adb (Time_Stamp_Mismatch): In minimal recompilation mode, use Stringt Mark and Release to avoid growing the Stringt internal tables uselessly. * stringt.adb (Strings_Last): New global variable (String_Chars_Last): New global variable. (Mark, Release): New procedures. * stringt.ads (Mark, Release) New procedures. Index: ali-util.adb =================================================================== --- ali-util.adb (revision 188428) +++ ali-util.adb (working copy) @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2011, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2012, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -32,6 +32,7 @@ with Scng; with Sinput.C; with Snames; use Snames; +with Stringt; with Styleg; package body ALI.Util is @@ -476,6 +477,8 @@ -- ??? It is probably worth updating the ALI file with a new -- field to avoid recomputing it each time. + Stringt.Mark; + if Checksums_Match (Get_File_Checksum (Sdep.Table (D).Sfile), Source.Table (Src).Checksum) @@ -491,6 +494,8 @@ Sdep.Table (D).Stamp := Source.Table (Src).Stamp; end if; + Stringt.Release; + end if; if (not Read_Only) or else Source.Table (Src).Source_Found then Index: stringt.adb =================================================================== --- stringt.adb (revision 188428) +++ stringt.adb (working copy) @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2009, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2012, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -70,6 +70,12 @@ -- when Start_String is called with a parameter that is the last string -- currently allocated in the table. + Strings_Last : String_Id := First_String_Id; + String_Chars_Last : Int := 0; + -- Strings_Last and String_Chars_Last are used by procedure Mark and + -- Release to get a snapshot of the tables and to restore them to their + -- previous situation. + ------------------------------- -- Add_String_To_Name_Buffer -- ------------------------------- @@ -129,6 +135,26 @@ Strings.Release; end Lock; + ---------- + -- Mark -- + ---------- + + procedure Mark is + begin + Strings_Last := Strings.Last; + String_Chars_Last := String_Chars.Last; + end Mark; + + ------------- + -- Release -- + ------------- + + procedure Release is + begin + Strings.Set_Last (Strings_Last); + String_Chars.Set_Last (String_Chars_Last); + end Release; + ------------------ -- Start_String -- ------------------ Index: stringt.ads =================================================================== --- stringt.ads (revision 188428) +++ stringt.ads (working copy) @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 1992-2009, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2012, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -62,6 +62,14 @@ procedure Unlock; -- Unlock internal tables, in case back end needs to modify them + procedure Mark; + -- Take a snapshot of the internal tables + + procedure Release; + -- Restore the internal tables to the situation when Mark was last called. + -- Mark and Release are used when getting checksums of sources in minimal + -- recompilation mode, to reduce memory usage. + procedure Start_String; -- Sets up for storing a new string in the table. To store a string, a -- call is first made to Start_String, then successive calls are