mirror of
https://github.com/golang/go
synced 2024-11-26 17:16:54 -07:00
reflect: fix memmove for big endian cases with new ABI
Some memmoves in reflect/value.go for copying arguments related to the new ABI were using the address of the target or source instead of using IntArgRegAddr or FloatArgRegAddr to adjust the address for big endian. This was found when testing patches for ppc64 and fixes the failures that were found. Change-Id: I119aa090a2a8eb859020ff1a1736107a6d0b76f1 Reviewed-on: https://go-review.googlesource.com/c/go/+/343869 Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com> Trust: Michael Knyszek <mknyszek@google.com> Trust: Lynn Boger <laboger@linux.vnet.ibm.com>
This commit is contained in:
parent
4fbb5c8666
commit
f1d8ea1da3
@ -508,7 +508,7 @@ func (v Value) call(op string, in []Value) []Value {
|
|||||||
// Copy values to "integer registers."
|
// Copy values to "integer registers."
|
||||||
if v.flag&flagIndir != 0 {
|
if v.flag&flagIndir != 0 {
|
||||||
offset := add(v.ptr, st.offset, "precomputed value offset")
|
offset := add(v.ptr, st.offset, "precomputed value offset")
|
||||||
memmove(unsafe.Pointer(®Args.Ints[st.ireg]), offset, st.size)
|
memmove(regArgs.IntRegArgAddr(st.ireg, st.size), offset, st.size)
|
||||||
} else {
|
} else {
|
||||||
if st.kind == abiStepPointer {
|
if st.kind == abiStepPointer {
|
||||||
// Duplicate this pointer in the pointer area of the
|
// Duplicate this pointer in the pointer area of the
|
||||||
@ -524,7 +524,7 @@ func (v Value) call(op string, in []Value) []Value {
|
|||||||
panic("attempted to copy pointer to FP register")
|
panic("attempted to copy pointer to FP register")
|
||||||
}
|
}
|
||||||
offset := add(v.ptr, st.offset, "precomputed value offset")
|
offset := add(v.ptr, st.offset, "precomputed value offset")
|
||||||
memmove(unsafe.Pointer(®Args.Floats[st.freg]), offset, st.size)
|
memmove(regArgs.FloatRegArgAddr(st.freg, st.size), offset, st.size)
|
||||||
default:
|
default:
|
||||||
panic("unknown ABI part kind")
|
panic("unknown ABI part kind")
|
||||||
}
|
}
|
||||||
@ -610,13 +610,13 @@ func (v Value) call(op string, in []Value) []Value {
|
|||||||
switch st.kind {
|
switch st.kind {
|
||||||
case abiStepIntReg:
|
case abiStepIntReg:
|
||||||
offset := add(s, st.offset, "precomputed value offset")
|
offset := add(s, st.offset, "precomputed value offset")
|
||||||
memmove(offset, unsafe.Pointer(®Args.Ints[st.ireg]), st.size)
|
memmove(offset, regArgs.IntRegArgAddr(st.ireg, st.size), st.size)
|
||||||
case abiStepPointer:
|
case abiStepPointer:
|
||||||
s := add(s, st.offset, "precomputed value offset")
|
s := add(s, st.offset, "precomputed value offset")
|
||||||
*((*unsafe.Pointer)(s)) = regArgs.Ptrs[st.ireg]
|
*((*unsafe.Pointer)(s)) = regArgs.Ptrs[st.ireg]
|
||||||
case abiStepFloatReg:
|
case abiStepFloatReg:
|
||||||
offset := add(s, st.offset, "precomputed value offset")
|
offset := add(s, st.offset, "precomputed value offset")
|
||||||
memmove(offset, unsafe.Pointer(®Args.Floats[st.freg]), st.size)
|
memmove(offset, regArgs.FloatRegArgAddr(st.freg, st.size), st.size)
|
||||||
case abiStepStack:
|
case abiStepStack:
|
||||||
panic("register-based return value has stack component")
|
panic("register-based return value has stack component")
|
||||||
default:
|
default:
|
||||||
@ -698,13 +698,13 @@ func callReflect(ctxt *makeFuncImpl, frame unsafe.Pointer, retValid *bool, regs
|
|||||||
switch st.kind {
|
switch st.kind {
|
||||||
case abiStepIntReg:
|
case abiStepIntReg:
|
||||||
offset := add(v.ptr, st.offset, "precomputed value offset")
|
offset := add(v.ptr, st.offset, "precomputed value offset")
|
||||||
memmove(offset, unsafe.Pointer(®s.Ints[st.ireg]), st.size)
|
memmove(offset, regs.IntRegArgAddr(st.ireg, st.size), st.size)
|
||||||
case abiStepPointer:
|
case abiStepPointer:
|
||||||
s := add(v.ptr, st.offset, "precomputed value offset")
|
s := add(v.ptr, st.offset, "precomputed value offset")
|
||||||
*((*unsafe.Pointer)(s)) = regs.Ptrs[st.ireg]
|
*((*unsafe.Pointer)(s)) = regs.Ptrs[st.ireg]
|
||||||
case abiStepFloatReg:
|
case abiStepFloatReg:
|
||||||
offset := add(v.ptr, st.offset, "precomputed value offset")
|
offset := add(v.ptr, st.offset, "precomputed value offset")
|
||||||
memmove(offset, unsafe.Pointer(®s.Floats[st.freg]), st.size)
|
memmove(offset, regs.FloatRegArgAddr(st.freg, st.size), st.size)
|
||||||
case abiStepStack:
|
case abiStepStack:
|
||||||
panic("register-based return value has stack component")
|
panic("register-based return value has stack component")
|
||||||
default:
|
default:
|
||||||
@ -784,7 +784,7 @@ func callReflect(ctxt *makeFuncImpl, frame unsafe.Pointer, retValid *bool, regs
|
|||||||
// Copy values to "integer registers."
|
// Copy values to "integer registers."
|
||||||
if v.flag&flagIndir != 0 {
|
if v.flag&flagIndir != 0 {
|
||||||
offset := add(v.ptr, st.offset, "precomputed value offset")
|
offset := add(v.ptr, st.offset, "precomputed value offset")
|
||||||
memmove(unsafe.Pointer(®s.Ints[st.ireg]), offset, st.size)
|
memmove(regs.IntRegArgAddr(st.ireg, st.size), offset, st.size)
|
||||||
} else {
|
} else {
|
||||||
// Only populate the Ints space on the return path.
|
// Only populate the Ints space on the return path.
|
||||||
// This is safe because out is kept alive until the
|
// This is safe because out is kept alive until the
|
||||||
@ -799,7 +799,7 @@ func callReflect(ctxt *makeFuncImpl, frame unsafe.Pointer, retValid *bool, regs
|
|||||||
panic("attempted to copy pointer to FP register")
|
panic("attempted to copy pointer to FP register")
|
||||||
}
|
}
|
||||||
offset := add(v.ptr, st.offset, "precomputed value offset")
|
offset := add(v.ptr, st.offset, "precomputed value offset")
|
||||||
memmove(unsafe.Pointer(®s.Floats[st.freg]), offset, st.size)
|
memmove(regs.FloatRegArgAddr(st.freg, st.size), offset, st.size)
|
||||||
default:
|
default:
|
||||||
panic("unknown ABI part kind")
|
panic("unknown ABI part kind")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user