[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Knowing where a function has been used (bis) [Was: Re: Optimising El
From: |
Emanuel Berg |
Subject: |
Re: Knowing where a function has been used (bis) [Was: Re: Optimising Elisp code] |
Date: |
Sun, 07 Oct 2018 17:59:43 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) |
Stefan Monnier wrote:
> Try M-x disassemble RET add-it RET
> to see how the two calls where compiled.
OK, here goes:
(defsubst add-it-inline (i j)
(+ i j) )
(defun add-it (a b)
(+ a b) )
(defun test-normal ()
(add-it 1 2) )
;; (test-normal)
;; byte code for test-normal:
;; args: nil
;; 0 constant add-it
;; 1 constant 1
;; 2 constant 2
;; 3 call 2
;; 4 return
(defun test-inline ()
(add-it-inline 10 20) )
;; (test-inline)
;; byte code for test-inline:
;; args: nil
;; 0 constant 10
;; 1 constant 20
;; 2 varbind j
;; 3 dup
;; 4 varbind i
;; 5 varref j
;; 6 plus
;; 7 unbind 2
;; 8 return
OK, so there is no call, instead the code
is inserted. I suppose this is a glitch in the
Matrix, becuase what I can reCALL this is what
I've been saying this whole time...
But anyway, instead of dwelling on the past,
meditate on this:
;; byte code for add-it:
;; args: (a b)
;; 0 varref a
;; 1 varref b
;; 2 plus
;; 3 return
So as for machine instructions, the inline
version, "test-inline", has 9.
The "test-normal" has 5. The non-inlined
"add-it" has 4. 5 + 4 = 9. And I've saved the
best forst last: 9 = 9!
So there is no gain as to the number of machine
instructions. So where is the gain? The `call'
instruction specifically, or the implied
funcall overhead not visible in
the disassembly?
--
underground experts united
http://user.it.uu.se/~embe8573
- Re: Optimising Elisp code, (continued)
- Re: Optimising Elisp code, Garreau, Alexandre, 2018/10/06
- Re: Optimising Elisp code, tomas, 2018/10/06
- Knowing where a function has been used (bis) [Was: Re: Optimising Elisp code], Garreau, Alexandre, 2018/10/06
- Re: Knowing where a function has been used (bis) [Was: Re: Optimising Elisp code], tomas, 2018/10/06
- Re: Knowing where a function has been used (bis) [Was: Re: Optimising Elisp code], Garreau, Alexandre, 2018/10/06
- Re: Knowing where a function has been used (bis) [Was: Re: Optimising Elisp code], tomas, 2018/10/07
- Re: Knowing where a function has been used (bis) [Was: Re: Optimising Elisp code], Garreau, Alexandre, 2018/10/07
- Message not available
- Re: Knowing where a function has been used (bis) [Was: Re: Optimising Elisp code], Emanuel Berg, 2018/10/07
- Message not available
- Re: Knowing where a function has been used (bis) [Was: Re: Optimising Elisp code], Emanuel Berg, 2018/10/07
- Re: Knowing where a function has been used (bis) [Was: Re: Optimising Elisp code], Stefan Monnier, 2018/10/07
- Message not available
- Re: Knowing where a function has been used (bis) [Was: Re: Optimising Elisp code],
Emanuel Berg <=
- Re: Optimising Elisp code [again], Garreau, Alexandre, 2018/10/07
- Message not available
- Re: Optimising Elisp code [again], Emanuel Berg, 2018/10/08
- Re: Optimising Elisp code [again], tomas, 2018/10/08
- Message not available
- Re: Optimising Elisp code [again], Barry Margolin, 2018/10/08
- Re: Optimising Elisp code [again], Emanuel Berg, 2018/10/09
- Re: Optimising Elisp code [again], Garreau, Alexandre, 2018/10/09
- Message not available
- Re: Optimising Elisp code [again], Emanuel Berg, 2018/10/09
- Re: Optimising Elisp code [again], Garreau, Alexandre, 2018/10/09
- Message not available
- Re: Optimising Elisp code [again], Emanuel Berg, 2018/10/09
- Re: Optimising Elisp code [again], Garreau, Alexandre, 2018/10/09