Verified Commit a4fb66aa authored by nagayama15's avatar nagayama15

chore(ordering): rename embedding function

parent 10ca4db0
...@@ -108,6 +108,8 @@ namespace kyut { ...@@ -108,6 +108,8 @@ namespace kyut {
} }
const auto bit_width = factorial_bit_width_table[count]; const auto bit_width = factorial_bit_width_table[count];
assert(watermark < (std::uint64_t{1} << bit_width));
w.write(watermark, bit_width); w.write(watermark, bit_width);
return bit_width; return bit_width;
......
...@@ -9,8 +9,8 @@ namespace kyut { ...@@ -9,8 +9,8 @@ namespace kyut {
class BitStreamWriter; class BitStreamWriter;
} // namespace kyut } // namespace kyut
namespace kyut::methods { namespace kyut::methods::function_ordering {
std::size_t embed_by_function_ordering(CircularBitStreamReader& r, wasm::Module& module, std::size_t chunk_size) { std::size_t embed(CircularBitStreamReader& r, wasm::Module& module, std::size_t chunk_size) {
const auto begin = std::begin(module.functions); const auto begin = std::begin(module.functions);
const auto end = std::end(module.functions); const auto end = std::end(module.functions);
...@@ -18,7 +18,7 @@ namespace kyut::methods { ...@@ -18,7 +18,7 @@ namespace kyut::methods {
return f->body == nullptr; return f->body == nullptr;
}); });
return embed_by_ordering( const auto size_bits = embed_by_ordering(
r, r,
chunk_size, chunk_size,
start, start,
...@@ -26,7 +26,9 @@ namespace kyut::methods { ...@@ -26,7 +26,9 @@ namespace kyut::methods {
[](const auto& a, const auto& b) { [](const auto& a, const auto& b) {
return a->name < b->name; return a->name < b->name;
}); });
return size_bits;
} }
} // namespace kyut::methods } // namespace kyut::methods::function_ordering
#endif // INCLUDE_kyut_methods_FunctionOrdering_hpp #endif // INCLUDE_kyut_methods_FunctionOrdering_hpp
...@@ -57,17 +57,17 @@ int main(int argc, char* argv[]) { ...@@ -57,17 +57,17 @@ int main(int argc, char* argv[]) {
const auto output = options.get<std::string>("output"); const auto output = options.get<std::string>("output");
const auto method = options.get<std::string>("method"); const auto method = options.get<std::string>("method");
const auto watermark = options.get<std::string>("watermark"); 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 { try {
kyut::CircularBitStreamReader r{watermark};
wasm::Module module{}; wasm::Module module{};
wasm::ModuleReader{}.read(input, module); wasm::ModuleReader{}.read(input, module);
kyut::CircularBitStreamReader r{watermark};
std::size_t size_bits; std::size_t size_bits;
if (method == "function-ordering") { 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 { } else {
WASM_UNREACHABLE(("unknown method: " + method).c_str()); 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