From: Thien-Thi Nguyen <ttn@gnuvola.org>
To: alinsoar@voila.fr
Cc: emacs-devel@gnu.org
Subject: Re: stack size info
Date: Sat, 24 Mar 2007 09:38:10 -0400 [thread overview]
Message-ID: <E1HV6Re-00032g-21@mail.agora-net.com> (raw)
In-Reply-To: <22933993.657431174662526198.JavaMail.www@wwinf4203> (message from A Soare on Fri, 23 Mar 2007 16:08:46 +0100 (CET))
From: A Soare <alinsoar@voila.fr>
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
next prev parent reply other threads:[~2007-03-24 13:38 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-23 15:08 stack size info A Soare
2007-03-24 13:38 ` Thien-Thi Nguyen [this message]
-- strict thread matches above, loose matches on Subject: below --
2007-03-26 10:42 A Soare
2007-03-22 15:19 A Soare
2007-03-22 18:24 ` David Kastrup
2007-03-23 15:01 ` Thien-Thi Nguyen
2007-03-23 16:00 ` Stefan Monnier
2007-03-20 13:22 A Soare
2007-03-20 16:14 ` ttn
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E1HV6Re-00032g-21@mail.agora-net.com \
--to=ttn@gnuvola.org \
--cc=alinsoar@voila.fr \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).