tinygo/src/runtime/arch_amd64.go
Ayke van Laethem eb34afde4b
amd64: align on 16 bytes instead of 8
Some instructions emitted by LLVM (like movaps) expect 16-byte
alignment, while the allocator assumed that 8-byte alignment is good
enough.

TODO: this issue came to light with LLVM optimizing a complex128 store
to the movaps instruction, which must be aligned. It looks like this
means that the <2 x double> IR type is actually 16-byte aligned instead
of 8-byte like a double. If this is the case, the alignment of complex
numbers needs to be updated in the whole compiler.
2019-02-05 17:11:09 +01:00

13 строки
315 Б
Go

package runtime
const GOARCH = "amd64"
// The bitness of the CPU (e.g. 8, 32, 64).
const TargetBits = 64
// Align a pointer.
// Note that some amd64 instructions (like movaps) expect 16-byte aligned
// memory, thus the result must be 16-byte aligned.
func align(ptr uintptr) uintptr {
return (ptr + 15) &^ 15
}