From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 61368 invoked by alias); 18 Jun 2016 19:46:42 -0000 Mailing-List: contact fortran-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: fortran-owner@gcc.gnu.org Received: (qmail 61339 invoked by uid 89); 18 Jun 2016 19:46:41 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=compromise, repdotnopgmailcom, resistance, rep.dot.nop@gmail.com X-Spam-User: qpsmtpd, 2 recipients X-HELO: mail-wm0-f54.google.com Received: from mail-wm0-f54.google.com (HELO mail-wm0-f54.google.com) (74.125.82.54) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Sat, 18 Jun 2016 19:46:38 +0000 Received: by mail-wm0-f54.google.com with SMTP id v199so24987005wmv.0; Sat, 18 Jun 2016 12:46:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:user-agent:in-reply-to:references:mime-version :content-transfer-encoding:subject:from:date:to:cc:message-id; bh=BvpbE/+LVNxDxn0uBQXcjUe6WCoJQD0ZE2G0Uw+y79I=; b=i8W6q/Ai4w+7z+w9wfyMovNOTG1CUDiQDAtikxsiLdDiHT9MRXNtbiHY7MMwQSc66x o8eyL0mjXwhFsRZZEGUXWY4P3j4x/uxOTU5heuQ0T1Kx0nqJkyO7iUopLpm1d2C9MRWm BdK1Kz6eWXIOdtu6z/cwDEajWVC2XTOkyFZ5JXA8enkohdLIKjNinpk03u9yYBO5J56C E2lx9jICDYj0WMJG3Y7VUa+mFZau+Em/3jS0jY+P0XZ7jNlu53S3HNctmGB2q2c0Gd+B abtA5qDP+1Or9Lac8MBxl9AuPlbUD1ejB88jqL6kR521tQTvtnuweFiSoyMzmxCrBwEW 5Ciw== X-Gm-Message-State: ALyK8tJYdw/8jgNj4SSPaVYj0M0tbVdDI4k6vNTfJqA2tyAUhaMt9YsyAdP5MKDyXbtjZA== X-Received: by 10.194.39.202 with SMTP id r10mr7378124wjk.93.1466279194911; Sat, 18 Jun 2016 12:46:34 -0700 (PDT) Received: from [10.45.252.35] (089144230035.atnat0039.highway.a1.net. [89.144.230.35]) by smtp.gmail.com with ESMTPSA id r16sm5102954wmb.23.2016.06.18.12.46.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Jun 2016 12:46:34 -0700 (PDT) User-Agent: K-9 Mail for Android In-Reply-To: References: <1448974501-30981-1-git-send-email-rep.dot.nop@gmail.com> <1448974501-30981-2-git-send-email-rep.dot.nop@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Subject: Re: [PATCH] Derive interface buffers from max name length From: Bernhard Reutner-Fischer Date: Sat, 18 Jun 2016 19:46:00 -0000 To: Janne Blomqvist CC: Fortran List ,GCC Patches Message-ID: <84A89967-93B1-47B5-8312-3BC999FEF0EA@gmail.com> X-IsSubscribed: yes X-SW-Source: 2016-06/txt/msg00048.txt.bz2 On December 3, 2015 10:46:09 AM GMT+01:00, Janne Blomqvist wrote: >On Tue, Dec 1, 2015 at 6:51 PM, Bernhard Reutner-Fischer > wrote: >> On 1 December 2015 at 15:52, Janne Blomqvist > wrote: >>> On Tue, Dec 1, 2015 at 2:54 PM, Bernhard Reutner-Fischer >>> wrote: >>>> These three function used a hardcoded buffer of 100 but would be >better >>>> off to base off GFC_MAX_SYMBOL_LEN which denotes the maximum length >of a >>>> name in any of our supported standards (63 as of f2003 ff.). >>> >>> Please use xasprintf() instead (and free the result, or course). One >>> of my backburner projects is to get rid of these static symbol >>> buffers, and use dynamic buffers (or the symbol table) instead. We >>> IIRC already have some ugly hacks by using hashing to get around >>> GFC_MAX_SYMBOL_LEN when handling mangled symbols. Your patch doesn't >>> make the situation worse per se, but if you're going to fix it, lets >>> do it properly. >> >> I see. >> >> /scratch/src/gcc-6.0.mine/gcc/fortran$ git grep >> "^[[:space:]]*char[[:space:]][[:space:]]*[^[;[:space:]]*\[" | wc -l >> 142 >> /scratch/src/gcc-6.0.mine/gcc/fortran$ git grep "xasprintf" | wc -l >> 32 > >Yes, that's why it's on the TODO-list rather than on the DONE-list. :) > >> What about memory fragmentation when switching to heap-based >allocation? >> Or is there consensus that these are in the noise compared to other >> parts of the compiler? > >Heap fragmentation is an issue, yes. I'm not sure it's that >performance-critical, but I don't think there is any consensus. I just >want to avoid ugly hacks like symbol hashing to fit within some fixed >buffer. Perhaps an good compromise would be something like std::string >with small string optimization, but as you have seen there is some >resistance to C++. But this is more relevant for mangled symbols, so >GFC_MAX_MANGLED_SYMBOL_LEN is more relevant here, and there's only a >few of them left. So, well, if you're sure that mangled symbols are >never copied into the buffers your patch modifies, please consider >your original patch Ok as well. Whichever you prefer. > >Performance-wise I think a bigger benefit would be to use the symbol >table more and then e.g. be able to do pointer comparisons rather than >strcmp(). But that is certainly much more work. Hm, worth a look indeed since that would certainly be a step in the right direction. > >> BTW: >> $ git grep APO >> io.c: static const char *delim[] = { "APOSTROPHE", "QUOTE", "NONE", >NULL }; >> io.c: static const char *delim[] = { "APOSTROPHE", "QUOTE", "NONE", >NULL }; > >? What are you saying? delim is duplicated, we should remove one instance. thanks,