From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jimmy Yuen Ho Wong Newsgroups: gmane.emacs.devel Subject: Re: How does nativecomp compile circular lists? Date: Wed, 28 Jul 2021 03:09:24 +0100 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000d1b9eb05c8257bd2" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28930"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Emacs-Devel devel To: Andrea Corallo Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Jul 28 04:10:44 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 1m8Z1v-0007JB-OO for ged-emacs-devel@m.gmane-mx.org; Wed, 28 Jul 2021 04:10:43 +0200 Original-Received: from localhost ([::1]:38314 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m8Z1u-0007qu-02 for ged-emacs-devel@m.gmane-mx.org; Tue, 27 Jul 2021 22:10:42 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46212) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m8Z1I-0007BX-Fm for emacs-devel@gnu.org; Tue, 27 Jul 2021 22:10:04 -0400 Original-Received: from mail-lf1-x132.google.com ([2a00:1450:4864:20::132]:46829) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m8Z1G-0003Sc-BQ for emacs-devel@gnu.org; Tue, 27 Jul 2021 22:10:04 -0400 Original-Received: by mail-lf1-x132.google.com with SMTP id m13so937903lfg.13 for ; Tue, 27 Jul 2021 19:10:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=B6KlRyhOxKrWe53rKpu+7huAXFbgT5R47ymU7Ga4bJ8=; b=F3s4PM8CQZAdNdB3O6YpFCOCnc+HXP9ZluzIo1wxPPKW1JCoZDtXoS20zGwxSKN4Yp Hmu2v8b2cO6KJlyUbRVH9CAVwz75CtGUv1L7z2DL6UeCX0/S9uV7ghg5EW1/+KRtlLOc PzJ171vmj5Cq6elY9+E1zV0fW3op8lN+5hqTIBj64yDOMyqbJI41cp03TirgjLykCvXq KlNHgLlqY0AqgNmq0T7erzhOZdvC66hIcUlfdWydKmP3Ak35dx4U2W0DnsFaQQAFfZ91 NTS7mj6oKaGGVQK3JIMUn6d/pWqr+YE2/h5WcVl/VklLsxbNq9Kri59FbE3vuxnxboUf 3tSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=B6KlRyhOxKrWe53rKpu+7huAXFbgT5R47ymU7Ga4bJ8=; b=RIo9CSQZJtu69VYIjFhfTYXO2BtVnaFxK+3+cCscOSzk0iG2GBAjxQD5OspuSwNsXo qwqGJgPZzGHvJyRWlHc01RQi/1W3cGg9QaDGkY+xR5fPv7jWwEL0l0dPqWNxSx6XWP6/ SW2jHgKtISNAD0A0nHw5rNXw+Q0hqzhrFkTeuYUhVnYOvrBqK0s2gQjxSzZu1b7tJq7d vN2t2RGN/MrZBAgQ2x7A1jLBdEvQ181fWFK4S02E0erlztb4RS5hPyIq2r1uLVZtCjWr SVeta2UbDWoZEAsqUWqoNBD+TFfBQQI6rGWTC+XcGmQ9jPdH/+2bgPqkAAfCD4fKVLqP Tovg== X-Gm-Message-State: AOAM530fwuVXNqCNP7Kc3lVn0yT8BBt1V2gTQeksGGlIRf3ZRBueGu+M tXPxHJ2rLR7a7iMW+AoRGh90j5ts5a7GEEbWRfY= X-Google-Smtp-Source: ABdhPJwjJeEmL5mkWCOgmpqdavzW2cPdQ8OSv2jzsoRaHaiHjB0WBVGEgAaf7Yd9VeTR9aZnjdWM+GBUpNLiKWqMcaM= X-Received: by 2002:ac2:5b41:: with SMTP id i1mr18188348lfp.348.1627438200239; Tue, 27 Jul 2021 19:10:00 -0700 (PDT) In-Reply-To: Received-SPF: pass client-ip=2a00:1450:4864:20::132; envelope-from=wyuenho@gmail.com; helo=mail-lf1-x132.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=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:271716 Archived-At: --000000000000d1b9eb05c8257bd2 Content-Type: text/plain; charset="UTF-8" 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 > --000000000000d1b9eb05c8257bd2 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I think I've found out what that stacktrace means= . The regular expression in disassemble-internal hasn't taken into acco= unt LLVM's=C2=A0objdump output format for mach-o objects. The first cou= ple of lines of the *Disassemble* buffer looks like this on macOS:

<= br>/Users/wyuenho/.emacs.d/eln-cache/28_0_50-83d1a9b9/markdown-mode-4888e15= 3-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.xctoolcha= in/usr/bin/objdump: warning: '/Users/wyuenho/.emacs.d/eln-cache/28_0_50= -83d1a9b9/markdown-mode-4888e153-14d4f01e.eln': failed to parse debug i= nformation for /Users/wyuenho/.emacs.d/eln-cache/28_0_50-83d1a9b9/markdown-= mode-4888e153-14d4f01e.eln
=C2=A0 =C2=A0 2fa0: 8b 05 86 9f 08 00 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 movl 565126(%rip), %eax =C2=A0# 8cf2c &l= t;_quitcounter>
=C2=A0 =C2=A0 2fa6: 83 c0 01 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 addl $1, %eax

Jimmy


=
On Tue, Ju= l 27, 2021 at 10:28 AM Andrea Corallo <a= krl@sdf.org> wrote:
Jimmy Yuen Ho Wong <wyuenho@gmail.com> writes:

> I'm not exactly sure how to even ask this question, as I've se= en various packages fail to natively compile circular lists
> or optimize it wrongly. So I've come up with a simple test case fo= r me to be able to disassemble the bytecode and the
> native code, and see if I could spot the problem, but disassembling na= tively compiled code doesn't seem to work.
>
> Test case:
>
> (defun test-circular-list ()
>=C2=A0 =C2=A0(let ((l (list 1 2 3)))
>=C2=A0 =C2=A0 =C2=A0(setcdr (last l) l)
>=C2=A0 =C2=A0 =C2=A0l))
>
> (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 "^.*<F746573742d6= 3697263756c61722d6c697374_test_cir...")
>=C2=A0 =C2=A0re-search-forward("^.*<F746573742d63697263756c6172= 2d6c697374_test_cir...")
>=C2=A0 =C2=A0disassemble-internal(test-circular-list 0 nil)
>=C2=A0 =C2=A0disassemble(test-circular-list nil 0 t)
>=C2=A0 =C2=A0funcall-interactively(disassemble test-circular-list nil 0= t)
>=C2=A0 =C2=A0command-execute(disassemble record)
>=C2=A0 =C2=A0execute-extended-command(nil "disassemble" nil)<= br> >=C2=A0 =C2=A0funcall-interactively(execute-extended-command nil "d= isassemble" nil)
>=C2=A0 =C2=A0command-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

=C2=A0 Andrea
--000000000000d1b9eb05c8257bd2--