From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Benchmarking temporary Lisp objects [Was: Re: [RFC] temporary Lisp_Strings] Date: Mon, 08 Sep 2014 08:44:57 -0400 Message-ID: References: <5405BE5D.1090003@yandex.ru> <5405DE8B.4050201@yandex.ru> <5406EC21.4060200@yandex.ru> <5407281C.3090302@cs.ucla.edu> <54073621.2040403@yandex.ru> <540744F5.2010804@cs.ucla.edu> <5407F1B7.6090704@yandex.ru> <5407F4E6.2040809@cs.ucla.edu> <5407FDF4.7020504@yandex.ru> <54086B1A.8070506@yandex.ru> <54087B5E.10402@yandex.ru> <54088D63.8010406@cs.ucla.edu> <54093561.2010507@yandex.ru> <5409630B.6030201@cs.ucla.edu> <540D85E3.5090407@yandex.ru> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1410180360 13733 80.91.229.3 (8 Sep 2014 12:46:00 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 8 Sep 2014 12:46:00 +0000 (UTC) Cc: Paul Eggert , Emacs development discussions To: Dmitry Antipov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Sep 08 14:45:53 2014 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XQyKO-0006sr-JU for ged-emacs-devel@m.gmane.org; Mon, 08 Sep 2014 14:45:52 +0200 Original-Received: from localhost ([::1]:43121 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XQyKO-0002Cx-5i for ged-emacs-devel@m.gmane.org; Mon, 08 Sep 2014 08:45:52 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33089) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XQyJr-0002CU-V4 for emacs-devel@gnu.org; Mon, 08 Sep 2014 08:45:27 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XQyJh-00027S-Ju for emacs-devel@gnu.org; Mon, 08 Sep 2014 08:45:19 -0400 Original-Received: from pruche.dit.umontreal.ca ([132.204.246.22]:53741) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XQyJh-00027M-Em for emacs-devel@gnu.org; Mon, 08 Sep 2014 08:45:09 -0400 Original-Received: from pastel.home (lechon.iro.umontreal.ca [132.204.27.242]) by pruche.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id s88CiwRo020575; Mon, 8 Sep 2014 08:44:58 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id DB8BD60BF3; Mon, 8 Sep 2014 08:44:57 -0400 (EDT) In-Reply-To: <540D85E3.5090407@yandex.ru> (Dmitry Antipov's message of "Mon, 08 Sep 2014 14:33:07 +0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux) X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV5058=0 X-NAI-Spam-Version: 2.3.0.9378 : core <5058> : inlines <1260> : streams <1284480> : uri <1811667> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 132.204.246.22 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:174081 Archived-At: > Surely such an errors are possible. But if we use alloca in general, > there is always a possibility for someone to misuse pointer returned > from it, no matter whether that pointer is used for Lisp_Objects or not. There's an important difference: an object that is accessible from the Elisp world should never have such "stack-allocation" constraint, because that is a kind of semantic constraint that is common in C but which doesn't exist in C. So as long as your Lips_Objects stay within the C world, it's indeed acceptable, since the C programmer presumably knows that memory management is a big dangerous mess; but as soon as your alloca'd object gets to the Elisp world this is not acceptable any more since it introduces a new kind of problem to this Elisp world. > Any developer good enough in C should be able to find, track and fix > this class of errors, so I don't see a problem here. Agreed, as long as the object doesn't get to Elisp. The tricky part here is that Elisp can be invoked at many different points, and we tend to keep adding new such points via new hooks. So the places where alloca can be used are probably somewhat rare. > Of course, no one should detect charsets by scanning buffer in such a way, IOW, this is not a good argument in favor of using alloca there. Stefan