mirror of
https://github.com/golang/go
synced 2024-11-16 21:44:52 -07:00
cmd/compile: move ssagen.dvarint to objw.Uvarint
Follow up discussion in CL 535077. Change-Id: I102c90839e39c463e878ff925872376303724e12 Reviewed-on: https://go-review.googlesource.com/c/go/+/535636 Reviewed-by: Matthew Dempsky <mdempsky@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Than McIntosh <thanm@google.com> Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
This commit is contained in:
parent
da7ac77380
commit
070c1fcbc5
@ -9,6 +9,7 @@ import (
|
||||
"cmd/compile/internal/bitvec"
|
||||
"cmd/compile/internal/types"
|
||||
"cmd/internal/obj"
|
||||
"encoding/binary"
|
||||
)
|
||||
|
||||
// Uint8 writes an unsigned byte v into s at offset off,
|
||||
@ -29,6 +30,14 @@ func Uintptr(s *obj.LSym, off int, v uint64) int {
|
||||
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 {
|
||||
|
@ -7,7 +7,6 @@ package ssagen
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"go/constant"
|
||||
"html"
|
||||
@ -257,19 +256,6 @@ func abiForFunc(fn *ir.Func, abi0, abi1 *abi.ABIConfig) *abi.ABIConfig {
|
||||
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.
|
||||
@ -298,8 +284,8 @@ func (s *state) emitOpenDeferInfo() {
|
||||
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.
|
||||
|
Loading…
Reference in New Issue
Block a user