-
Notifications
You must be signed in to change notification settings - Fork 16
/
opcodes.go
529 lines (525 loc) · 28.3 KB
/
opcodes.go
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
// Generated by internal/cmd/opcodes/generate.go
package codegen
import (
"gate.computer/wag/internal/gen"
"gate.computer/wag/internal/isa/prop"
"gate.computer/wag/internal/loader"
"gate.computer/wag/wa"
"gate.computer/wag/wa/opcode"
)
var opcodeImpls = [256]opImpl{
opcode.Unreachable: {genUnreachable, 0},
opcode.Nop: {genNop, 0},
opcode.Block: {nil, 0}, // initialized by init()
opcode.Loop: {nil, 0}, // initialized by init()
opcode.If: {nil, 0}, // initialized by init()
opcode.Else: {badGen, 0},
0x06: {badGen, 0},
0x07: {badGen, 0},
0x08: {badGen, 0},
0x09: {badGen, 0},
0x0a: {badGen, 0},
opcode.End: {nil, 0},
opcode.Br: {genBr, 0},
opcode.BrIf: {genBrIf, 0},
opcode.BrTable: {genBrTable, 0},
opcode.Return: {genReturn, 0},
opcode.Call: {genCall, 0},
opcode.CallIndirect: {genCallIndirect, 0},
0x12: {badGen, 0},
0x13: {badGen, 0},
0x14: {badGen, 0},
0x15: {badGen, 0},
0x16: {badGen, 0},
0x17: {badGen, 0},
0x18: {badGen, 0},
0x19: {badGen, 0},
opcode.Drop: {genDrop, 0},
opcode.Select: {genSelect, 0},
0x1c: {badGen, 0},
0x1d: {badGen, 0},
0x1e: {badGen, 0},
0x1f: {badGen, 0},
opcode.GetLocal: {genGetLocal, 0},
opcode.SetLocal: {genSetLocal, 0},
opcode.TeeLocal: {genTeeLocal, 0},
opcode.GetGlobal: {genGetGlobal, 0},
opcode.SetGlobal: {genSetGlobal, 0},
0x25: {badGen, 0},
0x26: {badGen, 0},
0x27: {badGen, 0},
opcode.I32Load: {genLoad, opInfo(wa.I32) | (opInfo(2) << 8) | (opInfo(prop.I32Load) << 16)},
opcode.I64Load: {genLoad, opInfo(wa.I64) | (opInfo(3) << 8) | (opInfo(prop.I64Load) << 16)},
opcode.F32Load: {genLoad, opInfo(wa.F32) | (opInfo(2) << 8) | (opInfo(prop.F32Load) << 16)},
opcode.F64Load: {genLoad, opInfo(wa.F64) | (opInfo(3) << 8) | (opInfo(prop.F64Load) << 16)},
opcode.I32Load8S: {genLoad, opInfo(wa.I32) | (opInfo(0) << 8) | (opInfo(prop.I32Load8S) << 16)},
opcode.I32Load8U: {genLoad, opInfo(wa.I32) | (opInfo(0) << 8) | (opInfo(prop.I32Load8U) << 16)},
opcode.I32Load16S: {genLoad, opInfo(wa.I32) | (opInfo(1) << 8) | (opInfo(prop.I32Load16S) << 16)},
opcode.I32Load16U: {genLoad, opInfo(wa.I32) | (opInfo(1) << 8) | (opInfo(prop.I32Load16U) << 16)},
opcode.I64Load8S: {genLoad, opInfo(wa.I64) | (opInfo(0) << 8) | (opInfo(prop.I64Load8S) << 16)},
opcode.I64Load8U: {genLoad, opInfo(wa.I64) | (opInfo(0) << 8) | (opInfo(prop.I64Load8U) << 16)},
opcode.I64Load16S: {genLoad, opInfo(wa.I64) | (opInfo(1) << 8) | (opInfo(prop.I64Load16S) << 16)},
opcode.I64Load16U: {genLoad, opInfo(wa.I64) | (opInfo(1) << 8) | (opInfo(prop.I64Load16U) << 16)},
opcode.I64Load32S: {genLoad, opInfo(wa.I64) | (opInfo(2) << 8) | (opInfo(prop.I64Load32S) << 16)},
opcode.I64Load32U: {genLoad, opInfo(wa.I64) | (opInfo(2) << 8) | (opInfo(prop.I64Load32U) << 16)},
opcode.I32Store: {genStore, opInfo(wa.I32) | (opInfo(2) << 8) | (opInfo(prop.I32Store) << 16)},
opcode.I64Store: {genStore, opInfo(wa.I64) | (opInfo(3) << 8) | (opInfo(prop.I64Store) << 16)},
opcode.F32Store: {genStore, opInfo(wa.F32) | (opInfo(2) << 8) | (opInfo(prop.F32Store) << 16)},
opcode.F64Store: {genStore, opInfo(wa.F64) | (opInfo(3) << 8) | (opInfo(prop.F64Store) << 16)},
opcode.I32Store8: {genStore, opInfo(wa.I32) | (opInfo(0) << 8) | (opInfo(prop.I32Store8) << 16)},
opcode.I32Store16: {genStore, opInfo(wa.I32) | (opInfo(1) << 8) | (opInfo(prop.I32Store16) << 16)},
opcode.I64Store8: {genStore, opInfo(wa.I64) | (opInfo(0) << 8) | (opInfo(prop.I64Store8) << 16)},
opcode.I64Store16: {genStore, opInfo(wa.I64) | (opInfo(1) << 8) | (opInfo(prop.I64Store16) << 16)},
opcode.I64Store32: {genStore, opInfo(wa.I64) | (opInfo(2) << 8) | (opInfo(prop.I64Store32) << 16)},
opcode.CurrentMemory: {genCurrentMemory, 0},
opcode.GrowMemory: {genGrowMemory, 0},
opcode.I32Const: {genConstI32, opInfo(wa.I32)},
opcode.I64Const: {genConstI64, opInfo(wa.I64)},
opcode.F32Const: {genConstF32, opInfo(wa.F32)},
opcode.F64Const: {genConstF64, opInfo(wa.F64)},
opcode.I32Eqz: {genUnary, opInfo(wa.I32) | (opInfo(prop.IntEqz) << 16)},
opcode.I32Eq: {genBinaryCommute, opInfo(wa.I32) | (opInfo(prop.IntEq) << 16)},
opcode.I32Ne: {genBinaryCommute, opInfo(wa.I32) | (opInfo(prop.IntNe) << 16)},
opcode.I32LtS: {genBinary, opInfo(wa.I32) | (opInfo(prop.IntLtS) << 16)},
opcode.I32LtU: {genBinary, opInfo(wa.I32) | (opInfo(prop.IntLtU) << 16)},
opcode.I32GtS: {genBinary, opInfo(wa.I32) | (opInfo(prop.IntGtS) << 16)},
opcode.I32GtU: {genBinary, opInfo(wa.I32) | (opInfo(prop.IntGtU) << 16)},
opcode.I32LeS: {genBinary, opInfo(wa.I32) | (opInfo(prop.IntLeS) << 16)},
opcode.I32LeU: {genBinary, opInfo(wa.I32) | (opInfo(prop.IntLeU) << 16)},
opcode.I32GeS: {genBinary, opInfo(wa.I32) | (opInfo(prop.IntGeS) << 16)},
opcode.I32GeU: {genBinary, opInfo(wa.I32) | (opInfo(prop.IntGeU) << 16)},
opcode.I64Eqz: {genUnary, opInfo(wa.I64) | (opInfo(prop.IntEqz) << 16)},
opcode.I64Eq: {genBinaryCommute, opInfo(wa.I64) | (opInfo(prop.IntEq) << 16)},
opcode.I64Ne: {genBinaryCommute, opInfo(wa.I64) | (opInfo(prop.IntNe) << 16)},
opcode.I64LtS: {genBinary, opInfo(wa.I64) | (opInfo(prop.IntLtS) << 16)},
opcode.I64LtU: {genBinary, opInfo(wa.I64) | (opInfo(prop.IntLtU) << 16)},
opcode.I64GtS: {genBinary, opInfo(wa.I64) | (opInfo(prop.IntGtS) << 16)},
opcode.I64GtU: {genBinary, opInfo(wa.I64) | (opInfo(prop.IntGtU) << 16)},
opcode.I64LeS: {genBinary, opInfo(wa.I64) | (opInfo(prop.IntLeS) << 16)},
opcode.I64LeU: {genBinary, opInfo(wa.I64) | (opInfo(prop.IntLeU) << 16)},
opcode.I64GeS: {genBinary, opInfo(wa.I64) | (opInfo(prop.IntGeS) << 16)},
opcode.I64GeU: {genBinary, opInfo(wa.I64) | (opInfo(prop.IntGeU) << 16)},
opcode.F32Eq: {genBinaryCommute, opInfo(wa.F32) | (opInfo(prop.FloatEq) << 16)},
opcode.F32Ne: {genBinaryCommute, opInfo(wa.F32) | (opInfo(prop.FloatNe) << 16)},
opcode.F32Lt: {genBinary, opInfo(wa.F32) | (opInfo(prop.FloatLt) << 16)},
opcode.F32Gt: {genBinary, opInfo(wa.F32) | (opInfo(prop.FloatGt) << 16)},
opcode.F32Le: {genBinary, opInfo(wa.F32) | (opInfo(prop.FloatLe) << 16)},
opcode.F32Ge: {genBinary, opInfo(wa.F32) | (opInfo(prop.FloatGe) << 16)},
opcode.F64Eq: {genBinaryCommute, opInfo(wa.F64) | (opInfo(prop.FloatEq) << 16)},
opcode.F64Ne: {genBinaryCommute, opInfo(wa.F64) | (opInfo(prop.FloatNe) << 16)},
opcode.F64Lt: {genBinary, opInfo(wa.F64) | (opInfo(prop.FloatLt) << 16)},
opcode.F64Gt: {genBinary, opInfo(wa.F64) | (opInfo(prop.FloatGt) << 16)},
opcode.F64Le: {genBinary, opInfo(wa.F64) | (opInfo(prop.FloatLe) << 16)},
opcode.F64Ge: {genBinary, opInfo(wa.F64) | (opInfo(prop.FloatGe) << 16)},
opcode.I32Clz: {genUnary, opInfo(wa.I32) | (opInfo(prop.IntClz) << 16)},
opcode.I32Ctz: {genUnary, opInfo(wa.I32) | (opInfo(prop.IntCtz) << 16)},
opcode.I32Popcnt: {genUnary, opInfo(wa.I32) | (opInfo(prop.IntPopcnt) << 16)},
opcode.I32Add: {genBinaryCommute, opInfo(wa.I32) | (opInfo(prop.IntAdd) << 16)},
opcode.I32Sub: {genBinary, opInfo(wa.I32) | (opInfo(prop.IntSub) << 16)},
opcode.I32Mul: {genBinaryCommute, opInfo(wa.I32) | (opInfo(prop.IntMul) << 16)},
opcode.I32DivS: {genBinary, opInfo(wa.I32) | (opInfo(prop.IntDivS) << 16)},
opcode.I32DivU: {genBinary, opInfo(wa.I32) | (opInfo(prop.IntDivU) << 16)},
opcode.I32RemS: {genBinary, opInfo(wa.I32) | (opInfo(prop.IntRemS) << 16)},
opcode.I32RemU: {genBinary, opInfo(wa.I32) | (opInfo(prop.IntRemU) << 16)},
opcode.I32And: {genBinaryCommute, opInfo(wa.I32) | (opInfo(prop.IntAnd) << 16)},
opcode.I32Or: {genBinaryCommute, opInfo(wa.I32) | (opInfo(prop.IntOr) << 16)},
opcode.I32Xor: {genBinaryCommute, opInfo(wa.I32) | (opInfo(prop.IntXor) << 16)},
opcode.I32Shl: {genBinary, opInfo(wa.I32) | (opInfo(prop.IntShl) << 16)},
opcode.I32ShrS: {genBinary, opInfo(wa.I32) | (opInfo(prop.IntShrS) << 16)},
opcode.I32ShrU: {genBinary, opInfo(wa.I32) | (opInfo(prop.IntShrU) << 16)},
opcode.I32Rotl: {genBinary, opInfo(wa.I32) | (opInfo(prop.IntRotl) << 16)},
opcode.I32Rotr: {genBinary, opInfo(wa.I32) | (opInfo(prop.IntRotr) << 16)},
opcode.I64Clz: {genUnary, opInfo(wa.I64) | (opInfo(prop.IntClz) << 16)},
opcode.I64Ctz: {genUnary, opInfo(wa.I64) | (opInfo(prop.IntCtz) << 16)},
opcode.I64Popcnt: {genUnary, opInfo(wa.I64) | (opInfo(prop.IntPopcnt) << 16)},
opcode.I64Add: {genBinaryCommute, opInfo(wa.I64) | (opInfo(prop.IntAdd) << 16)},
opcode.I64Sub: {genBinary, opInfo(wa.I64) | (opInfo(prop.IntSub) << 16)},
opcode.I64Mul: {genBinaryCommute, opInfo(wa.I64) | (opInfo(prop.IntMul) << 16)},
opcode.I64DivS: {genBinary, opInfo(wa.I64) | (opInfo(prop.IntDivS) << 16)},
opcode.I64DivU: {genBinary, opInfo(wa.I64) | (opInfo(prop.IntDivU) << 16)},
opcode.I64RemS: {genBinary, opInfo(wa.I64) | (opInfo(prop.IntRemS) << 16)},
opcode.I64RemU: {genBinary, opInfo(wa.I64) | (opInfo(prop.IntRemU) << 16)},
opcode.I64And: {genBinaryCommute, opInfo(wa.I64) | (opInfo(prop.IntAnd) << 16)},
opcode.I64Or: {genBinaryCommute, opInfo(wa.I64) | (opInfo(prop.IntOr) << 16)},
opcode.I64Xor: {genBinaryCommute, opInfo(wa.I64) | (opInfo(prop.IntXor) << 16)},
opcode.I64Shl: {genBinary, opInfo(wa.I64) | (opInfo(prop.IntShl) << 16)},
opcode.I64ShrS: {genBinary, opInfo(wa.I64) | (opInfo(prop.IntShrS) << 16)},
opcode.I64ShrU: {genBinary, opInfo(wa.I64) | (opInfo(prop.IntShrU) << 16)},
opcode.I64Rotl: {genBinary, opInfo(wa.I64) | (opInfo(prop.IntRotl) << 16)},
opcode.I64Rotr: {genBinary, opInfo(wa.I64) | (opInfo(prop.IntRotr) << 16)},
opcode.F32Abs: {genUnary, opInfo(wa.F32) | (opInfo(prop.FloatAbs) << 16)},
opcode.F32Neg: {genUnary, opInfo(wa.F32) | (opInfo(prop.FloatNeg) << 16)},
opcode.F32Ceil: {genUnary, opInfo(wa.F32) | (opInfo(prop.FloatCeil) << 16)},
opcode.F32Floor: {genUnary, opInfo(wa.F32) | (opInfo(prop.FloatFloor) << 16)},
opcode.F32Trunc: {genUnary, opInfo(wa.F32) | (opInfo(prop.FloatTrunc) << 16)},
opcode.F32Nearest: {genUnary, opInfo(wa.F32) | (opInfo(prop.FloatNearest) << 16)},
opcode.F32Sqrt: {genUnary, opInfo(wa.F32) | (opInfo(prop.FloatSqrt) << 16)},
opcode.F32Add: {genBinaryCommute, opInfo(wa.F32) | (opInfo(prop.FloatAdd) << 16)},
opcode.F32Sub: {genBinary, opInfo(wa.F32) | (opInfo(prop.FloatSub) << 16)},
opcode.F32Mul: {genBinaryCommute, opInfo(wa.F32) | (opInfo(prop.FloatMul) << 16)},
opcode.F32Div: {genBinary, opInfo(wa.F32) | (opInfo(prop.FloatDiv) << 16)},
opcode.F32Min: {genBinaryCommute, opInfo(wa.F32) | (opInfo(prop.FloatMin) << 16)},
opcode.F32Max: {genBinaryCommute, opInfo(wa.F32) | (opInfo(prop.FloatMax) << 16)},
opcode.F32Copysign: {genBinary, opInfo(wa.F32) | (opInfo(prop.FloatCopysign) << 16)},
opcode.F64Abs: {genUnary, opInfo(wa.F64) | (opInfo(prop.FloatAbs) << 16)},
opcode.F64Neg: {genUnary, opInfo(wa.F64) | (opInfo(prop.FloatNeg) << 16)},
opcode.F64Ceil: {genUnary, opInfo(wa.F64) | (opInfo(prop.FloatCeil) << 16)},
opcode.F64Floor: {genUnary, opInfo(wa.F64) | (opInfo(prop.FloatFloor) << 16)},
opcode.F64Trunc: {genUnary, opInfo(wa.F64) | (opInfo(prop.FloatTrunc) << 16)},
opcode.F64Nearest: {genUnary, opInfo(wa.F64) | (opInfo(prop.FloatNearest) << 16)},
opcode.F64Sqrt: {genUnary, opInfo(wa.F64) | (opInfo(prop.FloatSqrt) << 16)},
opcode.F64Add: {genBinaryCommute, opInfo(wa.F64) | (opInfo(prop.FloatAdd) << 16)},
opcode.F64Sub: {genBinary, opInfo(wa.F64) | (opInfo(prop.FloatSub) << 16)},
opcode.F64Mul: {genBinaryCommute, opInfo(wa.F64) | (opInfo(prop.FloatMul) << 16)},
opcode.F64Div: {genBinary, opInfo(wa.F64) | (opInfo(prop.FloatDiv) << 16)},
opcode.F64Min: {genBinaryCommute, opInfo(wa.F64) | (opInfo(prop.FloatMin) << 16)},
opcode.F64Max: {genBinaryCommute, opInfo(wa.F64) | (opInfo(prop.FloatMax) << 16)},
opcode.F64Copysign: {genBinary, opInfo(wa.F64) | (opInfo(prop.FloatCopysign) << 16)},
opcode.I32WrapI64: {genWrap, 0},
opcode.I32TruncSF32: {genConvert, opInfo(wa.I32) | (opInfo(wa.F32) << 8) | (opInfo(prop.TruncS) << 16)},
opcode.I32TruncUF32: {genConvert, opInfo(wa.I32) | (opInfo(wa.F32) << 8) | (opInfo(prop.TruncU) << 16)},
opcode.I32TruncSF64: {genConvert, opInfo(wa.I32) | (opInfo(wa.F64) << 8) | (opInfo(prop.TruncS) << 16)},
opcode.I32TruncUF64: {genConvert, opInfo(wa.I32) | (opInfo(wa.F64) << 8) | (opInfo(prop.TruncU) << 16)},
opcode.I64ExtendSI32: {genConvert, opInfo(wa.I64) | (opInfo(wa.I32) << 8) | (opInfo(prop.ExtendS) << 16)},
opcode.I64ExtendUI32: {genConvert, opInfo(wa.I64) | (opInfo(wa.I32) << 8) | (opInfo(prop.ExtendU) << 16)},
opcode.I64TruncSF32: {genConvert, opInfo(wa.I64) | (opInfo(wa.F32) << 8) | (opInfo(prop.TruncS) << 16)},
opcode.I64TruncUF32: {genConvert, opInfo(wa.I64) | (opInfo(wa.F32) << 8) | (opInfo(prop.TruncU) << 16)},
opcode.I64TruncSF64: {genConvert, opInfo(wa.I64) | (opInfo(wa.F64) << 8) | (opInfo(prop.TruncS) << 16)},
opcode.I64TruncUF64: {genConvert, opInfo(wa.I64) | (opInfo(wa.F64) << 8) | (opInfo(prop.TruncU) << 16)},
opcode.F32ConvertSI32: {genConvert, opInfo(wa.F32) | (opInfo(wa.I32) << 8) | (opInfo(prop.ConvertS) << 16)},
opcode.F32ConvertUI32: {genConvert, opInfo(wa.F32) | (opInfo(wa.I32) << 8) | (opInfo(prop.ConvertU) << 16)},
opcode.F32ConvertSI64: {genConvert, opInfo(wa.F32) | (opInfo(wa.I64) << 8) | (opInfo(prop.ConvertS) << 16)},
opcode.F32ConvertUI64: {genConvert, opInfo(wa.F32) | (opInfo(wa.I64) << 8) | (opInfo(prop.ConvertU) << 16)},
opcode.F32DemoteF64: {genConvert, opInfo(wa.F32) | (opInfo(wa.F64) << 8) | (opInfo(prop.Demote) << 16)},
opcode.F64ConvertSI32: {genConvert, opInfo(wa.F64) | (opInfo(wa.I32) << 8) | (opInfo(prop.ConvertS) << 16)},
opcode.F64ConvertUI32: {genConvert, opInfo(wa.F64) | (opInfo(wa.I32) << 8) | (opInfo(prop.ConvertU) << 16)},
opcode.F64ConvertSI64: {genConvert, opInfo(wa.F64) | (opInfo(wa.I64) << 8) | (opInfo(prop.ConvertS) << 16)},
opcode.F64ConvertUI64: {genConvert, opInfo(wa.F64) | (opInfo(wa.I64) << 8) | (opInfo(prop.ConvertU) << 16)},
opcode.F64PromoteF32: {genConvert, opInfo(wa.F64) | (opInfo(wa.F32) << 8) | (opInfo(prop.Promote) << 16)},
opcode.I32ReinterpretF32: {genConvert, opInfo(wa.I32) | (opInfo(wa.F32) << 8) | (opInfo(prop.ReinterpretFloat) << 16)},
opcode.I64ReinterpretF64: {genConvert, opInfo(wa.I64) | (opInfo(wa.F64) << 8) | (opInfo(prop.ReinterpretFloat) << 16)},
opcode.F32ReinterpretI32: {genConvert, opInfo(wa.F32) | (opInfo(wa.I32) << 8) | (opInfo(prop.ReinterpretInt) << 16)},
opcode.F64ReinterpretI64: {genConvert, opInfo(wa.F64) | (opInfo(wa.I64) << 8) | (opInfo(prop.ReinterpretInt) << 16)},
0xc0: {badGen, 0},
0xc1: {badGen, 0},
0xc2: {badGen, 0},
0xc3: {badGen, 0},
0xc4: {badGen, 0},
0xc5: {badGen, 0},
0xc6: {badGen, 0},
0xc7: {badGen, 0},
0xc8: {badGen, 0},
0xc9: {badGen, 0},
0xca: {badGen, 0},
0xcb: {badGen, 0},
0xcc: {badGen, 0},
0xcd: {badGen, 0},
0xce: {badGen, 0},
0xcf: {badGen, 0},
0xd0: {badGen, 0},
0xd1: {badGen, 0},
0xd2: {badGen, 0},
0xd3: {badGen, 0},
0xd4: {badGen, 0},
0xd5: {badGen, 0},
0xd6: {badGen, 0},
0xd7: {badGen, 0},
0xd8: {badGen, 0},
0xd9: {badGen, 0},
0xda: {badGen, 0},
0xdb: {badGen, 0},
0xdc: {badGen, 0},
0xdd: {badGen, 0},
0xde: {badGen, 0},
0xdf: {badGen, 0},
0xe0: {badGen, 0},
0xe1: {badGen, 0},
0xe2: {badGen, 0},
0xe3: {badGen, 0},
0xe4: {badGen, 0},
0xe5: {badGen, 0},
0xe6: {badGen, 0},
0xe7: {badGen, 0},
0xe8: {badGen, 0},
0xe9: {badGen, 0},
0xea: {badGen, 0},
0xeb: {badGen, 0},
0xec: {badGen, 0},
0xed: {badGen, 0},
0xee: {badGen, 0},
0xef: {badGen, 0},
0xf0: {badGen, 0},
0xf1: {badGen, 0},
0xf2: {badGen, 0},
0xf3: {badGen, 0},
0xf4: {badGen, 0},
0xf5: {badGen, 0},
0xf6: {badGen, 0},
0xf7: {badGen, 0},
0xf8: {badGen, 0},
0xf9: {badGen, 0},
0xfa: {badGen, 0},
0xfb: {badGen, 0},
0xfc: {badGen, 0},
0xfd: {badGen, 0},
0xfe: {badGen, 0},
0xff: {badGen, 0},
}
var opcodeSkips = [256]func(*gen.Func, *loader.L, opcode.Opcode){
opcode.Unreachable: skipNothing,
opcode.Nop: skipNothing,
opcode.Block: nil, // initialized by init()
opcode.Loop: nil, // initialized by init()
opcode.If: nil, // initialized by init()
opcode.Else: badSkip,
0x06: badSkip,
0x07: badSkip,
0x08: badSkip,
0x09: badSkip,
0x0a: badSkip,
opcode.End: nil,
opcode.Br: skipVaruint32,
opcode.BrIf: skipVaruint32,
opcode.BrTable: skipBrTable,
opcode.Return: skipNothing,
opcode.Call: skipVaruint32,
opcode.CallIndirect: skipCallIndirect,
0x12: badSkip,
0x13: badSkip,
0x14: badSkip,
0x15: badSkip,
0x16: badSkip,
0x17: badSkip,
0x18: badSkip,
0x19: badSkip,
opcode.Drop: skipNothing,
opcode.Select: skipNothing,
0x1c: badSkip,
0x1d: badSkip,
0x1e: badSkip,
0x1f: badSkip,
opcode.GetLocal: skipVaruint32,
opcode.SetLocal: skipVaruint32,
opcode.TeeLocal: skipVaruint32,
opcode.GetGlobal: skipVaruint32,
opcode.SetGlobal: skipVaruint32,
0x25: badSkip,
0x26: badSkip,
0x27: badSkip,
opcode.I32Load: skipMemoryImmediate,
opcode.I64Load: skipMemoryImmediate,
opcode.F32Load: skipMemoryImmediate,
opcode.F64Load: skipMemoryImmediate,
opcode.I32Load8S: skipMemoryImmediate,
opcode.I32Load8U: skipMemoryImmediate,
opcode.I32Load16S: skipMemoryImmediate,
opcode.I32Load16U: skipMemoryImmediate,
opcode.I64Load8S: skipMemoryImmediate,
opcode.I64Load8U: skipMemoryImmediate,
opcode.I64Load16S: skipMemoryImmediate,
opcode.I64Load16U: skipMemoryImmediate,
opcode.I64Load32S: skipMemoryImmediate,
opcode.I64Load32U: skipMemoryImmediate,
opcode.I32Store: skipMemoryImmediate,
opcode.I64Store: skipMemoryImmediate,
opcode.F32Store: skipMemoryImmediate,
opcode.F64Store: skipMemoryImmediate,
opcode.I32Store8: skipMemoryImmediate,
opcode.I32Store16: skipMemoryImmediate,
opcode.I64Store8: skipMemoryImmediate,
opcode.I64Store16: skipMemoryImmediate,
opcode.I64Store32: skipMemoryImmediate,
opcode.CurrentMemory: skipVaruint1,
opcode.GrowMemory: skipVaruint1,
opcode.I32Const: skipVarint32,
opcode.I64Const: skipVarint64,
opcode.F32Const: skipUint32,
opcode.F64Const: skipUint64,
opcode.I32Eqz: skipNothing,
opcode.I32Eq: skipNothing,
opcode.I32Ne: skipNothing,
opcode.I32LtS: skipNothing,
opcode.I32LtU: skipNothing,
opcode.I32GtS: skipNothing,
opcode.I32GtU: skipNothing,
opcode.I32LeS: skipNothing,
opcode.I32LeU: skipNothing,
opcode.I32GeS: skipNothing,
opcode.I32GeU: skipNothing,
opcode.I64Eqz: skipNothing,
opcode.I64Eq: skipNothing,
opcode.I64Ne: skipNothing,
opcode.I64LtS: skipNothing,
opcode.I64LtU: skipNothing,
opcode.I64GtS: skipNothing,
opcode.I64GtU: skipNothing,
opcode.I64LeS: skipNothing,
opcode.I64LeU: skipNothing,
opcode.I64GeS: skipNothing,
opcode.I64GeU: skipNothing,
opcode.F32Eq: skipNothing,
opcode.F32Ne: skipNothing,
opcode.F32Lt: skipNothing,
opcode.F32Gt: skipNothing,
opcode.F32Le: skipNothing,
opcode.F32Ge: skipNothing,
opcode.F64Eq: skipNothing,
opcode.F64Ne: skipNothing,
opcode.F64Lt: skipNothing,
opcode.F64Gt: skipNothing,
opcode.F64Le: skipNothing,
opcode.F64Ge: skipNothing,
opcode.I32Clz: skipNothing,
opcode.I32Ctz: skipNothing,
opcode.I32Popcnt: skipNothing,
opcode.I32Add: skipNothing,
opcode.I32Sub: skipNothing,
opcode.I32Mul: skipNothing,
opcode.I32DivS: skipNothing,
opcode.I32DivU: skipNothing,
opcode.I32RemS: skipNothing,
opcode.I32RemU: skipNothing,
opcode.I32And: skipNothing,
opcode.I32Or: skipNothing,
opcode.I32Xor: skipNothing,
opcode.I32Shl: skipNothing,
opcode.I32ShrS: skipNothing,
opcode.I32ShrU: skipNothing,
opcode.I32Rotl: skipNothing,
opcode.I32Rotr: skipNothing,
opcode.I64Clz: skipNothing,
opcode.I64Ctz: skipNothing,
opcode.I64Popcnt: skipNothing,
opcode.I64Add: skipNothing,
opcode.I64Sub: skipNothing,
opcode.I64Mul: skipNothing,
opcode.I64DivS: skipNothing,
opcode.I64DivU: skipNothing,
opcode.I64RemS: skipNothing,
opcode.I64RemU: skipNothing,
opcode.I64And: skipNothing,
opcode.I64Or: skipNothing,
opcode.I64Xor: skipNothing,
opcode.I64Shl: skipNothing,
opcode.I64ShrS: skipNothing,
opcode.I64ShrU: skipNothing,
opcode.I64Rotl: skipNothing,
opcode.I64Rotr: skipNothing,
opcode.F32Abs: skipNothing,
opcode.F32Neg: skipNothing,
opcode.F32Ceil: skipNothing,
opcode.F32Floor: skipNothing,
opcode.F32Trunc: skipNothing,
opcode.F32Nearest: skipNothing,
opcode.F32Sqrt: skipNothing,
opcode.F32Add: skipNothing,
opcode.F32Sub: skipNothing,
opcode.F32Mul: skipNothing,
opcode.F32Div: skipNothing,
opcode.F32Min: skipNothing,
opcode.F32Max: skipNothing,
opcode.F32Copysign: skipNothing,
opcode.F64Abs: skipNothing,
opcode.F64Neg: skipNothing,
opcode.F64Ceil: skipNothing,
opcode.F64Floor: skipNothing,
opcode.F64Trunc: skipNothing,
opcode.F64Nearest: skipNothing,
opcode.F64Sqrt: skipNothing,
opcode.F64Add: skipNothing,
opcode.F64Sub: skipNothing,
opcode.F64Mul: skipNothing,
opcode.F64Div: skipNothing,
opcode.F64Min: skipNothing,
opcode.F64Max: skipNothing,
opcode.F64Copysign: skipNothing,
opcode.I32WrapI64: skipNothing,
opcode.I32TruncSF32: skipNothing,
opcode.I32TruncUF32: skipNothing,
opcode.I32TruncSF64: skipNothing,
opcode.I32TruncUF64: skipNothing,
opcode.I64ExtendSI32: skipNothing,
opcode.I64ExtendUI32: skipNothing,
opcode.I64TruncSF32: skipNothing,
opcode.I64TruncUF32: skipNothing,
opcode.I64TruncSF64: skipNothing,
opcode.I64TruncUF64: skipNothing,
opcode.F32ConvertSI32: skipNothing,
opcode.F32ConvertUI32: skipNothing,
opcode.F32ConvertSI64: skipNothing,
opcode.F32ConvertUI64: skipNothing,
opcode.F32DemoteF64: skipNothing,
opcode.F64ConvertSI32: skipNothing,
opcode.F64ConvertUI32: skipNothing,
opcode.F64ConvertSI64: skipNothing,
opcode.F64ConvertUI64: skipNothing,
opcode.F64PromoteF32: skipNothing,
opcode.I32ReinterpretF32: skipNothing,
opcode.I64ReinterpretF64: skipNothing,
opcode.F32ReinterpretI32: skipNothing,
opcode.F64ReinterpretI64: skipNothing,
0xc0: badSkip,
0xc1: badSkip,
0xc2: badSkip,
0xc3: badSkip,
0xc4: badSkip,
0xc5: badSkip,
0xc6: badSkip,
0xc7: badSkip,
0xc8: badSkip,
0xc9: badSkip,
0xca: badSkip,
0xcb: badSkip,
0xcc: badSkip,
0xcd: badSkip,
0xce: badSkip,
0xcf: badSkip,
0xd0: badSkip,
0xd1: badSkip,
0xd2: badSkip,
0xd3: badSkip,
0xd4: badSkip,
0xd5: badSkip,
0xd6: badSkip,
0xd7: badSkip,
0xd8: badSkip,
0xd9: badSkip,
0xda: badSkip,
0xdb: badSkip,
0xdc: badSkip,
0xdd: badSkip,
0xde: badSkip,
0xdf: badSkip,
0xe0: badSkip,
0xe1: badSkip,
0xe2: badSkip,
0xe3: badSkip,
0xe4: badSkip,
0xe5: badSkip,
0xe6: badSkip,
0xe7: badSkip,
0xe8: badSkip,
0xe9: badSkip,
0xea: badSkip,
0xeb: badSkip,
0xec: badSkip,
0xed: badSkip,
0xee: badSkip,
0xef: badSkip,
0xf0: badSkip,
0xf1: badSkip,
0xf2: badSkip,
0xf3: badSkip,
0xf4: badSkip,
0xf5: badSkip,
0xf6: badSkip,
0xf7: badSkip,
0xf8: badSkip,
0xf9: badSkip,
0xfa: badSkip,
0xfb: badSkip,
0xfc: badSkip,
0xfd: badSkip,
0xfe: badSkip,
0xff: badSkip,
}