summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/ctor-eval/global-get-init.wast8
-rw-r--r--test/ctor-eval/global-get-init.wast.ctors (renamed from test/ctor-eval/imported3.wast.ctors)0
-rw-r--r--test/ctor-eval/global-get-init.wast.out7
-rw-r--r--test/ctor-eval/globals.wast16
-rw-r--r--test/ctor-eval/globals.wast.ctors1
-rw-r--r--test/ctor-eval/globals.wast.out12
-rw-r--r--test/ctor-eval/imported-global.wast (renamed from test/ctor-eval/imported3.wast)0
-rw-r--r--test/ctor-eval/imported-global.wast.ctors1
-rw-r--r--test/ctor-eval/imported-global.wast.out (renamed from test/ctor-eval/imported3.wast.out)0
-rw-r--r--test/ctor-eval/imported2.wast26
-rw-r--r--test/ctor-eval/imported2.wast.ctors1
-rw-r--r--test/ctor-eval/imported2.wast.out23
12 files changed, 45 insertions, 50 deletions
diff --git a/test/ctor-eval/global-get-init.wast b/test/ctor-eval/global-get-init.wast
new file mode 100644
index 000000000..125e672d6
--- /dev/null
+++ b/test/ctor-eval/global-get-init.wast
@@ -0,0 +1,8 @@
+(module
+ (import "import" "global" (global $imported i32))
+ (func $test1 (export "test1")
+ ;; This should be safe to eval in theory, but the imported global stops us,
+ ;; so this function will not be optimized out.
+ ;; TODO: perhaps if we never use that global that is ok?
+ )
+)
diff --git a/test/ctor-eval/imported3.wast.ctors b/test/ctor-eval/global-get-init.wast.ctors
index a5bce3fd2..a5bce3fd2 100644
--- a/test/ctor-eval/imported3.wast.ctors
+++ b/test/ctor-eval/global-get-init.wast.ctors
diff --git a/test/ctor-eval/global-get-init.wast.out b/test/ctor-eval/global-get-init.wast.out
new file mode 100644
index 000000000..ad0110039
--- /dev/null
+++ b/test/ctor-eval/global-get-init.wast.out
@@ -0,0 +1,7 @@
+(module
+ (type $none_=>_none (func))
+ (export "test1" (func $test1))
+ (func $test1
+ (nop)
+ )
+)
diff --git a/test/ctor-eval/globals.wast b/test/ctor-eval/globals.wast
new file mode 100644
index 000000000..47a2023e1
--- /dev/null
+++ b/test/ctor-eval/globals.wast
@@ -0,0 +1,16 @@
+(module
+ (global $g1 (mut i32) (i32.const 10))
+ (global $g2 (mut i32) (i32.const 20))
+ (func $test1 (export "test1")
+ (global.set $g1 (i32.const 30))
+ (global.set $g2 (i32.const 40))
+ (global.set $g1 (i32.const 50)) ;; this overrides the previous 30
+ )
+ (func $keepalive (export "keepalive") (result i32)
+ ;; Keep the globals alive so we can see their values.
+ (i32.add
+ (global.get $g1)
+ (global.get $g2)
+ )
+ )
+)
diff --git a/test/ctor-eval/globals.wast.ctors b/test/ctor-eval/globals.wast.ctors
new file mode 100644
index 000000000..a5bce3fd2
--- /dev/null
+++ b/test/ctor-eval/globals.wast.ctors
@@ -0,0 +1 @@
+test1
diff --git a/test/ctor-eval/globals.wast.out b/test/ctor-eval/globals.wast.out
new file mode 100644
index 000000000..1165d9255
--- /dev/null
+++ b/test/ctor-eval/globals.wast.out
@@ -0,0 +1,12 @@
+(module
+ (type $none_=>_i32 (func (result i32)))
+ (global $g1 (mut i32) (i32.const 50))
+ (global $g2 (mut i32) (i32.const 40))
+ (export "keepalive" (func $keepalive))
+ (func $keepalive (result i32)
+ (i32.add
+ (global.get $g1)
+ (global.get $g2)
+ )
+ )
+)
diff --git a/test/ctor-eval/imported3.wast b/test/ctor-eval/imported-global.wast
index 92fda3fa0..92fda3fa0 100644
--- a/test/ctor-eval/imported3.wast
+++ b/test/ctor-eval/imported-global.wast
diff --git a/test/ctor-eval/imported-global.wast.ctors b/test/ctor-eval/imported-global.wast.ctors
new file mode 100644
index 000000000..a5bce3fd2
--- /dev/null
+++ b/test/ctor-eval/imported-global.wast.ctors
@@ -0,0 +1 @@
+test1
diff --git a/test/ctor-eval/imported3.wast.out b/test/ctor-eval/imported-global.wast.out
index e141211b1..e141211b1 100644
--- a/test/ctor-eval/imported3.wast.out
+++ b/test/ctor-eval/imported-global.wast.out
diff --git a/test/ctor-eval/imported2.wast b/test/ctor-eval/imported2.wast
deleted file mode 100644
index 579a8f383..000000000
--- a/test/ctor-eval/imported2.wast
+++ /dev/null
@@ -1,26 +0,0 @@
-(module
- (memory 256 256)
- (data (i32.const 10) "waka waka waka waka waka")
- ;; stack imports are special-cased
- (import "env" "STACKTOP" (global $STACKTOP i32))
- (import "env" "STACK_MAX" (global $STACK_MAX i32))
- ;; other imports must not be touched!
- (import "env" "tempDoublePtr" (global $tempDoublePtr i32))
- (export "test1" $test1)
- (export "test2" $test2)
- (export "test3" $test3)
- ;; ok to modify a global, if we keep it the same value
- (global $mine (mut i32) (i32.const 1))
- (func $test1
- (global.set $mine (i32.const 2))
- (global.set $mine (i32.const 1)) ;; restore!
- (i32.store8 (i32.const 12) (i32.const 115))
- )
- (func $test2
- (global.set $mine (i32.const 2)) ;; embadden
- (i32.store8 (i32.const 13) (i32.const 115))
- )
- (func $test3
- (i32.store8 (i32.const 14) (i32.const 115))
- )
-)
diff --git a/test/ctor-eval/imported2.wast.ctors b/test/ctor-eval/imported2.wast.ctors
deleted file mode 100644
index c7060ede5..000000000
--- a/test/ctor-eval/imported2.wast.ctors
+++ /dev/null
@@ -1 +0,0 @@
-test1,test2,test3
diff --git a/test/ctor-eval/imported2.wast.out b/test/ctor-eval/imported2.wast.out
deleted file mode 100644
index 6fabeadd6..000000000
--- a/test/ctor-eval/imported2.wast.out
+++ /dev/null
@@ -1,23 +0,0 @@
-(module
- (type $none_=>_none (func))
- (global $mine (mut i32) (i32.const 1))
- (memory $0 256 256)
- (data (i32.const 10) "wasa waka waka waka waka")
- (export "test2" (func $test2))
- (export "test3" (func $test3))
- (func $test2
- (global.set $mine
- (i32.const 2)
- )
- (i32.store8
- (i32.const 13)
- (i32.const 115)
- )
- )
- (func $test3
- (i32.store8
- (i32.const 14)
- (i32.const 115)
- )
- )
-)