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: How does nativecomp compile circular lists? Date: Tue, 27 Jul 2021 08:21:51 +0100 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="00000000000067cc5505c815bb60" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17496"; mail-complaints-to="usenet@ciao.gmane.io" To: Emacs-Devel devel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Jul 27 09:23:09 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 1m8HQi-0004Pk-KQ for ged-emacs-devel@m.gmane-mx.org; Tue, 27 Jul 2021 09:23:08 +0200 Original-Received: from localhost ([::1]:58464 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m8HQh-0003yD-3S for ged-emacs-devel@m.gmane-mx.org; Tue, 27 Jul 2021 03:23:07 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:59624) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m8HQ8-0003Iv-CK for emacs-devel@gnu.org; Tue, 27 Jul 2021 03:22:32 -0400 Original-Received: from mail-lf1-x12e.google.com ([2a00:1450:4864:20::12e]:42889) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m8HQ6-0005c7-GS for emacs-devel@gnu.org; Tue, 27 Jul 2021 03:22:32 -0400 Original-Received: by mail-lf1-x12e.google.com with SMTP id u3so20033396lff.9 for ; Tue, 27 Jul 2021 00:22:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=cMhDpjL4GnrxHmPYEnJlnuT4jQecFMyGzjQJRjoXFd8=; b=C87jLbN4sMTVazaUiNMEMpdekq8yjWTNN/+yDpjZf5NRps/CUjSlW+2HNqKPQyvjln tjprzgcmROiqsuCaZWkn/gFAGNxFr3zGBJuAY/Iw+5A9fPtLHWoMzQlFzp7nQeIkiK2w AKM1Cel4quMXpp8PmHUef2j49zpLOptDMMfuCyMWpP+LxJmNsjDthIETd6+e+8iFESj4 iZa4lqIE/N5VKykFbBHK8IYZgdgXDtB9usk5Y+Vfu/4K4T6/Y64lVKMpPhY/rYRoKjya 3JGPR922ceJJXI4q1zF1qnoJo9TUkZwHou/wwR0YHraFyG578ePgBpFmW9vnhkynShoI ItFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=cMhDpjL4GnrxHmPYEnJlnuT4jQecFMyGzjQJRjoXFd8=; b=PkK6EYF8e6pwyqhujSuX/Zm3Xmr2kNRKBbSiu1VZuI7/iL0qiIrlI9nYdoeiInrAfD lZIn1VLo2rkPI9qAgfNdiUXFngc2mQeSouCAtXSbi4/PmXlxWwZ14x47xFkAcwWvZeVf MjhMamgaaJJQn1VsxESoNe3fzDpeI5IgLG7Hez0bjmG95Pptic/8gVcwTrt+ZmpwDUgF q4YexaLlql+yPmDcEzcMT8vciHqJrOfun0px0xD/Gwu2cBBQed/cypXtKfcU+HIpGrBN 2HN3CSvPDqNuNVTtWorvpB8kpkvskWvReO/knD2bwFLXhEEas9PwAqiJ2szXq3wC/Qtl 4dzg== X-Gm-Message-State: AOAM531O/4y5gdW/cWbOtls5H1H70V4y2O41Qx+3zztw2oQQlgqPSj63 gyW5lZci4qbYfNx8kZUxCIUf0ia88KZ9D8my8KtBwhFnnak= X-Google-Smtp-Source: ABdhPJxUVI4cjsf+T7UybecF6Xu7Aew9/W0cLAmC/L7pBFFVOrPrq8WCb3OsAntB/pPVMzA3NSAXT/ED3dT7svfitTU= X-Received: by 2002:ac2:5e9a:: with SMTP id b26mr16127630lfq.362.1627370547562; Tue, 27 Jul 2021 00:22:27 -0700 (PDT) Received-SPF: pass client-ip=2a00:1450:4864:20::12e; envelope-from=wyuenho@gmail.com; helo=mail-lf1-x12e.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:271685 Archived-At: --00000000000067cc5505c815bb60 Content-Type: text/plain; charset="UTF-8" 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 "^.*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=C2=A0it wr= ongly. 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 ()
=C2=A0 (let ((l (= list 1 2 3)))
=C2=A0 =C2=A0 (setcdr (last l) l)
=C2=A0 =C2=A0 l))
=
(print (test-circular-list))

(provide 'test-circular-list)
M-x emacs-lisp-byte-compile-and-load
M-x disass= emble RET test-circular-list (works)

M-x emacs-lis= p-native-compile-and-load
M-x disassemble RET test-circular-list = (doesn't work)

Debugger entered--Lisp error: (search-failed &quo= t;^.*<F746573742d63697263756c61722d6c697374_test_cir...")
=C2=A0= re-search-forward("^.*<F746573742d63697263756c61722d6c697374_test_= cir...")
=C2=A0 disassemble-internal(test-circular-list 0 nil)
= =C2=A0 disassemble(test-circular-list nil 0 t)
=C2=A0 funcall-interactiv= ely(disassemble test-circular-list nil 0 t)
=C2=A0 command-execute(disas= semble record)
=C2=A0 execute-extended-command(nil "disassemble&quo= t; nil)
=C2=A0 funcall-interactively(execute-extended-command nil "= disassemble" nil)
=C2=A0 command-execute(execute-extended-command)<= br>
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 wi= th this journey into my deep dive into how native compiling circular lists = work.

Jimmy Yuen Ho Wong
--00000000000067cc5505c815bb60--