From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Andrea Corallo via "Emacs development discussions." Newsgroups: gmane.emacs.devel Subject: Re: How does nativecomp compile circular lists? Date: Wed, 28 Jul 2021 07:20:09 +0000 Message-ID: References: <6247f78b-282f-27e7-e0cf-6bc3b1cdee26@gmail.com> Reply-To: Andrea Corallo Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5876"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: emacs-devel@gnu.org To: Jimmy Yuen Ho Wong Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Jul 28 09:21:38 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m8dso-0001IW-Gb for ged-emacs-devel@m.gmane-mx.org; Wed, 28 Jul 2021 09:21:38 +0200 Original-Received: from localhost ([::1]:38762 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m8dsn-0007NR-JE for ged-emacs-devel@m.gmane-mx.org; Wed, 28 Jul 2021 03:21:37 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:36718) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m8drT-0006Ts-Ul for emacs-devel@gnu.org; Wed, 28 Jul 2021 03:20:15 -0400 Original-Received: from mx.sdf.org ([205.166.94.24]:49286) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m8drR-0008LY-Hn for emacs-devel@gnu.org; Wed, 28 Jul 2021 03:20:15 -0400 Original-Received: from mab (ma.sdf.org [205.166.94.33]) by mx.sdf.org (8.15.2/8.14.5) with ESMTPS id 16S7K9OX003687 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits) verified NO); Wed, 28 Jul 2021 07:20:10 GMT In-Reply-To: <6247f78b-282f-27e7-e0cf-6bc3b1cdee26@gmail.com> (Jimmy Yuen Ho Wong's message of "Wed, 28 Jul 2021 03:58:13 +0100") Received-SPF: pass client-ip=205.166.94.24; envelope-from=akrl@sdf.org; helo=mx.sdf.org X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 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-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:271724 Archived-At: Jimmy Yuen Ho Wong writes: > On 28/07/2021 3:09 AM, Jimmy Yuen Ho Wong wrote: > > I think I've found out what that stacktrace means. The regular expression in disassemble-internal hasn't taken into > account LLVM's objdump output format for mach-o objects. The first couple of lines of the *Disassemble* buffer looks > like this on macOS: > > /Users/wyuenho/.emacs.d/eln-cache/28_0_50-83d1a9b9/markdown-mode-4888e153-14d4f01e.eln: file format mach-o 64-bit > x86-64 > > Disassembly of section __TEXT,__text: > > 0000000000002fa0 <_maybe_gc_quit>: > /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/objdump: warning: > '/Users/wyuenho/.emacs.d/eln-cache/28_0_50-83d1a9b9/markdown-mode-4888e153-14d4f01e.eln': failed to parse debug > information for /Users/wyuenho/.emacs.d/eln-cache/28_0_50-83d1a9b9/markdown-mode-4888e153-14d4f01e.eln > 2fa0: 8b 05 86 9f 08 00 movl 565126(%rip), %eax # 8cf2c <_quitcounter> > 2fa6: 83 c0 01 addl $1, %eax > > Jimmy > > On Tue, Jul 27, 2021 at 10:28 AM Andrea Corallo wrote: > > Jimmy Yuen Ho Wong writes: > > > I'm not exactly sure how to even ask this question, as I've seen various packages fail to natively compile > circular lists > > or optimize it wrongly. So I've come up with a simple test case for me to be able to disassemble the bytecode > and the > > native code, and see if I could spot the problem, but disassembling natively compiled code doesn't seem to > work. > > > > Test case: > > > > (defun test-circular-list () > > (let ((l (list 1 2 3))) > > (setcdr (last l) l) > > l)) > > > > (print (test-circular-list)) > > > > (provide 'test-circular-list) > > > > M-x emacs-lisp-byte-compile-and-load > > M-x disassemble RET test-circular-list (works) > > > > M-x emacs-lisp-native-compile-and-load > > M-x disassemble RET test-circular-list (doesn't work) > > > > Debugger entered--Lisp error: (search-failed "^.* > re-search-forward("^.* > disassemble-internal(test-circular-list 0 nil) > > disassemble(test-circular-list nil 0 t) > > funcall-interactively(disassemble test-circular-list nil 0 t) > > command-execute(disassemble record) > > execute-extended-command(nil "disassemble" nil) > > funcall-interactively(execute-extended-command nil "disassemble" nil) > > command-execute(execute-extended-command) > > > > Furthermore, this test case, though superficially similar, doesn't seem to be able to reproduce the same > failure to > > natively compile issue as seen in powerline. > > > > There seems to be more than one thing wrong with this journey into my deep dive into how native compiling > circular lists > > work. > > > > Jimmy Yuen Ho Wong > > > > Hi Jimmy, > > I'm failing to reproduce this issue. > > Disassembling following your instructions works here. Also the compiled > `test-circular-list' function as expected here. > > Am I missing something? > > Best Regards > > Andrea > > Sorry wrong patch from the last email. This is the correct one. [re-adding the list] Hi Jimmy, thanks for the patch. So I guess is clear this is unrelated to circular lists and probably disassemble is just broken for every native compiled function in this configuration. We might have other architecture+OS where function labels start with '_' but so far the patch LGTM, I just suggest a small nit. > diff --git a/lisp/emacs-lisp/disass.el b/lisp/emacs-lisp/disass.el > index 6ac76f1c19..d0e3bf7bf4 100644 > --- a/lisp/emacs-lisp/disass.el > +++ b/lisp/emacs-lisp/disass.el > @@ -95,6 +95,7 @@ disassemble-internal > (re-search-forward (concat "^.*" > (regexp-quote > (concat "<" > + (if (eq system-type 'darwin) "_") ^^^ I'd use `when' here. > (comp-c-func-name > (subr-name obj) "F" t) > ">:")))) Do you aready have copyright assignment? Best Regards Andrea