Verified Commit a4fb66aa authored by nagayama15's avatar nagayama15

chore(ordering): rename embedding function

parent 10ca4db0
......@@ -108,6 +108,8 @@ namespace kyut {
}
const auto bit_width = factorial_bit_width_table[count];
assert(watermark < (std::uint64_t{1} << bit_width));
w.write(watermark, bit_width);
return bit_width;
......
......@@ -9,8 +9,8 @@ namespace kyut {
class BitStreamWriter;
} // namespace kyut
namespace kyut::methods {
std::size_t embed_by_function_ordering(CircularBitStreamReader& r, wasm::Module& module, std::size_t chunk_size) {
namespace kyut::methods::function_ordering {
std::size_t embed(CircularBitStreamReader& r, wasm::Module& module, std::size_t chunk_size) {
const auto begin = std::begin(module.functions);
const auto end = std::end(module.functions);
......@@ -18,7 +18,7 @@ namespace kyut::methods {
return f->body == nullptr;
});
return embed_by_ordering(
const auto size_bits = embed_by_ordering(
r,
chunk_size,
start,
......@@ -26,7 +26,9 @@ namespace kyut::methods {
[](const auto& a, const auto& b) {
return a->name < b->name;
});
return size_bits;
}
} // namespace kyut::methods
} // namespace kyut::methods::function_ordering
#endif // INCLUDE_kyut_methods_FunctionOrdering_hpp
......@@ -57,17 +57,17 @@ int main(int argc, char* argv[]) {
const auto output = options.get<std::string>("output");
const auto method = options.get<std::string>("method");
const auto watermark = options.get<std::string>("watermark");
[[maybe_unused]] const auto chunk_size = options.get<std::size_t>("chunk-size");
const auto chunk_size = options.get<std::size_t>("chunk-size");
try {
kyut::CircularBitStreamReader r{watermark};
wasm::Module module{};
wasm::ModuleReader{}.read(input, module);
kyut::CircularBitStreamReader r{watermark};
std::size_t size_bits;
if (method == "function-ordering") {
size_bits = kyut::methods::embed_by_function_ordering(r, module, chunk_size);
size_bits = kyut::methods::function_ordering::embed(r, module, chunk_size);
} else {
WASM_UNREACHABLE(("unknown method: " + method).c_str());
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment