From f2e6492b233c4090bd0be31c5fbd82308eecc153 Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Sun, 1 Dec 2024 09:32:31 +0100 Subject: [PATCH] mips: fix a bug when scanning the stack Previously the assembler was reordering this code: jal tinygo_scanstack move $a0, $sp Into this: jal tinygo_scanstack nop move $a0, $sp So it was "helpfully" inserting a branch delay slot, even though this was already being taken care of. Somehow this didn't break, but it does break in the WIP threading branch (https://github.com/tinygo-org/tinygo/pull/4559) where this bug leads to a crash. --- src/internal/task/task_stack_mipsx.S | 4 ++++ src/runtime/asm_mipsx.S | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/internal/task/task_stack_mipsx.S b/src/internal/task/task_stack_mipsx.S index 903a847c74..018c63d935 100644 --- a/src/internal/task/task_stack_mipsx.S +++ b/src/internal/task/task_stack_mipsx.S @@ -1,3 +1,7 @@ +// Do not reorder instructions to insert a branch delay slot. +// We know what we're doing, and will manually fill the branch delay slot. +.set noreorder + .section .text.tinygo_startTask .global tinygo_startTask .type tinygo_startTask, %function diff --git a/src/runtime/asm_mipsx.S b/src/runtime/asm_mipsx.S index e380643645..f2e81bd941 100644 --- a/src/runtime/asm_mipsx.S +++ b/src/runtime/asm_mipsx.S @@ -1,3 +1,7 @@ +// Do not reorder instructions to insert a branch delay slot. +// We know what we're doing, and will manually fill the branch delay slot. +.set noreorder + .section .text.tinygo_scanCurrentStack .global tinygo_scanCurrentStack .type tinygo_scanCurrentStack, %function