Just add a simple magic number with each op, to detect when
the reader gets desynchronized from the writer.
Change-Id: Iac7dab7f465b0021b1d7ae31c8f8a353ac3663a2
Reviewed-on: https://go-review.googlesource.com/c/go/+/299769
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
interfaceType
)
+const (
+ debug = false
+ magic = 0x6742937dc293105
+)
+
func WriteExports(out *bufio.Writer) {
p := iexporter{
allPkgs: map[*types.Pkg]bool{},
}
func (w *exportWriter) op(op ir.Op) {
+ if debug {
+ w.uint64(magic)
+ }
w.uint64(uint64(op))
}
}
func (r *importReader) op() ir.Op {
+ if debug && r.uint64() != magic {
+ base.Fatalf("import stream has desynchronized")
+ }
return ir.Op(r.uint64())
}