]> Cypherpunks repositories - gostls13.git/commitdiff
go/types: less closure creations in gcimporter.
authorRémy Oudompheng <oudomphe@phare.normalesup.org>
Sun, 6 Jan 2013 22:38:38 +0000 (23:38 +0100)
committerRémy Oudompheng <oudomphe@phare.normalesup.org>
Sun, 6 Jan 2013 22:38:38 +0000 (23:38 +0100)
Closures are incredibly expensive on linux/arm due to
repetitive flush of instruction cache.

go test -short on ODROID-X:

Before:
ok      exp/gotype      17.091s
ok      go/types        2.225s

After:
ok      exp/gotype      7.193s
ok      go/types        1.143s

R=dave, minux.ma, rsc
CC=golang-dev, remy
https://golang.org/cl/7062045

src/pkg/go/types/gcimporter.go

index 0e20d5c9a990bc00e5259122b70a1657ab77b756..38b94676bfcabfa9d9b98e4dc9ecfe154dd37f2b 100644 (file)
@@ -408,18 +408,13 @@ func (p *gcParser) parseField() *Field {
 func (p *gcParser) parseStructType() Type {
        var fields []*Field
 
-       parseField := func() {
-               fields = append(fields, p.parseField())
-       }
-
        p.expectKeyword("struct")
        p.expect('{')
-       if p.tok != '}' {
-               parseField()
-               for p.tok == ';' {
-                       p.next()
-                       parseField()
+       for p.tok != '}' {
+               if len(fields) > 0 {
+                       p.expect(';')
                }
+               fields = append(fields, p.parseField())
        }
        p.expect('}')
 
@@ -450,7 +445,11 @@ func (p *gcParser) parseParameter() (par *Var, isVariadic bool) {
 // ParameterList = { Parameter "," } Parameter .
 //
 func (p *gcParser) parseParameters() (list []*Var, isVariadic bool) {
-       parseParameter := func() {
+       p.expect('(')
+       for p.tok != ')' {
+               if len(list) > 0 {
+                       p.expect(',')
+               }
                par, variadic := p.parseParameter()
                list = append(list, par)
                if variadic {
@@ -460,15 +459,6 @@ func (p *gcParser) parseParameters() (list []*Var, isVariadic bool) {
                        isVariadic = true
                }
        }
-
-       p.expect('(')
-       if p.tok != ')' {
-               parseParameter()
-               for p.tok == ',' {
-                       p.next()
-                       parseParameter()
-               }
-       }
        p.expect(')')
 
        return
@@ -509,20 +499,15 @@ func (p *gcParser) parseSignature() *Signature {
 func (p *gcParser) parseInterfaceType() Type {
        var methods []*Method
 
-       parseMethod := func() {
-               name := p.parseName()
-               typ := p.parseSignature()
-               methods = append(methods, &Method{name, typ})
-       }
-
        p.expectKeyword("interface")
        p.expect('{')
-       if p.tok != '}' {
-               parseMethod()
-               for p.tok == ';' {
-                       p.next()
-                       parseMethod()
+       for p.tok != '}' {
+               if len(methods) > 0 {
+                       p.expect(';')
                }
+               name := p.parseName()
+               typ := p.parseSignature()
+               methods = append(methods, &Method{name, typ})
        }
        p.expect('}')