aboutsummaryrefslogtreecommitdiffhomepage
path: root/testdata
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2023-02-17 01:19:53 +0100
committerRon Evans <[email protected]>2023-02-18 10:50:26 +0100
commitc02cc339c564afd767dba0cf2b8a05e959e6ef5b (patch)
tree702e3b5abe629dc76ab96b76a5620cd5413af606 /testdata
parent361ecf9ea452b8787f9b68689216bb26227bd64a (diff)
downloadtinygo-c02cc339c564afd767dba0cf2b8a05e959e6ef5b.tar.gz
tinygo-c02cc339c564afd767dba0cf2b8a05e959e6ef5b.zip
runtime: implement KeepAlive using inline assembly
Diffstat (limited to 'testdata')
-rw-r--r--testdata/gc.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/testdata/gc.go b/testdata/gc.go
index eb594db6c..456d763b4 100644
--- a/testdata/gc.go
+++ b/testdata/gc.go
@@ -1,5 +1,7 @@
package main
+import "runtime"
+
var xorshift32State uint32 = 1
func xorshift32(x uint32) uint32 {
@@ -17,6 +19,7 @@ func randuint32() uint32 {
func main() {
testNonPointerHeap()
+ testKeepAlive()
}
var scalarSlices [4][]byte
@@ -64,3 +67,10 @@ func testNonPointerHeap() {
}
println("ok")
}
+
+func testKeepAlive() {
+ // There isn't much we can test, but at least we can test that
+ // runtime.KeepAlive compiles correctly.
+ var x int
+ runtime.KeepAlive(&x)
+}