"cmd/compile/internal/bitvec"
"cmd/compile/internal/types"
"cmd/internal/obj"
+ "encoding/binary"
)
// Uint8 writes an unsigned byte v into s at offset off,
return UintN(s, off, v, types.PtrSize)
}
+// Uvarint writes a varint v into s at offset off,
+// and returns the next unused offset.
+func Uvarint(s *obj.LSym, off int, v uint64) int {
+ var buf [binary.MaxVarintLen64]byte
+ n := binary.PutUvarint(buf[:], v)
+ return int(s.WriteBytes(base.Ctxt, int64(off), buf[:n]))
+}
+
func Bool(s *obj.LSym, off int, v bool) int {
w := 0
if v {
import (
"bufio"
"bytes"
- "encoding/binary"
"fmt"
"go/constant"
"html"
return a
}
-// dvarint writes a varint v to the funcdata in symbol x and returns the new offset.
-func dvarint(x *obj.LSym, off int, v int64) int {
- if v < 0 {
- panic(fmt.Sprintf("dvarint: bad offset for funcdata - %v", v))
- }
- var buf [binary.MaxVarintLen64]byte
- n := binary.PutUvarint(buf[:], uint64(v))
- for _, b := range buf[:n] {
- off = objw.Uint8(x, off, b)
- }
- return off
-}
-
// emitOpenDeferInfo emits FUNCDATA information about the defers in a function
// that is using open-coded defers. This funcdata is used to determine the active
// defers in a function and execute those defers during panic processing.
s.curfn.LSym.Func().OpenCodedDeferInfo = x
off := 0
- off = dvarint(x, off, -s.deferBitsTemp.FrameOffset())
- off = dvarint(x, off, -firstOffset)
+ off = objw.Uvarint(x, off, uint64(-s.deferBitsTemp.FrameOffset()))
+ off = objw.Uvarint(x, off, uint64(-firstOffset))
}
// buildssa builds an SSA function for fn.