Thanks for the guidance, the corresponding documentation helped me a lot
在2023年9月28日星期四 UTC+8 11:34:21 写道:
> On Tue, Sep 26, 2023 at 11:06 PM j2gg0s wrote:
> >
> > Related go code:
> > 22 //go:noinline
> > 23 func add(a, b int) int {
> > 24 defer func() {
> > 25 fmt.Println(3)
> > 26 }()
> > 27
On Tue, Sep 26, 2023 at 11:06 PM j2gg0s wrote:
>
> Related go code:
> 22 //go:noinline
> 23 func add(a, b int) int {
> 24 defer func() {
> 25 fmt.Println(3)
> 26 }()
> 27 return a + b
> 28 }
>
> Build by: GOOS=linux GOARCH=
It's not a bug or a performance issue.
Just because I am about to have a long hoilday, so I want to learn some
knowledge about go compiler.
But as a newbie in assembly, I spent some time on Google but couldn't
understand this instruction.
在2023年9月27日星期三 UTC+8 12:43:05 写道:
> More context regardi
Related go code:
22 //go:noinline
23 func add(a, b int) int {
24 defer func() {
25 fmt.Println(3)
26 }()
27 return a + b
28 }
Build by: GOOS=linux GOARCH=amd64 go21 build main.go
Disassembler by: objdump -D -S main
Assembl
On Tue, Sep 26, 2023 at 9:10 PM j2gg0s wrote:
>
> Already read it, I actually started here.
>
> What I can't understand is x64 rip-relative address.
>
> leaq132795(%rip), %rcx # 0x49b4e8
>
> why 132795, and what is loaded into rcx
It's a reference to another address in the program. The
More context regarding your question might help. Why are you trying to
understand the assembly code? Are you trying to debug a failure in the
wild? Are you trying to make the implementation more efficient? Are you
simply curious how the implementation works? Your question is rather broad
and likely
Thanks @lan
Already read it, I actually started here.
What I can't understand is x64 rip-relative address.
leaq132795(%rip), %rcx # 0x49b4e8
why 132795, and what is loaded into rcx
在2023年9月27日星期三 UTC+8 09:38:17 写道:
> On Tue, Sep 26, 2023 at 7:43 AM j2gg0s wrote:
> >
> > How to unde
On Tue, Sep 26, 2023 at 7:43 AM j2gg0s wrote:
>
> How to understand assmbly code ` 47ae26: 48 8d 0d bb 06 02 00 leaq
> 132795(%rip), %rcx # 0x49b4e8 `
The best place to start is
https://go.googlesource.com/proposal/+/refs/heads/master/design/34481-opencoded-defers.md
Ian
--
How to understand assmbly code ` 47ae26: 48 8d 0d bb 06 02 00
leaq132795(%rip), %rcx # 0x49b4e8 `
Go code:
```
//go:noinline
func add(a, b int) int {
defer func() {
fmt.Println(3)
}()
return a + b
}
func main() {
add(10, 20)
}
``