Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,8 @@ jobs:
- benchmark:
min_time: "0.01"
- spectest:
expected_passed: 5358
expected_failed: 74
expected_passed: 5364
expected_failed: 68
expected_skipped: 6381

sanitizers-macos:
Expand All @@ -288,8 +288,8 @@ jobs:
- benchmark:
min_time: "0.01"
- spectest:
expected_passed: 5358
expected_failed: 74
expected_passed: 5364
expected_failed: 68
expected_skipped: 6381

benchmark:
Expand Down Expand Up @@ -400,8 +400,8 @@ jobs:
expected_failed: 9
expected_skipped: 7323
- spectest:
expected_passed: 5358
expected_failed: 74
expected_passed: 5364
expected_failed: 68
expected_skipped: 6381
- collect_coverage_data

Expand Down
15 changes: 4 additions & 11 deletions lib/fizzy/parser_expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,17 +272,6 @@ parser_result<Code> parse_expr(const uint8_t* pos, const uint8_t* end, FuncIdx f
throw parser_error{"invalid instruction " + std::to_string(*(pos - 1))};

// Floating point instructions are unsupported
case Instr::f32_load:
case Instr::f64_load:
case Instr::f32_store:
case Instr::f64_store:
if (!module.has_memory())
throw validation_error{"memory instructions require imported or defined memory"};
// alignment
std::tie(std::ignore, pos) = leb128u_decode<uint32_t>(pos, end);
// offset
std::tie(std::ignore, pos) = leb128u_decode<uint32_t>(pos, end);
break;
case Instr::f32_const:
pos = skip(4, pos, end);
break;
Expand Down Expand Up @@ -772,6 +761,10 @@ parser_result<Code> parse_expr(const uint8_t* pos, const uint8_t* end, FuncIdx f
case Instr::i64_store8:
case Instr::i64_store16:
case Instr::i64_store32:
case Instr::f32_load:
case Instr::f64_load:
case Instr::f32_store:
case Instr::f64_store:
{
uint32_t align;
std::tie(align, pos) = leb128u_decode<uint32_t>(pos, end);
Expand Down
43 changes: 28 additions & 15 deletions test/unittests/validation_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,13 +338,11 @@ TEST(validation, memory_size_no_memory)
TEST(validation, store_alignment)
{
// NOTE: could use instruction_metrics here, but better to have two sources of truth for testing
const std::tuple<Instr, int, Instr> test_cases[] = {
{Instr::i32_store8, 0, Instr::i32_const}, {Instr::i32_store16, 1, Instr::i32_const},
{Instr::i32_store, 2, Instr::i32_const}, {Instr::i64_store8, 0, Instr::i64_const},
{Instr::i64_store16, 1, Instr::i64_const}, {Instr::i64_store32, 2, Instr::i64_const},
{Instr::i64_store, 3, Instr::i64_const},
// TODO: include floating point
};
const std::tuple<Instr, int, Instr> test_cases[] = {{Instr::i32_store8, 0, Instr::i32_const},
{Instr::i32_store16, 1, Instr::i32_const}, {Instr::i32_store, 2, Instr::i32_const},
{Instr::i64_store8, 0, Instr::i64_const}, {Instr::i64_store16, 1, Instr::i64_const},
{Instr::i64_store32, 2, Instr::i64_const}, {Instr::i64_store, 3, Instr::i64_const},
{Instr::f32_store, 2, Instr::f32_const}, {Instr::f64_store, 3, Instr::f64_const}};

for (const auto& test_case : test_cases)
{
Expand All @@ -361,9 +359,15 @@ TEST(validation, store_alignment)
const auto type_section = make_vec({"60017f00"_bytes});
const auto function_section = make_vec({"00"_bytes});
// NOTE: this depends on align < 0x80
const auto code_bin = bytes{0, // vec(locals)
uint8_t(Instr::local_get), 0, uint8_t(push_address_instr), 0, uint8_t(instr),
uint8_t(align), 0, uint8_t(Instr::end)};
auto code_bin = bytes{0, // vec(locals)
uint8_t(Instr::local_get), 0, uint8_t(push_address_instr)};
if (push_address_instr == Instr::f32_const)
code_bin += "00000000"_bytes;
else if (push_address_instr == Instr::f64_const)
code_bin += "0000000000000000"_bytes;
else
code_bin += "00"_bytes;
code_bin += bytes{uint8_t(instr), uint8_t(align), 0, uint8_t(Instr::end)};
const auto code_section = make_vec({add_size_prefix(code_bin)});
const auto memory_section = "01007f"_bytes;
const auto bin = bytes{wasm_prefix} + make_section(1, type_section) +
Expand All @@ -386,11 +390,20 @@ TEST(validation, load_alignment)
{
// NOTE: could use instruction_metrics here, but better to have two sources of truth for testing
const std::map<Instr, int> test_cases{
{Instr::i32_load8_s, 0}, {Instr::i32_load8_u, 0}, {Instr::i32_load16_s, 1},
{Instr::i32_load16_u, 1}, {Instr::i32_load, 2}, {Instr::i64_load8_s, 0},
{Instr::i64_load8_u, 0}, {Instr::i64_load16_s, 1}, {Instr::i64_load16_u, 1},
{Instr::i64_load32_s, 2}, {Instr::i64_load32_u, 2}, {Instr::i64_load, 3},
// TODO: include floating point
{Instr::i32_load8_s, 0},
{Instr::i32_load8_u, 0},
{Instr::i32_load16_s, 1},
{Instr::i32_load16_u, 1},
{Instr::i32_load, 2},
{Instr::i64_load8_s, 0},
{Instr::i64_load8_u, 0},
{Instr::i64_load16_s, 1},
{Instr::i64_load16_u, 1},
{Instr::i64_load32_s, 2},
{Instr::i64_load32_u, 2},
{Instr::i64_load, 3},
{Instr::f32_load, 2},
{Instr::f64_load, 3},
};

for (const auto test_case : test_cases)
Expand Down