From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thien-Thi Nguyen Newsgroups: gmane.emacs.devel Subject: Re: stack size info Date: Sat, 24 Mar 2007 09:38:10 -0400 Message-ID: References: <22933993.657431174662526198.JavaMail.www@wwinf4203> Reply-To: ttn@gnuvola.org NNTP-Posting-Host: lo.gmane.org X-Trace: sea.gmane.org 1174743505 5043 80.91.229.12 (24 Mar 2007 13:38:25 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 24 Mar 2007 13:38:25 +0000 (UTC) Cc: emacs-devel@gnu.org To: alinsoar@voila.fr Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Mar 24 14:38:17 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 1HV6Rk-0007yp-Aq for ged-emacs-devel@m.gmane.org; Sat, 24 Mar 2007 14:38:16 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HV6Tl-0000pB-6m for ged-emacs-devel@m.gmane.org; Sat, 24 Mar 2007 08:40:21 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HV6Ti-0000p5-K5 for emacs-devel@gnu.org; Sat, 24 Mar 2007 09:40:18 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HV6Th-0000ot-A6 for emacs-devel@gnu.org; Sat, 24 Mar 2007 09:40:18 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HV6Th-0000op-2d for emacs-devel@gnu.org; Sat, 24 Mar 2007 08:40:17 -0500 Original-Received: from mail.agora-net.com ([67.59.132.6]) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1HV6Rf-0001lK-8q for emacs-devel@gnu.org; Sat, 24 Mar 2007 09:38:11 -0400 Original-Received: from ttn by mail.agora-net.com with local (Exim 4.50) id 1HV6Re-00032g-21; Sat, 24 Mar 2007 09:38:10 -0400 In-reply-to: <22933993.657431174662526198.JavaMail.www@wwinf4203> (message from A Soare on Fri, 23 Mar 2007 16:08:46 +0100 (CET)) X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: ttn@agora-net.com X-SA-Exim-Scanned: No (on mail.agora-net.com); SAEximRunCond expanded to false X-detected-kernel: Linux 2.6 (newer, 3) 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:68468 Archived-At: From: A Soare Date: Fri, 23 Mar 2007 16:08:46 +0100 (CET) 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