Coverage Report

Created: 2026-06-30 06:10

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/WasmEdge/lib/loader/ast/instruction.cpp
Line
Count
Source
1
// SPDX-License-Identifier: Apache-2.0
2
// SPDX-FileCopyrightText: Copyright The WasmEdge Authors
3
4
#include "loader/loader.h"
5
6
#include <utility>
7
8
using namespace std::literals;
9
10
namespace WasmEdge {
11
namespace Loader {
12
13
// OpCode loader. See "include/loader/loader.h".
14
10.9M
Expect<OpCode> Loader::loadOpCode() {
15
10.9M
  EXPECTED_TRY(uint8_t Prefix, FMgr.readByte());
16
17
10.9M
  if (Prefix >= 0xFBU && Prefix <= 0xFEU) {
18
    // Multi-byte OpCode case.
19
1.05M
    EXPECTED_TRY(uint32_t Extend, FMgr.readU32());
20
1.05M
    if (Prefix == 0xFBU) {
21
42.5k
      switch (Extend) {
22
0
#define UseOpCode
23
0
#define Line(NAME, STRING, PREFIX)
24
0
#define Line_FB(NAME, STRING, PREFIX, EXTEND)                                  \
25
42.5k
  case EXTEND:                                                                 \
26
42.5k
    return OpCode::NAME;
27
0
#define Line_FC(NAME, STRING, PREFIX, EXTEND)
28
0
#define Line_FD(NAME, STRING, PREFIX, EXTEND)
29
0
#define Line_FE(NAME, STRING, PREFIX, EXTEND)
30
0
#include "common/enum.inc"
31
0
#undef Line
32
0
#undef Line_FB
33
0
#undef Line_FC
34
0
#undef Line_FD
35
0
#undef Line_FE
36
0
#undef UseOpCode
37
6
      default:
38
6
        return Unexpect(ErrCode::Value::IllegalOpCode);
39
42.5k
      }
40
1.01M
    } else if (Prefix == 0xFCU) {
41
36.8k
      switch (Extend) {
42
0
#define UseOpCode
43
0
#define Line(NAME, STRING, PREFIX)
44
0
#define Line_FB(NAME, STRING, PREFIX, EXTEND)
45
0
#define Line_FC(NAME, STRING, PREFIX, EXTEND)                                  \
46
36.8k
  case EXTEND:                                                                 \
47
36.8k
    return OpCode::NAME;
48
0
#define Line_FD(NAME, STRING, PREFIX, EXTEND)
49
0
#define Line_FE(NAME, STRING, PREFIX, EXTEND)
50
0
#include "common/enum.inc"
51
0
#undef Line
52
0
#undef Line_FB
53
0
#undef Line_FC
54
0
#undef Line_FD
55
0
#undef Line_FE
56
0
#undef UseOpCode
57
8
      default:
58
8
        return Unexpect(ErrCode::Value::IllegalOpCode);
59
36.8k
      }
60
976k
    } else if (Prefix == 0xFDU) {
61
967k
      switch (Extend) {
62
0
#define UseOpCode
63
0
#define Line(NAME, STRING, PREFIX)
64
0
#define Line_FB(NAME, STRING, PREFIX, EXTEND)
65
0
#define Line_FC(NAME, STRING, PREFIX, EXTEND)
66
0
#define Line_FD(NAME, STRING, PREFIX, EXTEND)                                  \
67
967k
  case EXTEND:                                                                 \
68
967k
    return OpCode::NAME;
69
0
#define Line_FE(NAME, STRING, PREFIX, EXTEND)
70
0
#include "common/enum.inc"
71
0
#undef Line
72
0
#undef Line_FB
73
0
#undef Line_FC
74
0
#undef Line_FD
75
0
#undef Line_FE
76
0
#undef UseOpCode
77
66
      default:
78
66
        return Unexpect(ErrCode::Value::IllegalOpCode);
79
967k
      }
80
967k
    } else {
81
9.30k
      switch (Extend) {
82
0
#define UseOpCode
83
0
#define Line(NAME, STRING, PREFIX)
84
0
#define Line_FB(NAME, STRING, PREFIX, EXTEND)
85
0
#define Line_FC(NAME, STRING, PREFIX, EXTEND)
86
0
#define Line_FD(NAME, STRING, PREFIX, EXTEND)
87
0
#define Line_FE(NAME, STRING, PREFIX, EXTEND)                                  \
88
9.29k
  case EXTEND:                                                                 \
89
9.29k
    return OpCode::NAME;
90
0
#include "common/enum.inc"
91
0
#undef Line
92
0
#undef Line_FB
93
0
#undef Line_FC
94
0
#undef Line_FD
95
0
#undef Line_FE
96
0
#undef UseOpCode
97
10
      default:
98
10
        return Unexpect(ErrCode::Value::IllegalOpCode);
99
9.30k
      }
100
9.30k
    }
101
9.94M
  } else {
102
    // Single-byte OpCode case.
103
9.94M
    switch (Prefix) {
104
0
#define UseOpCode
105
0
#define Line(NAME, STRING, PREFIX)                                             \
106
9.94M
  case PREFIX:                                                                 \
107
9.94M
    return OpCode::NAME;
108
0
#define Line_FB(NAME, STRING, PREFIX, EXTEND)
109
0
#define Line_FC(NAME, STRING, PREFIX, EXTEND)
110
0
#define Line_FD(NAME, STRING, PREFIX, EXTEND)
111
0
#define Line_FE(NAME, STRING, PREFIX, EXTEND)
112
0
#include "common/enum.inc"
113
0
#undef Line
114
0
#undef Line_FB
115
0
#undef Line_FC
116
0
#undef Line_FD
117
0
#undef Line_FE
118
0
#undef UseOpCode
119
169
    default:
120
169
      return Unexpect(ErrCode::Value::IllegalOpCode);
121
9.94M
    }
122
9.94M
  }
123
10.9M
}
124
125
// Load instruction sequence. See "include/loader/loader.h".
126
34.3k
Expect<AST::InstrVec> Loader::loadInstrSeq(std::optional<uint64_t> SizeBound) {
127
34.3k
  AST::InstrVec Instrs;
128
34.3k
  std::vector<std::pair<OpCode, uint32_t>> BlockStack;
129
34.3k
  uint32_t Cnt = 0;
130
34.3k
  bool IsReachEnd = false;
131
  // Read opcode until the End code of the top block.
132
10.9M
  do {
133
    // Read the opcode and check for errors.
134
10.9M
    uint64_t Offset = FMgr.getOffset();
135
10.9M
    EXPECTED_TRY(OpCode Code, loadOpCode().map_error([this](auto E) {
136
10.9M
      return logLoadError(E, FMgr.getLastOffset(), ASTNodeAttr::Instruction);
137
10.9M
    }));
138
139
    // Check with proposals.
140
10.9M
    if (auto Res = Conf.isInstrNeedProposal(Code); unlikely(!!Res)) {
141
118
      return logNeedProposal(ErrCode::Value::IllegalOpCode, Res.value(), Offset,
142
118
                             ASTNodeAttr::Instruction);
143
118
    }
144
145
10.9M
    auto logIllegalOpCode = [this, &Offset,
146
10.9M
                             &SizeBound]() -> Unexpected<ErrCode> {
147
51
      if (SizeBound.has_value() && FMgr.getOffset() > SizeBound.value()) {
148
18
        return logLoadError(ErrCode::Value::ENDCodeExpected, Offset,
149
18
                            ASTNodeAttr::Instruction);
150
33
      } else {
151
33
        return logLoadError(ErrCode::Value::IllegalOpCode, Offset,
152
33
                            ASTNodeAttr::Instruction);
153
33
      }
154
51
    };
155
156
    // Process the instruction that contains a block.
157
10.9M
    switch (Code) {
158
108k
    case OpCode::Block:
159
707k
    case OpCode::Loop:
160
828k
    case OpCode::If:
161
843k
    case OpCode::Try_table:
162
843k
      BlockStack.emplace_back(Code, Cnt);
163
843k
      break;
164
5.00k
    case OpCode::Else: {
165
5.00k
      if (BlockStack.size() == 0 || BlockStack.back().first != OpCode::If) {
166
        // An Else instruction appeared outside the If-block.
167
47
        return logIllegalOpCode();
168
47
      }
169
4.95k
      uint32_t Pos = BlockStack.back().second;
170
4.95k
      if (Instrs[Pos].getJumpElse() > 0) {
171
        // An Else instruction appeared before in this If-block.
172
4
        return logIllegalOpCode();
173
4
      }
174
4.95k
      Instrs[Pos].setJumpElse(Cnt - Pos);
175
4.95k
      break;
176
4.95k
    }
177
10.1M
    default:
178
10.1M
      break;
179
10.9M
    }
180
181
    // Create the instruction node and load contents.
182
10.9M
    Instrs.emplace_back(Code, static_cast<uint32_t>(Offset));
183
10.9M
    EXPECTED_TRY(loadInstruction(Instrs.back()));
184
185
10.9M
    if (Code == OpCode::End) {
186
      // Post process the End instruction.
187
76.7k
      if (BlockStack.size() > 0) {
188
45.6k
        Instrs.back().setExprLast(false);
189
45.6k
        const auto &[BackOp, Pos] = BlockStack.back();
190
45.6k
        if (BackOp == OpCode::Block || BackOp == OpCode::Loop ||
191
31.2k
            BackOp == OpCode::If) {
192
31.2k
          Instrs.back().setTryBlockLast(false);
193
31.2k
          Instrs[Pos].setJumpEnd(Cnt - Pos);
194
31.2k
          if (BackOp == OpCode::If) {
195
10.0k
            if (Instrs[Pos].getJumpElse() == 0) {
196
              // For an if block without an else branch, set the else jump to
197
              // the end jump.
198
7.11k
              Instrs[Pos].setJumpElse(Cnt - Pos);
199
7.11k
            } else {
200
2.90k
              const uint32_t ElsePos = Pos + Instrs[Pos].getJumpElse();
201
2.90k
              Instrs[ElsePos].setJumpEnd(Cnt - ElsePos);
202
2.90k
            }
203
10.0k
          }
204
31.2k
        } else if (BackOp == OpCode::Try_table) {
205
14.3k
          Instrs.back().setTryBlockLast(true);
206
14.3k
          Instrs[Pos].getTryCatch().JumpEnd = Cnt - Pos;
207
14.3k
        }
208
45.6k
        BlockStack.pop_back();
209
45.6k
      } else {
210
31.0k
        Instrs.back().setExprLast(true);
211
31.0k
        IsReachEnd = true;
212
31.0k
      }
213
76.7k
    }
214
10.9M
    Cnt++;
215
10.9M
  } while (!IsReachEnd);
216
217
  // Check the loaded offset should match the segment boundary.
218
31.0k
  if (SizeBound.has_value()) {
219
18.3k
    auto Offset = FMgr.getOffset();
220
18.3k
    if (Offset < SizeBound.value()) {
221
7
      return logLoadError(ErrCode::Value::JunkSection, Offset,
222
7
                          ASTNodeAttr::Instruction);
223
18.3k
    } else if (Offset > SizeBound.value()) {
224
72
      return logLoadError(ErrCode::Value::SectionSizeMismatch, Offset,
225
72
                          ASTNodeAttr::Instruction);
226
72
    }
227
18.3k
  }
228
30.9k
  return Instrs;
229
31.0k
}
230
231
// Load instruction node. See "include/loader/loader.h".
232
11.0M
Expect<void> Loader::loadInstruction(AST::Instruction &Instr) {
233
  // Node: The instruction has checked for the proposals. Need to check their
234
  // immediates.
235
236
11.0M
  auto ReportError = [this](auto E) {
237
787
    return logLoadError(E, FMgr.getLastOffset(), ASTNodeAttr::Instruction);
238
787
  };
239
240
11.0M
  auto readU8 = [this, ReportError](uint8_t &Dst) -> Expect<void> {
241
56.5k
    EXPECTED_TRY(Dst, FMgr.readByte().map_error(ReportError));
242
56.4k
    return {};
243
56.5k
  };
244
245
11.0M
  auto readU32 = [this, ReportError](uint32_t &Dst) -> Expect<void> {
246
476k
    EXPECTED_TRY(Dst, FMgr.readU32().map_error(ReportError));
247
476k
    return {};
248
476k
  };
249
250
11.0M
  auto readU64 = [this, ReportError](uint64_t &Dst) -> Expect<void> {
251
167k
    EXPECTED_TRY(Dst, FMgr.readU64().map_error(ReportError));
252
167k
    return {};
253
167k
  };
254
255
11.0M
  auto readMemImmediate = [this, readU32, readU64, &Instr]() -> Expect<void> {
256
167k
    Instr.getTargetIndex() = 0;
257
167k
    EXPECTED_TRY(readU32(Instr.getMemoryAlign()));
258
167k
    if (Conf.hasProposal(Proposal::MultiMemories) &&
259
167k
        Instr.getMemoryAlign() >= 64) {
260
2.05k
      Instr.getMemoryAlign() -= 64;
261
2.05k
      EXPECTED_TRY(readU32(Instr.getTargetIndex()));
262
2.05k
    }
263
167k
    uint32_t MaxAlign = Conf.hasProposal(Proposal::Memory64) ? 64U : 32U;
264
167k
    if (unlikely(Instr.getMemoryAlign() >= MaxAlign)) {
265
69
      return logLoadError(ErrCode::Value::MalformedMemoryOpFlags,
266
69
                          FMgr.getLastOffset(), ASTNodeAttr::Instruction);
267
69
    }
268
167k
    if (Conf.hasProposal(Proposal::Memory64)) {
269
167k
      EXPECTED_TRY(readU64(Instr.getMemoryOffset()));
270
167k
    } else {
271
0
      uint32_t Offset;
272
0
      EXPECTED_TRY(readU32(Offset));
273
0
      Instr.getMemoryOffset() = static_cast<uint64_t>(Offset);
274
0
    }
275
167k
    return {};
276
167k
  };
277
278
11.0M
  auto readCheckZero = [this, readU8](uint32_t &Dst) -> Expect<void> {
279
1.04k
    uint8_t C = 0;
280
1.04k
    EXPECTED_TRY(readU8(C));
281
1.04k
    if (C != UINT8_C(0)) {
282
1
      return logLoadError(ErrCode::Value::ExpectedZeroByte,
283
1
                          FMgr.getLastOffset(), ASTNodeAttr::Instruction);
284
1
    }
285
1.04k
    Dst = 0;
286
1.04k
    return {};
287
1.04k
  };
288
289
11.0M
  auto readBlockType = [this, ReportError](BlockType &Dst) -> Expect<void> {
290
843k
    auto StartOffset = FMgr.getOffset();
291
    // Read the block return type.
292
843k
    EXPECTED_TRY(int64_t Code, FMgr.readS33().map_error(ReportError));
293
842k
    if (Code < 0) {
294
      // The empty and valtype cases are encoded as a single-byte SLEB128,
295
      // i.e. the decoded value must be in [-64, -1]. Any negative value
296
      // smaller than -64 means a non-canonical multi-byte SLEB128 encoding,
297
      // which is not a valid blocktype.
298
515k
      if (Code < -64) {
299
25
        return logLoadError(ErrCode::Value::MalformedValType,
300
25
                            FMgr.getLastOffset(), ASTNodeAttr::Instruction);
301
25
      }
302
515k
      TypeCode TypeByte = static_cast<TypeCode>(Code & INT64_C(0x7F));
303
515k
      if (TypeByte == TypeCode::Epsilon) {
304
        // Empty case.
305
4.74k
        Dst.setEmpty();
306
510k
      } else {
307
        // Value type case. Seek back to the origin offset and read the
308
        // valtype.
309
510k
        FMgr.seek(StartOffset);
310
        // The AST node information is handled.
311
510k
        EXPECTED_TRY(auto Type, loadValType(ASTNodeAttr::Instruction));
312
510k
        Dst.setData(Type);
313
510k
      }
314
515k
    } else {
315
      // Type index case.
316
327k
      if (unlikely(!Conf.hasProposal(Proposal::MultiValue))) {
317
0
        return logNeedProposal(ErrCode::Value::MalformedValType,
318
0
                               Proposal::MultiValue, FMgr.getLastOffset(),
319
0
                               ASTNodeAttr::Instruction);
320
0
      }
321
327k
      Dst.setData(static_cast<uint32_t>(Code));
322
327k
    }
323
842k
    return {};
324
842k
  };
325
326
11.0M
  switch (Instr.getOpCode()) {
327
  // Control instructions.
328
4.18M
  case OpCode::Unreachable:
329
4.55M
  case OpCode::Nop:
330
4.56M
  case OpCode::Return:
331
4.57M
  case OpCode::Throw_ref:
332
4.65M
  case OpCode::End:
333
4.65M
  case OpCode::Else:
334
4.65M
    return {};
335
336
108k
  case OpCode::Block:
337
707k
  case OpCode::Loop:
338
828k
  case OpCode::If:
339
828k
    return readBlockType(Instr.getBlockType());
340
341
14.5k
  case OpCode::Try_table: {
342
14.5k
    Instr.setTryCatch();
343
    // Read the result type.
344
14.5k
    EXPECTED_TRY(readBlockType(Instr.getTryCatch().ResType));
345
28.9k
    EXPECTED_TRY(uint32_t VecCnt, loadVecCnt().map_error(ReportError));
346
28.9k
    Instr.getTryCatch().Catch.resize(VecCnt);
347
28.9k
    for (uint32_t I = 0; I < VecCnt; ++I) {
348
3.09k
      auto &Desc = Instr.getTryCatch().Catch[I];
349
      // Read the catch flag.
350
3.09k
      EXPECTED_TRY(uint8_t Flag, FMgr.readByte().map_error(ReportError));
351
3.09k
      if (unlikely(Flag > 0x03U)) {
352
20
        return logLoadError(ErrCode::Value::MalformedCatchFlags,
353
20
                            FMgr.getLastOffset(), ASTNodeAttr::Instruction);
354
20
      }
355
3.07k
      Desc.IsRef = (Flag & 0x01U) ? true : false;
356
3.07k
      Desc.IsAll = (Flag & 0x02U) ? true : false;
357
3.07k
      if (!Desc.IsAll) {
358
        // Read the tag index.
359
2.33k
        EXPECTED_TRY(readU32(Desc.TagIndex));
360
2.33k
      }
361
      // Read the label index.
362
3.07k
      EXPECTED_TRY(readU32(Desc.LabelIndex));
363
3.07k
    }
364
14.4k
    return {};
365
28.9k
  }
366
367
1.72k
  case OpCode::Throw:
368
1.72k
    return readU32(Instr.getTargetIndex());
369
370
7.03k
  case OpCode::Br:
371
14.8k
  case OpCode::Br_if:
372
15.9k
  case OpCode::Br_on_null:
373
16.2k
  case OpCode::Br_on_non_null:
374
16.2k
    return readU32(Instr.getJump().TargetIndex);
375
376
11.1k
  case OpCode::Br_table: {
377
    // Read the vector of labels.
378
11.1k
    EXPECTED_TRY(uint32_t VecCnt, loadVecCnt().map_error(ReportError));
379
11.1k
    Instr.setLabelListSize(VecCnt + 1);
380
91.2k
    for (uint32_t I = 0; I < VecCnt; ++I) {
381
80.1k
      EXPECTED_TRY(readU32(Instr.getLabelList()[I].TargetIndex));
382
80.1k
    }
383
    // Read default label.
384
11.0k
    return readU32(Instr.getLabelList()[VecCnt].TargetIndex);
385
11.1k
  }
386
387
10.2k
  case OpCode::Call:
388
10.6k
  case OpCode::Return_call:
389
11.9k
  case OpCode::Call_ref:
390
12.3k
  case OpCode::Return_call_ref:
391
12.3k
    return readU32(Instr.getTargetIndex());
392
393
19.1k
  case OpCode::Call_indirect:
394
19.6k
  case OpCode::Return_call_indirect: {
395
    // Read the type index.
396
19.6k
    EXPECTED_TRY(readU32(Instr.getTargetIndex()));
397
19.6k
    uint64_t SrcIdxOffset = FMgr.getOffset();
398
    // Read the table index.
399
19.6k
    EXPECTED_TRY(readU32(Instr.getSourceIndex()));
400
19.5k
    if ((Instr.getSourceIndex() > 0 || FMgr.getOffset() - SrcIdxOffset > 1) &&
401
13.6k
        !Conf.hasProposal(Proposal::ReferenceTypes)) {
402
0
      return logNeedProposal(ErrCode::Value::ExpectedZeroByte,
403
0
                             Proposal::ReferenceTypes, FMgr.getLastOffset(),
404
0
                             ASTNodeAttr::Instruction);
405
0
    }
406
19.5k
    return {};
407
19.5k
  }
408
409
  // Reference Instructions.
410
33.3k
  case OpCode::Ref__null:
411
33.8k
  case OpCode::Ref__test_null:
412
35.2k
  case OpCode::Ref__cast_null: {
413
    // The AST node information is handled.
414
35.2k
    EXPECTED_TRY(auto Type,
415
35.2k
                 loadHeapType(TypeCode::RefNull, ASTNodeAttr::Instruction));
416
35.2k
    Instr.setValType(Type);
417
35.2k
    return {};
418
35.2k
  }
419
394
  case OpCode::Ref__test:
420
2.29k
  case OpCode::Ref__cast: {
421
    // The AST node information is handled.
422
2.29k
    EXPECTED_TRY(auto Type,
423
2.29k
                 loadHeapType(TypeCode::Ref, ASTNodeAttr::Instruction));
424
2.29k
    Instr.setValType(Type);
425
2.29k
    return {};
426
2.29k
  }
427
8.64k
  case OpCode::Ref__is_null:
428
9.31k
  case OpCode::Ref__eq:
429
10.9k
  case OpCode::Ref__as_non_null:
430
10.9k
    return {};
431
11.6k
  case OpCode::Ref__func:
432
22.4k
  case OpCode::Struct__new:
433
22.8k
  case OpCode::Struct__new_default:
434
23.5k
  case OpCode::Array__new:
435
23.9k
  case OpCode::Array__new_default:
436
24.5k
  case OpCode::Array__get:
437
25.2k
  case OpCode::Array__get_s:
438
26.5k
  case OpCode::Array__get_u:
439
26.6k
  case OpCode::Array__set:
440
26.8k
  case OpCode::Array__fill:
441
26.8k
    return readU32(Instr.getTargetIndex());
442
286
  case OpCode::Struct__get:
443
2.12k
  case OpCode::Struct__get_s:
444
2.36k
  case OpCode::Struct__get_u:
445
2.79k
  case OpCode::Struct__set:
446
6.98k
  case OpCode::Array__new_fixed:
447
7.22k
  case OpCode::Array__new_data:
448
7.38k
  case OpCode::Array__new_elem:
449
7.86k
  case OpCode::Array__copy:
450
8.26k
  case OpCode::Array__init_data:
451
8.83k
  case OpCode::Array__init_elem:
452
8.83k
    EXPECTED_TRY(readU32(Instr.getTargetIndex()));
453
8.81k
    return readU32(Instr.getSourceIndex());
454
473
  case OpCode::Br_on_cast:
455
1.65k
  case OpCode::Br_on_cast_fail: {
456
    // Read the flag.
457
1.65k
    uint8_t Flag = 0U;
458
1.65k
    EXPECTED_TRY(readU8(Flag).map_error(ReportError));
459
    // Read the label index.
460
1.65k
    uint32_t LabelIdx = 0U;
461
1.65k
    EXPECTED_TRY(readU32(LabelIdx).map_error(ReportError));
462
    // Read the heap types.
463
1.65k
    Instr.setBrCast(LabelIdx);
464
1.65k
    TypeCode TC = ((Flag & 0x01U) ? TypeCode::RefNull : TypeCode::Ref);
465
1.65k
    EXPECTED_TRY(
466
1.64k
        Instr.getBrCast().RType1,
467
1.64k
        loadHeapType(TC, ASTNodeAttr::Instruction).map_error(ReportError));
468
1.64k
    TC = ((Flag & 0x02U) ? TypeCode::RefNull : TypeCode::Ref);
469
1.64k
    EXPECTED_TRY(
470
1.64k
        Instr.getBrCast().RType2,
471
1.64k
        loadHeapType(TC, ASTNodeAttr::Instruction).map_error(ReportError));
472
1.64k
    return {};
473
1.64k
  }
474
808
  case OpCode::Array__len:
475
1.64k
  case OpCode::Any__convert_extern:
476
3.67k
  case OpCode::Extern__convert_any:
477
12.0k
  case OpCode::Ref__i31:
478
12.3k
  case OpCode::I31__get_s:
479
12.7k
  case OpCode::I31__get_u:
480
12.7k
    return {};
481
482
  // Parametric Instructions.
483
44.2k
  case OpCode::Drop:
484
140k
  case OpCode::Select:
485
140k
    return {};
486
1.67k
  case OpCode::Select_t: {
487
    // Read the vector of value types.
488
1.67k
    EXPECTED_TRY(uint32_t VecCnt, loadVecCnt().map_error(ReportError));
489
1.65k
    Instr.setValTypeListSize(VecCnt);
490
60.8k
    for (uint32_t I = 0; I < VecCnt; ++I) {
491
      // The AST node information is handled.
492
59.2k
      EXPECTED_TRY(Instr.getValTypeList()[I],
493
59.2k
                   loadValType(ASTNodeAttr::Instruction));
494
59.2k
    }
495
1.64k
    return {};
496
1.65k
  }
497
498
  // Variable Instructions.
499
27.1k
  case OpCode::Local__get:
500
37.8k
  case OpCode::Local__set:
501
44.9k
  case OpCode::Local__tee:
502
48.5k
  case OpCode::Global__get:
503
51.3k
  case OpCode::Global__set:
504
51.3k
    return readU32(Instr.getTargetIndex());
505
506
  // Table Instructions.
507
310
  case OpCode::Table__init:
508
310
    EXPECTED_TRY(readU32(Instr.getSourceIndex()));
509
307
    [[fallthrough]];
510
2.92k
  case OpCode::Table__get:
511
4.51k
  case OpCode::Table__set:
512
7.00k
  case OpCode::Table__grow:
513
7.76k
  case OpCode::Table__size:
514
8.05k
  case OpCode::Table__fill:
515
9.38k
  case OpCode::Elem__drop:
516
9.38k
    return readU32(Instr.getTargetIndex());
517
1.25k
  case OpCode::Table__copy:
518
1.25k
    EXPECTED_TRY(readU32(Instr.getTargetIndex()));
519
1.25k
    return readU32(Instr.getSourceIndex());
520
521
  // Memory Instructions.
522
4.39k
  case OpCode::I32__load:
523
11.2k
  case OpCode::I64__load:
524
12.1k
  case OpCode::F32__load:
525
15.0k
  case OpCode::F64__load:
526
18.4k
  case OpCode::I32__load8_s:
527
20.3k
  case OpCode::I32__load8_u:
528
22.9k
  case OpCode::I32__load16_s:
529
29.4k
  case OpCode::I32__load16_u:
530
33.9k
  case OpCode::I64__load8_s:
531
38.1k
  case OpCode::I64__load8_u:
532
43.6k
  case OpCode::I64__load16_s:
533
54.0k
  case OpCode::I64__load16_u:
534
57.6k
  case OpCode::I64__load32_s:
535
61.5k
  case OpCode::I64__load32_u:
536
63.6k
  case OpCode::I32__store:
537
68.8k
  case OpCode::I64__store:
538
71.6k
  case OpCode::F32__store:
539
72.7k
  case OpCode::F64__store:
540
75.8k
  case OpCode::I32__store8:
541
79.7k
  case OpCode::I32__store16:
542
83.0k
  case OpCode::I64__store8:
543
86.2k
  case OpCode::I64__store16:
544
87.7k
  case OpCode::I64__store32:
545
87.7k
    return readMemImmediate();
546
547
742
  case OpCode::Memory__init:
548
742
    if (!HasDataSection) {
549
2
      return logLoadError(ErrCode::Value::DataCountRequired, Instr.getOffset(),
550
2
                          ASTNodeAttr::Instruction);
551
2
    }
552
740
    EXPECTED_TRY(readU32(Instr.getSourceIndex()));
553
735
    [[fallthrough]];
554
15.3k
  case OpCode::Memory__grow:
555
26.1k
  case OpCode::Memory__size:
556
28.5k
  case OpCode::Memory__fill:
557
28.5k
    if (Conf.hasProposal(Proposal::MultiMemories)) {
558
28.5k
      return readU32(Instr.getTargetIndex());
559
28.5k
    }
560
0
    return readCheckZero(Instr.getTargetIndex());
561
794
  case OpCode::Memory__copy:
562
794
    if (Conf.hasProposal(Proposal::MultiMemories)) {
563
794
      EXPECTED_TRY(readU32(Instr.getTargetIndex()));
564
792
      return readU32(Instr.getSourceIndex());
565
794
    }
566
0
    EXPECTED_TRY(readCheckZero(Instr.getTargetIndex()));
567
0
    return readCheckZero(Instr.getSourceIndex());
568
700
  case OpCode::Data__drop:
569
700
    if (!HasDataSection) {
570
2
      return logLoadError(ErrCode::Value::DataCountRequired, Instr.getOffset(),
571
2
                          ASTNodeAttr::Instruction);
572
2
    }
573
698
    return readU32(Instr.getTargetIndex());
574
575
  // Const Instructions.
576
2.38M
  case OpCode::I32__const:
577
2.38M
    EXPECTED_TRY(FMgr.readS32().map_error(ReportError).map([&](int32_t Num) {
578
      // Should clear the higher bits.
579
2.38M
      Instr.setNum(static_cast<uint128_t>(0U));
580
2.38M
      Instr.setNum(static_cast<uint32_t>(Num));
581
2.38M
    }));
582
2.38M
    return {};
583
309k
  case OpCode::I64__const:
584
309k
    EXPECTED_TRY(FMgr.readS64().map_error(ReportError).map([&](int64_t Num) {
585
      // Should clear the higher bits.
586
309k
      Instr.setNum(static_cast<uint128_t>(0U));
587
309k
      Instr.setNum(static_cast<uint64_t>(Num));
588
309k
    }));
589
309k
    return {};
590
44.7k
  case OpCode::F32__const:
591
44.7k
    EXPECTED_TRY(FMgr.readF32().map_error(ReportError).map([&](float Num) {
592
44.7k
      Instr.setNum(Num);
593
44.7k
    }));
594
44.7k
    return {};
595
19.0k
  case OpCode::F64__const:
596
19.0k
    EXPECTED_TRY(FMgr.readF64().map_error(ReportError).map([&](double Num) {
597
19.0k
      Instr.setNum(Num);
598
19.0k
    }));
599
19.0k
    return {};
600
601
  // Unary Numeric Instructions.
602
25.4k
  case OpCode::I32__eqz:
603
40.9k
  case OpCode::I32__clz:
604
47.1k
  case OpCode::I32__ctz:
605
143k
  case OpCode::I32__popcnt:
606
159k
  case OpCode::I64__eqz:
607
161k
  case OpCode::I64__clz:
608
164k
  case OpCode::I64__ctz:
609
260k
  case OpCode::I64__popcnt:
610
262k
  case OpCode::F32__abs:
611
265k
  case OpCode::F32__neg:
612
269k
  case OpCode::F32__ceil:
613
275k
  case OpCode::F32__floor:
614
279k
  case OpCode::F32__trunc:
615
289k
  case OpCode::F32__nearest:
616
298k
  case OpCode::F32__sqrt:
617
300k
  case OpCode::F64__abs:
618
302k
  case OpCode::F64__neg:
619
310k
  case OpCode::F64__ceil:
620
313k
  case OpCode::F64__floor:
621
318k
  case OpCode::F64__trunc:
622
321k
  case OpCode::F64__nearest:
623
326k
  case OpCode::F64__sqrt:
624
329k
  case OpCode::I32__wrap_i64:
625
340k
  case OpCode::I32__trunc_f32_s:
626
349k
  case OpCode::I32__trunc_f32_u:
627
351k
  case OpCode::I32__trunc_f64_s:
628
441k
  case OpCode::I32__trunc_f64_u:
629
452k
  case OpCode::I64__extend_i32_s:
630
458k
  case OpCode::I64__extend_i32_u:
631
460k
  case OpCode::I64__trunc_f32_s:
632
462k
  case OpCode::I64__trunc_f32_u:
633
467k
  case OpCode::I64__trunc_f64_s:
634
471k
  case OpCode::I64__trunc_f64_u:
635
485k
  case OpCode::F32__convert_i32_s:
636
494k
  case OpCode::F32__convert_i32_u:
637
498k
  case OpCode::F32__convert_i64_s:
638
503k
  case OpCode::F32__convert_i64_u:
639
504k
  case OpCode::F32__demote_f64:
640
514k
  case OpCode::F64__convert_i32_s:
641
522k
  case OpCode::F64__convert_i32_u:
642
548k
  case OpCode::F64__convert_i64_s:
643
556k
  case OpCode::F64__convert_i64_u:
644
558k
  case OpCode::F64__promote_f32:
645
565k
  case OpCode::I32__reinterpret_f32:
646
570k
  case OpCode::I64__reinterpret_f64:
647
591k
  case OpCode::F32__reinterpret_i32:
648
619k
  case OpCode::F64__reinterpret_i64:
649
630k
  case OpCode::I32__extend8_s:
650
640k
  case OpCode::I32__extend16_s:
651
644k
  case OpCode::I64__extend8_s:
652
673k
  case OpCode::I64__extend16_s:
653
680k
  case OpCode::I64__extend32_s:
654
688k
  case OpCode::I32__trunc_sat_f32_s:
655
690k
  case OpCode::I32__trunc_sat_f32_u:
656
693k
  case OpCode::I32__trunc_sat_f64_s:
657
695k
  case OpCode::I32__trunc_sat_f64_u:
658
698k
  case OpCode::I64__trunc_sat_f32_s:
659
700k
  case OpCode::I64__trunc_sat_f32_u:
660
704k
  case OpCode::I64__trunc_sat_f64_s:
661
706k
  case OpCode::I64__trunc_sat_f64_u:
662
663
  // Binary Numeric Instructions.
664
710k
  case OpCode::I32__eq:
665
714k
  case OpCode::I32__ne:
666
725k
  case OpCode::I32__lt_s:
667
751k
  case OpCode::I32__lt_u:
668
762k
  case OpCode::I32__gt_s:
669
786k
  case OpCode::I32__gt_u:
670
798k
  case OpCode::I32__le_s:
671
802k
  case OpCode::I32__le_u:
672
811k
  case OpCode::I32__ge_s:
673
819k
  case OpCode::I32__ge_u:
674
823k
  case OpCode::I64__eq:
675
829k
  case OpCode::I64__ne:
676
837k
  case OpCode::I64__lt_s:
677
839k
  case OpCode::I64__lt_u:
678
842k
  case OpCode::I64__gt_s:
679
843k
  case OpCode::I64__gt_u:
680
847k
  case OpCode::I64__le_s:
681
857k
  case OpCode::I64__le_u:
682
858k
  case OpCode::I64__ge_s:
683
861k
  case OpCode::I64__ge_u:
684
863k
  case OpCode::F32__eq:
685
864k
  case OpCode::F32__ne:
686
867k
  case OpCode::F32__lt:
687
885k
  case OpCode::F32__gt:
688
891k
  case OpCode::F32__le:
689
894k
  case OpCode::F32__ge:
690
907k
  case OpCode::F64__eq:
691
909k
  case OpCode::F64__ne:
692
912k
  case OpCode::F64__lt:
693
916k
  case OpCode::F64__gt:
694
920k
  case OpCode::F64__le:
695
927k
  case OpCode::F64__ge:
696
697
932k
  case OpCode::I32__add:
698
942k
  case OpCode::I32__sub:
699
949k
  case OpCode::I32__mul:
700
975k
  case OpCode::I32__div_s:
701
993k
  case OpCode::I32__div_u:
702
999k
  case OpCode::I32__rem_s:
703
1.02M
  case OpCode::I32__rem_u:
704
1.02M
  case OpCode::I32__and:
705
1.03M
  case OpCode::I32__or:
706
1.05M
  case OpCode::I32__xor:
707
1.07M
  case OpCode::I32__shl:
708
1.08M
  case OpCode::I32__shr_s:
709
1.11M
  case OpCode::I32__shr_u:
710
1.12M
  case OpCode::I32__rotl:
711
1.13M
  case OpCode::I32__rotr:
712
1.15M
  case OpCode::I64__add:
713
1.16M
  case OpCode::I64__sub:
714
1.16M
  case OpCode::I64__mul:
715
1.16M
  case OpCode::I64__div_s:
716
1.18M
  case OpCode::I64__div_u:
717
1.19M
  case OpCode::I64__rem_s:
718
1.19M
  case OpCode::I64__rem_u:
719
1.20M
  case OpCode::I64__and:
720
1.21M
  case OpCode::I64__or:
721
1.21M
  case OpCode::I64__xor:
722
1.21M
  case OpCode::I64__shl:
723
1.22M
  case OpCode::I64__shr_s:
724
1.22M
  case OpCode::I64__shr_u:
725
1.23M
  case OpCode::I64__rotl:
726
1.24M
  case OpCode::I64__rotr:
727
1.24M
  case OpCode::F32__add:
728
1.25M
  case OpCode::F32__sub:
729
1.25M
  case OpCode::F32__mul:
730
1.25M
  case OpCode::F32__div:
731
1.25M
  case OpCode::F32__min:
732
1.26M
  case OpCode::F32__max:
733
1.26M
  case OpCode::F32__copysign:
734
1.26M
  case OpCode::F64__add:
735
1.27M
  case OpCode::F64__sub:
736
1.28M
  case OpCode::F64__mul:
737
1.28M
  case OpCode::F64__div:
738
1.28M
  case OpCode::F64__min:
739
1.29M
  case OpCode::F64__max:
740
1.29M
  case OpCode::F64__copysign:
741
1.29M
    return {};
742
743
  // SIMD Memory Instruction.
744
25.0k
  case OpCode::V128__load:
745
28.8k
  case OpCode::V128__load8x8_s:
746
29.5k
  case OpCode::V128__load8x8_u:
747
30.6k
  case OpCode::V128__load16x4_s:
748
34.0k
  case OpCode::V128__load16x4_u:
749
36.3k
  case OpCode::V128__load32x2_s:
750
36.9k
  case OpCode::V128__load32x2_u:
751
39.0k
  case OpCode::V128__load8_splat:
752
43.3k
  case OpCode::V128__load16_splat:
753
45.9k
  case OpCode::V128__load32_splat:
754
47.6k
  case OpCode::V128__load64_splat:
755
51.2k
  case OpCode::V128__load32_zero:
756
51.8k
  case OpCode::V128__load64_zero:
757
52.7k
  case OpCode::V128__store:
758
52.7k
    return readMemImmediate();
759
810
  case OpCode::V128__load8_lane:
760
6.12k
  case OpCode::V128__load16_lane:
761
7.63k
  case OpCode::V128__load32_lane:
762
9.42k
  case OpCode::V128__load64_lane:
763
11.2k
  case OpCode::V128__store8_lane:
764
11.7k
  case OpCode::V128__store16_lane:
765
17.1k
  case OpCode::V128__store32_lane:
766
18.6k
  case OpCode::V128__store64_lane:
767
    // Read memory immediate.
768
18.6k
    EXPECTED_TRY(readMemImmediate());
769
    // Read lane index.
770
18.5k
    return readU8(Instr.getMemoryLane());
771
772
  // SIMD Const Instruction.
773
978
  case OpCode::V128__const:
774
  // SIMD Shuffle Instruction.
775
2.12k
  case OpCode::I8x16__shuffle: {
776
    // Read value.
777
2.12k
    uint128_t Value = 0U;
778
35.8k
    for (uint32_t I = 0U; I < 16U; ++I) {
779
33.7k
      EXPECTED_TRY(FMgr.readByte().map_error(ReportError).map([&](uint8_t B) {
780
33.7k
        Value |= static_cast<uint128_t>(static_cast<uint32_t>(B)) << (I * 8U);
781
33.7k
      }));
782
33.7k
    }
783
2.10k
    Instr.setNum(Value);
784
2.10k
    return {};
785
2.12k
  }
786
787
  // SIMD Lane Instructions.
788
5.40k
  case OpCode::I8x16__extract_lane_s:
789
5.93k
  case OpCode::I8x16__extract_lane_u:
790
9.39k
  case OpCode::I8x16__replace_lane:
791
12.8k
  case OpCode::I16x8__extract_lane_s:
792
14.7k
  case OpCode::I16x8__extract_lane_u:
793
16.8k
  case OpCode::I16x8__replace_lane:
794
22.1k
  case OpCode::I32x4__extract_lane:
795
25.7k
  case OpCode::I32x4__replace_lane:
796
26.9k
  case OpCode::I64x2__extract_lane:
797
28.8k
  case OpCode::I64x2__replace_lane:
798
29.7k
  case OpCode::F32x4__extract_lane:
799
31.3k
  case OpCode::F32x4__replace_lane:
800
33.2k
  case OpCode::F64x2__extract_lane:
801
35.2k
  case OpCode::F64x2__replace_lane:
802
    // Read lane index.
803
35.2k
    return readU8(Instr.getMemoryLane());
804
805
  // SIMD Numeric Instructions.
806
4.29k
  case OpCode::I8x16__swizzle:
807
190k
  case OpCode::I8x16__splat:
808
236k
  case OpCode::I16x8__splat:
809
246k
  case OpCode::I32x4__splat:
810
248k
  case OpCode::I64x2__splat:
811
249k
  case OpCode::F32x4__splat:
812
254k
  case OpCode::F64x2__splat:
813
814
259k
  case OpCode::I8x16__eq:
815
260k
  case OpCode::I8x16__ne:
816
263k
  case OpCode::I8x16__lt_s:
817
264k
  case OpCode::I8x16__lt_u:
818
272k
  case OpCode::I8x16__gt_s:
819
274k
  case OpCode::I8x16__gt_u:
820
275k
  case OpCode::I8x16__le_s:
821
276k
  case OpCode::I8x16__le_u:
822
278k
  case OpCode::I8x16__ge_s:
823
281k
  case OpCode::I8x16__ge_u:
824
825
286k
  case OpCode::I16x8__eq:
826
289k
  case OpCode::I16x8__ne:
827
293k
  case OpCode::I16x8__lt_s:
828
298k
  case OpCode::I16x8__lt_u:
829
302k
  case OpCode::I16x8__gt_s:
830
308k
  case OpCode::I16x8__gt_u:
831
311k
  case OpCode::I16x8__le_s:
832
312k
  case OpCode::I16x8__le_u:
833
315k
  case OpCode::I16x8__ge_s:
834
319k
  case OpCode::I16x8__ge_u:
835
836
321k
  case OpCode::I32x4__eq:
837
323k
  case OpCode::I32x4__ne:
838
327k
  case OpCode::I32x4__lt_s:
839
327k
  case OpCode::I32x4__lt_u:
840
328k
  case OpCode::I32x4__gt_s:
841
330k
  case OpCode::I32x4__gt_u:
842
338k
  case OpCode::I32x4__le_s:
843
339k
  case OpCode::I32x4__le_u:
844
339k
  case OpCode::I32x4__ge_s:
845
342k
  case OpCode::I32x4__ge_u:
846
847
352k
  case OpCode::F32x4__eq:
848
354k
  case OpCode::F32x4__ne:
849
356k
  case OpCode::F32x4__lt:
850
357k
  case OpCode::F32x4__gt:
851
360k
  case OpCode::F32x4__le:
852
361k
  case OpCode::F32x4__ge:
853
854
371k
  case OpCode::F64x2__eq:
855
372k
  case OpCode::F64x2__ne:
856
373k
  case OpCode::F64x2__lt:
857
380k
  case OpCode::F64x2__gt:
858
382k
  case OpCode::F64x2__le:
859
386k
  case OpCode::F64x2__ge:
860
861
398k
  case OpCode::V128__not:
862
399k
  case OpCode::V128__and:
863
400k
  case OpCode::V128__andnot:
864
402k
  case OpCode::V128__or:
865
404k
  case OpCode::V128__xor:
866
404k
  case OpCode::V128__bitselect:
867
406k
  case OpCode::V128__any_true:
868
869
428k
  case OpCode::I8x16__abs:
870
457k
  case OpCode::I8x16__neg:
871
459k
  case OpCode::I8x16__popcnt:
872
460k
  case OpCode::I8x16__all_true:
873
464k
  case OpCode::I8x16__bitmask:
874
466k
  case OpCode::I8x16__narrow_i16x8_s:
875
467k
  case OpCode::I8x16__narrow_i16x8_u:
876
470k
  case OpCode::I8x16__shl:
877
473k
  case OpCode::I8x16__shr_s:
878
474k
  case OpCode::I8x16__shr_u:
879
475k
  case OpCode::I8x16__add:
880
478k
  case OpCode::I8x16__add_sat_s:
881
479k
  case OpCode::I8x16__add_sat_u:
882
483k
  case OpCode::I8x16__sub:
883
486k
  case OpCode::I8x16__sub_sat_s:
884
488k
  case OpCode::I8x16__sub_sat_u:
885
490k
  case OpCode::I8x16__min_s:
886
499k
  case OpCode::I8x16__min_u:
887
500k
  case OpCode::I8x16__max_s:
888
502k
  case OpCode::I8x16__max_u:
889
503k
  case OpCode::I8x16__avgr_u:
890
891
505k
  case OpCode::I16x8__abs:
892
506k
  case OpCode::I16x8__neg:
893
507k
  case OpCode::I16x8__all_true:
894
511k
  case OpCode::I16x8__bitmask:
895
512k
  case OpCode::I16x8__narrow_i32x4_s:
896
515k
  case OpCode::I16x8__narrow_i32x4_u:
897
522k
  case OpCode::I16x8__extend_low_i8x16_s:
898
522k
  case OpCode::I16x8__extend_high_i8x16_s:
899
524k
  case OpCode::I16x8__extend_low_i8x16_u:
900
525k
  case OpCode::I16x8__extend_high_i8x16_u:
901
525k
  case OpCode::I16x8__shl:
902
527k
  case OpCode::I16x8__shr_s:
903
528k
  case OpCode::I16x8__shr_u:
904
529k
  case OpCode::I16x8__add:
905
531k
  case OpCode::I16x8__add_sat_s:
906
532k
  case OpCode::I16x8__add_sat_u:
907
536k
  case OpCode::I16x8__sub:
908
541k
  case OpCode::I16x8__sub_sat_s:
909
542k
  case OpCode::I16x8__sub_sat_u:
910
543k
  case OpCode::I16x8__mul:
911
545k
  case OpCode::I16x8__min_s:
912
547k
  case OpCode::I16x8__min_u:
913
550k
  case OpCode::I16x8__max_s:
914
553k
  case OpCode::I16x8__max_u:
915
557k
  case OpCode::I16x8__avgr_u:
916
558k
  case OpCode::I16x8__extmul_low_i8x16_s:
917
561k
  case OpCode::I16x8__extmul_high_i8x16_s:
918
561k
  case OpCode::I16x8__extmul_low_i8x16_u:
919
567k
  case OpCode::I16x8__extmul_high_i8x16_u:
920
569k
  case OpCode::I16x8__q15mulr_sat_s:
921
572k
  case OpCode::I16x8__extadd_pairwise_i8x16_s:
922
577k
  case OpCode::I16x8__extadd_pairwise_i8x16_u:
923
924
578k
  case OpCode::I32x4__abs:
925
580k
  case OpCode::I32x4__neg:
926
583k
  case OpCode::I32x4__all_true:
927
587k
  case OpCode::I32x4__bitmask:
928
588k
  case OpCode::I32x4__extend_low_i16x8_s:
929
590k
  case OpCode::I32x4__extend_high_i16x8_s:
930
600k
  case OpCode::I32x4__extend_low_i16x8_u:
931
601k
  case OpCode::I32x4__extend_high_i16x8_u:
932
606k
  case OpCode::I32x4__shl:
933
607k
  case OpCode::I32x4__shr_s:
934
611k
  case OpCode::I32x4__shr_u:
935
613k
  case OpCode::I32x4__add:
936
614k
  case OpCode::I32x4__sub:
937
616k
  case OpCode::I32x4__mul:
938
618k
  case OpCode::I32x4__min_s:
939
619k
  case OpCode::I32x4__min_u:
940
620k
  case OpCode::I32x4__max_s:
941
622k
  case OpCode::I32x4__max_u:
942
623k
  case OpCode::I32x4__extmul_low_i16x8_s:
943
624k
  case OpCode::I32x4__extmul_high_i16x8_s:
944
625k
  case OpCode::I32x4__extmul_low_i16x8_u:
945
626k
  case OpCode::I32x4__extmul_high_i16x8_u:
946
632k
  case OpCode::I32x4__extadd_pairwise_i16x8_s:
947
653k
  case OpCode::I32x4__extadd_pairwise_i16x8_u:
948
949
655k
  case OpCode::I64x2__abs:
950
657k
  case OpCode::I64x2__neg:
951
658k
  case OpCode::I64x2__bitmask:
952
660k
  case OpCode::I64x2__extend_low_i32x4_s:
953
663k
  case OpCode::I64x2__extend_high_i32x4_s:
954
666k
  case OpCode::I64x2__extend_low_i32x4_u:
955
672k
  case OpCode::I64x2__extend_high_i32x4_u:
956
672k
  case OpCode::I64x2__shl:
957
675k
  case OpCode::I64x2__shr_s:
958
675k
  case OpCode::I64x2__shr_u:
959
677k
  case OpCode::I64x2__add:
960
679k
  case OpCode::I64x2__sub:
961
680k
  case OpCode::I64x2__mul:
962
683k
  case OpCode::I64x2__eq:
963
684k
  case OpCode::I64x2__ne:
964
687k
  case OpCode::I64x2__lt_s:
965
688k
  case OpCode::I64x2__gt_s:
966
688k
  case OpCode::I64x2__le_s:
967
691k
  case OpCode::I64x2__ge_s:
968
694k
  case OpCode::I64x2__all_true:
969
695k
  case OpCode::I64x2__extmul_low_i32x4_s:
970
697k
  case OpCode::I64x2__extmul_high_i32x4_s:
971
699k
  case OpCode::I64x2__extmul_low_i32x4_u:
972
703k
  case OpCode::I64x2__extmul_high_i32x4_u:
973
974
704k
  case OpCode::F32x4__abs:
975
706k
  case OpCode::F32x4__neg:
976
707k
  case OpCode::F32x4__sqrt:
977
712k
  case OpCode::F32x4__add:
978
713k
  case OpCode::F32x4__sub:
979
716k
  case OpCode::F32x4__mul:
980
717k
  case OpCode::F32x4__div:
981
719k
  case OpCode::F32x4__min:
982
720k
  case OpCode::F32x4__max:
983
729k
  case OpCode::F32x4__pmin:
984
730k
  case OpCode::F32x4__pmax:
985
986
733k
  case OpCode::F64x2__abs:
987
736k
  case OpCode::F64x2__neg:
988
738k
  case OpCode::F64x2__sqrt:
989
740k
  case OpCode::F64x2__add:
990
745k
  case OpCode::F64x2__sub:
991
745k
  case OpCode::F64x2__mul:
992
746k
  case OpCode::F64x2__div:
993
747k
  case OpCode::F64x2__min:
994
747k
  case OpCode::F64x2__max:
995
749k
  case OpCode::F64x2__pmin:
996
750k
  case OpCode::F64x2__pmax:
997
998
752k
  case OpCode::I32x4__trunc_sat_f32x4_s:
999
770k
  case OpCode::I32x4__trunc_sat_f32x4_u:
1000
771k
  case OpCode::F32x4__convert_i32x4_s:
1001
776k
  case OpCode::F32x4__convert_i32x4_u:
1002
780k
  case OpCode::I32x4__trunc_sat_f64x2_s_zero:
1003
790k
  case OpCode::I32x4__trunc_sat_f64x2_u_zero:
1004
794k
  case OpCode::F64x2__convert_low_i32x4_s:
1005
802k
  case OpCode::F64x2__convert_low_i32x4_u:
1006
807k
  case OpCode::F32x4__demote_f64x2_zero:
1007
812k
  case OpCode::F64x2__promote_low_f32x4:
1008
1009
814k
  case OpCode::I32x4__dot_i16x8_s:
1010
822k
  case OpCode::F32x4__ceil:
1011
832k
  case OpCode::F32x4__floor:
1012
837k
  case OpCode::F32x4__trunc:
1013
839k
  case OpCode::F32x4__nearest:
1014
841k
  case OpCode::F64x2__ceil:
1015
843k
  case OpCode::F64x2__floor:
1016
846k
  case OpCode::F64x2__trunc:
1017
848k
  case OpCode::F64x2__nearest:
1018
848k
    return {};
1019
1020
229
  case OpCode::I8x16__relaxed_swizzle:
1021
474
  case OpCode::I32x4__relaxed_trunc_f32x4_s:
1022
1.01k
  case OpCode::I32x4__relaxed_trunc_f32x4_u:
1023
1.69k
  case OpCode::I32x4__relaxed_trunc_f64x2_s_zero:
1024
1.99k
  case OpCode::I32x4__relaxed_trunc_f64x2_u_zero:
1025
2.54k
  case OpCode::F32x4__relaxed_madd:
1026
2.86k
  case OpCode::F32x4__relaxed_nmadd:
1027
3.29k
  case OpCode::F64x2__relaxed_madd:
1028
3.60k
  case OpCode::F64x2__relaxed_nmadd:
1029
4.00k
  case OpCode::I8x16__relaxed_laneselect:
1030
5.02k
  case OpCode::I16x8__relaxed_laneselect:
1031
5.44k
  case OpCode::I32x4__relaxed_laneselect:
1032
6.05k
  case OpCode::I64x2__relaxed_laneselect:
1033
6.66k
  case OpCode::F32x4__relaxed_min:
1034
6.90k
  case OpCode::F32x4__relaxed_max:
1035
7.47k
  case OpCode::F64x2__relaxed_min:
1036
8.07k
  case OpCode::F64x2__relaxed_max:
1037
8.47k
  case OpCode::I16x8__relaxed_q15mulr_s:
1038
9.43k
  case OpCode::I16x8__relaxed_dot_i8x16_i7x16_s:
1039
10.2k
  case OpCode::I32x4__relaxed_dot_i8x16_i7x16_add_s:
1040
10.2k
    return {};
1041
1042
  // Atomic Memory Instructions.
1043
1.04k
  case OpCode::Atomic__fence:
1044
1.04k
    return readCheckZero(Instr.getTargetIndex());
1045
1046
3.06k
  case OpCode::Memory__atomic__notify:
1047
7.84k
  case OpCode::Memory__atomic__wait32:
1048
8.13k
  case OpCode::Memory__atomic__wait64:
1049
1050
8.13k
  case OpCode::I32__atomic__load:
1051
8.13k
  case OpCode::I64__atomic__load:
1052
8.13k
  case OpCode::I32__atomic__load8_u:
1053
8.13k
  case OpCode::I32__atomic__load16_u:
1054
8.13k
  case OpCode::I64__atomic__load8_u:
1055
8.13k
  case OpCode::I64__atomic__load16_u:
1056
8.13k
  case OpCode::I64__atomic__load32_u:
1057
8.13k
  case OpCode::I32__atomic__store:
1058
8.13k
  case OpCode::I64__atomic__store:
1059
8.13k
  case OpCode::I32__atomic__store8:
1060
8.13k
  case OpCode::I32__atomic__store16:
1061
8.13k
  case OpCode::I64__atomic__store8:
1062
8.13k
  case OpCode::I64__atomic__store16:
1063
8.13k
  case OpCode::I64__atomic__store32:
1064
8.13k
  case OpCode::I32__atomic__rmw__add:
1065
8.13k
  case OpCode::I64__atomic__rmw__add:
1066
8.13k
  case OpCode::I32__atomic__rmw8__add_u:
1067
8.13k
  case OpCode::I32__atomic__rmw16__add_u:
1068
8.13k
  case OpCode::I64__atomic__rmw8__add_u:
1069
8.13k
  case OpCode::I64__atomic__rmw16__add_u:
1070
8.13k
  case OpCode::I64__atomic__rmw32__add_u:
1071
8.13k
  case OpCode::I32__atomic__rmw__sub:
1072
8.13k
  case OpCode::I64__atomic__rmw__sub:
1073
8.13k
  case OpCode::I32__atomic__rmw8__sub_u:
1074
8.13k
  case OpCode::I32__atomic__rmw16__sub_u:
1075
8.13k
  case OpCode::I64__atomic__rmw8__sub_u:
1076
8.13k
  case OpCode::I64__atomic__rmw16__sub_u:
1077
8.13k
  case OpCode::I64__atomic__rmw32__sub_u:
1078
8.13k
  case OpCode::I32__atomic__rmw__and:
1079
8.13k
  case OpCode::I64__atomic__rmw__and:
1080
8.13k
  case OpCode::I32__atomic__rmw8__and_u:
1081
8.13k
  case OpCode::I32__atomic__rmw16__and_u:
1082
8.13k
  case OpCode::I64__atomic__rmw8__and_u:
1083
8.13k
  case OpCode::I64__atomic__rmw16__and_u:
1084
8.13k
  case OpCode::I64__atomic__rmw32__and_u:
1085
8.13k
  case OpCode::I32__atomic__rmw__or:
1086
8.13k
  case OpCode::I64__atomic__rmw__or:
1087
8.13k
  case OpCode::I32__atomic__rmw8__or_u:
1088
8.13k
  case OpCode::I32__atomic__rmw16__or_u:
1089
8.13k
  case OpCode::I64__atomic__rmw8__or_u:
1090
8.13k
  case OpCode::I64__atomic__rmw16__or_u:
1091
8.13k
  case OpCode::I64__atomic__rmw32__or_u:
1092
8.13k
  case OpCode::I32__atomic__rmw__xor:
1093
8.13k
  case OpCode::I64__atomic__rmw__xor:
1094
8.13k
  case OpCode::I32__atomic__rmw8__xor_u:
1095
8.13k
  case OpCode::I32__atomic__rmw16__xor_u:
1096
8.13k
  case OpCode::I64__atomic__rmw8__xor_u:
1097
8.13k
  case OpCode::I64__atomic__rmw16__xor_u:
1098
8.13k
  case OpCode::I64__atomic__rmw32__xor_u:
1099
8.13k
  case OpCode::I32__atomic__rmw__xchg:
1100
8.13k
  case OpCode::I64__atomic__rmw__xchg:
1101
8.13k
  case OpCode::I32__atomic__rmw8__xchg_u:
1102
8.13k
  case OpCode::I32__atomic__rmw16__xchg_u:
1103
8.13k
  case OpCode::I64__atomic__rmw8__xchg_u:
1104
8.13k
  case OpCode::I64__atomic__rmw16__xchg_u:
1105
8.13k
  case OpCode::I64__atomic__rmw32__xchg_u:
1106
8.13k
  case OpCode::I32__atomic__rmw__cmpxchg:
1107
8.13k
  case OpCode::I64__atomic__rmw__cmpxchg:
1108
8.13k
  case OpCode::I32__atomic__rmw8__cmpxchg_u:
1109
8.13k
  case OpCode::I32__atomic__rmw16__cmpxchg_u:
1110
8.13k
  case OpCode::I64__atomic__rmw8__cmpxchg_u:
1111
8.13k
  case OpCode::I64__atomic__rmw16__cmpxchg_u:
1112
8.13k
  case OpCode::I64__atomic__rmw32__cmpxchg_u:
1113
8.13k
    return readMemImmediate();
1114
1115
0
  default:
1116
0
    assumingUnreachable();
1117
11.0M
  }
1118
11.0M
}
1119
1120
} // namespace Loader
1121
} // namespace WasmEdge