From 26b6d0b06d4d0f82a2e60299df149ebeb955e851 Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Tue, 20 Dec 2022 17:13:33 +0100 Subject: [PATCH] runtime: arm actually has 8-byte alignment Specification: https://developer.arm.com/documentation/dui0472/k/C-and-C---Implementation-Details/Basic-data-types-in-ARM-C-and-C-- There are multiple types that have an 8-byte alignment (long long, double) so we need to use the same maximum alignment in TinyGo. Fixing this is necessary for the precise GC. --- src/runtime/arch_arm.go | 4 ++-- src/runtime/arch_cortexm.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/runtime/arch_arm.go b/src/runtime/arch_arm.go index 16d3649b..1868b7eb 100644 --- a/src/runtime/arch_arm.go +++ b/src/runtime/arch_arm.go @@ -9,9 +9,9 @@ const TargetBits = 32 const deferExtraRegs = 0 -// Align on word boundary. +// Align on the maximum alignment for this platform (double). func align(ptr uintptr) uintptr { - return (ptr + 3) &^ 3 + return (ptr + 7) &^ 7 } func getCurrentStackPointer() uintptr { diff --git a/src/runtime/arch_cortexm.go b/src/runtime/arch_cortexm.go index 613dfd5f..45134405 100644 --- a/src/runtime/arch_cortexm.go +++ b/src/runtime/arch_cortexm.go @@ -15,7 +15,7 @@ const deferExtraRegs = 0 // Align on word boundary. func align(ptr uintptr) uintptr { - return (ptr + 3) &^ 3 + return (ptr + 7) &^ 7 } func getCurrentStackPointer() uintptr {