unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* How does nativecomp compile circular lists?
@ 2021-07-27  7:21 Jimmy Yuen Ho Wong
  2021-07-27  9:28 ` Andrea Corallo via Emacs development discussions.
  2021-07-28  1:15 ` Michael Heerdegen
  0 siblings, 2 replies; 12+ messages in thread
From: Jimmy Yuen Ho Wong @ 2021-07-27  7:21 UTC (permalink / raw)
  To: Emacs-Devel devel

[-- Attachment #1: Type: text/plain, Size: 1648 bytes --]

I'm not exactly sure how to even ask this question, as I've seen various
packages fail to natively compile circular lists
<https://github.com/milkypostman/powerline/pull/189> or optimize it wrongly
<https://github.com/jrblevin/markdown-mode/pull/624>. 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
"^.*<F746573742d63697263756c61722d6c697374_test_cir...")
  re-search-forward("^.*<F746573742d63697263756c61722d6c697374_test_cir...")
  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

[-- Attachment #2: Type: text/html, Size: 1931 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: How does nativecomp compile circular lists?
  2021-07-27  7:21 How does nativecomp compile circular lists? Jimmy Yuen Ho Wong
@ 2021-07-27  9:28 ` Andrea Corallo via Emacs development discussions.
  2021-07-28  2:09   ` Jimmy Yuen Ho Wong
  2021-07-28  1:15 ` Michael Heerdegen
  1 sibling, 1 reply; 12+ messages in thread
From: Andrea Corallo via Emacs development discussions. @ 2021-07-27  9:28 UTC (permalink / raw)
  To: Jimmy Yuen Ho Wong; +Cc: Emacs-Devel devel

Jimmy Yuen Ho Wong <wyuenho@gmail.com> 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 "^.*<F746573742d63697263756c61722d6c697374_test_cir...")
>   re-search-forward("^.*<F746573742d63697263756c61722d6c697374_test_cir...")
>   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



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: How does nativecomp compile circular lists?
  2021-07-27  7:21 How does nativecomp compile circular lists? Jimmy Yuen Ho Wong
  2021-07-27  9:28 ` Andrea Corallo via Emacs development discussions.
@ 2021-07-28  1:15 ` Michael Heerdegen
  2021-07-28  2:18   ` Jimmy Yuen Ho Wong
  1 sibling, 1 reply; 12+ messages in thread
From: Michael Heerdegen @ 2021-07-28  1:15 UTC (permalink / raw)
  To: emacs-devel

Jimmy Yuen Ho Wong <wyuenho@gmail.com> writes:

> (defun test-circular-list ()
>   (let ((l (list 1 2 3)))
>     (setcdr (last l) l)
>     l))

Does compiling that involve circular lists?  The compiler doesn't call
the function, and there is no circular structure in that code...right?

Michael.




^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: How does nativecomp compile circular lists?
  2021-07-27  9:28 ` Andrea Corallo via Emacs development discussions.
@ 2021-07-28  2:09   ` Jimmy Yuen Ho Wong
       [not found]     ` <6247f78b-282f-27e7-e0cf-6bc3b1cdee26@gmail.com>
  0 siblings, 1 reply; 12+ messages in thread
From: Jimmy Yuen Ho Wong @ 2021-07-28  2:09 UTC (permalink / raw)
  To: Andrea Corallo; +Cc: Emacs-Devel devel

[-- Attachment #1: Type: text/plain, Size: 2986 bytes --]

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 <akrl@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 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
> "^.*<F746573742d63697263756c61722d6c697374_test_cir...")
> >
>  re-search-forward("^.*<F746573742d63697263756c61722d6c697374_test_cir...")
> >   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
>

[-- Attachment #2: Type: text/html, Size: 3927 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: How does nativecomp compile circular lists?
  2021-07-28  1:15 ` Michael Heerdegen
@ 2021-07-28  2:18   ` Jimmy Yuen Ho Wong
  0 siblings, 0 replies; 12+ messages in thread
From: Jimmy Yuen Ho Wong @ 2021-07-28  2:18 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: Emacs-Devel devel

[-- Attachment #1: Type: text/plain, Size: 868 bytes --]

That appears to be the case in elisp bytecode. What I'm trying to compare
is how the GCC JIT deals with it. This simple test case I've taken out of
powerline doesn't seem to produce different results between elisp and
nativecomp tho, so the problem may have to do with how circular lists
interact with something else, and how the JIT chooses to optimize it. I'm
just trying to chase down these recurring issues that seem to emanate from
circular lists.

Jimmy


On Wed, Jul 28, 2021 at 2:15 AM Michael Heerdegen <michael_heerdegen@web.de>
wrote:

> Jimmy Yuen Ho Wong <wyuenho@gmail.com> writes:
>
> > (defun test-circular-list ()
> >   (let ((l (list 1 2 3)))
> >     (setcdr (last l) l)
> >     l))
>
> Does compiling that involve circular lists?  The compiler doesn't call
> the function, and there is no circular structure in that code...right?
>
> Michael.
>
>
>

[-- Attachment #2: Type: text/html, Size: 1434 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: How does nativecomp compile circular lists?
       [not found]     ` <6247f78b-282f-27e7-e0cf-6bc3b1cdee26@gmail.com>
@ 2021-07-28  7:20       ` Andrea Corallo via Emacs development discussions.
  2021-07-28 13:49         ` Jimmy Yuen Ho Wong
  0 siblings, 1 reply; 12+ messages in thread
From: Andrea Corallo via Emacs development discussions. @ 2021-07-28  7:20 UTC (permalink / raw)
  To: Jimmy Yuen Ho Wong; +Cc: emacs-devel

Jimmy Yuen Ho Wong <wyuenho@gmail.com> 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 <akrl@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 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 "^.*<F746573742d63697263756c61722d6c697374_test_cir...")
>  >   re-search-forward("^.*<F746573742d63697263756c61722d6c697374_test_cir...")
>  >   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



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: How does nativecomp compile circular lists?
  2021-07-28  7:20       ` Andrea Corallo via Emacs development discussions.
@ 2021-07-28 13:49         ` Jimmy Yuen Ho Wong
  2021-07-28 15:11           ` Andrea Corallo via Emacs development discussions.
  0 siblings, 1 reply; 12+ messages in thread
From: Jimmy Yuen Ho Wong @ 2021-07-28 13:49 UTC (permalink / raw)
  To: Andrea Corallo; +Cc: Emacs-Devel devel

[-- Attachment #1: Type: text/plain, Size: 5343 bytes --]

On Wed, Jul 28, 2021 at 8:20 AM Andrea Corallo <akrl@sdf.org> wrote:

> Jimmy Yuen Ho Wong <wyuenho@gmail.com> 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 <akrl@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 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
> "^.*<F746573742d63697263756c61722d6c697374_test_cir...")
> >  >
>  re-search-forward("^.*<F746573742d63697263756c61722d6c697374_test_cir...")
> >  >   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
>

I do have an existing copyright assignment. No objection to using a when
there, would you like me to submit a new patch or you are fine with editing
it yourself?

As to whether this is related to circular lists, I'm not so sure yet.
There's definitely something in native compilation that compiles code that
behaves differently when circular lists are involved, I just haven't found
out what interaction with circular lists will result in compilation failure
or optimizing the result away. Any clues for what I should try is much
appreciated.

[-- Attachment #2: Type: text/html, Size: 7102 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: How does nativecomp compile circular lists?
  2021-07-28 13:49         ` Jimmy Yuen Ho Wong
@ 2021-07-28 15:11           ` Andrea Corallo via Emacs development discussions.
  2021-07-29 10:43             ` Jimmy Yuen Ho Wong
  0 siblings, 1 reply; 12+ messages in thread
From: Andrea Corallo via Emacs development discussions. @ 2021-07-28 15:11 UTC (permalink / raw)
  To: Jimmy Yuen Ho Wong; +Cc: Emacs-Devel devel

Jimmy Yuen Ho Wong <wyuenho@gmail.com> writes:

[...]

>  [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
>
> I do have an existing copyright assignment. No objection to using a when there, would you like me to submit a new patch
> or you are fine with editing it yourself?

If you could provide a complete patch (including Changelog entry) that
would be appreciated thanks (please see the CONTRIBUTE file if in
doubt).  I'll be happy to install your patch if you don't have write
access.

> As to whether this is related to circular lists, I'm not so sure yet.

This is certanly not related to circular lists, this is just about how
lables are named on this specific triplet.

> There's definitely something in native compilation
> that compiles code that behaves differently when circular lists are involved, I just haven't found out what interaction
> with circular lists will result in compilation failure or optimizing the result away. Any clues for what I should try is
> much appreciated.

If you have some code/package that behaves differently byte vs native
compiled you should be able to identify the function causing the
difference when executed.  Once that is done we could start
investigating.

Regards

  Andrea



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: How does nativecomp compile circular lists?
  2021-07-28 15:11           ` Andrea Corallo via Emacs development discussions.
@ 2021-07-29 10:43             ` Jimmy Yuen Ho Wong
  2021-07-30  8:20               ` Andrea Corallo via Emacs development discussions.
  0 siblings, 1 reply; 12+ messages in thread
From: Jimmy Yuen Ho Wong @ 2021-07-29 10:43 UTC (permalink / raw)
  To: Andrea Corallo; +Cc: Emacs-Devel devel


[-- Attachment #1.1: Type: text/plain, Size: 2675 bytes --]

On 28/07/2021 4:11 PM, Andrea Corallo wrote:
> Jimmy Yuen Ho Wong <wyuenho@gmail.com> writes:
>
> [...]
>
>>   [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
>>
>> I do have an existing copyright assignment. No objection to using a when there, would you like me to submit a new patch
>> or you are fine with editing it yourself?
> If you could provide a complete patch (including Changelog entry) that
> would be appreciated thanks (please see the CONTRIBUTE file if in
> doubt).  I'll be happy to install your patch if you don't have write
> access.
>
>> As to whether this is related to circular lists, I'm not so sure yet.
> This is certanly not related to circular lists, this is just about how
> lables are named on this specific triplet.
>
>> There's definitely something in native compilation
>> that compiles code that behaves differently when circular lists are involved, I just haven't found out what interaction
>> with circular lists will result in compilation failure or optimizing the result away. Any clues for what I should try is
>> much appreciated.
> If you have some code/package that behaves differently byte vs native
> compiled you should be able to identify the function causing the
> difference when executed.  Once that is done we could start
> investigating.
>
> Regards
>
>    Andrea

Here's a new patch. Thanks in advance for installing it.


[-- Attachment #1.2: Type: text/html, Size: 3426 bytes --]

[-- Attachment #2: disass.el.patch --]
[-- Type: text/plain, Size: 656 bytes --]

diff --git a/lisp/emacs-lisp/disass.el b/lisp/emacs-lisp/disass.el
index 6ac76f1c19..bb2e4849ad 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 "<"
+                                                  (when (eq system-type 'darwin) "_")
                                                   (comp-c-func-name
                                                    (subr-name obj) "F" t)
                                                   ">:"))))

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: How does nativecomp compile circular lists?
  2021-07-29 10:43             ` Jimmy Yuen Ho Wong
@ 2021-07-30  8:20               ` Andrea Corallo via Emacs development discussions.
  2021-08-03  7:23                 ` Jimmy Yuen Ho Wong
  0 siblings, 1 reply; 12+ messages in thread
From: Andrea Corallo via Emacs development discussions. @ 2021-07-30  8:20 UTC (permalink / raw)
  To: Jimmy Yuen Ho Wong; +Cc: Emacs-Devel devel

Jimmy Yuen Ho Wong <wyuenho@gmail.com> writes:
>
> Here's a new patch. Thanks in advance for installing it.
>
> diff --git a/lisp/emacs-lisp/disass.el b/lisp/emacs-lisp/disass.el
> index 6ac76f1c19..bb2e4849ad 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 "<"
> +                                                  (when (eq system-type 'darwin) "_")
>                                                    (comp-c-func-name
>                                                     (subr-name obj) "F" t)
>                                                    ">:"))))

Hi Jimmy,

as mentioned please write a Changelog entry (see the CONTRIBUTE file).

TIA

  Andrea
  



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: How does nativecomp compile circular lists?
  2021-07-30  8:20               ` Andrea Corallo via Emacs development discussions.
@ 2021-08-03  7:23                 ` Jimmy Yuen Ho Wong
  2021-08-03  8:28                   ` Andrea Corallo via Emacs development discussions.
  0 siblings, 1 reply; 12+ messages in thread
From: Jimmy Yuen Ho Wong @ 2021-08-03  7:23 UTC (permalink / raw)
  To: Andrea Corallo; +Cc: Emacs-Devel devel


[-- Attachment #1.1: Type: text/plain, Size: 1048 bytes --]

On 30/07/2021 9:20 AM, Andrea Corallo wrote:
> Jimmy Yuen Ho Wong <wyuenho@gmail.com> writes:
>> Here's a new patch. Thanks in advance for installing it.
>>
>> diff --git a/lisp/emacs-lisp/disass.el b/lisp/emacs-lisp/disass.el
>> index 6ac76f1c19..bb2e4849ad 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 "<"
>> +                                                  (when (eq system-type 'darwin) "_")
>>                                                     (comp-c-func-name
>>                                                      (subr-name obj) "F" t)
>>                                                     ">:"))))
> Hi Jimmy,
>
> as mentioned please write a Changelog entry (see the CONTRIBUTE file).
>
> TIA
>
>    Andrea
>    

Here's a new patch with a Changelog commit message. Thanks.

-- 
Jimmy Wong


[-- Attachment #1.2: Type: text/html, Size: 1620 bytes --]

[-- Attachment #2: 0001-Fix-error-while-disassembling-native-code-on-macOS.patch --]
[-- Type: text/plain, Size: 1112 bytes --]

From 2d1fbfc87b87e2726252e05db6f27177c6965b09 Mon Sep 17 00:00:00 2001
From: Jimmy Yuen Ho Wong <wyuenho@gmail.com>
Date: Tue, 3 Aug 2021 08:14:38 +0100
Subject: [PATCH] Fix error while disassembling native code on macOS

* lisp/emacs-lisp/disass.el (disassemble-internal): Make sure the
regexp that searches for a symbol takes into account of llvm-objdump's
output format.
---
 lisp/emacs-lisp/disass.el | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lisp/emacs-lisp/disass.el b/lisp/emacs-lisp/disass.el
index 6ac76f1c19..bb2e4849ad 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 "<"
+                                                  (when (eq system-type 'darwin) "_")
                                                   (comp-c-func-name
                                                    (subr-name obj) "F" t)
                                                   ">:"))))
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: How does nativecomp compile circular lists?
  2021-08-03  7:23                 ` Jimmy Yuen Ho Wong
@ 2021-08-03  8:28                   ` Andrea Corallo via Emacs development discussions.
  0 siblings, 0 replies; 12+ messages in thread
From: Andrea Corallo via Emacs development discussions. @ 2021-08-03  8:28 UTC (permalink / raw)
  To: Jimmy Yuen Ho Wong; +Cc: Emacs-Devel devel

Jimmy Yuen Ho Wong <wyuenho@gmail.com> writes:

> On 30/07/2021 9:20 AM, Andrea Corallo wrote:
>
>  Jimmy Yuen Ho Wong <wyuenho@gmail.com> writes:
>
>  
> Here's a new patch. Thanks in advance for installing it.
>
> diff --git a/lisp/emacs-lisp/disass.el b/lisp/emacs-lisp/disass.el
> index 6ac76f1c19..bb2e4849ad 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 "<"
> +                                                  (when (eq system-type 'darwin) "_")
>                                                    (comp-c-func-name
>                                                     (subr-name obj) "F" t)
>                                                    ">:"))))
>
>
> Hi Jimmy,
>
> as mentioned please write a Changelog entry (see the CONTRIBUTE file).
>
> TIA
>
>   Andrea
>   
> Here's a new patch with a Changelog commit message. Thanks.

Applied as b44abacc8c.

Thanks

  Andrea



^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2021-08-03  8:28 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-27  7:21 How does nativecomp compile circular lists? Jimmy Yuen Ho Wong
2021-07-27  9:28 ` Andrea Corallo via Emacs development discussions.
2021-07-28  2:09   ` Jimmy Yuen Ho Wong
     [not found]     ` <6247f78b-282f-27e7-e0cf-6bc3b1cdee26@gmail.com>
2021-07-28  7:20       ` Andrea Corallo via Emacs development discussions.
2021-07-28 13:49         ` Jimmy Yuen Ho Wong
2021-07-28 15:11           ` Andrea Corallo via Emacs development discussions.
2021-07-29 10:43             ` Jimmy Yuen Ho Wong
2021-07-30  8:20               ` Andrea Corallo via Emacs development discussions.
2021-08-03  7:23                 ` Jimmy Yuen Ho Wong
2021-08-03  8:28                   ` Andrea Corallo via Emacs development discussions.
2021-07-28  1:15 ` Michael Heerdegen
2021-07-28  2:18   ` Jimmy Yuen Ho Wong

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).