1 /* Copyright 2018 Mozilla Foundation
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 use std::error::Error;
17 use std::fmt;
18 use std::result;
19 
20 #[derive(Debug, Clone)]
21 pub struct BinaryReaderError {
22     // Wrap the actual error data in a `Box` so that the error is just one
23     // word. This means that we can continue returning small `Result`s in
24     // registers.
25     pub(crate) inner: Box<BinaryReaderErrorInner>,
26 }
27 
28 #[derive(Debug, Clone)]
29 pub(crate) struct BinaryReaderErrorInner {
30     pub(crate) message: String,
31     pub(crate) offset: usize,
32     pub(crate) needed_hint: Option<usize>,
33 }
34 
35 pub type Result<T, E = BinaryReaderError> = result::Result<T, E>;
36 
37 impl Error for BinaryReaderError {}
38 
39 impl fmt::Display for BinaryReaderError {
fmt(&self, f: &mut fmt::Formatter) -> fmt::Result40     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
41         write!(
42             f,
43             "{} (at offset {})",
44             self.inner.message, self.inner.offset
45         )
46     }
47 }
48 
49 impl BinaryReaderError {
new(message: impl Into<String>, offset: usize) -> Self50     pub(crate) fn new(message: impl Into<String>, offset: usize) -> Self {
51         let message = message.into();
52         BinaryReaderError {
53             inner: Box::new(BinaryReaderErrorInner {
54                 message,
55                 offset,
56                 needed_hint: None,
57             }),
58         }
59     }
60 
eof(offset: usize, needed_hint: usize) -> Self61     pub(crate) fn eof(offset: usize, needed_hint: usize) -> Self {
62         BinaryReaderError {
63             inner: Box::new(BinaryReaderErrorInner {
64                 message: "Unexpected EOF".to_string(),
65                 offset,
66                 needed_hint: Some(needed_hint),
67             }),
68         }
69     }
70 
71     /// Get this error's message.
message(&self) -> &str72     pub fn message(&self) -> &str {
73         &self.inner.message
74     }
75 
76     /// Get the offset within the Wasm binary where the error occured.
offset(&self) -> usize77     pub fn offset(&self) -> usize {
78         self.inner.offset
79     }
80 }
81 
82 #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
83 pub enum CustomSectionKind {
84     Unknown,
85     Name,
86     Producers,
87     SourceMappingURL,
88     Reloc,
89     Linking,
90 }
91 
92 /// Section code as defined [here].
93 ///
94 /// [here]: https://webassembly.github.io/spec/core/binary/modules.html#sections
95 #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
96 pub enum SectionCode<'a> {
97     Custom {
98         name: &'a str,
99         kind: CustomSectionKind,
100     },
101     Type,       // Function signature declarations
102     Alias,      // Aliased indices from nested/parent modules
103     Import,     // Import declarations
104     Module,     // Module declarations
105     Instance,   // Instance definitions
106     Function,   // Function declarations
107     Table,      // Indirect function table and other tables
108     Memory,     // Memory attributes
109     Global,     // Global declarations
110     Export,     // Exports
111     Start,      // Start function declaration
112     Element,    // Elements section
113     ModuleCode, // Module definitions
114     Code,       // Function bodies (code)
115     Data,       // Data segments
116     DataCount,  // Count of passive data segments
117     Event,      // Event declarations
118 }
119 
120 /// Types as defined [here].
121 ///
122 /// [here]: https://webassembly.github.io/spec/core/syntax/types.html#types
123 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
124 pub enum Type {
125     I32,
126     I64,
127     F32,
128     F64,
129     V128,
130     FuncRef,
131     ExternRef,
132     ExnRef,
133     Func,
134     EmptyBlockType,
135 }
136 
137 /// Either a value type or a function type.
138 #[derive(Debug, Copy, Clone, PartialEq, Eq)]
139 pub enum TypeOrFuncType {
140     /// A value type.
141     ///
142     /// When used as the type for a block, this type is the optional result
143     /// type: `[] -> [t?]`.
144     Type(Type),
145 
146     /// A function type (referenced as an index into the types section).
147     FuncType(u32),
148 }
149 
150 /// External types as defined [here].
151 ///
152 /// [here]: https://webassembly.github.io/spec/core/syntax/types.html#external-types
153 #[derive(Debug, Copy, Clone)]
154 pub enum ExternalKind {
155     Function,
156     Table,
157     Memory,
158     Event,
159     Global,
160     Type,
161     Module,
162     Instance,
163 }
164 
165 #[derive(Debug, Clone)]
166 pub enum TypeDef<'a> {
167     Func(FuncType),
168     Instance(InstanceType<'a>),
169     Module(ModuleType<'a>),
170 }
171 
172 #[derive(Debug, Clone, Eq, PartialEq, Hash)]
173 pub struct FuncType {
174     pub params: Box<[Type]>,
175     pub returns: Box<[Type]>,
176 }
177 
178 #[derive(Debug, Clone)]
179 pub struct InstanceType<'a> {
180     pub exports: Box<[ExportType<'a>]>,
181 }
182 
183 #[derive(Debug, Clone)]
184 pub struct ModuleType<'a> {
185     pub imports: Box<[crate::Import<'a>]>,
186     pub exports: Box<[ExportType<'a>]>,
187 }
188 
189 #[derive(Debug, Clone)]
190 pub struct ExportType<'a> {
191     pub name: &'a str,
192     pub ty: ImportSectionEntryType,
193 }
194 
195 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
196 pub struct ResizableLimits {
197     pub initial: u32,
198     pub maximum: Option<u32>,
199 }
200 
201 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
202 pub struct ResizableLimits64 {
203     pub initial: u64,
204     pub maximum: Option<u64>,
205 }
206 
207 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
208 pub struct TableType {
209     pub element_type: Type,
210     pub limits: ResizableLimits,
211 }
212 
213 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
214 pub enum MemoryType {
215     M32 {
216         limits: ResizableLimits,
217         shared: bool,
218     },
219     M64 {
220         limits: ResizableLimits64,
221         shared: bool,
222     },
223 }
224 
225 #[derive(Debug, Copy, Clone, PartialEq, Eq)]
226 pub struct EventType {
227     pub type_index: u32,
228 }
229 
230 impl MemoryType {
index_type(&self) -> Type231     pub fn index_type(&self) -> Type {
232         match self {
233             MemoryType::M32 { .. } => Type::I32,
234             MemoryType::M64 { .. } => Type::I64,
235         }
236     }
237 }
238 
239 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
240 pub struct GlobalType {
241     pub content_type: Type,
242     pub mutable: bool,
243 }
244 
245 #[derive(Debug, Copy, Clone)]
246 pub enum ImportSectionEntryType {
247     Function(u32),
248     Table(TableType),
249     Memory(MemoryType),
250     Event(EventType),
251     Global(GlobalType),
252     Module(u32),
253     Instance(u32),
254 }
255 
256 #[derive(Debug, Copy, Clone)]
257 pub struct MemoryImmediate {
258     /// Alignment, stored as `n` where the actual alignment is `2^n`
259     pub align: u8,
260     pub offset: u32,
261     pub memory: u32,
262 }
263 
264 #[derive(Debug, Copy, Clone)]
265 pub struct Naming<'a> {
266     pub index: u32,
267     pub name: &'a str,
268 }
269 
270 #[derive(Debug, Copy, Clone)]
271 pub enum NameType {
272     Module,
273     Function,
274     Local,
275     Unknown(u32),
276 }
277 
278 #[derive(Debug, Copy, Clone)]
279 pub enum LinkingType {
280     StackPointer(u32),
281 }
282 
283 #[derive(Debug, Copy, Clone)]
284 pub enum RelocType {
285     FunctionIndexLEB,
286     TableIndexSLEB,
287     TableIndexI32,
288     GlobalAddrLEB,
289     GlobalAddrSLEB,
290     GlobalAddrI32,
291     TypeIndexLEB,
292     GlobalIndexLEB,
293 }
294 
295 /// A br_table entries representation.
296 #[derive(Clone)]
297 pub struct BrTable<'a> {
298     pub(crate) reader: crate::BinaryReader<'a>,
299     pub(crate) cnt: usize,
300 }
301 
302 /// An IEEE binary32 immediate floating point value, represented as a u32
303 /// containing the bitpattern.
304 ///
305 /// All bit patterns are allowed.
306 #[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
307 pub struct Ieee32(pub(crate) u32);
308 
309 impl Ieee32 {
bits(self) -> u32310     pub fn bits(self) -> u32 {
311         self.0
312     }
313 }
314 
315 /// An IEEE binary64 immediate floating point value, represented as a u64
316 /// containing the bitpattern.
317 ///
318 /// All bit patterns are allowed.
319 #[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
320 pub struct Ieee64(pub(crate) u64);
321 
322 impl Ieee64 {
bits(self) -> u64323     pub fn bits(self) -> u64 {
324         self.0
325     }
326 }
327 
328 #[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
329 pub struct V128(pub(crate) [u8; 16]);
330 
331 impl V128 {
bytes(&self) -> &[u8; 16]332     pub fn bytes(&self) -> &[u8; 16] {
333         &self.0
334     }
335 }
336 
337 pub type SIMDLaneIndex = u8;
338 
339 /// Instructions as defined [here].
340 ///
341 /// [here]: https://webassembly.github.io/spec/core/binary/instructions.html
342 #[derive(Debug, Clone)]
343 pub enum Operator<'a> {
344     Unreachable,
345     Nop,
346     Block {
347         ty: TypeOrFuncType,
348     },
349     Loop {
350         ty: TypeOrFuncType,
351     },
352     If {
353         ty: TypeOrFuncType,
354     },
355     Else,
356     Try {
357         ty: TypeOrFuncType,
358     },
359     Catch {
360         index: u32,
361     },
362     Throw {
363         index: u32,
364     },
365     Rethrow {
366         relative_depth: u32,
367     },
368     Unwind,
369     End,
370     Br {
371         relative_depth: u32,
372     },
373     BrIf {
374         relative_depth: u32,
375     },
376     BrTable {
377         table: BrTable<'a>,
378     },
379     Return,
380     Call {
381         function_index: u32,
382     },
383     CallIndirect {
384         index: u32,
385         table_index: u32,
386     },
387     ReturnCall {
388         function_index: u32,
389     },
390     ReturnCallIndirect {
391         index: u32,
392         table_index: u32,
393     },
394     Delegate {
395         relative_depth: u32,
396     },
397     CatchAll,
398     Drop,
399     Select,
400     TypedSelect {
401         ty: Type,
402     },
403     LocalGet {
404         local_index: u32,
405     },
406     LocalSet {
407         local_index: u32,
408     },
409     LocalTee {
410         local_index: u32,
411     },
412     GlobalGet {
413         global_index: u32,
414     },
415     GlobalSet {
416         global_index: u32,
417     },
418     I32Load {
419         memarg: MemoryImmediate,
420     },
421     I64Load {
422         memarg: MemoryImmediate,
423     },
424     F32Load {
425         memarg: MemoryImmediate,
426     },
427     F64Load {
428         memarg: MemoryImmediate,
429     },
430     I32Load8S {
431         memarg: MemoryImmediate,
432     },
433     I32Load8U {
434         memarg: MemoryImmediate,
435     },
436     I32Load16S {
437         memarg: MemoryImmediate,
438     },
439     I32Load16U {
440         memarg: MemoryImmediate,
441     },
442     I64Load8S {
443         memarg: MemoryImmediate,
444     },
445     I64Load8U {
446         memarg: MemoryImmediate,
447     },
448     I64Load16S {
449         memarg: MemoryImmediate,
450     },
451     I64Load16U {
452         memarg: MemoryImmediate,
453     },
454     I64Load32S {
455         memarg: MemoryImmediate,
456     },
457     I64Load32U {
458         memarg: MemoryImmediate,
459     },
460     I32Store {
461         memarg: MemoryImmediate,
462     },
463     I64Store {
464         memarg: MemoryImmediate,
465     },
466     F32Store {
467         memarg: MemoryImmediate,
468     },
469     F64Store {
470         memarg: MemoryImmediate,
471     },
472     I32Store8 {
473         memarg: MemoryImmediate,
474     },
475     I32Store16 {
476         memarg: MemoryImmediate,
477     },
478     I64Store8 {
479         memarg: MemoryImmediate,
480     },
481     I64Store16 {
482         memarg: MemoryImmediate,
483     },
484     I64Store32 {
485         memarg: MemoryImmediate,
486     },
487     MemorySize {
488         mem: u32,
489         mem_byte: u8,
490     },
491     MemoryGrow {
492         mem: u32,
493         mem_byte: u8,
494     },
495     I32Const {
496         value: i32,
497     },
498     I64Const {
499         value: i64,
500     },
501     F32Const {
502         value: Ieee32,
503     },
504     F64Const {
505         value: Ieee64,
506     },
507     RefNull {
508         ty: Type,
509     },
510     RefIsNull,
511     RefFunc {
512         function_index: u32,
513     },
514     I32Eqz,
515     I32Eq,
516     I32Ne,
517     I32LtS,
518     I32LtU,
519     I32GtS,
520     I32GtU,
521     I32LeS,
522     I32LeU,
523     I32GeS,
524     I32GeU,
525     I64Eqz,
526     I64Eq,
527     I64Ne,
528     I64LtS,
529     I64LtU,
530     I64GtS,
531     I64GtU,
532     I64LeS,
533     I64LeU,
534     I64GeS,
535     I64GeU,
536     F32Eq,
537     F32Ne,
538     F32Lt,
539     F32Gt,
540     F32Le,
541     F32Ge,
542     F64Eq,
543     F64Ne,
544     F64Lt,
545     F64Gt,
546     F64Le,
547     F64Ge,
548     I32Clz,
549     I32Ctz,
550     I32Popcnt,
551     I32Add,
552     I32Sub,
553     I32Mul,
554     I32DivS,
555     I32DivU,
556     I32RemS,
557     I32RemU,
558     I32And,
559     I32Or,
560     I32Xor,
561     I32Shl,
562     I32ShrS,
563     I32ShrU,
564     I32Rotl,
565     I32Rotr,
566     I64Clz,
567     I64Ctz,
568     I64Popcnt,
569     I64Add,
570     I64Sub,
571     I64Mul,
572     I64DivS,
573     I64DivU,
574     I64RemS,
575     I64RemU,
576     I64And,
577     I64Or,
578     I64Xor,
579     I64Shl,
580     I64ShrS,
581     I64ShrU,
582     I64Rotl,
583     I64Rotr,
584     F32Abs,
585     F32Neg,
586     F32Ceil,
587     F32Floor,
588     F32Trunc,
589     F32Nearest,
590     F32Sqrt,
591     F32Add,
592     F32Sub,
593     F32Mul,
594     F32Div,
595     F32Min,
596     F32Max,
597     F32Copysign,
598     F64Abs,
599     F64Neg,
600     F64Ceil,
601     F64Floor,
602     F64Trunc,
603     F64Nearest,
604     F64Sqrt,
605     F64Add,
606     F64Sub,
607     F64Mul,
608     F64Div,
609     F64Min,
610     F64Max,
611     F64Copysign,
612     I32WrapI64,
613     I32TruncF32S,
614     I32TruncF32U,
615     I32TruncF64S,
616     I32TruncF64U,
617     I64ExtendI32S,
618     I64ExtendI32U,
619     I64TruncF32S,
620     I64TruncF32U,
621     I64TruncF64S,
622     I64TruncF64U,
623     F32ConvertI32S,
624     F32ConvertI32U,
625     F32ConvertI64S,
626     F32ConvertI64U,
627     F32DemoteF64,
628     F64ConvertI32S,
629     F64ConvertI32U,
630     F64ConvertI64S,
631     F64ConvertI64U,
632     F64PromoteF32,
633     I32ReinterpretF32,
634     I64ReinterpretF64,
635     F32ReinterpretI32,
636     F64ReinterpretI64,
637     I32Extend8S,
638     I32Extend16S,
639     I64Extend8S,
640     I64Extend16S,
641     I64Extend32S,
642 
643     // 0xFC operators
644     // Non-trapping Float-to-int Conversions
645     I32TruncSatF32S,
646     I32TruncSatF32U,
647     I32TruncSatF64S,
648     I32TruncSatF64U,
649     I64TruncSatF32S,
650     I64TruncSatF32U,
651     I64TruncSatF64S,
652     I64TruncSatF64U,
653 
654     // 0xFC operators
655     // bulk memory https://github.com/WebAssembly/bulk-memory-operations/blob/master/proposals/bulk-memory-operations/Overview.md
656     MemoryInit {
657         segment: u32,
658         mem: u32,
659     },
660     DataDrop {
661         segment: u32,
662     },
663     MemoryCopy {
664         src: u32,
665         dst: u32,
666     },
667     MemoryFill {
668         mem: u32,
669     },
670     TableInit {
671         segment: u32,
672         table: u32,
673     },
674     ElemDrop {
675         segment: u32,
676     },
677     TableCopy {
678         dst_table: u32,
679         src_table: u32,
680     },
681     TableFill {
682         table: u32,
683     },
684     TableGet {
685         table: u32,
686     },
687     TableSet {
688         table: u32,
689     },
690     TableGrow {
691         table: u32,
692     },
693     TableSize {
694         table: u32,
695     },
696 
697     // 0xFE operators
698     // https://github.com/WebAssembly/threads/blob/master/proposals/threads/Overview.md
699     MemoryAtomicNotify {
700         memarg: MemoryImmediate,
701     },
702     MemoryAtomicWait32 {
703         memarg: MemoryImmediate,
704     },
705     MemoryAtomicWait64 {
706         memarg: MemoryImmediate,
707     },
708     AtomicFence {
709         flags: u8,
710     },
711     I32AtomicLoad {
712         memarg: MemoryImmediate,
713     },
714     I64AtomicLoad {
715         memarg: MemoryImmediate,
716     },
717     I32AtomicLoad8U {
718         memarg: MemoryImmediate,
719     },
720     I32AtomicLoad16U {
721         memarg: MemoryImmediate,
722     },
723     I64AtomicLoad8U {
724         memarg: MemoryImmediate,
725     },
726     I64AtomicLoad16U {
727         memarg: MemoryImmediate,
728     },
729     I64AtomicLoad32U {
730         memarg: MemoryImmediate,
731     },
732     I32AtomicStore {
733         memarg: MemoryImmediate,
734     },
735     I64AtomicStore {
736         memarg: MemoryImmediate,
737     },
738     I32AtomicStore8 {
739         memarg: MemoryImmediate,
740     },
741     I32AtomicStore16 {
742         memarg: MemoryImmediate,
743     },
744     I64AtomicStore8 {
745         memarg: MemoryImmediate,
746     },
747     I64AtomicStore16 {
748         memarg: MemoryImmediate,
749     },
750     I64AtomicStore32 {
751         memarg: MemoryImmediate,
752     },
753     I32AtomicRmwAdd {
754         memarg: MemoryImmediate,
755     },
756     I64AtomicRmwAdd {
757         memarg: MemoryImmediate,
758     },
759     I32AtomicRmw8AddU {
760         memarg: MemoryImmediate,
761     },
762     I32AtomicRmw16AddU {
763         memarg: MemoryImmediate,
764     },
765     I64AtomicRmw8AddU {
766         memarg: MemoryImmediate,
767     },
768     I64AtomicRmw16AddU {
769         memarg: MemoryImmediate,
770     },
771     I64AtomicRmw32AddU {
772         memarg: MemoryImmediate,
773     },
774     I32AtomicRmwSub {
775         memarg: MemoryImmediate,
776     },
777     I64AtomicRmwSub {
778         memarg: MemoryImmediate,
779     },
780     I32AtomicRmw8SubU {
781         memarg: MemoryImmediate,
782     },
783     I32AtomicRmw16SubU {
784         memarg: MemoryImmediate,
785     },
786     I64AtomicRmw8SubU {
787         memarg: MemoryImmediate,
788     },
789     I64AtomicRmw16SubU {
790         memarg: MemoryImmediate,
791     },
792     I64AtomicRmw32SubU {
793         memarg: MemoryImmediate,
794     },
795     I32AtomicRmwAnd {
796         memarg: MemoryImmediate,
797     },
798     I64AtomicRmwAnd {
799         memarg: MemoryImmediate,
800     },
801     I32AtomicRmw8AndU {
802         memarg: MemoryImmediate,
803     },
804     I32AtomicRmw16AndU {
805         memarg: MemoryImmediate,
806     },
807     I64AtomicRmw8AndU {
808         memarg: MemoryImmediate,
809     },
810     I64AtomicRmw16AndU {
811         memarg: MemoryImmediate,
812     },
813     I64AtomicRmw32AndU {
814         memarg: MemoryImmediate,
815     },
816     I32AtomicRmwOr {
817         memarg: MemoryImmediate,
818     },
819     I64AtomicRmwOr {
820         memarg: MemoryImmediate,
821     },
822     I32AtomicRmw8OrU {
823         memarg: MemoryImmediate,
824     },
825     I32AtomicRmw16OrU {
826         memarg: MemoryImmediate,
827     },
828     I64AtomicRmw8OrU {
829         memarg: MemoryImmediate,
830     },
831     I64AtomicRmw16OrU {
832         memarg: MemoryImmediate,
833     },
834     I64AtomicRmw32OrU {
835         memarg: MemoryImmediate,
836     },
837     I32AtomicRmwXor {
838         memarg: MemoryImmediate,
839     },
840     I64AtomicRmwXor {
841         memarg: MemoryImmediate,
842     },
843     I32AtomicRmw8XorU {
844         memarg: MemoryImmediate,
845     },
846     I32AtomicRmw16XorU {
847         memarg: MemoryImmediate,
848     },
849     I64AtomicRmw8XorU {
850         memarg: MemoryImmediate,
851     },
852     I64AtomicRmw16XorU {
853         memarg: MemoryImmediate,
854     },
855     I64AtomicRmw32XorU {
856         memarg: MemoryImmediate,
857     },
858     I32AtomicRmwXchg {
859         memarg: MemoryImmediate,
860     },
861     I64AtomicRmwXchg {
862         memarg: MemoryImmediate,
863     },
864     I32AtomicRmw8XchgU {
865         memarg: MemoryImmediate,
866     },
867     I32AtomicRmw16XchgU {
868         memarg: MemoryImmediate,
869     },
870     I64AtomicRmw8XchgU {
871         memarg: MemoryImmediate,
872     },
873     I64AtomicRmw16XchgU {
874         memarg: MemoryImmediate,
875     },
876     I64AtomicRmw32XchgU {
877         memarg: MemoryImmediate,
878     },
879     I32AtomicRmwCmpxchg {
880         memarg: MemoryImmediate,
881     },
882     I64AtomicRmwCmpxchg {
883         memarg: MemoryImmediate,
884     },
885     I32AtomicRmw8CmpxchgU {
886         memarg: MemoryImmediate,
887     },
888     I32AtomicRmw16CmpxchgU {
889         memarg: MemoryImmediate,
890     },
891     I64AtomicRmw8CmpxchgU {
892         memarg: MemoryImmediate,
893     },
894     I64AtomicRmw16CmpxchgU {
895         memarg: MemoryImmediate,
896     },
897     I64AtomicRmw32CmpxchgU {
898         memarg: MemoryImmediate,
899     },
900 
901     // 0xFD operators
902     // SIMD https://webassembly.github.io/simd/core/binary/instructions.html
903     V128Load {
904         memarg: MemoryImmediate,
905     },
906     V128Load8x8S {
907         memarg: MemoryImmediate,
908     },
909     V128Load8x8U {
910         memarg: MemoryImmediate,
911     },
912     V128Load16x4S {
913         memarg: MemoryImmediate,
914     },
915     V128Load16x4U {
916         memarg: MemoryImmediate,
917     },
918     V128Load32x2S {
919         memarg: MemoryImmediate,
920     },
921     V128Load32x2U {
922         memarg: MemoryImmediate,
923     },
924     V128Load8Splat {
925         memarg: MemoryImmediate,
926     },
927     V128Load16Splat {
928         memarg: MemoryImmediate,
929     },
930     V128Load32Splat {
931         memarg: MemoryImmediate,
932     },
933     V128Load64Splat {
934         memarg: MemoryImmediate,
935     },
936     V128Load32Zero {
937         memarg: MemoryImmediate,
938     },
939     V128Load64Zero {
940         memarg: MemoryImmediate,
941     },
942     V128Store {
943         memarg: MemoryImmediate,
944     },
945     V128Load8Lane {
946         memarg: MemoryImmediate,
947         lane: SIMDLaneIndex,
948     },
949     V128Load16Lane {
950         memarg: MemoryImmediate,
951         lane: SIMDLaneIndex,
952     },
953     V128Load32Lane {
954         memarg: MemoryImmediate,
955         lane: SIMDLaneIndex,
956     },
957     V128Load64Lane {
958         memarg: MemoryImmediate,
959         lane: SIMDLaneIndex,
960     },
961     V128Store8Lane {
962         memarg: MemoryImmediate,
963         lane: SIMDLaneIndex,
964     },
965     V128Store16Lane {
966         memarg: MemoryImmediate,
967         lane: SIMDLaneIndex,
968     },
969     V128Store32Lane {
970         memarg: MemoryImmediate,
971         lane: SIMDLaneIndex,
972     },
973     V128Store64Lane {
974         memarg: MemoryImmediate,
975         lane: SIMDLaneIndex,
976     },
977     V128Const {
978         value: V128,
979     },
980     I8x16Shuffle {
981         lanes: [SIMDLaneIndex; 16],
982     },
983     I8x16ExtractLaneS {
984         lane: SIMDLaneIndex,
985     },
986     I8x16ExtractLaneU {
987         lane: SIMDLaneIndex,
988     },
989     I8x16ReplaceLane {
990         lane: SIMDLaneIndex,
991     },
992     I16x8ExtractLaneS {
993         lane: SIMDLaneIndex,
994     },
995     I16x8ExtractLaneU {
996         lane: SIMDLaneIndex,
997     },
998     I16x8ReplaceLane {
999         lane: SIMDLaneIndex,
1000     },
1001     I32x4ExtractLane {
1002         lane: SIMDLaneIndex,
1003     },
1004     I32x4ReplaceLane {
1005         lane: SIMDLaneIndex,
1006     },
1007     I64x2ExtractLane {
1008         lane: SIMDLaneIndex,
1009     },
1010     I64x2ReplaceLane {
1011         lane: SIMDLaneIndex,
1012     },
1013     F32x4ExtractLane {
1014         lane: SIMDLaneIndex,
1015     },
1016     F32x4ReplaceLane {
1017         lane: SIMDLaneIndex,
1018     },
1019     F64x2ExtractLane {
1020         lane: SIMDLaneIndex,
1021     },
1022     F64x2ReplaceLane {
1023         lane: SIMDLaneIndex,
1024     },
1025     I8x16Swizzle,
1026     I8x16Splat,
1027     I16x8Splat,
1028     I32x4Splat,
1029     I64x2Splat,
1030     F32x4Splat,
1031     F64x2Splat,
1032     I8x16Eq,
1033     I8x16Ne,
1034     I8x16LtS,
1035     I8x16LtU,
1036     I8x16GtS,
1037     I8x16GtU,
1038     I8x16LeS,
1039     I8x16LeU,
1040     I8x16GeS,
1041     I8x16GeU,
1042     I16x8Eq,
1043     I16x8Ne,
1044     I16x8LtS,
1045     I16x8LtU,
1046     I16x8GtS,
1047     I16x8GtU,
1048     I16x8LeS,
1049     I16x8LeU,
1050     I16x8GeS,
1051     I16x8GeU,
1052     I32x4Eq,
1053     I32x4Ne,
1054     I32x4LtS,
1055     I32x4LtU,
1056     I32x4GtS,
1057     I32x4GtU,
1058     I32x4LeS,
1059     I32x4LeU,
1060     I32x4GeS,
1061     I32x4GeU,
1062     I64x2Eq,
1063     I64x2Ne,
1064     I64x2LtS,
1065     I64x2GtS,
1066     I64x2LeS,
1067     I64x2GeS,
1068     F32x4Eq,
1069     F32x4Ne,
1070     F32x4Lt,
1071     F32x4Gt,
1072     F32x4Le,
1073     F32x4Ge,
1074     F64x2Eq,
1075     F64x2Ne,
1076     F64x2Lt,
1077     F64x2Gt,
1078     F64x2Le,
1079     F64x2Ge,
1080     V128Not,
1081     V128And,
1082     V128AndNot,
1083     V128Or,
1084     V128Xor,
1085     V128Bitselect,
1086     V128AnyTrue,
1087     I8x16Abs,
1088     I8x16Neg,
1089     I8x16Popcnt,
1090     I8x16AllTrue,
1091     I8x16Bitmask,
1092     I8x16NarrowI16x8S,
1093     I8x16NarrowI16x8U,
1094     I8x16Shl,
1095     I8x16ShrS,
1096     I8x16ShrU,
1097     I8x16Add,
1098     I8x16AddSatS,
1099     I8x16AddSatU,
1100     I8x16Sub,
1101     I8x16SubSatS,
1102     I8x16SubSatU,
1103     I8x16MinS,
1104     I8x16MinU,
1105     I8x16MaxS,
1106     I8x16MaxU,
1107     I8x16RoundingAverageU,
1108     I16x8ExtAddPairwiseI8x16S,
1109     I16x8ExtAddPairwiseI8x16U,
1110     I16x8Abs,
1111     I16x8Neg,
1112     I16x8Q15MulrSatS,
1113     I16x8AllTrue,
1114     I16x8Bitmask,
1115     I16x8NarrowI32x4S,
1116     I16x8NarrowI32x4U,
1117     I16x8ExtendLowI8x16S,
1118     I16x8ExtendHighI8x16S,
1119     I16x8ExtendLowI8x16U,
1120     I16x8ExtendHighI8x16U,
1121     I16x8Shl,
1122     I16x8ShrS,
1123     I16x8ShrU,
1124     I16x8Add,
1125     I16x8AddSatS,
1126     I16x8AddSatU,
1127     I16x8Sub,
1128     I16x8SubSatS,
1129     I16x8SubSatU,
1130     I16x8Mul,
1131     I16x8MinS,
1132     I16x8MinU,
1133     I16x8MaxS,
1134     I16x8MaxU,
1135     I16x8RoundingAverageU,
1136     I16x8ExtMulLowI8x16S,
1137     I16x8ExtMulHighI8x16S,
1138     I16x8ExtMulLowI8x16U,
1139     I16x8ExtMulHighI8x16U,
1140     I32x4ExtAddPairwiseI16x8S,
1141     I32x4ExtAddPairwiseI16x8U,
1142     I32x4Abs,
1143     I32x4Neg,
1144     I32x4AllTrue,
1145     I32x4Bitmask,
1146     I32x4ExtendLowI16x8S,
1147     I32x4ExtendHighI16x8S,
1148     I32x4ExtendLowI16x8U,
1149     I32x4ExtendHighI16x8U,
1150     I32x4Shl,
1151     I32x4ShrS,
1152     I32x4ShrU,
1153     I32x4Add,
1154     I32x4Sub,
1155     I32x4Mul,
1156     I32x4MinS,
1157     I32x4MinU,
1158     I32x4MaxS,
1159     I32x4MaxU,
1160     I32x4DotI16x8S,
1161     I32x4ExtMulLowI16x8S,
1162     I32x4ExtMulHighI16x8S,
1163     I32x4ExtMulLowI16x8U,
1164     I32x4ExtMulHighI16x8U,
1165     I64x2Abs,
1166     I64x2Neg,
1167     I64x2AllTrue,
1168     I64x2Bitmask,
1169     I64x2ExtendLowI32x4S,
1170     I64x2ExtendHighI32x4S,
1171     I64x2ExtendLowI32x4U,
1172     I64x2ExtendHighI32x4U,
1173     I64x2Shl,
1174     I64x2ShrS,
1175     I64x2ShrU,
1176     I64x2Add,
1177     I64x2Sub,
1178     I64x2Mul,
1179     I64x2ExtMulLowI32x4S,
1180     I64x2ExtMulHighI32x4S,
1181     I64x2ExtMulLowI32x4U,
1182     I64x2ExtMulHighI32x4U,
1183     F32x4Ceil,
1184     F32x4Floor,
1185     F32x4Trunc,
1186     F32x4Nearest,
1187     F32x4Abs,
1188     F32x4Neg,
1189     F32x4Sqrt,
1190     F32x4Add,
1191     F32x4Sub,
1192     F32x4Mul,
1193     F32x4Div,
1194     F32x4Min,
1195     F32x4Max,
1196     F32x4PMin,
1197     F32x4PMax,
1198     F64x2Ceil,
1199     F64x2Floor,
1200     F64x2Trunc,
1201     F64x2Nearest,
1202     F64x2Abs,
1203     F64x2Neg,
1204     F64x2Sqrt,
1205     F64x2Add,
1206     F64x2Sub,
1207     F64x2Mul,
1208     F64x2Div,
1209     F64x2Min,
1210     F64x2Max,
1211     F64x2PMin,
1212     F64x2PMax,
1213     I32x4TruncSatF32x4S,
1214     I32x4TruncSatF32x4U,
1215     F32x4ConvertI32x4S,
1216     F32x4ConvertI32x4U,
1217     I32x4TruncSatF64x2SZero,
1218     I32x4TruncSatF64x2UZero,
1219     F64x2ConvertLowI32x4S,
1220     F64x2ConvertLowI32x4U,
1221     F32x4DemoteF64x2Zero,
1222     F64x2PromoteLowF32x4,
1223 }
1224