Coverage Report

Created: 2026-05-16 07:03

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/serenity/Userland/Libraries/LibWasm/Printer/Printer.cpp
Line
Count
Source
1
/*
2
 * Copyright (c) 2021, Ali Mohammad Pur <mpfard@serenityos.org>
3
 *
4
 * SPDX-License-Identifier: BSD-2-Clause
5
 */
6
7
#include <AK/HashMap.h>
8
#include <AK/TemporaryChange.h>
9
#include <LibWasm/AbstractMachine/AbstractMachine.h>
10
#include <LibWasm/Printer/Printer.h>
11
12
namespace Wasm {
13
14
struct Names {
15
    static HashMap<OpCode, ByteString> instruction_names;
16
    static HashMap<ByteString, OpCode> instructions_by_name;
17
};
18
19
ByteString instruction_name(OpCode const& opcode)
20
0
{
21
0
    return Names::instruction_names.get(opcode).value_or("<unknown>");
22
0
}
23
24
Optional<OpCode> instruction_from_name(StringView name)
25
0
{
26
0
    if (Names::instructions_by_name.is_empty()) {
27
0
        for (auto& entry : Names::instruction_names)
28
0
            Names::instructions_by_name.set(entry.value, entry.key);
29
0
    }
30
31
0
    return Names::instructions_by_name.get(name).copy();
32
0
}
33
34
void Printer::print_indent()
35
0
{
36
0
    for (size_t i = 0; i < m_indent; ++i)
37
0
        m_stream.write_until_depleted("  "sv.bytes()).release_value_but_fixme_should_propagate_errors();
38
0
}
39
40
void Printer::print(Wasm::BlockType const& type)
41
0
{
42
0
    print_indent();
43
0
    print("(type block ");
44
0
    switch (type.kind()) {
45
0
    case Wasm::BlockType::Kind::Index:
46
0
        print("index {})\n", type.type_index().value());
47
0
        return;
48
0
    case Wasm::BlockType::Kind::Type: {
49
0
        print("type\n");
50
0
        {
51
0
            TemporaryChange change { m_indent, m_indent + 1 };
52
0
            print(type.value_type());
53
0
        }
54
0
        print_indent();
55
0
        print(")\n");
56
0
        return;
57
0
    }
58
0
    case Wasm::BlockType::Kind ::Empty:
59
0
        print("empty)\n");
60
0
        return;
61
0
    }
62
0
    VERIFY_NOT_REACHED();
63
0
}
64
65
void Printer::print(Wasm::CodeSection const& section)
66
0
{
67
0
    if (section.functions().is_empty())
68
0
        return;
69
0
    print_indent();
70
0
    print("(section code\n");
71
0
    {
72
0
        TemporaryChange change { m_indent, m_indent + 1 };
73
0
        for (auto& code : section.functions())
74
0
            print(code);
75
0
    }
76
0
    print_indent();
77
0
    print(")\n");
78
0
}
79
80
void Printer::print(Wasm::CodeSection::Code const& code)
81
0
{
82
0
    print(code.func());
83
0
}
84
85
void Printer::print(Wasm::CustomSection const& section)
86
0
{
87
0
    print_indent();
88
0
    print("(section custom\n");
89
0
    {
90
0
        TemporaryChange change { m_indent, m_indent + 1 };
91
0
        print_indent();
92
0
        print("(name `{}')\n", section.name());
93
0
        print_indent();
94
0
        print("(contents {} bytes)\n", section.contents().size());
95
0
    }
96
0
    print_indent();
97
0
    print(")\n");
98
0
}
99
100
void Printer::print(Wasm::DataCountSection const& section)
101
0
{
102
0
    if (!section.count().has_value())
103
0
        return;
104
0
    print_indent();
105
0
    print("(section data count\n");
106
0
    if (section.count().has_value()) {
107
0
        TemporaryChange change { m_indent, m_indent + 1 };
108
0
        print_indent();
109
0
        print("(count `{}')\n", *section.count());
110
0
    }
111
0
    print_indent();
112
0
    print(")\n");
113
0
}
114
115
void Printer::print(Wasm::DataSection const& section)
116
0
{
117
0
    if (section.data().is_empty())
118
0
        return;
119
0
    print_indent();
120
0
    print("(section data\n");
121
0
    {
122
0
        TemporaryChange change { m_indent, m_indent + 1 };
123
0
        for (auto& entry : section.data())
124
0
            print(entry);
125
0
    }
126
0
    print_indent();
127
0
    print(")\n");
128
0
}
129
130
void Printer::print(Wasm::DataSection::Data const& data)
131
0
{
132
0
    print_indent();
133
0
    print("(data with value\n");
134
0
    {
135
0
        TemporaryChange change { m_indent, m_indent + 1 };
136
0
        data.value().visit(
137
0
            [this](DataSection::Data::Passive const& value) {
138
0
                print_indent();
139
0
                print("(passive init {}xu8 (", value.init.size());
140
0
                print(ByteString::join(' ', value.init, "{:x}"sv));
141
0
                print(")\n");
142
0
            },
143
0
            [this](DataSection::Data::Active const& value) {
144
0
                print_indent();
145
0
                print("(active init {}xu8 (", value.init.size());
146
0
                print(ByteString::join(' ', value.init, "{:x}"sv));
147
0
                print("\n");
148
0
                {
149
0
                    TemporaryChange change { m_indent, m_indent + 1 };
150
0
                    print_indent();
151
0
                    print("(offset\n");
152
0
                    {
153
0
                        TemporaryChange change { m_indent, m_indent + 1 };
154
0
                        print(value.offset);
155
0
                    }
156
0
                    print_indent();
157
0
                    print(")\n");
158
0
                }
159
0
                {
160
0
                    TemporaryChange change { m_indent, m_indent + 1 };
161
0
                    print_indent();
162
0
                    print("(index {})\n", value.index.value());
163
0
                }
164
0
            });
165
0
    }
166
0
    print_indent();
167
0
    print(")\n");
168
0
}
169
170
void Printer::print(Wasm::ElementSection const& section)
171
0
{
172
0
    if (section.segments().is_empty())
173
0
        return;
174
0
    print_indent();
175
0
    print("(section element\n");
176
0
    {
177
0
        TemporaryChange change { m_indent, m_indent + 1 };
178
0
        for (auto& entry : section.segments())
179
0
            print(entry);
180
0
    }
181
0
    print_indent();
182
0
    print(")\n");
183
0
}
184
185
void Printer::print(Wasm::ElementSection::Element const& element)
186
0
{
187
0
    print_indent();
188
0
    print("(element ");
189
0
    {
190
0
        TemporaryChange<size_t> change { m_indent, 0 };
191
0
        print(element.type);
192
0
    }
193
0
    {
194
0
        TemporaryChange change { m_indent, m_indent + 1 };
195
0
        print_indent();
196
0
        print("(init\n");
197
0
        {
198
0
            TemporaryChange change { m_indent, m_indent + 1 };
199
0
            for (auto& entry : element.init)
200
0
                print(entry);
201
0
        }
202
0
        print_indent();
203
0
        print(")\n");
204
0
        print_indent();
205
0
        print("(mode ");
206
0
        element.mode.visit(
207
0
            [this](ElementSection::Active const& active) {
208
0
                print("\n");
209
0
                {
210
0
                    TemporaryChange change { m_indent, m_indent + 1 };
211
0
                    print_indent();
212
0
                    print("(active index {}\n", active.index.value());
213
0
                    {
214
0
                        print(active.expression);
215
0
                    }
216
0
                    print_indent();
217
0
                    print(")\n");
218
0
                }
219
0
                print_indent();
220
0
            },
221
0
            [this](ElementSection::Passive const&) { print("passive"); },
222
0
            [this](ElementSection::Declarative const&) { print("declarative"); });
223
0
        print(")\n");
224
0
    }
225
0
}
226
227
void Printer::print(Wasm::ExportSection const& section)
228
0
{
229
0
    if (section.entries().is_empty())
230
0
        return;
231
0
    print_indent();
232
0
    print("(section export\n");
233
0
    {
234
0
        TemporaryChange change { m_indent, m_indent + 1 };
235
0
        for (auto& entry : section.entries())
236
0
            print(entry);
237
0
    }
238
0
    print_indent();
239
0
    print(")\n");
240
0
}
241
242
void Printer::print(Wasm::ExportSection::Export const& entry)
243
0
{
244
0
    print_indent();
245
0
    print("(export `{}' as\n", entry.name());
246
0
    {
247
0
        TemporaryChange change { m_indent, m_indent + 1 };
248
0
        print_indent();
249
0
        entry.description().visit(
250
0
            [this](FunctionIndex const& index) { print("(function index {})\n", index.value()); },
251
0
            [this](TableIndex const& index) { print("(table index {})\n", index.value()); },
252
0
            [this](MemoryIndex const& index) { print("(memory index {})\n", index.value()); },
253
0
            [this](GlobalIndex const& index) { print("(global index {})\n", index.value()); });
254
0
    }
255
0
    print_indent();
256
0
    print(")\n");
257
0
}
258
259
void Printer::print(Wasm::Expression const& expression)
260
0
{
261
0
    TemporaryChange change { m_indent, m_indent + 1 };
262
0
    for (auto& instr : expression.instructions())
263
0
        print(instr);
264
0
}
265
266
void Printer::print(Wasm::CodeSection::Func const& func)
267
0
{
268
0
    print_indent();
269
0
    print("(function\n");
270
0
    {
271
0
        TemporaryChange change { m_indent, m_indent + 1 };
272
0
        {
273
0
            print_indent();
274
0
            print("(locals\n");
275
0
            {
276
0
                TemporaryChange change { m_indent, m_indent + 1 };
277
0
                for (auto& locals : func.locals())
278
0
                    print(locals);
279
0
            }
280
0
            print_indent();
281
0
            print(")\n");
282
0
        }
283
0
        print_indent();
284
0
        print("(body\n");
285
0
        print(func.body());
286
0
        print_indent();
287
0
        print(")\n");
288
0
    }
289
0
    print_indent();
290
0
    print(")\n");
291
0
}
292
293
void Printer::print(Wasm::FunctionSection const& section)
294
0
{
295
0
    if (section.types().is_empty())
296
0
        return;
297
0
    print_indent();
298
0
    print("(section function\n");
299
0
    {
300
0
        TemporaryChange change { m_indent, m_indent + 1 };
301
0
        for (auto& index : section.types()) {
302
0
            print_indent();
303
0
            print("(type index {})\n", index.value());
304
0
        }
305
0
    }
306
0
    print_indent();
307
0
    print(")\n");
308
0
}
309
310
void Printer::print(Wasm::FunctionType const& type)
311
0
{
312
0
    print_indent();
313
0
    print("(type function\n");
314
0
    {
315
0
        TemporaryChange change { m_indent, m_indent + 1 };
316
0
        print_indent();
317
0
        print("(parameters\n");
318
0
        {
319
0
            TemporaryChange change { m_indent, m_indent + 1 };
320
0
            for (auto& param : type.parameters())
321
0
                print(param);
322
0
        }
323
0
        print_indent();
324
0
        print(")\n");
325
0
    }
326
0
    {
327
0
        TemporaryChange change { m_indent, m_indent + 1 };
328
0
        print_indent();
329
0
        print("(results\n");
330
0
        {
331
0
            TemporaryChange change { m_indent, m_indent + 1 };
332
0
            for (auto& type : type.results())
333
0
                print(type);
334
0
        }
335
0
        print_indent();
336
0
        print(")\n");
337
0
    }
338
0
    print_indent();
339
0
    print(")\n");
340
0
}
341
342
void Printer::print(Wasm::GlobalSection const& section)
343
0
{
344
0
    if (section.entries().is_empty())
345
0
        return;
346
0
    print_indent();
347
0
    print("(section global\n");
348
0
    {
349
0
        TemporaryChange change { m_indent, m_indent + 1 };
350
0
        for (auto& entry : section.entries())
351
0
            print(entry);
352
0
    }
353
0
    print_indent();
354
0
    print(")\n");
355
0
}
356
357
void Printer::print(Wasm::GlobalSection::Global const& entry)
358
0
{
359
0
    print_indent();
360
0
    print("(global\n");
361
0
    {
362
0
        TemporaryChange change { m_indent, m_indent + 1 };
363
0
        print_indent();
364
0
        print("(type\n");
365
0
        {
366
0
            TemporaryChange change { m_indent, m_indent + 1 };
367
0
            print(entry.type());
368
0
        }
369
0
        print_indent();
370
0
        print(")\n");
371
0
    }
372
0
    {
373
0
        TemporaryChange change { m_indent, m_indent + 1 };
374
0
        print_indent();
375
0
        print("(init\n");
376
0
        {
377
0
            TemporaryChange change { m_indent, m_indent + 1 };
378
0
            print(entry.expression());
379
0
        }
380
0
        print_indent();
381
0
        print(")\n");
382
0
    }
383
0
    print_indent();
384
0
    print(")\n");
385
0
}
386
387
void Printer::print(Wasm::GlobalType const& type)
388
0
{
389
0
    print_indent();
390
0
    print("(type global {}mutable\n", type.is_mutable() ? "" : "im");
391
0
    {
392
0
        TemporaryChange change { m_indent, m_indent + 1 };
393
0
        print(type.type());
394
0
    }
395
0
    print_indent();
396
0
    print(")\n");
397
0
}
398
399
void Printer::print(Wasm::ImportSection const& section)
400
0
{
401
0
    if (section.imports().is_empty())
402
0
        return;
403
0
    print_indent();
404
0
    print("(section import\n");
405
0
    {
406
0
        TemporaryChange change { m_indent, m_indent + 1 };
407
0
        for (auto& import : section.imports())
408
0
            print(import);
409
0
    }
410
0
    print_indent();
411
0
    print(")\n");
412
0
}
413
414
void Printer::print(Wasm::ImportSection::Import const& import)
415
0
{
416
0
    print_indent();
417
0
    print("(import `{}' from `{}' as\n", import.name(), import.module());
418
0
    {
419
0
        TemporaryChange change { m_indent, m_indent + 1 };
420
0
        import.description().visit(
421
0
            [this](auto const& type) {
422
0
                print(type);
423
0
            },
Unexecuted instantiation: Printer.cpp:auto Wasm::Printer::print(Wasm::ImportSection::Import const&)::$_0::operator()<Wasm::TableType>(Wasm::TableType const&) const
Unexecuted instantiation: Printer.cpp:auto Wasm::Printer::print(Wasm::ImportSection::Import const&)::$_0::operator()<Wasm::MemoryType>(Wasm::MemoryType const&) const
Unexecuted instantiation: Printer.cpp:auto Wasm::Printer::print(Wasm::ImportSection::Import const&)::$_0::operator()<Wasm::GlobalType>(Wasm::GlobalType const&) const
Unexecuted instantiation: Printer.cpp:auto Wasm::Printer::print(Wasm::ImportSection::Import const&)::$_0::operator()<Wasm::FunctionType>(Wasm::FunctionType const&) const
424
0
            [this](TypeIndex const& index) {
425
0
                print_indent();
426
0
                print("(type index {})\n", index.value());
427
0
            });
428
0
    }
429
0
    print_indent();
430
0
    print(")\n");
431
0
}
432
433
void Printer::print(Wasm::Instruction const& instruction)
434
0
{
435
0
    print_indent();
436
0
    print("({}", instruction_name(instruction.opcode()));
437
0
    if (instruction.arguments().has<u8>()) {
438
0
        print(")\n");
439
0
    } else {
440
0
        print(" ");
441
0
        instruction.arguments().visit(
442
0
            [&](BlockType const& type) { print(type); },
443
0
            [&](DataIndex const& index) { print("(data index {})", index.value()); },
444
0
            [&](ElementIndex const& index) { print("(element index {})", index.value()); },
445
0
            [&](FunctionIndex const& index) { print("(function index {})", index.value()); },
446
0
            [&](GlobalIndex const& index) { print("(global index {})", index.value()); },
447
0
            [&](LabelIndex const& index) { print("(label index {})", index.value()); },
448
0
            [&](LocalIndex const& index) { print("(local index {})", index.value()); },
449
0
            [&](TableIndex const& index) { print("(table index {})", index.value()); },
450
0
            [&](Instruction::IndirectCallArgs const& args) { print("(indirect (type index {}) (table index {}))", args.type.value(), args.table.value()); },
451
0
            [&](Instruction::MemoryArgument const& args) { print("(memory index {} (align {}) (offset {}))", args.memory_index.value(), args.align, args.offset); },
452
0
            [&](Instruction::MemoryAndLaneArgument const& args) { print("(memory index {} (align {}) (offset {})) (lane {})", args.memory.memory_index.value(), args.memory.align, args.memory.offset, args.lane); },
453
0
            [&](Instruction::MemoryInitArgs const& args) { print("(memory index {}) (data index {})", args.memory_index.value(), args.data_index.value()); },
454
0
            [&](Instruction::MemoryCopyArgs const& args) { print("(from (memory index {}) to (memory index {}))", args.src_index.value(), args.dst_index.value()); },
455
0
            [&](Instruction::MemoryIndexArgument const& args) { print("(memory index {})", args.memory_index.value()); },
456
0
            [&](Instruction::LaneIndex const& args) { print("(lane {})", args.lane); },
457
0
            [&](Instruction::ShuffleArgument const& args) {
458
0
                print("{{ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} }}",
459
0
                    args.lanes[0], args.lanes[1], args.lanes[2], args.lanes[3],
460
0
                    args.lanes[4], args.lanes[5], args.lanes[6], args.lanes[7],
461
0
                    args.lanes[8], args.lanes[9], args.lanes[10], args.lanes[11],
462
0
                    args.lanes[12], args.lanes[13], args.lanes[14], args.lanes[15]);
463
0
            },
464
0
            [&](Instruction::StructuredInstructionArgs const& args) {
465
0
                print("(structured\n");
466
0
                TemporaryChange change { m_indent, m_indent + 1 };
467
0
                print(args.block_type);
468
0
                print_indent();
469
0
                print("(else {}) (end {}))", args.else_ip.has_value() ? ByteString::number(args.else_ip->value()) : "(none)", args.end_ip.value());
470
0
            },
471
0
            [&](Instruction::TableBranchArgs const& args) {
472
0
                print("(table_branch");
473
0
                for (auto& label : args.labels)
474
0
                    print(" (label {})", label.value());
475
0
                print(" (label {}))", args.default_.value());
476
0
            },
477
0
            [&](Instruction::TableElementArgs const& args) { print("(table_element (table index {}) (element index {}))", args.table_index.value(), args.element_index.value()); },
478
0
            [&](Instruction::TableTableArgs const& args) { print("(table_table (table index {}) (table index {}))", args.lhs.value(), args.rhs.value()); },
479
0
            [&](ValueType const& type) { print(type); },
480
0
            [&](Vector<ValueType> const&) { print("(types...)"); },
481
0
            [&](auto const& value) { print("{}", value); });
Unexecuted instantiation: Printer.cpp:auto Wasm::Printer::print(Wasm::Instruction const&)::$_22::operator()<double>(double const&) const
Unexecuted instantiation: Printer.cpp:auto Wasm::Printer::print(Wasm::Instruction const&)::$_22::operator()<float>(float const&) const
Unexecuted instantiation: Printer.cpp:auto Wasm::Printer::print(Wasm::Instruction const&)::$_22::operator()<int>(int const&) const
Unexecuted instantiation: Printer.cpp:auto Wasm::Printer::print(Wasm::Instruction const&)::$_22::operator()<long>(long const&) const
Unexecuted instantiation: Printer.cpp:auto Wasm::Printer::print(Wasm::Instruction const&)::$_22::operator()<AK::Detail::UFixedBigInt<128ul, AK::Detail::StaticStorage<false, 128ul> > >(AK::Detail::UFixedBigInt<128ul, AK::Detail::StaticStorage<false, 128ul> > const&) const
Unexecuted instantiation: Printer.cpp:auto Wasm::Printer::print(Wasm::Instruction const&)::$_22::operator()<unsigned char>(unsigned char const&) const
482
483
0
        print(")\n");
484
0
    }
485
0
}
486
487
void Printer::print(Wasm::Limits const& limits)
488
0
{
489
0
    print_indent();
490
0
    print("(limits min={}", limits.min());
491
0
    if (limits.max().has_value())
492
0
        print(" max={}", limits.max().value());
493
0
    else
494
0
        print(" unbounded");
495
0
    print(")\n");
496
0
}
497
498
void Printer::print(Wasm::Locals const& local)
499
0
{
500
0
    print_indent();
501
0
    print("(local x{} of type\n", local.n());
502
0
    {
503
0
        TemporaryChange change { m_indent, m_indent + 1 };
504
0
        print(local.type());
505
0
    }
506
0
    print_indent();
507
0
    print(")\n");
508
0
}
509
510
void Printer::print(Wasm::MemorySection const& section)
511
0
{
512
0
    if (section.memories().is_empty())
513
0
        return;
514
0
    print_indent();
515
0
    print("(section memory\n");
516
0
    {
517
0
        TemporaryChange change { m_indent, m_indent + 1 };
518
0
        for (auto& memory : section.memories())
519
0
            print(memory);
520
0
    }
521
0
    print_indent();
522
0
    print(")\n");
523
0
}
524
525
void Printer::print(Wasm::MemorySection::Memory const& memory)
526
0
{
527
0
    print_indent();
528
0
    print("(memory\n");
529
0
    {
530
0
        TemporaryChange change { m_indent, m_indent + 1 };
531
0
        print(memory.type());
532
0
    }
533
0
    print_indent();
534
0
    print(")\n");
535
0
}
536
537
void Printer::print(Wasm::MemoryType const& type)
538
0
{
539
0
    print_indent();
540
0
    print("(type memory\n");
541
0
    {
542
0
        TemporaryChange change { m_indent, m_indent + 1 };
543
0
        print(type.limits());
544
0
    }
545
0
    print_indent();
546
0
    print(")\n");
547
0
}
548
549
void Printer::print(Wasm::Module const& module)
550
0
{
551
0
    print_indent();
552
0
    {
553
0
        TemporaryChange change { m_indent, m_indent + 1 };
554
0
        print("(module\n");
555
0
        for (auto& custom_section : module.custom_sections())
556
0
            print(custom_section);
557
0
        print(module.type_section());
558
0
        print(module.import_section());
559
0
        print(module.function_section());
560
0
        print(module.table_section());
561
0
        print(module.memory_section());
562
0
        print(module.global_section());
563
0
        print(module.export_section());
564
0
        print(module.start_section());
565
0
        print(module.element_section());
566
0
        print(module.code_section());
567
0
        print(module.data_section());
568
0
        print(module.data_count_section());
569
0
    }
570
0
    print_indent();
571
0
    print(")\n");
572
0
}
573
574
void Printer::print(Wasm::StartSection const& section)
575
0
{
576
0
    if (!section.function().has_value())
577
0
        return;
578
0
    print_indent();
579
0
    print("(section start\n");
580
0
    {
581
0
        TemporaryChange change { m_indent, m_indent + 1 };
582
0
        print(*section.function());
583
0
    }
584
0
    print_indent();
585
0
    print(")\n");
586
0
}
587
588
void Printer::print(Wasm::StartSection::StartFunction const& function)
589
0
{
590
0
    print_indent();
591
0
    print("(start function index {})\n", function.index().value());
592
0
}
593
594
void Printer::print(Wasm::TableSection const& section)
595
0
{
596
0
    if (section.tables().is_empty())
597
0
        return;
598
0
    print_indent();
599
0
    print("(section table\n");
600
0
    {
601
0
        TemporaryChange change { m_indent, m_indent + 1 };
602
0
        for (auto& table : section.tables())
603
0
            print(table);
604
0
    }
605
0
    print_indent();
606
0
    print(")\n");
607
0
}
608
609
void Printer::print(Wasm::TableSection::Table const& table)
610
0
{
611
0
    print_indent();
612
0
    print("(table\n");
613
0
    {
614
0
        TemporaryChange change { m_indent, m_indent + 1 };
615
0
        print(table.type());
616
0
    }
617
0
    print_indent();
618
0
    print(")\n");
619
0
}
620
621
void Printer::print(Wasm::TableType const& type)
622
0
{
623
0
    print_indent();
624
0
    print("(type table min:{}", type.limits().min());
625
0
    if (type.limits().max().has_value())
626
0
        print(" max:{}", type.limits().max().value());
627
0
    print("\n");
628
0
    {
629
0
        TemporaryChange change { m_indent, m_indent + 1 };
630
0
        print(type.element_type());
631
0
    }
632
0
    print_indent();
633
0
    print(")\n");
634
0
}
635
636
void Printer::print(Wasm::TypeSection const& section)
637
0
{
638
0
    if (section.types().is_empty())
639
0
        return;
640
0
    print_indent();
641
0
    print("(section type\n");
642
0
    {
643
0
        TemporaryChange change { m_indent, m_indent + 1 };
644
0
        for (auto& type : section.types())
645
0
            print(type);
646
0
    }
647
0
    print_indent();
648
0
    print(")\n");
649
0
}
650
651
void Printer::print(Wasm::ValueType const& type)
652
0
{
653
0
    print_indent();
654
0
    print("(type {})\n", ValueType::kind_name(type.kind()));
655
0
}
656
657
void Printer::print(Wasm::Value const& value, Wasm::ValueType const& type)
658
0
{
659
0
    print_indent();
660
0
    switch (type.kind()) {
661
0
    case ValueType::I32:
662
0
        print(ByteString::formatted("{}", value.to<i32>()));
663
0
        break;
664
0
    case ValueType::I64:
665
0
        print(ByteString::formatted("{}", value.to<i64>()));
666
0
        break;
667
0
    case ValueType::F32:
668
0
        print(ByteString::formatted("{}", value.to<f32>()));
669
0
        break;
670
0
    case ValueType::F64:
671
0
        print(ByteString::formatted("{}", value.to<f64>()));
672
0
        break;
673
0
    case ValueType::V128:
674
0
        print(ByteString::formatted("v128({:x})", value.value()));
675
0
        break;
676
0
    case ValueType::FunctionReference:
677
0
    case ValueType::ExternReference:
678
0
        print(ByteString::formatted("addr({})",
679
0
            value.to<Reference>().ref().visit(
680
0
                [](Wasm::Reference::Null const&) { return ByteString("null"); },
681
0
                [](auto const& ref) { return ByteString::number(ref.address.value()); })));
Unexecuted instantiation: Printer.cpp:auto Wasm::Printer::print(Wasm::Value const&, Wasm::ValueType const&)::$_1::operator()<Wasm::Reference::Func>(Wasm::Reference::Func const&) const
Unexecuted instantiation: Printer.cpp:auto Wasm::Printer::print(Wasm::Value const&, Wasm::ValueType const&)::$_1::operator()<Wasm::Reference::Extern>(Wasm::Reference::Extern const&) const
682
0
        break;
683
0
    }
684
0
    TemporaryChange<size_t> change { m_indent, 0 };
685
0
}
686
687
void Printer::print(Wasm::Value const& value)
688
0
{
689
0
    print_indent();
690
0
    print("{:x}", value.value());
691
0
    TemporaryChange<size_t> change { m_indent, 0 };
692
0
}
693
694
void Printer::print(Wasm::Reference const& value)
695
0
{
696
0
    print_indent();
697
0
    print(
698
0
        "addr({})\n",
699
0
        value.ref().visit(
700
0
            [](Wasm::Reference::Null const&) { return ByteString("null"); },
701
0
            [](auto const& ref) { return ByteString::number(ref.address.value()); }));
Unexecuted instantiation: Printer.cpp:auto Wasm::Printer::print(Wasm::Reference const&)::$_1::operator()<Wasm::Reference::Func>(Wasm::Reference::Func const&) const
Unexecuted instantiation: Printer.cpp:auto Wasm::Printer::print(Wasm::Reference const&)::$_1::operator()<Wasm::Reference::Extern>(Wasm::Reference::Extern const&) const
702
0
}
703
}
704
705
HashMap<Wasm::OpCode, ByteString> Wasm::Names::instruction_names {
706
    { Instructions::unreachable, "unreachable" },
707
    { Instructions::nop, "nop" },
708
    { Instructions::block, "block" },
709
    { Instructions::loop, "loop" },
710
    { Instructions::if_, "if" },
711
    { Instructions::br, "br" },
712
    { Instructions::br_if, "br.if" },
713
    { Instructions::br_table, "br.table" },
714
    { Instructions::return_, "return" },
715
    { Instructions::call, "call" },
716
    { Instructions::call_indirect, "call.indirect" },
717
    { Instructions::drop, "drop" },
718
    { Instructions::select, "select" },
719
    { Instructions::select_typed, "select.typed" },
720
    { Instructions::local_get, "local.get" },
721
    { Instructions::local_set, "local.set" },
722
    { Instructions::local_tee, "local.tee" },
723
    { Instructions::global_get, "global.get" },
724
    { Instructions::global_set, "global.set" },
725
    { Instructions::table_get, "table.get" },
726
    { Instructions::table_set, "table.set" },
727
    { Instructions::i32_load, "i32.load" },
728
    { Instructions::i64_load, "i64.load" },
729
    { Instructions::f32_load, "f32.load" },
730
    { Instructions::f64_load, "f64.load" },
731
    { Instructions::i32_load8_s, "i32.load8_s" },
732
    { Instructions::i32_load8_u, "i32.load8_u" },
733
    { Instructions::i32_load16_s, "i32.load16_s" },
734
    { Instructions::i32_load16_u, "i32.load16_u" },
735
    { Instructions::i64_load8_s, "i64.load8_s" },
736
    { Instructions::i64_load8_u, "i64.load8_u" },
737
    { Instructions::i64_load16_s, "i64.load16_s" },
738
    { Instructions::i64_load16_u, "i64.load16_u" },
739
    { Instructions::i64_load32_s, "i64.load32_s" },
740
    { Instructions::i64_load32_u, "i64.load32_u" },
741
    { Instructions::i32_store, "i32.store" },
742
    { Instructions::i64_store, "i64.store" },
743
    { Instructions::f32_store, "f32.store" },
744
    { Instructions::f64_store, "f64.store" },
745
    { Instructions::i32_store8, "i32.store8" },
746
    { Instructions::i32_store16, "i32.store16" },
747
    { Instructions::i64_store8, "i64.store8" },
748
    { Instructions::i64_store16, "i64.store16" },
749
    { Instructions::i64_store32, "i64.store32" },
750
    { Instructions::memory_size, "memory.size" },
751
    { Instructions::memory_grow, "memory.grow" },
752
    { Instructions::i32_const, "i32.const" },
753
    { Instructions::i64_const, "i64.const" },
754
    { Instructions::f32_const, "f32.const" },
755
    { Instructions::f64_const, "f64.const" },
756
    { Instructions::i32_eqz, "i32.eqz" },
757
    { Instructions::i32_eq, "i32.eq" },
758
    { Instructions::i32_ne, "i32.ne" },
759
    { Instructions::i32_lts, "i32.lts" },
760
    { Instructions::i32_ltu, "i32.ltu" },
761
    { Instructions::i32_gts, "i32.gts" },
762
    { Instructions::i32_gtu, "i32.gtu" },
763
    { Instructions::i32_les, "i32.les" },
764
    { Instructions::i32_leu, "i32.leu" },
765
    { Instructions::i32_ges, "i32.ges" },
766
    { Instructions::i32_geu, "i32.geu" },
767
    { Instructions::i64_eqz, "i64.eqz" },
768
    { Instructions::i64_eq, "i64.eq" },
769
    { Instructions::i64_ne, "i64.ne" },
770
    { Instructions::i64_lts, "i64.lts" },
771
    { Instructions::i64_ltu, "i64.ltu" },
772
    { Instructions::i64_gts, "i64.gts" },
773
    { Instructions::i64_gtu, "i64.gtu" },
774
    { Instructions::i64_les, "i64.les" },
775
    { Instructions::i64_leu, "i64.leu" },
776
    { Instructions::i64_ges, "i64.ges" },
777
    { Instructions::i64_geu, "i64.geu" },
778
    { Instructions::f32_eq, "f32.eq" },
779
    { Instructions::f32_ne, "f32.ne" },
780
    { Instructions::f32_lt, "f32.lt" },
781
    { Instructions::f32_gt, "f32.gt" },
782
    { Instructions::f32_le, "f32.le" },
783
    { Instructions::f32_ge, "f32.ge" },
784
    { Instructions::f64_eq, "f64.eq" },
785
    { Instructions::f64_ne, "f64.ne" },
786
    { Instructions::f64_lt, "f64.lt" },
787
    { Instructions::f64_gt, "f64.gt" },
788
    { Instructions::f64_le, "f64.le" },
789
    { Instructions::f64_ge, "f64.ge" },
790
    { Instructions::i32_clz, "i32.clz" },
791
    { Instructions::i32_ctz, "i32.ctz" },
792
    { Instructions::i32_popcnt, "i32.popcnt" },
793
    { Instructions::i32_add, "i32.add" },
794
    { Instructions::i32_sub, "i32.sub" },
795
    { Instructions::i32_mul, "i32.mul" },
796
    { Instructions::i32_divs, "i32.divs" },
797
    { Instructions::i32_divu, "i32.divu" },
798
    { Instructions::i32_rems, "i32.rems" },
799
    { Instructions::i32_remu, "i32.remu" },
800
    { Instructions::i32_and, "i32.and" },
801
    { Instructions::i32_or, "i32.or" },
802
    { Instructions::i32_xor, "i32.xor" },
803
    { Instructions::i32_shl, "i32.shl" },
804
    { Instructions::i32_shrs, "i32.shrs" },
805
    { Instructions::i32_shru, "i32.shru" },
806
    { Instructions::i32_rotl, "i32.rotl" },
807
    { Instructions::i32_rotr, "i32.rotr" },
808
    { Instructions::i64_clz, "i64.clz" },
809
    { Instructions::i64_ctz, "i64.ctz" },
810
    { Instructions::i64_popcnt, "i64.popcnt" },
811
    { Instructions::i64_add, "i64.add" },
812
    { Instructions::i64_sub, "i64.sub" },
813
    { Instructions::i64_mul, "i64.mul" },
814
    { Instructions::i64_divs, "i64.divs" },
815
    { Instructions::i64_divu, "i64.divu" },
816
    { Instructions::i64_rems, "i64.rems" },
817
    { Instructions::i64_remu, "i64.remu" },
818
    { Instructions::i64_and, "i64.and" },
819
    { Instructions::i64_or, "i64.or" },
820
    { Instructions::i64_xor, "i64.xor" },
821
    { Instructions::i64_shl, "i64.shl" },
822
    { Instructions::i64_shrs, "i64.shrs" },
823
    { Instructions::i64_shru, "i64.shru" },
824
    { Instructions::i64_rotl, "i64.rotl" },
825
    { Instructions::i64_rotr, "i64.rotr" },
826
    { Instructions::f32_abs, "f32.abs" },
827
    { Instructions::f32_neg, "f32.neg" },
828
    { Instructions::f32_ceil, "f32.ceil" },
829
    { Instructions::f32_floor, "f32.floor" },
830
    { Instructions::f32_trunc, "f32.trunc" },
831
    { Instructions::f32_nearest, "f32.nearest" },
832
    { Instructions::f32_sqrt, "f32.sqrt" },
833
    { Instructions::f32_add, "f32.add" },
834
    { Instructions::f32_sub, "f32.sub" },
835
    { Instructions::f32_mul, "f32.mul" },
836
    { Instructions::f32_div, "f32.div" },
837
    { Instructions::f32_min, "f32.min" },
838
    { Instructions::f32_max, "f32.max" },
839
    { Instructions::f32_copysign, "f32.copysign" },
840
    { Instructions::f64_abs, "f64.abs" },
841
    { Instructions::f64_neg, "f64.neg" },
842
    { Instructions::f64_ceil, "f64.ceil" },
843
    { Instructions::f64_floor, "f64.floor" },
844
    { Instructions::f64_trunc, "f64.trunc" },
845
    { Instructions::f64_nearest, "f64.nearest" },
846
    { Instructions::f64_sqrt, "f64.sqrt" },
847
    { Instructions::f64_add, "f64.add" },
848
    { Instructions::f64_sub, "f64.sub" },
849
    { Instructions::f64_mul, "f64.mul" },
850
    { Instructions::f64_div, "f64.div" },
851
    { Instructions::f64_min, "f64.min" },
852
    { Instructions::f64_max, "f64.max" },
853
    { Instructions::f64_copysign, "f64.copysign" },
854
    { Instructions::i32_wrap_i64, "i32.wrap_i64" },
855
    { Instructions::i32_trunc_sf32, "i32.trunc_sf32" },
856
    { Instructions::i32_trunc_uf32, "i32.trunc_uf32" },
857
    { Instructions::i32_trunc_sf64, "i32.trunc_sf64" },
858
    { Instructions::i32_trunc_uf64, "i32.trunc_uf64" },
859
    { Instructions::i64_extend_si32, "i64.extend_si32" },
860
    { Instructions::i64_extend_ui32, "i64.extend_ui32" },
861
    { Instructions::i64_trunc_sf32, "i64.trunc_sf32" },
862
    { Instructions::i64_trunc_uf32, "i64.trunc_uf32" },
863
    { Instructions::i64_trunc_sf64, "i64.trunc_sf64" },
864
    { Instructions::i64_trunc_uf64, "i64.trunc_uf64" },
865
    { Instructions::f32_convert_si32, "f32.convert_si32" },
866
    { Instructions::f32_convert_ui32, "f32.convert_ui32" },
867
    { Instructions::f32_convert_si64, "f32.convert_si64" },
868
    { Instructions::f32_convert_ui64, "f32.convert_ui64" },
869
    { Instructions::f32_demote_f64, "f32.demote_f64" },
870
    { Instructions::f64_convert_si32, "f64.convert_si32" },
871
    { Instructions::f64_convert_ui32, "f64.convert_ui32" },
872
    { Instructions::f64_convert_si64, "f64.convert_si64" },
873
    { Instructions::f64_convert_ui64, "f64.convert_ui64" },
874
    { Instructions::f64_promote_f32, "f64.promote_f32" },
875
    { Instructions::i32_reinterpret_f32, "i32.reinterpret_f32" },
876
    { Instructions::i64_reinterpret_f64, "i64.reinterpret_f64" },
877
    { Instructions::f32_reinterpret_i32, "f32.reinterpret_i32" },
878
    { Instructions::f64_reinterpret_i64, "f64.reinterpret_i64" },
879
    { Instructions::i32_extend8_s, "i32.extend8_s" },
880
    { Instructions::i32_extend16_s, "i32.extend16_s" },
881
    { Instructions::i64_extend8_s, "i64.extend8_s" },
882
    { Instructions::i64_extend16_s, "i64.extend16_s" },
883
    { Instructions::i64_extend32_s, "i64.extend32_s" },
884
    { Instructions::ref_null, "ref.null" },
885
    { Instructions::ref_is_null, "ref.is.null" },
886
    { Instructions::ref_func, "ref.func" },
887
    { Instructions::i32_trunc_sat_f32_s, "i32.trunc_sat_f32_s" },
888
    { Instructions::i32_trunc_sat_f32_u, "i32.trunc_sat_f32_u" },
889
    { Instructions::i32_trunc_sat_f64_s, "i32.trunc_sat_f64_s" },
890
    { Instructions::i32_trunc_sat_f64_u, "i32.trunc_sat_f64_u" },
891
    { Instructions::i64_trunc_sat_f32_s, "i64.trunc_sat_f32_s" },
892
    { Instructions::i64_trunc_sat_f32_u, "i64.trunc_sat_f32_u" },
893
    { Instructions::i64_trunc_sat_f64_s, "i64.trunc_sat_f64_s" },
894
    { Instructions::i64_trunc_sat_f64_u, "i64.trunc_sat_f64_u" },
895
    { Instructions::memory_init, "memory.init" },
896
    { Instructions::data_drop, "data.drop" },
897
    { Instructions::memory_copy, "memory.copy" },
898
    { Instructions::memory_fill, "memory.fill" },
899
    { Instructions::table_init, "table.init" },
900
    { Instructions::elem_drop, "elem.drop" },
901
    { Instructions::table_copy, "table.copy" },
902
    { Instructions::table_grow, "table.grow" },
903
    { Instructions::table_size, "table.size" },
904
    { Instructions::table_fill, "table.fill" },
905
    { Instructions::v128_load, "v128.load" },
906
    { Instructions::v128_load8x8_s, "v128.load8x8_s" },
907
    { Instructions::v128_load8x8_u, "v128.load8x8_u" },
908
    { Instructions::v128_load16x4_s, "v128.load16x4_s" },
909
    { Instructions::v128_load16x4_u, "v128.load16x4_u" },
910
    { Instructions::v128_load32x2_s, "v128.load32x2_s" },
911
    { Instructions::v128_load32x2_u, "v128.load32x2_u" },
912
    { Instructions::v128_load8_splat, "v128.load8_splat" },
913
    { Instructions::v128_load16_splat, "v128.load16_splat" },
914
    { Instructions::v128_load32_splat, "v128.load32_splat" },
915
    { Instructions::v128_load64_splat, "v128.load64_splat" },
916
    { Instructions::v128_store, "v128.store" },
917
    { Instructions::v128_const, "v128.const" },
918
    { Instructions::i8x16_shuffle, "i8x16.shuffle" },
919
    { Instructions::i8x16_swizzle, "i8x16.swizzle" },
920
    { Instructions::i8x16_splat, "i8x16.splat" },
921
    { Instructions::i16x8_splat, "i16x8.splat" },
922
    { Instructions::i32x4_splat, "i32x4.splat" },
923
    { Instructions::i64x2_splat, "i64x2.splat" },
924
    { Instructions::f32x4_splat, "f32x4.splat" },
925
    { Instructions::f64x2_splat, "f64x2.splat" },
926
    { Instructions::i8x16_extract_lane_s, "i8x16.extract_lane_s" },
927
    { Instructions::i8x16_extract_lane_u, "i8x16.extract_lane_u" },
928
    { Instructions::i8x16_replace_lane, "i8x16.replace_lane" },
929
    { Instructions::i16x8_extract_lane_s, "i16x8.extract_lane_s" },
930
    { Instructions::i16x8_extract_lane_u, "i16x8.extract_lane_u" },
931
    { Instructions::i16x8_replace_lane, "i16x8.replace_lane" },
932
    { Instructions::i32x4_extract_lane, "i32x4.extract_lane" },
933
    { Instructions::i32x4_replace_lane, "i32x4.replace_lane" },
934
    { Instructions::i64x2_extract_lane, "i64x2.extract_lane" },
935
    { Instructions::i64x2_replace_lane, "i64x2.replace_lane" },
936
    { Instructions::f32x4_extract_lane, "f32x4.extract_lane" },
937
    { Instructions::f32x4_replace_lane, "f32x4.replace_lane" },
938
    { Instructions::f64x2_extract_lane, "f64x2.extract_lane" },
939
    { Instructions::f64x2_replace_lane, "f64x2.replace_lane" },
940
    { Instructions::i8x16_eq, "i8x16.eq" },
941
    { Instructions::i8x16_ne, "i8x16.ne" },
942
    { Instructions::i8x16_lt_s, "i8x16.lt_s" },
943
    { Instructions::i8x16_lt_u, "i8x16.lt_u" },
944
    { Instructions::i8x16_gt_s, "i8x16.gt_s" },
945
    { Instructions::i8x16_gt_u, "i8x16.gt_u" },
946
    { Instructions::i8x16_le_s, "i8x16.le_s" },
947
    { Instructions::i8x16_le_u, "i8x16.le_u" },
948
    { Instructions::i8x16_ge_s, "i8x16.ge_s" },
949
    { Instructions::i8x16_ge_u, "i8x16.ge_u" },
950
    { Instructions::i16x8_eq, "i16x8.eq" },
951
    { Instructions::i16x8_ne, "i16x8.ne" },
952
    { Instructions::i16x8_lt_s, "i16x8.lt_s" },
953
    { Instructions::i16x8_lt_u, "i16x8.lt_u" },
954
    { Instructions::i16x8_gt_s, "i16x8.gt_s" },
955
    { Instructions::i16x8_gt_u, "i16x8.gt_u" },
956
    { Instructions::i16x8_le_s, "i16x8.le_s" },
957
    { Instructions::i16x8_le_u, "i16x8.le_u" },
958
    { Instructions::i16x8_ge_s, "i16x8.ge_s" },
959
    { Instructions::i16x8_ge_u, "i16x8.ge_u" },
960
    { Instructions::i32x4_eq, "i32x4.eq" },
961
    { Instructions::i32x4_ne, "i32x4.ne" },
962
    { Instructions::i32x4_lt_s, "i32x4.lt_s" },
963
    { Instructions::i32x4_lt_u, "i32x4.lt_u" },
964
    { Instructions::i32x4_gt_s, "i32x4.gt_s" },
965
    { Instructions::i32x4_gt_u, "i32x4.gt_u" },
966
    { Instructions::i32x4_le_s, "i32x4.le_s" },
967
    { Instructions::i32x4_le_u, "i32x4.le_u" },
968
    { Instructions::i32x4_ge_s, "i32x4.ge_s" },
969
    { Instructions::i32x4_ge_u, "i32x4.ge_u" },
970
    { Instructions::f32x4_eq, "f32x4.eq" },
971
    { Instructions::f32x4_ne, "f32x4.ne" },
972
    { Instructions::f32x4_lt, "f32x4.lt" },
973
    { Instructions::f32x4_gt, "f32x4.gt" },
974
    { Instructions::f32x4_le, "f32x4.le" },
975
    { Instructions::f32x4_ge, "f32x4.ge" },
976
    { Instructions::f64x2_eq, "f64x2.eq" },
977
    { Instructions::f64x2_ne, "f64x2.ne" },
978
    { Instructions::f64x2_lt, "f64x2.lt" },
979
    { Instructions::f64x2_gt, "f64x2.gt" },
980
    { Instructions::f64x2_le, "f64x2.le" },
981
    { Instructions::f64x2_ge, "f64x2.ge" },
982
    { Instructions::v128_not, "v128.not" },
983
    { Instructions::v128_and, "v128.and" },
984
    { Instructions::v128_andnot, "v128.andnot" },
985
    { Instructions::v128_or, "v128.or" },
986
    { Instructions::v128_xor, "v128.xor" },
987
    { Instructions::v128_bitselect, "v128.bitselect" },
988
    { Instructions::v128_any_true, "v128.any_true" },
989
    { Instructions::v128_load8_lane, "v128.load8_lane" },
990
    { Instructions::v128_load16_lane, "v128.load16_lane" },
991
    { Instructions::v128_load32_lane, "v128.load32_lane" },
992
    { Instructions::v128_load64_lane, "v128.load64_lane" },
993
    { Instructions::v128_store8_lane, "v128.store8_lane" },
994
    { Instructions::v128_store16_lane, "v128.store16_lane" },
995
    { Instructions::v128_store32_lane, "v128.store32_lane" },
996
    { Instructions::v128_store64_lane, "v128.store64_lane" },
997
    { Instructions::v128_load32_zero, "v128.load32_zero" },
998
    { Instructions::v128_load64_zero, "v128.load64_zero" },
999
    { Instructions::f32x4_demote_f64x2_zero, "f32x4.demote_f64x2_zero" },
1000
    { Instructions::f64x2_promote_low_f32x4, "f64x2.promote_low_f32x4" },
1001
    { Instructions::i8x16_abs, "i8x16.abs" },
1002
    { Instructions::i8x16_neg, "i8x16.neg" },
1003
    { Instructions::i8x16_popcnt, "i8x16.popcnt" },
1004
    { Instructions::i8x16_all_true, "i8x16.all_true" },
1005
    { Instructions::i8x16_bitmask, "i8x16.bitmask" },
1006
    { Instructions::i8x16_narrow_i16x8_s, "i8x16.narrow_i16x8_s" },
1007
    { Instructions::i8x16_narrow_i16x8_u, "i8x16.narrow_i16x8_u" },
1008
    { Instructions::f32x4_ceil, "f32x4.ceil" },
1009
    { Instructions::f32x4_floor, "f32x4.floor" },
1010
    { Instructions::f32x4_trunc, "f32x4.trunc" },
1011
    { Instructions::f32x4_nearest, "f32x4.nearest" },
1012
    { Instructions::i8x16_shl, "i8x16.shl" },
1013
    { Instructions::i8x16_shr_s, "i8x16.shr_s" },
1014
    { Instructions::i8x16_shr_u, "i8x16.shr_u" },
1015
    { Instructions::i8x16_add, "i8x16.add" },
1016
    { Instructions::i8x16_add_sat_s, "i8x16.add_sat_s" },
1017
    { Instructions::i8x16_add_sat_u, "i8x16.add_sat_u" },
1018
    { Instructions::i8x16_sub, "i8x16.sub" },
1019
    { Instructions::i8x16_sub_sat_s, "i8x16.sub_sat_s" },
1020
    { Instructions::i8x16_sub_sat_u, "i8x16.sub_sat_u" },
1021
    { Instructions::f64x2_ceil, "f64x2.ceil" },
1022
    { Instructions::f64x2_floor, "f64x2.floor" },
1023
    { Instructions::i8x16_min_s, "i8x16.min_s" },
1024
    { Instructions::i8x16_min_u, "i8x16.min_u" },
1025
    { Instructions::i8x16_max_s, "i8x16.max_s" },
1026
    { Instructions::i8x16_max_u, "i8x16.max_u" },
1027
    { Instructions::f64x2_trunc, "f64x2.trunc" },
1028
    { Instructions::i8x16_avgr_u, "i8x16.avgr_u" },
1029
    { Instructions::i16x8_extadd_pairwise_i8x16_s, "i16x8.extadd_pairwise_i8x16_s" },
1030
    { Instructions::i16x8_extadd_pairwise_i8x16_u, "i16x8.extadd_pairwise_i8x16_u" },
1031
    { Instructions::i32x4_extadd_pairwise_i16x8_s, "i32x4.extadd_pairwise_i16x8_s" },
1032
    { Instructions::i32x4_extadd_pairwise_i16x8_u, "i32x4.extadd_pairwise_i16x8_u" },
1033
    { Instructions::i16x8_abs, "i16x8.abs" },
1034
    { Instructions::i16x8_neg, "i16x8.neg" },
1035
    { Instructions::i16x8_q15mulr_sat_s, "i16x8.q15mulr_sat_s" },
1036
    { Instructions::i16x8_all_true, "i16x8.all_true" },
1037
    { Instructions::i16x8_bitmask, "i16x8.bitmask" },
1038
    { Instructions::i16x8_narrow_i32x4_s, "i16x8.narrow_i32x4_s" },
1039
    { Instructions::i16x8_narrow_i32x4_u, "i16x8.narrow_i32x4_u" },
1040
    { Instructions::i16x8_extend_low_i8x16_s, "i16x8.extend_low_i8x16_s" },
1041
    { Instructions::i16x8_extend_high_i8x16_s, "i16x8.extend_high_i8x16_s" },
1042
    { Instructions::i16x8_extend_low_i8x16_u, "i16x8.extend_low_i8x16_u" },
1043
    { Instructions::i16x8_extend_high_i8x16_u, "i16x8.extend_high_i8x16_u" },
1044
    { Instructions::i16x8_shl, "i16x8.shl" },
1045
    { Instructions::i16x8_shr_s, "i16x8.shr_s" },
1046
    { Instructions::i16x8_shr_u, "i16x8.shr_u" },
1047
    { Instructions::i16x8_add, "i16x8.add" },
1048
    { Instructions::i16x8_add_sat_s, "i16x8.add_sat_s" },
1049
    { Instructions::i16x8_add_sat_u, "i16x8.add_sat_u" },
1050
    { Instructions::i16x8_sub, "i16x8.sub" },
1051
    { Instructions::i16x8_sub_sat_s, "i16x8.sub_sat_s" },
1052
    { Instructions::i16x8_sub_sat_u, "i16x8.sub_sat_u" },
1053
    { Instructions::f64x2_nearest, "f64x2.nearest" },
1054
    { Instructions::i16x8_mul, "i16x8.mul" },
1055
    { Instructions::i16x8_min_s, "i16x8.min_s" },
1056
    { Instructions::i16x8_min_u, "i16x8.min_u" },
1057
    { Instructions::i16x8_max_s, "i16x8.max_s" },
1058
    { Instructions::i16x8_max_u, "i16x8.max_u" },
1059
    { Instructions::i16x8_avgr_u, "i16x8.avgr_u" },
1060
    { Instructions::i16x8_extmul_low_i8x16_s, "i16x8.extmul_low_i8x16_s" },
1061
    { Instructions::i16x8_extmul_high_i8x16_s, "i16x8.extmul_high_i8x16_s" },
1062
    { Instructions::i16x8_extmul_low_i8x16_u, "i16x8.extmul_low_i8x16_u" },
1063
    { Instructions::i16x8_extmul_high_i8x16_u, "i16x8.extmul_high_i8x16_u" },
1064
    { Instructions::i32x4_abs, "i32x4.abs" },
1065
    { Instructions::i32x4_neg, "i32x4.neg" },
1066
    { Instructions::i32x4_all_true, "i32x4.all_true" },
1067
    { Instructions::i32x4_bitmask, "i32x4.bitmask" },
1068
    { Instructions::i32x4_extend_low_i16x8_s, "i32x4.extend_low_i16x8_s" },
1069
    { Instructions::i32x4_extend_high_i16x8_s, "i32x4.extend_high_i16x8_s" },
1070
    { Instructions::i32x4_extend_low_i16x8_u, "i32x4.extend_low_i16x8_u" },
1071
    { Instructions::i32x4_extend_high_i16x8_u, "i32x4.extend_high_i16x8_u" },
1072
    { Instructions::i32x4_shl, "i32x4.shl" },
1073
    { Instructions::i32x4_shr_s, "i32x4.shr_s" },
1074
    { Instructions::i32x4_shr_u, "i32x4.shr_u" },
1075
    { Instructions::i32x4_add, "i32x4.add" },
1076
    { Instructions::i32x4_sub, "i32x4.sub" },
1077
    { Instructions::i32x4_mul, "i32x4.mul" },
1078
    { Instructions::i32x4_min_s, "i32x4.min_s" },
1079
    { Instructions::i32x4_min_u, "i32x4.min_u" },
1080
    { Instructions::i32x4_max_s, "i32x4.max_s" },
1081
    { Instructions::i32x4_max_u, "i32x4.max_u" },
1082
    { Instructions::i32x4_dot_i16x8_s, "i32x4.dot_i16x8_s" },
1083
    { Instructions::i32x4_extmul_low_i16x8_s, "i32x4.extmul_low_i16x8_s" },
1084
    { Instructions::i32x4_extmul_high_i16x8_s, "i32x4.extmul_high_i16x8_s" },
1085
    { Instructions::i32x4_extmul_low_i16x8_u, "i32x4.extmul_low_i16x8_u" },
1086
    { Instructions::i32x4_extmul_high_i16x8_u, "i32x4.extmul_high_i16x8_u" },
1087
    { Instructions::i64x2_abs, "i64x2.abs" },
1088
    { Instructions::i64x2_neg, "i64x2.neg" },
1089
    { Instructions::i64x2_all_true, "i64x2.all_true" },
1090
    { Instructions::i64x2_bitmask, "i64x2.bitmask" },
1091
    { Instructions::i64x2_extend_low_i32x4_s, "i64x2.extend_low_i32x4_s" },
1092
    { Instructions::i64x2_extend_high_i32x4_s, "i64x2.extend_high_i32x4_s" },
1093
    { Instructions::i64x2_extend_low_i32x4_u, "i64x2.extend_low_i32x4_u" },
1094
    { Instructions::i64x2_extend_high_i32x4_u, "i64x2.extend_high_i32x4_u" },
1095
    { Instructions::i64x2_shl, "i64x2.shl" },
1096
    { Instructions::i64x2_shr_s, "i64x2.shr_s" },
1097
    { Instructions::i64x2_shr_u, "i64x2.shr_u" },
1098
    { Instructions::i64x2_add, "i64x2.add" },
1099
    { Instructions::i64x2_sub, "i64x2.sub" },
1100
    { Instructions::i64x2_mul, "i64x2.mul" },
1101
    { Instructions::i64x2_eq, "i64x2.eq" },
1102
    { Instructions::i64x2_ne, "i64x2.ne" },
1103
    { Instructions::i64x2_lt_s, "i64x2.lt_s" },
1104
    { Instructions::i64x2_gt_s, "i64x2.gt_s" },
1105
    { Instructions::i64x2_le_s, "i64x2.le_s" },
1106
    { Instructions::i64x2_ge_s, "i64x2.ge_s" },
1107
    { Instructions::i64x2_extmul_low_i32x4_s, "i64x2.extmul_low_i32x4_s" },
1108
    { Instructions::i64x2_extmul_high_i32x4_s, "i64x2.extmul_high_i32x4_s" },
1109
    { Instructions::i64x2_extmul_low_i32x4_u, "i64x2.extmul_low_i32x4_u" },
1110
    { Instructions::i64x2_extmul_high_i32x4_u, "i64x2.extmul_high_i32x4_u" },
1111
    { Instructions::f32x4_abs, "f32x4.abs" },
1112
    { Instructions::f32x4_neg, "f32x4.neg" },
1113
    { Instructions::f32x4_sqrt, "f32x4.sqrt" },
1114
    { Instructions::f32x4_add, "f32x4.add" },
1115
    { Instructions::f32x4_sub, "f32x4.sub" },
1116
    { Instructions::f32x4_mul, "f32x4.mul" },
1117
    { Instructions::f32x4_div, "f32x4.div" },
1118
    { Instructions::f32x4_min, "f32x4.min" },
1119
    { Instructions::f32x4_max, "f32x4.max" },
1120
    { Instructions::f32x4_pmin, "f32x4.pmin" },
1121
    { Instructions::f32x4_pmax, "f32x4.pmax" },
1122
    { Instructions::f64x2_abs, "f64x2.abs" },
1123
    { Instructions::f64x2_neg, "f64x2.neg" },
1124
    { Instructions::f64x2_sqrt, "f64x2.sqrt" },
1125
    { Instructions::f64x2_add, "f64x2.add" },
1126
    { Instructions::f64x2_sub, "f64x2.sub" },
1127
    { Instructions::f64x2_mul, "f64x2.mul" },
1128
    { Instructions::f64x2_div, "f64x2.div" },
1129
    { Instructions::f64x2_min, "f64x2.min" },
1130
    { Instructions::f64x2_max, "f64x2.max" },
1131
    { Instructions::f64x2_pmin, "f64x2.pmin" },
1132
    { Instructions::f64x2_pmax, "f64x2.pmax" },
1133
    { Instructions::i32x4_trunc_sat_f32x4_s, "i32x4.trunc_sat_f32x4_s" },
1134
    { Instructions::i32x4_trunc_sat_f32x4_u, "i32x4.trunc_sat_f32x4_u" },
1135
    { Instructions::f32x4_convert_i32x4_s, "f32x4.convert_i32x4_s" },
1136
    { Instructions::f32x4_convert_i32x4_u, "f32x4.convert_i32x4_u" },
1137
    { Instructions::i32x4_trunc_sat_f64x2_s_zero, "i32x4.trunc_sat_f64x2_s_zero" },
1138
    { Instructions::i32x4_trunc_sat_f64x2_u_zero, "i32x4.trunc_sat_f64x2_u_zero" },
1139
    { Instructions::f64x2_convert_low_i32x4_s, "f64x2.convert_low_i32x4_s" },
1140
    { Instructions::f64x2_convert_low_i32x4_u, "f64x2.convert_low_i32x4_u" },
1141
    { Instructions::structured_else, "synthetic:else" },
1142
    { Instructions::structured_end, "synthetic:end" },
1143
};
1144
HashMap<ByteString, Wasm::OpCode> Wasm::Names::instructions_by_name;