From 0aa2317096fde91c51a279b885765b5e26359150 Mon Sep 17 00:00:00 2001 From: Rob Pike Date: Fri, 10 Sep 2010 20:55:29 -0700 Subject: [PATCH] arm: work around reg allocator bug in 5g, in two parts. 1) hack regalloc to leave R9 (m) and R10 (g) alone. the real fix is tricker, but this gets us running 2) fix up the few places in the package sources that the shortage of registers affects, by simplifying some expressions. all of this should be reverted when the right fix is in. Fixes #1084. R=rsc CC=golang-dev https://golang.org/cl/2132046 --- src/cmd/5g/gsubr.c | 3 +++ src/pkg/compress/flate/huffman_bit_writer.go | 10 ++++++++-- src/pkg/gob/decode.go | 11 ++++++++--- src/pkg/log/log.go | 6 +++++- src/pkg/net/ip.go | 14 ++++++++++---- src/pkg/time/format.go | 16 +++++++++++----- src/pkg/xml/xml.go | 10 ++++++++-- 7 files changed, 53 insertions(+), 17 deletions(-) diff --git a/src/cmd/5g/gsubr.c b/src/cmd/5g/gsubr.c index 70ebad6edd..584a0f62b8 100644 --- a/src/cmd/5g/gsubr.c +++ b/src/cmd/5g/gsubr.c @@ -213,6 +213,9 @@ regalloc(Node *n, Type *t, Node *o) { int i, et, fixfree, floatfree; + // guarantee R9 and R10 (m and g) are left alone. BUG. + reg[9] = 1; + reg[10] = 1; if(debug['r']) { fixfree = 0; for(i=REGALLOC_R0; i<=REGALLOC_RMAX; i++) diff --git a/src/pkg/compress/flate/huffman_bit_writer.go b/src/pkg/compress/flate/huffman_bit_writer.go index abff82dd69..294cdf6532 100644 --- a/src/pkg/compress/flate/huffman_bit_writer.go +++ b/src/pkg/compress/flate/huffman_bit_writer.go @@ -110,8 +110,14 @@ func newHuffmanBitWriter(w io.Writer) *huffmanBitWriter { } func (err WrongValueError) String() string { - return "huffmanBitWriter: " + err.name + " should belong to [" + strconv.Itoa64(int64(err.from)) + ";" + - strconv.Itoa64(int64(err.to)) + "] but actual value is " + strconv.Itoa64(int64(err.value)) + // BUG: work around bug in 5g by simplifying expression. + // return "huffmanBitWriter: " + err.name + " should belong to [" + strconv.Itoa64(int64(err.from)) + ";" + + // strconv.Itoa64(int64(err.to)) + "] but actual value is " + strconv.Itoa64(int64(err.value)) + str := "huffmanBitWriter: " + err.name + " should belong to [" + str += strconv.Itoa64(int64(err.from)) + ";" + str += strconv.Itoa64(int64(err.to)) + "] but actual value is " + str += strconv.Itoa64(int64(err.value)) + return str } func (w *huffmanBitWriter) flushBits() { diff --git a/src/pkg/gob/decode.go b/src/pkg/gob/decode.go index a70799e9a7..a91a98bf15 100644 --- a/src/pkg/gob/decode.go +++ b/src/pkg/gob/decode.go @@ -867,9 +867,14 @@ func (dec *Decoder) compileDec(remoteId typeId, rt reflect.Type) (engine *decEng continue } if !dec.compatibleType(localField.Type, wireField.id) { - return nil, os.ErrorString("gob: wrong type (" + - localField.Type.String() + ") for received field " + - wireStruct.name + "." + wireField.name) + // BUG: work around bug in 5g by simplifying expression. + // return nil, os.ErrorString("gob: wrong type (" + + // localField.Type.String() + ") for received field " + + // wireStruct.name + "." + wireField.name) + str := "gob: wrong type (" + str += localField.Type.String() + ") for received field " + str += wireStruct.name + "." + wireField.name + return nil, os.ErrorString(str) } op, indir, err := dec.decOpFor(wireField.id, localField.Type, localField.Name) if err != nil { diff --git a/src/pkg/log/log.go b/src/pkg/log/log.go index 28d6204eb6..cfc1bd7767 100644 --- a/src/pkg/log/log.go +++ b/src/pkg/log/log.go @@ -86,7 +86,11 @@ func (l *Logger) formatHeader(ns int64, calldepth int) string { if l.flag&(Ldate|Ltime|Lmicroseconds) != 0 { t := time.SecondsToLocalTime(ns / 1e9) if l.flag&(Ldate) != 0 { - h += itoa(int(t.Year), 4) + "/" + itoa(t.Month, 2) + "/" + itoa(t.Day, 2) + " " + // BUG: work around bug in 5g by simplifying expression. + // h += itoa(int(t.Year), 4) + "/" + itoa(t.Month, 2) + "/" + itoa(t.Day, 2) + " " + h += itoa(int(t.Year), 4) + h += "/" + itoa(t.Month, 2) + h += "/" + itoa(t.Day, 2) + " " } if l.flag&(Ltime|Lmicroseconds) != 0 { h += itoa(t.Hour, 2) + ":" + itoa(t.Minute, 2) + ":" + itoa(t.Second, 2) diff --git a/src/pkg/net/ip.go b/src/pkg/net/ip.go index e82224a283..29a72971f5 100644 --- a/src/pkg/net/ip.go +++ b/src/pkg/net/ip.go @@ -200,10 +200,16 @@ func (ip IP) String() string { // If IPv4, use dotted notation. if p4 := p.To4(); len(p4) == 4 { - return itod(uint(p4[0])) + "." + - itod(uint(p4[1])) + "." + - itod(uint(p4[2])) + "." + - itod(uint(p4[3])) + // BUG: work around bug in 5g by simplifying expression. + // return itod(uint(p4[0])) + "." + + // itod(uint(p4[1])) + "." + + // itod(uint(p4[2])) + "." + + // itod(uint(p4[3])) + str := itod(uint(p4[0])) + "." + str += itod(uint(p4[1])) + "." + str += itod(uint(p4[2])) + "." + str += itod(uint(p4[3])) + return str } if len(p) != IPv6len { return "?" diff --git a/src/pkg/time/format.go b/src/pkg/time/format.go index 355721e183..bc94cb78e2 100644 --- a/src/pkg/time/format.go +++ b/src/pkg/time/format.go @@ -356,11 +356,17 @@ type ParseError struct { // String is the string representation of a ParseError. func (e *ParseError) String() string { if e.Message == "" { - return "parsing time " + - strconv.Quote(e.Value) + " as " + - strconv.Quote(e.Layout) + ": cannot parse " + - strconv.Quote(e.ValueElem) + " as " + - strconv.Quote(e.LayoutElem) + // BUG: work around bug in 5g by simplifying expression. + // return "parsing time " + + // strconv.Quote(e.Value) + " as " + + // strconv.Quote(e.Layout) + ": cannot parse " + + // strconv.Quote(e.ValueElem) + " as " + + // strconv.Quote(e.LayoutElem) + str := "parsing time " + strconv.Quote(e.Value) + " as " + str += strconv.Quote(e.Layout) + ": cannot parse " + str += strconv.Quote(e.ValueElem) + " as " + str += strconv.Quote(e.LayoutElem) + return str } return "parsing time " + strconv.Quote(e.Value) + e.Message diff --git a/src/pkg/xml/xml.go b/src/pkg/xml/xml.go index cd67f6e265..c72d726c76 100644 --- a/src/pkg/xml/xml.go +++ b/src/pkg/xml/xml.go @@ -371,8 +371,14 @@ func (p *Parser) popElement(t *EndElement) bool { p.err = p.syntaxError("element <" + s.name.Local + "> closed by ") return false case s.name.Space != name.Space: - p.err = p.syntaxError("element <" + s.name.Local + "> in space " + s.name.Space + - "closed by in space " + name.Space) + // BUG: work around bug in 5g by simplifying expression. + // p.err = p.syntaxError("element <" + s.name.Local + "> in space " + s.name.Space + + // "closed by in space " + name.Space) + str := "element <" + s.name.Local + str += "> in space " + s.name.Space + str += "closed by in space " + name.Space + p.err = p.syntaxError(str) return false } -- 2.50.0