]> Cypherpunks repositories - gostls13.git/commit
cmd/gc: avoid use of goprintf
authorRuss Cox <rsc@golang.org>
Wed, 29 Oct 2014 01:52:53 +0000 (21:52 -0400)
committerRuss Cox <rsc@golang.org>
Wed, 29 Oct 2014 01:52:53 +0000 (21:52 -0400)
commit5e568545991cb358a8a004b21e23ac6fa9801124
treeac094c574d3f32f9eca8c2c253e5a2ed5b4d230a
parent5f54f06a359f2973521ff3f42899c12d3a6a7fed
cmd/gc: avoid use of goprintf

goprintf is a printf-like print for Go.
It is used in the code generated by 'defer print(...)' and 'go print(...)'.

Normally print(1, 2, 3) turns into

        printint(1)
        printint(2)
        printint(3)

but defer and go need a single function call to give the runtime;
they give the runtime something like goprintf("%d%d%d", 1, 2, 3).

Variadic functions like goprintf cannot be described in the new
type information world, so we have to replace it.

Replace with a custom function, so that defer print(1, 2, 3) turns
into

        defer func(a1, a2, a3 int) {
                print(a1, a2, a3)
        }(1, 2, 3)

(and then the print becomes three different printints as usual).

Fixes #8614.

LGTM=austin
R=austin
CC=golang-codereviews, r
https://golang.org/cl/159700043
src/cmd/gc/builtin.c
src/cmd/gc/runtime.go
src/cmd/gc/walk.c
src/runtime/print1.go