mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-04 11:07:46 +00:00
ca7c849da3
Previously we used the i386 target, probably with all optional features disabled. However, the Pentium 4 has been released a _long_ time ago and it seems reasonable to me to take that as a minimum requirement. Upstream Go now also seems to move in this direction: https://github.com/golang/go/issues/40255 The main motivation for this is that there were floating point issues when running the tests for the math package: GOARCH=386 tinygo test math I haven't investigated what's the issue, but I strongly suspect it's caused by the weird x87 80-bit floating point format. This could perhaps be fixed in a different way (by setting the FPU precision to 64 bits) but I figured that just setting the minimum requirement to the Pentium 4 would probably be fine. If needed, we can respect the GO386 environment variable to support these very old CPUs. To support this newer CPU, I had to make sure that the stack is aligned to 16 bytes everywhere. This was not yet always the case.
24 lines
724 B
ArmAsm
24 lines
724 B
ArmAsm
.section .text.tinygo_scanCurrentStack
|
|
.global tinygo_scanCurrentStack
|
|
.type tinygo_scanCurrentStack, %function
|
|
tinygo_scanCurrentStack:
|
|
// Sources:
|
|
// * https://stackoverflow.com/questions/18024672/what-registers-are-preserved-through-a-linux-x86-64-function-call
|
|
// * https://godbolt.org/z/q7e8dn
|
|
|
|
// Save callee-saved registers.
|
|
pushl %ebx
|
|
pushl %esi
|
|
pushl %edi
|
|
pushl %ebp
|
|
|
|
// Scan the stack.
|
|
subl $8, %esp // adjust the stack before the call to maintain 16-byte alignment
|
|
pushl %esp
|
|
calll tinygo_scanstack
|
|
|
|
// Restore the stack pointer. Registers do not need to be restored as they
|
|
// were only pushed to be discoverable by the GC.
|
|
addl $28, %esp
|
|
retl
|