@@ -334,11 +334,12 @@ TEST(parser_expr, instr_br_table)
334
334
335
335
EXPECT_THAT (code.instructions ,
336
336
ElementsAre (Instr::block, Instr::block, Instr::block, Instr::block, Instr::block,
337
- Instr::local_get, 0 , 0 , 0 , 0 , Instr::br_table, Instr::i32_const, 0x41 , 0 , 0 , 0 ,
338
- Instr::return_, Instr::end, Instr::i32_const, 0x42 , 0 , 0 , 0 , Instr::return_, Instr::end,
339
- Instr::i32_const, 0x43 , 0 , 0 , 0 , Instr::return_, Instr::end, Instr::i32_const, 0x44 , 0 ,
340
- 0 , 0 , Instr::return_, Instr::end, Instr::i32_const, 0x45 , 0 , 0 , 0 , Instr::return_,
341
- Instr::end, Instr::i32_const, 0x46 , 0 , 0 , 0 , Instr::end));
337
+ Instr::local_get, 0 , 0 , 0 , 0 , Instr::br_table, /* label_count:*/ 4 , 0 , 0 , 0 ,
338
+ /* arity:*/ 0 , 0 , 0 , 0 , Instr::i32_const, 0x41 , 0 , 0 , 0 , Instr::return_, Instr::end,
339
+ Instr::i32_const, 0x42 , 0 , 0 , 0 , Instr::return_, Instr::end, Instr::i32_const, 0x43 , 0 ,
340
+ 0 , 0 , Instr::return_, Instr::end, Instr::i32_const, 0x44 , 0 , 0 , 0 , Instr::return_,
341
+ Instr::end, Instr::i32_const, 0x45 , 0 , 0 , 0 , Instr::return_, Instr::end,
342
+ Instr::i32_const, 0x46 , 0 , 0 , 0 , Instr::end));
342
343
343
344
// br_imm_size = 12
344
345
// return_imm_size = br_imm_size + arity_size = 16
@@ -348,27 +349,24 @@ TEST(parser_expr, instr_br_table)
348
349
// br_3_offset = br_2_offset + 4 + return_imm_size = 0x98
349
350
// br_4_offset = br_3_offset + 4 + return_imm_size = 0xac
350
351
const auto expected_br_imm =
351
- " 04000000" // label_count
352
- " 00000000" // arity
353
-
354
- " 27000000" // code_offset
355
- " 84000000" // imm_offset
352
+ " 2f000000" // code_offset
353
+ " 7c000000" // imm_offset
356
354
" 00000000" // stack_drop
357
355
358
- " 20000000 " // code_offset
359
- " 74000000 " // imm_offset
356
+ " 28000000 " // code_offset
357
+ " 6c000000 " // imm_offset
360
358
" 00000000" // stack_drop
361
359
362
- " 19000000 " // code_offset
363
- " 64000000 " // imm_offset
360
+ " 21000000 " // code_offset
361
+ " 5c000000 " // imm_offset
364
362
" 00000000" // stack_drop
365
363
366
- " 12000000 " // code_offset
367
- " 54000000 " // imm_offset
364
+ " 1a000000 " // code_offset
365
+ " 4c000000 " // imm_offset
368
366
" 00000000" // stack_drop
369
367
370
- " 2e000000 " // code_offset
371
- " 94000000 " // imm_offset
368
+ " 36000000 " // code_offset
369
+ " 8c000000 " // imm_offset
372
370
" 00000000" _bytes; // stack_drop
373
371
374
372
EXPECT_EQ (code.immediates .substr (0 , expected_br_imm.size ()), expected_br_imm);
@@ -393,16 +391,14 @@ TEST(parser_expr, instr_br_table_empty_vector)
393
391
ASSERT_EQ (module->codesec .size (), 1 );
394
392
const auto & code = module->codesec [0 ];
395
393
396
- EXPECT_THAT (
397
- code. instructions , ElementsAre (Instr::block, Instr::local_get, 0 , 0 , 0 , 0 , Instr::br_table,
398
- Instr::i32_const, 0x63 , 0 , 0 , 0 , Instr::return_, Instr::end ,
399
- Instr::i32_const, 0x64 , 0 , 0 , 0 , Instr::end));
394
+ EXPECT_THAT (code. instructions ,
395
+ ElementsAre (Instr::block, Instr::local_get, 0 , 0 , 0 , 0 , Instr::br_table,
396
+ /* label_count: */ 0 , 0 , 0 , 0 , /* arity: */ 0 , 0 , 0 , 0 , Instr::i32_const, 0x63 , 0 , 0 , 0 ,
397
+ Instr::return_, Instr::end, Instr::i32_const, 0x64 , 0 , 0 , 0 , Instr::end));
400
398
401
399
const auto expected_br_imm =
402
- " 00000000" // label_count
403
- " 00000000" // arity
404
- " 0e000000" // code_offset
405
- " 24000000" // imm_offset
400
+ " 16000000" // code_offset
401
+ " 1c000000" // imm_offset
406
402
" 00000000" _bytes; // stack_drop
407
403
EXPECT_EQ (code.immediates .substr (0 , expected_br_imm.size ()), expected_br_imm);
408
404
EXPECT_EQ (code.max_stack_height , 1 );
@@ -417,8 +413,9 @@ TEST(parser_expr, instr_br_table_as_return)
417
413
418
414
const auto code_bin = i32_const (0 ) + " 0e00000b" _bytes;
419
415
const auto [code, _] = parse_expr (code_bin);
420
- EXPECT_THAT (
421
- code.instructions , ElementsAre (Instr::i32_const, 0 , 0 , 0 , 0 , Instr::br_table, Instr::end));
416
+ EXPECT_THAT (code.instructions ,
417
+ ElementsAre (Instr::i32_const, 0 , 0 , 0 , 0 , Instr::br_table, /* label_count:*/ 0 , 0 , 0 , 0 ,
418
+ /* arity:*/ 0 , 0 , 0 , 0 , Instr::end));
422
419
EXPECT_EQ (code.max_stack_height , 1 );
423
420
}
424
421
0 commit comments