@@ -334,11 +334,12 @@ TEST(parser_expr, instr_br_table)
334334
335335 EXPECT_THAT (code.instructions ,
336336 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));
342343
343344 // br_imm_size = 12
344345 // return_imm_size = br_imm_size + arity_size = 16
@@ -348,27 +349,24 @@ TEST(parser_expr, instr_br_table)
348349 // br_3_offset = br_2_offset + 4 + return_imm_size = 0x98
349350 // br_4_offset = br_3_offset + 4 + return_imm_size = 0xac
350351 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
356354 " 00000000" // stack_drop
357355
358- " 20000000 " // code_offset
359- " 74000000 " // imm_offset
356+ " 28000000 " // code_offset
357+ " 6c000000 " // imm_offset
360358 " 00000000" // stack_drop
361359
362- " 19000000 " // code_offset
363- " 64000000 " // imm_offset
360+ " 21000000 " // code_offset
361+ " 5c000000 " // imm_offset
364362 " 00000000" // stack_drop
365363
366- " 12000000 " // code_offset
367- " 54000000 " // imm_offset
364+ " 1a000000 " // code_offset
365+ " 4c000000 " // imm_offset
368366 " 00000000" // stack_drop
369367
370- " 2e000000 " // code_offset
371- " 94000000 " // imm_offset
368+ " 36000000 " // code_offset
369+ " 8c000000 " // imm_offset
372370 " 00000000" _bytes; // stack_drop
373371
374372 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)
393391 ASSERT_EQ (module ->codesec .size (), 1 );
394392 const auto & code = module ->codesec [0 ];
395393
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));
400398
401399 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
406402 " 00000000" _bytes; // stack_drop
407403 EXPECT_EQ (code.immediates .substr (0 , expected_br_imm.size ()), expected_br_imm);
408404 EXPECT_EQ (code.max_stack_height , 1 );
@@ -417,8 +413,9 @@ TEST(parser_expr, instr_br_table_as_return)
417413
418414 const auto code_bin = i32_const (0 ) + " 0e00000b" _bytes;
419415 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));
422419 EXPECT_EQ (code.max_stack_height , 1 );
423420}
424421
0 commit comments