Re: [go-nuts] go runtime/stubs.go noescape
I did some experiments to mimic the noescape function and modify it with/without the "exclusive-or",but it seems no influence for the escape analysis, sigh. -- 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/msgid/golang-nuts/dd140894-1e53-4788-a8d9-cd0eb8bc77e0%40googlegroups.com.
Re: [go-nuts] go runtime/stubs.go noescape
Yes, I'm just curious about the effect of the "exclusive or". -- 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/msgid/golang-nuts/2bdeacb7-1fe1-49b0-8bec-60b85fa9bc7d%40googlegroups.com.
Re: [go-nuts] go runtime/stubs.go noescape
I believe the question was about the specific implementation of noescape, specifically the "exclusive or" in that unsafe expression. To the original poster: are you just curious why, or is there a more specific question you have? I'm assuming that function looks like that to correctly trick the compiler; perhaps escape analysis gives up if you start xor-ing uintptr values or something like that. -- 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/msgid/golang-nuts/2f2b4f8d-1218-4a12-adf1-34e8b4d63648%40googlegroups.com.
Re: [go-nuts] go runtime/stubs.go noescape
On Sat, Oct 12, 2019 at 1:47 AM tokers wrote: > > Recently I read some go source code and when I read the noescape function in > runtime/stubs.go, I have a doubt about it. > > // noescape hides a pointer from escape analysis. noescape is > // the identity function but escape analysis doesn't think the > // output depends on the input. noescape is inlined and currently > // compiles down to zero instructions. > // USE CAREFULLY! > //go:nosplit > func noescape(p unsafe.Pointer) unsafe.Pointer { >x := uintptr(p) >return unsafe.Pointer(x ^ 0) > } > > > > I don't know what's the purpose of the exclusive or operation? Does it > necessary? The function comment seems clear. Can you be more specific about your question? This is necessary because sometimes the runtime needs to not allocate a value that would otherwise be allocated. For example, the runtime includes the implementation of the heap allocator, and clearly that implementation cannot itself allocate anything. The noescape function is used where allocation would otherwise occur, to ensure that it does not actually allocate. Ian -- 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/msgid/golang-nuts/CAOyqgcXf9mUbXfHrOa%2BmORh0pZ%3DOGmKsRsE8edze%2B19tcWh_kA%40mail.gmail.com.
[go-nuts] go runtime/stubs.go noescape
Hello! Recently I read some go source code and when I read the noescape function in runtime/stubs.go, I have a doubt about it. // noescape hides a pointer from escape analysis. noescape is // the identity function but escape analysis doesn't think the // output depends on the input. noescape is inlined and currently // compiles down to zero instructions. // USE CAREFULLY! //go:nosplit func noescape(p unsafe.Pointer) unsafe.Pointer { x := uintptr(p) return unsafe.Pointer(x ^ 0) } I don't know what's the purpose of the exclusive or operation? Does it necessary? -- 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/msgid/golang-nuts/35fdf376-75eb-4c58-898f-de3be915babe%40googlegroups.com.