FAQ

On Tue, Jun 7, 2016 at 1:46 PM, Kyle Stanly wrote:

The change I made in cmd/compile/internal/gc/builtin/runtime.go...

func makemap(mapType *byte, hint int64, mapbuf *any, bucketbuf *any,
debug uintptr) (hmap map[any]any)

Once again note debug is a uintptr so I can correctly print out the value.

runtime.go never mentioned needing to explicitly run mkbuiltin.go, I
simply ran go generate, which explains why I messed up. Am I supposed to
explicitly run `go run cmd/compile/internal/gc/mkbuiltin.go'? I figured
it'd be invoked automatically when I ran all.bat
Yes, you must do that manually. It's sort of a historical accident that we
do it this way, as mkbuiltin.go used to be a shell script and we didn't
want to have the build dependent on shell programs. We could change it now
that it is in Go and we depend on a bootstrap go implementation anyway.

The absence of makemap is what I'm confused about. I figured that it
didn't invoke makemap because debug is passed another value than 0, the
value I explicitly pass to mkcall1, seen below...
Absence of makemap from where? Be specific. It probably called makemap,
returned successfully, then got some corruption that caused a later
mapassign1 to fail.

n = mkcall1(fn, n.Type, init, typename(n.Type), conv(n.Left, Types[TINT64
]), a, r, conv(Nodintconst(0), Types[TUINTPTR]))

Lastly, makemap is defined as such...

func makemap(t *maptype, hint int64, h *hmap, bucket unsafe.Pointer,
debug uintptr) *hmap


On Tuesday, June 7, 2016 at 4:27:22 PM UTC-4, Keith Randall wrote:


On Tue, Jun 7, 2016 at 1:05 PM, Kyle Stanly wrote:

So, I've been experimenting quite a bit... first being, I want to add a
new argument to makemap, so I can add a specific flag for whether or not I
want debugging. For example, if it is enabled, I want it to print the value
of each argument, the entrance and exit of certain functions, the callers
up to what is relevant (I.E, up to main()), etc. This is so I can add
changes to the map and be able to debug certain changes and not be
overwhelmed with debug information from the hundreds of uses of map from
others.

Currently, I added a new parameter to make(map...) successfully, however
if I pass as a flag to the new argument to debug, I expect to see debug
information. Hence, I added to makemap a 5th argument...

func makemap(t *maptype, hint int64, h *hmap, bucket unsafe.Pointer,
debug bool) *hmap

Unfortunately it seems that... it's not so simple. I HAVE made the
appropriate changes in reflect_makemap, and made the appropriate changes to
'cmd/compile/internal/gc/builtin/runtime.go', I've run 'go generate' in the
root of the Go repository, and it continues to compile Go bootstrap tool,
Go toolchain, and go_bootstrap for host (windows/amd64), however fails when
I attempt to build packages and commands for windows/amd64, it fails with a
fatal error stating 'fatal error: evacuation not done in time'.
go generate is not required and will not do anything.
Did you change the signature of makemap in
cmd/compile/internal/gc/builtin/runtime.go and rerun
cmd/compile/internal/gc/mkbuiltin.go?

The stack trace is as follows... note debug shows an integer, I
converted the bool to an uintptr to see if it happened to be an address and
not garbage value. Its not entire garbage, because the value is consistent
each time I run it, so its probably the value from something else. I'm
assuming the ABI pushes parameters on the stack.


##### Building packages and commands for windows/amd64.
t: 0x6830e0 ;hint: 0 ;h: 0x0 ;bucket: 0x0 ;debug: 8429248
fatal error: evacuation not done in time

goroutine 1 [running, locked to thread]:
runtime.throw(0x6cc46f, 0x1b)
C:/Users/theif519/Documents/GitHub/go/src/runtime/panic.go:566
+0x9c fp=0xc042037cb8 sp=0xc042037c98
runtime.hashGrow(0x6830e0, 0x809ec0)
C:/Users/theif519/Documents/GitHub/go/src/runtime/hashmap.go:857
+0x195 fp=0xc042037cf0 sp=0xc042037cb8
runtime.mapassign1(0x6830e0, 0x809ec0, 0xc042037e40, 0xc042037e08)
C:/Users/theif519/Documents/GitHub/go/src/runtime/hashmap.go:553
+0x3a4 fp=0xc042037dc8 sp=0xc042037cf0
unicode.init()
C:/Users/theif519/Documents/GitHub/go/src/unicode/tables.go:16
+0xf8 fp=0xc042037e60 sp=0xc042037dc8
bytes.init()
C:/Users/theif519/Documents/GitHub/go/src/bytes/reader.go:151
+0x55 fp=0xc042037e90 sp=0xc042037e60
bufio.init()
C:/Users/theif519/Documents/GitHub/go/src/bufio/scan.go:410
+0x50 fp=0xc042037ec0 sp=0xc042037e90
main.init()
C:/Users/theif519/Documents/GitHub/go/src/cmd/go/zosarch.go:5
+0x55 fp=0xc042037f38 sp=0xc042037ec0
runtime.main()
C:/Users/theif519/Documents/GitHub/go/src/runtime/proc.go:172
+0x1bb fp=0xc042037f90 sp=0xc042037f38
runtime.goexit()

C:/Users/theif519/Documents/GitHub/go/src/runtime/asm_amd64.s:2059 +0x1
fp=0xc042037f98 sp=0xc042037f90

I'm confused, there is no makemap in this stack trace. Where is the
debug flag displayed?

Removing the extra parameter causes it to run just fine. Even if I could
(which I am thinking of doing) marking the Most Significant Bit of hint,
since it only uses the first 32-bits, for flags, I need to know how Go
handles passing it's parameters and why its so sensitive to minimal changes
like this.

Also, I'll assume that it did NOT go through make(...) because OMAKEMAP
explicitly sets debug to 0 for now, unconditionally, so it's being created
in some other manner. I was thinking, after doing some digging, that it
makes some specific assumptions in the assembly implementation of some go
functions, and only push 4 arguments instead of 5, hence the garbage
values. However, if it was pushed in reverse order, then that would not
explain the fact that some are nil and others are not. Are parameters
pushed through registers? That'd kind of make sense if that's the case,
because then the 5th one, R8 I think, would probably hold the previous
value.
No, everything is passed on the stack. It's not PUSHed but MOVed to the
argument slots. If you only reserved 4 slots and gave makemap 5 arguments,
that would clobber some local variable which could lead to arbitrarily bad
behavior. Make sure runtime.go/mkbuiltin
<https://goto.google.com/mkbuiltin>.go are done correctly. Also check
the generated assembly at a makemap call to see if it seems reasonable.

Perhaps I'm wrong and am just doing it wrong, I dunno, any help would be
appreciated. I just need to know what changes I should make to add a new
argument (that way I can create my own later on).

--
You received this message because you are subscribed to the Google
Groups "golang-dev" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to golang-dev+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups
"golang-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to golang-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "golang-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 7 of 23 | next ›
Discussion Overview
groupgolang-dev @
categoriesgo
postedJun 7, '16 at 8:05p
activeJun 10, '16 at 4:24p
posts23
users5
websitegolang.org

People

Translate

site design / logo © 2021 Grokbase