unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Help with the disassembly of a very short function, please.
@ 2022-01-01 19:01 Alan Mackenzie
  2022-01-01 19:43 ` Andreas Schwab
  0 siblings, 1 reply; 3+ messages in thread
From: Alan Mackenzie @ 2022-01-01 19:01 UTC (permalink / raw)
  To: emacs-devel

Hello, Emacs.

The following function comes from .../test/src/comp-tests.el, more or
less:

;; -*- lexical-binding: t -*-
(defun comp-test-55 (x)
  (unless (integerp x)
      x))

I byte compile it with C-x C-e then dump out its byte code with M-x
disassemble.  I get this:

byte code for comp-test-55:
  doc:   ...
    args: (arg1)
    0       dup
    1       integerp
    2       not
    3       goto-if-nil-else-pop 1
    6       dup
    7:1     return

..  In the case where x is not an integer, it seems that the dup at 6
will leave two many copies of x on the stack for the return.

In the case where x is an integer, it seems that the
goto-if-nil-else-pop will leave a nil on the stack over the original
x, returning the nil but leaving a superfluous copy of the integer x
on the stack.

So, either way, there is an unwanted copy of x left on the stack at the
end of the function.

I can't work this out.  What am I missing?

-- 
Alan Mackenzie (Nuremberg, Germany).



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-01-01 22:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-01 19:01 Help with the disassembly of a very short function, please Alan Mackenzie
2022-01-01 19:43 ` Andreas Schwab
2022-01-01 22:07   ` Alan Mackenzie

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).