Re: [go-nuts] How to understand assembly code related to defer

2023-09-26 Thread j2gg0s
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

Re: [go-nuts] How to understand assembly code related to defer

2023-09-26 Thread j2gg0s
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

Re: [go-nuts] Golang+CGO using ucontext crash(on purpose) with SIGSEGV or SIGTRAP while using different stacks

2023-09-26 Thread zzk819166453
-- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msg

Re: [go-nuts] How to understand assembly code related to defer

2023-09-26 Thread Ian Lance Taylor
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

Re: [go-nuts] How to understand assembly code related to defer

2023-09-26 Thread Kurtis Rader
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

Re: [go-nuts] How to understand assembly code related to defer

2023-09-26 Thread j2gg0s
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

[go-nuts] Re: Offline version of A Tour of Go

2023-09-26 Thread 王富民awaw
Thanks all for the instructions. I was initially thinking something closer to a single file like PDF. However, I might get away with a web server, too. Thanks On Tuesday, 26 September 2023 at 22:22:41 UTC+8 Pankaj Jangid wrote: > go install golang.org/x/website/tour@latest > > On Tuesday, 26 Sept

Re: [go-nuts] How to understand assembly code related to defer

2023-09-26 Thread Ian Lance Taylor
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 --

Re: [go-nuts] cgo and dynamic linking of shared labraries

2023-09-26 Thread Ian Lance Taylor
On Tue, Sep 26, 2023 at 3:32 AM sbezverk wrote: > > Thank you for your reply, I was under impression that prototype definitions > come from C header files, and since the compilation phase completes with > success, cgo finds all necessary function definitions. My problem is at the > linking pha

Re: [go-nuts] Ping on CL bringing AES speedup in CTR mode

2023-09-26 Thread Nagaev Boris
Hi folks! I updated the CL https://go-review.googlesource.com/c/go/+/413594 to fix the finding of the LUCI bot. Please take another look :) On Sun, Sep 10, 2023 at 6:49 PM Nagaev Boris wrote: > Hi again :-) > > I addressed feedback in CL > https://go-review.googlesource.com/c/go/+/413594 > Gene

[go-nuts] Re: How to understand assembly code related to defer

2023-09-26 Thread j2gg0s
Append: 49b4e8: c0 ae 47 00 00 00 00 shrb $0, 71(%rsi) 在2023年9月26日星期二 UTC+8 22:43:27 写道: > 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 { > def

Re: [go-nuts] When to share an interface, and when not to.

2023-09-26 Thread burak serdar
On Tue, Sep 26, 2023 at 6:18 AM Jerry Londergaard wrote: > > > Do I need to be re-defining this interface everywhere? I guess > an alternative would be to just re-use the `C.DoThinger`, but I feel like > this doesn't seem right as now A is directly importing C, which seems to > 'break' the abstr

[go-nuts] How to understand assembly code related to defer

2023-09-26 Thread j2gg0s
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) } ``

Re: [go-nuts] cgo and dynamic linking of shared labraries

2023-09-26 Thread sbezverk
Related question: is it possible to replace golang's "link" tool with "ld"? It looks like "ld" has greater flexibility to address my requirements. Thank you in advance for your guidance. Serguei On 26/09/23, 12:32, "sbezverk" mailto:sbezv...@gmail.com>> wrote: Thank you for your reply, I was

Re: [go-nuts] [ANN] GraphBLAS binding for Go

2023-09-26 Thread Costanza, Pascal
On 25 Sep 2023, at 23:31, Corin Lawson wrote: Fantastic work! I'm no authority on the subject of Go programming style but the CheckErrors and OK pattern seems very unusual. Can you tell me the reasons for that design choice? The CheckErrors and OK pattern is there to make error checking in Go

[go-nuts] Re: Offline version of A Tour of Go

2023-09-26 Thread Pankaj Jangid
go install golang.org/x/website/tour@latest On Tuesday, 26 September 2023 at 11:59:57 UTC+5:30 王富民awaw wrote: > Hi Friends of Go > > Is there an offline version of A Tour of Go? > Could be in PDF or Powerpoint or preferably Go's beautiful present format. > > A quick Google search didn't reveal an

[go-nuts] Re: weblist in go tool pprof does not work for me

2023-09-26 Thread Sergey Gorlov
Hello, Did you find a solution to this problem? I have the same problem with weblist. All the best, Sergey пятница, 24 июня 2022 г. в 15:27:11 UTC+3, Jochen Voss: > Hello, > > For a while, the "weblist" command in go tool pprof has been broken for me > ("list" still works). Is this a known

[go-nuts] When to share an interface, and when not to.

2023-09-26 Thread Jerry Londergaard
Hello, I'm trying to understand if I'm going overboard with defining interfaces where they are used (i.e am I re-defining them nu-necessarily). Here's an example. The interface is passed down from A->B->C where C (and only C) calls the DoThing() method of the interface: ---

Re: [go-nuts] Offline version of A Tour of Go

2023-09-26 Thread Roland Müller
The tour can be locally installed. https://pkg.go.dev/golang.org/x/website/tour#section-readme go get golang.org/x/tour In the tour/ directory go run . Then local Tour of Go is here: http://localhost:3999/ Am Dienstag, 26. September 2023 schrieb 王富民awaw : > Hi Friends of Go > Is there an offli

Re: [go-nuts] cgo and dynamic linking of shared labraries

2023-09-26 Thread sbezverk
Thank you for your reply, I was under impression that prototype definitions come from C header files, and since the compilation phase completes with success, cgo finds all necessary function definitions. My problem is at the linking phase when the linker by some reason tries to resolve ALL func