Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: wasmx/fizzy
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: f3655865b18a6941b613d196a18416bf4c7b48d4
Choose a base ref
..
head repository: wasmx/fizzy
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: d3f0e65fd45c865514a61189eab3341d4e93982f
Choose a head ref
Showing with 7 additions and 6 deletions.
  1. +4 −3 lib/fizzy/parser_expr.cpp
  2. +1 −1 lib/fizzy/types.hpp
  3. +2 −2 test/unittests/execute_death_test.cpp
7 changes: 4 additions & 3 deletions lib/fizzy/parser_expr.cpp
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@ inline void store(uint8_t* dst, T value) noexcept
}

template <typename T>
inline void push(bytes& b, T value)
inline void push(std::vector<uint8_t>& b, T value)
{
uint8_t storage[sizeof(T)];
store(storage, value);
@@ -198,7 +198,8 @@ inline void update_branch_stack(const ControlFrame& current_frame, const Control
drop_operand(current_frame, operand_stack, from_valtype(*branch_frame_type));
}

void push_branch_immediates(const ControlFrame& branch_frame, int stack_height, bytes& instructions)
void push_branch_immediates(
const ControlFrame& branch_frame, int stack_height, std::vector<uint8_t>& instructions)
{
// How many stack items to drop when taking the branch.
const auto stack_drop = stack_height - branch_frame.parent_stack_height;
@@ -871,7 +872,7 @@ parser_result<Code> parse_expr(const uint8_t* pos, const uint8_t* end, FuncIdx f
break;
}
}
code.instructions.push_back(opcode);
code.instructions.emplace_back(opcode);
}
assert(control_stack.empty());
return {code, pos};
2 changes: 1 addition & 1 deletion lib/fizzy/types.hpp
Original file line number Diff line number Diff line change
@@ -362,7 +362,7 @@ struct Code

// The instructions bytecode without immediate values.
// https://webassembly.github.io/spec/core/binary/instructions.html
bytes instructions;
std::vector<uint8_t> instructions;
};

/// The reference to the `code` in the wasm binary.
4 changes: 2 additions & 2 deletions test/unittests/execute_death_test.cpp
Original file line number Diff line number Diff line change
@@ -14,8 +14,8 @@ TEST(execute_death, malformed_instruction_opcode)
constexpr uint8_t malformed_opcode = 6;

Code code;
code.instructions.push_back(malformed_opcode);
code.instructions.push_back(static_cast<uint8_t>(Instr::end));
code.instructions.emplace_back(malformed_opcode);
code.instructions.emplace_back(static_cast<uint8_t>(Instr::end));

auto module = std::make_unique<Module>();
module->typesec.emplace_back(FuncType{});