From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Is byte-compiled code supposed to call `make-byte-code'? Date: Wed, 25 May 2016 10:13:28 -0400 Message-ID: References: <87iny3rw6r.fsf@linux-m68k.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1464185595 23591 80.91.229.3 (25 May 2016 14:13:15 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 25 May 2016 14:13:15 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed May 25 16:13:06 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1b5ZYX-0000uJ-5s for ged-emacs-devel@m.gmane.org; Wed, 25 May 2016 16:13:05 +0200 Original-Received: from localhost ([::1]:33199 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5ZYV-00063k-7z for ged-emacs-devel@m.gmane.org; Wed, 25 May 2016 10:13:03 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36342) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5ZYN-00061x-3P for emacs-devel@gnu.org; Wed, 25 May 2016 10:12:56 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b5ZYJ-0008OK-P9 for emacs-devel@gnu.org; Wed, 25 May 2016 10:12:54 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:57809) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5ZYJ-0008Nx-IJ for emacs-devel@gnu.org; Wed, 25 May 2016 10:12:51 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1b5ZYE-0000nl-E7 for emacs-devel@gnu.org; Wed, 25 May 2016 16:12:46 +0200 Original-Received: from 45.72.148.12 ([45.72.148.12]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 25 May 2016 16:12:46 +0200 Original-Received: from monnier by 45.72.148.12 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 25 May 2016 16:12:46 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 25 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 45.72.148.12 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) Cancel-Lock: sha1:t5OF2iRWmqZ6PR7YjIWUKH4qUis= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:204000 Archived-At: >> But it isn't a constant, it depends on the function's argument. > You are right, didn't think about it. However, given that it is a > repetetive process, shouldn't all constant parts of it be moved to C > level instead of bytecode, as an optimization? When Emacs-24.1 introduced lexical-binding, the focus was on: - preserving backward compatibility. - minimizing the amount of code changed. - providing correct semantics. - no speed regression. IOW performance of lexically scoped code was not on the agenda. Notice that the problem in the code you quote is not just the amount of byte-code, but also in the closure that's generated: whether we hide it inside a new "make-closure" bytecode or not, the construction of the new closure object is more costly than in most "standard" representation of closures (which normally only involves construction of one object, rather than two). So, yes, there's a fair bit of room for improvement (and not just in this one particular spot). Stefan