wasm: fix GC scanning of allocas

Scanning of allocas was entirely broken on WebAssembly. The code
intended to do this was never run. There were also no tests.

Looking into this further, I found that it is actually not really
necessary to do that: the C stack can be scanned conservatively and in
fact this was already done for goroutine stacks (because they live on
the heap and are always referenced). It wasn't done for the system stack
however.

With these fixes, I believe code should be both faster *and* more
correct.

I found this in my work to get opaque pointers supported in LLVM 15,
because the code that was never reached now finally got run and was
actually quite buggy.
This commit is contained in:
Ayke van Laethem
2022-10-16 00:44:38 +02:00
committed by Ron Evans
parent 6b46ae261a
commit 65d65c1313
7 changed files with 57 additions and 54 deletions
+3
View File
@@ -58,6 +58,8 @@ var (
globalsStart = uintptr(unsafe.Pointer(&globalsStartSymbol))
globalsEnd = uintptr(unsafe.Pointer(&heapStartSymbol))
stackTop = uintptr(unsafe.Pointer(&globalsStartSymbol))
)
func align(ptr uintptr) uintptr {
@@ -67,6 +69,7 @@ func align(ptr uintptr) uintptr {
return (ptr + heapAlign - 1) &^ (heapAlign - 1)
}
//export tinygo_getCurrentStackPointer
func getCurrentStackPointer() uintptr
// growHeap tries to grow the heap size. It returns true if it succeeds, false