From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: A Soare Newsgroups: gmane.emacs.devel Subject: Re: stack size info Date: Mon, 26 Mar 2007 12:42:40 +0200 (CEST) Message-ID: <24499085.634031174905760354.JavaMail.www@wwinf4004> Reply-To: alinsoar@voila.fr NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1174905812 15023 80.91.229.12 (26 Mar 2007 10:43:32 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 26 Mar 2007 10:43:32 +0000 (UTC) Cc: "Emacs Dev \[emacs-devel\]" To: ttn@gnuvola.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Mar 26 12:43:25 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1HVmfb-00008D-W1 for ged-emacs-devel@m.gmane.org; Mon, 26 Mar 2007 12:43:24 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HVmhq-0001gq-3E for ged-emacs-devel@m.gmane.org; Mon, 26 Mar 2007 05:45:42 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HVmhH-0001Bo-CM for emacs-devel@gnu.org; Mon, 26 Mar 2007 06:45:07 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HVmhG-0001Al-BG for emacs-devel@gnu.org; Mon, 26 Mar 2007 06:45:06 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HVmhG-0001Ai-9B for emacs-devel@gnu.org; Mon, 26 Mar 2007 05:45:06 -0500 Original-Received: from smtp1.voila.fr ([193.252.22.174]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1HVmf1-0002Js-5i for emacs-devel@gnu.org; Mon, 26 Mar 2007 06:42:47 -0400 Original-Received: from me-wanadoo.net (localhost [127.0.0.1]) by mwinf4014.voila.fr (SMTP Server) with ESMTP id 60437480026A; Mon, 26 Mar 2007 12:42:40 +0200 (CEST) Original-Received: from wwinf4004 (wwinf4004 [172.22.157.31]) by mwinf4014.voila.fr (SMTP Server) with ESMTP id 5943148002A6; Mon, 26 Mar 2007 12:42:40 +0200 (CEST) X-ME-UUID: 20070326104240365.5943148002A6@mwinf4014.voila.fr X-Originating-IP: [89.34.170.37] X-Wum-Nature: EMAIL-NATURE X-WUM-FROM: |~| X-WUM-TO: |~| X-WUM-CC: |~| X-WUM-REPLYTO: |~| X-detected-kernel: Linux 2.4-2.6 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:68585 Archived-At: > I can not imagine an example in which this STACKSIZE is greater than > the actual real size. Can somebody help me with an example, please? > > following is an example (created in the *scratch* buffer, btw, so > you can try to recreate it for yourself, as well). the annotations > (comments) on the right were added by hand. > > there are two functions and three function calls. the second and > third calls illustrate how one function might use a different amount > of stack depending on its operating environment (in this case, the > value of its arg OBJECT). that amount is at most 4, which coincides > (purposefully) with the STACKSIZE element in the byte-code function > object for `maybe'. > > to understand in more detail, you will need to understand how each > operation interacts with the stack (if at all). for more info, > place the cursor after the following form and type `C-x C-e': > > (info "(elisp)Disassembly") > > btw, the construct `(or (byte-compile FOO) (symbol-function FOO))' > is because `byte-compile' returns nil if FOO is already compiled. > > thi > > ___________________________________________________ > > (defun no-op () t) > no-op > > (disassemble (or (byte-compile 'no-op) > (symbol-function 'no-op)) > (current-buffer)) > byte code: > args: nil ; stack usage > 0 constant t ; 1 > 1 return ; 0 > > (defun maybe (object) > (when object > (let* ((a 42) > (b 6)) > (when (= a (+ b (* b b))) > object)))) > maybe > > (disassemble (or (byte-compile 'maybe) > (symbol-function 'maybe)) > (current-buffer)) > byte code: ; OBJECT: nil > args: (object) ; stack usage > 0 varref object ; 1 > 1 goto-if-nil-else-pop 2 ; (branch taken) > 4 constant 42 > 5 varbind a > 6 constant 6 > 7 varbind b > 8 varref a > 9 varref b > 10 dup > 11 dup > 12 mult > 13 plus > 14 eqlsign > 15 goto-if-nil-else-pop 1 > 18 varref object > 19:1 unbind 2 > 20:2 return ; 0 > > (disassemble (or (byte-compile 'maybe) > (symbol-function 'maybe)) > (current-buffer)) > byte code: ; OBJECT: 42 > args: (object) ; stack usage > 0 varref object ; 1 > 1 goto-if-nil-else-pop 2 ; 0 (branch not taken) > 4 constant 42 ; 1 > 5 varbind a ; 0 > 6 constant 6 ; 1 > 7 varbind b ; 0 > 8 varref a ; 1 > 9 varref b ; 2 > 10 dup ; 3 > 11 dup ; 4 > 12 mult ; 3 > 13 plus ; 2 > 14 eqlsign ; 1 > 15 goto-if-nil-else-pop 1 ; 0 (branch not taken) > 18 varref object ; 1 > 19:1 unbind 2 > 20:2 return ; 0 > > > Thank you very much. Alin Soare.