-
Notifications
You must be signed in to change notification settings - Fork 57
/
float_memory.wast
157 lines (136 loc) · 6.63 KB
/
float_memory.wast
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
;; Test that floating-point load and store are bit-preserving.
;; Test that load and store do not canonicalize NaNs as x87 does.
(module
(memory (data "\00\00\a0\7f"))
(func (export "f32.load") (result f32) (f32.load (i32.const 0)))
(func (export "i32.load") (result i32) (i32.load (i32.const 0)))
(func (export "f32.store") (f32.store (i32.const 0) (f32.const nan:0x200000)))
(func (export "i32.store") (i32.store (i32.const 0) (i32.const 0x7fa00000)))
(func (export "reset") (i32.store (i32.const 0) (i32.const 0)))
)
(assert_return (invoke "i32.load") (i32.const 0x7fa00000))
(assert_return (invoke "f32.load") (f32.const nan:0x200000))
(invoke "reset")
(assert_return (invoke "i32.load") (i32.const 0x0))
(assert_return (invoke "f32.load") (f32.const 0.0))
(invoke "f32.store")
(assert_return (invoke "i32.load") (i32.const 0x7fa00000))
(assert_return (invoke "f32.load") (f32.const nan:0x200000))
(invoke "reset")
(assert_return (invoke "i32.load") (i32.const 0x0))
(assert_return (invoke "f32.load") (f32.const 0.0))
(invoke "i32.store")
(assert_return (invoke "i32.load") (i32.const 0x7fa00000))
(assert_return (invoke "f32.load") (f32.const nan:0x200000))
(module
(memory (data "\00\00\00\00\00\00\f4\7f"))
(func (export "f64.load") (result f64) (f64.load (i32.const 0)))
(func (export "i64.load") (result i64) (i64.load (i32.const 0)))
(func (export "f64.store") (f64.store (i32.const 0) (f64.const nan:0x4000000000000)))
(func (export "i64.store") (i64.store (i32.const 0) (i64.const 0x7ff4000000000000)))
(func (export "reset") (i64.store (i32.const 0) (i64.const 0)))
)
(assert_return (invoke "i64.load") (i64.const 0x7ff4000000000000))
(assert_return (invoke "f64.load") (f64.const nan:0x4000000000000))
(invoke "reset")
(assert_return (invoke "i64.load") (i64.const 0x0))
(assert_return (invoke "f64.load") (f64.const 0.0))
(invoke "f64.store")
(assert_return (invoke "i64.load") (i64.const 0x7ff4000000000000))
(assert_return (invoke "f64.load") (f64.const nan:0x4000000000000))
(invoke "reset")
(assert_return (invoke "i64.load") (i64.const 0x0))
(assert_return (invoke "f64.load") (f64.const 0.0))
(invoke "i64.store")
(assert_return (invoke "i64.load") (i64.const 0x7ff4000000000000))
(assert_return (invoke "f64.load") (f64.const nan:0x4000000000000))
;; Test that unaligned load and store do not canonicalize NaNs.
(module
(memory (data "\00\00\00\a0\7f"))
(func (export "f32.load") (result f32) (f32.load (i32.const 1)))
(func (export "i32.load") (result i32) (i32.load (i32.const 1)))
(func (export "f32.store") (f32.store (i32.const 1) (f32.const nan:0x200000)))
(func (export "i32.store") (i32.store (i32.const 1) (i32.const 0x7fa00000)))
(func (export "reset") (i32.store (i32.const 1) (i32.const 0)))
)
(assert_return (invoke "i32.load") (i32.const 0x7fa00000))
(assert_return (invoke "f32.load") (f32.const nan:0x200000))
(invoke "reset")
(assert_return (invoke "i32.load") (i32.const 0x0))
(assert_return (invoke "f32.load") (f32.const 0.0))
(invoke "f32.store")
(assert_return (invoke "i32.load") (i32.const 0x7fa00000))
(assert_return (invoke "f32.load") (f32.const nan:0x200000))
(invoke "reset")
(assert_return (invoke "i32.load") (i32.const 0x0))
(assert_return (invoke "f32.load") (f32.const 0.0))
(invoke "i32.store")
(assert_return (invoke "i32.load") (i32.const 0x7fa00000))
(assert_return (invoke "f32.load") (f32.const nan:0x200000))
(module
(memory (data "\00\00\00\00\00\00\00\f4\7f"))
(func (export "f64.load") (result f64) (f64.load (i32.const 1)))
(func (export "i64.load") (result i64) (i64.load (i32.const 1)))
(func (export "f64.store") (f64.store (i32.const 1) (f64.const nan:0x4000000000000)))
(func (export "i64.store") (i64.store (i32.const 1) (i64.const 0x7ff4000000000000)))
(func (export "reset") (i64.store (i32.const 1) (i64.const 0)))
)
(assert_return (invoke "i64.load") (i64.const 0x7ff4000000000000))
(assert_return (invoke "f64.load") (f64.const nan:0x4000000000000))
(invoke "reset")
(assert_return (invoke "i64.load") (i64.const 0x0))
(assert_return (invoke "f64.load") (f64.const 0.0))
(invoke "f64.store")
(assert_return (invoke "i64.load") (i64.const 0x7ff4000000000000))
(assert_return (invoke "f64.load") (f64.const nan:0x4000000000000))
(invoke "reset")
(assert_return (invoke "i64.load") (i64.const 0x0))
(assert_return (invoke "f64.load") (f64.const 0.0))
(invoke "i64.store")
(assert_return (invoke "i64.load") (i64.const 0x7ff4000000000000))
(assert_return (invoke "f64.load") (f64.const nan:0x4000000000000))
;; Test that load and store do not canonicalize NaNs as some JS engines do.
(module
(memory (data "\01\00\d0\7f"))
(func (export "f32.load") (result f32) (f32.load (i32.const 0)))
(func (export "i32.load") (result i32) (i32.load (i32.const 0)))
(func (export "f32.store") (f32.store (i32.const 0) (f32.const nan:0x500001)))
(func (export "i32.store") (i32.store (i32.const 0) (i32.const 0x7fd00001)))
(func (export "reset") (i32.store (i32.const 0) (i32.const 0)))
)
(assert_return (invoke "i32.load") (i32.const 0x7fd00001))
(assert_return (invoke "f32.load") (f32.const nan:0x500001))
(invoke "reset")
(assert_return (invoke "i32.load") (i32.const 0x0))
(assert_return (invoke "f32.load") (f32.const 0.0))
(invoke "f32.store")
(assert_return (invoke "i32.load") (i32.const 0x7fd00001))
(assert_return (invoke "f32.load") (f32.const nan:0x500001))
(invoke "reset")
(assert_return (invoke "i32.load") (i32.const 0x0))
(assert_return (invoke "f32.load") (f32.const 0.0))
(invoke "i32.store")
(assert_return (invoke "i32.load") (i32.const 0x7fd00001))
(assert_return (invoke "f32.load") (f32.const nan:0x500001))
(module
(memory (data "\01\00\00\00\00\00\fc\7f"))
(func (export "f64.load") (result f64) (f64.load (i32.const 0)))
(func (export "i64.load") (result i64) (i64.load (i32.const 0)))
(func (export "f64.store") (f64.store (i32.const 0) (f64.const nan:0xc000000000001)))
(func (export "i64.store") (i64.store (i32.const 0) (i64.const 0x7ffc000000000001)))
(func (export "reset") (i64.store (i32.const 0) (i64.const 0)))
)
(assert_return (invoke "i64.load") (i64.const 0x7ffc000000000001))
(assert_return (invoke "f64.load") (f64.const nan:0xc000000000001))
(invoke "reset")
(assert_return (invoke "i64.load") (i64.const 0x0))
(assert_return (invoke "f64.load") (f64.const 0.0))
(invoke "f64.store")
(assert_return (invoke "i64.load") (i64.const 0x7ffc000000000001))
(assert_return (invoke "f64.load") (f64.const nan:0xc000000000001))
(invoke "reset")
(assert_return (invoke "i64.load") (i64.const 0x0))
(assert_return (invoke "f64.load") (f64.const 0.0))
(invoke "i64.store")
(assert_return (invoke "i64.load") (i64.const 0x7ffc000000000001))
(assert_return (invoke "f64.load") (f64.const nan:0xc000000000001))