From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Emanuel Berg Newsgroups: gmane.emacs.help Subject: Re: Knowing where a function has been used (bis) [Was: Re: Optimising Elisp code] Date: Sun, 07 Oct 2018 17:59:43 +0200 Organization: Aioe.org NNTP Server Message-ID: <86o9c5rbm8.fsf@zoho.com> References: <638fb7dc-6fc5-4645-8793-97a00038a3a8@googlegroups.com> <8hxojvzzzzzz.m4h.xxuns.g6.gal@portable.galex-713.eu> <20181006192457.GB7368@tuxteam.de> <86lg79yl54.fsf@zoho.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1538927952 11600 195.159.176.226 (7 Oct 2018 15:59:12 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 7 Oct 2018 15:59:12 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Oct 07 17:59:08 2018 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1g9BSV-0002uS-OT for geh-help-gnu-emacs@m.gmane.org; Sun, 07 Oct 2018 17:59:07 +0200 Original-Received: from localhost ([::1]:42769 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g9BUc-0007NK-3e for geh-help-gnu-emacs@m.gmane.org; Sun, 07 Oct 2018 12:01:18 -0400 Original-Path: usenet.stanford.edu!fu-berlin.de!news.uzoreto.com!aioe.org!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 71 Original-NNTP-Posting-Host: xQsFb8j6c/kdg9AvIrnVFA.user.gioia.aioe.org Original-X-Complaints-To: abuse@aioe.org Cancel-Lock: sha1:Uo+Og82a9/KcUVaaO+sgd08dEvY= Mail-Copies-To: never X-Notice: Filtered by postfilter v. 0.8.3 Original-Xref: usenet.stanford.edu gnu.emacs.help:224057 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:118183 Archived-At: 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