[go-nuts] maptype questions
for this code: m := make(map[int]int, 9) I think the compiler creates a maptype that is stored at type.*+60480(SB) that it uses for the call to runtime.makemap: m := make(map[int]int, 9) 0x10d0b81 488d05f8ec LEAQ type.*+60480(SB), AX 0x10d0b88 48890424 MOVQ AX, 0(SP) 0x10d0b8c 48c74424080900 MOVQ $0x9, 0x8(SP) 0x10d0b95 48c7442410 MOVQ $0x0, 0x10(SP) 0x10d0b9e 6690 NOPW 0x10d0ba0 e8fbdff3ff CALL runtime.makemap(SB) Where is the code in the compiler that creates the maptype? I'm wondering how the bucket size is computed and how the rest of the maptype structure is filled out. Is there a way to print out the type info stored in the binary? -- 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/63557cf7-e92f-48da-8ef8-910e5896cce7o%40googlegroups.com.
[go-nuts] who is mike?
who is mike wrt this commit? commit bc0b4f0d2a610059afb95ef0360704714815187d Author: Ken Thompson Date: Thu Nov 13 10:35:44 2008 -0800 mike's map code R=r OCL=19146 CL=19146 -- 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/ad88ffda-841c-4c22-a420-3d9210b2c1deo%40googlegroups.com.
[go-nuts] Re: [runtime] gostring question
On Tuesday, June 23, 2020 at 7:32:56 PM UTC-5, Bill Morgan wrote: > > I'm a C programmer so maybe this is a dumb question but, why does this > code in runtime/gostring.go allocate (rawstring) then copy data (memmove) > instead of just making the stringStruct.str point at the incoming data? > i.e. copy the pointer instead of allocating+copying data. > > > func gostring(p *byte) string { > l := findnull(p) > if l == 0 { > return "" > } > s, b := rawstring(l) > memmove(unsafe.Pointer([0]), unsafe.Pointer(p), uintptr(l)) > return s > } > looks like the code came from commit: 61dca94e107170d2ff3beb13bb9fa5ce49d8d6fd and the old string.c file had a gostringnocopy that copied the ptr instead of allocating and copying. Wondering why that was removed. I guess there must be some reason that you must have a duplicate copy. -- 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/5b23933b-5d8b-425a-85ea-6042069a661bo%40googlegroups.com.
[go-nuts] [runtime] gostring question
I'm a C programmer so maybe this is a dumb question but, why does this code in runtime/gostring.go allocate (rawstring) then copy data (memmove) instead of just making the stringStruct.str point at the incoming data? i.e. copy the pointer instead of allocating+copying data. func gostring(p *byte) string { l := findnull(p) if l == 0 { return "" } s, b := rawstring(l) memmove(unsafe.Pointer([0]), unsafe.Pointer(p), uintptr(l)) return s } -- 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/8955f1fd-5984-40a2-aae4-0946ae04bdd2o%40googlegroups.com.