AbstractMachine.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683
  1. /*
  2. * Copyright (c) 2021, Ali Mohammad Pur <mpfard@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/Function.h>
  8. #include <AK/HashMap.h>
  9. #include <AK/HashTable.h>
  10. #include <AK/OwnPtr.h>
  11. #include <AK/Result.h>
  12. #include <AK/StackInfo.h>
  13. #include <AK/UFixedBigInt.h>
  14. #include <LibWasm/Types.h>
  15. // NOTE: Special case for Wasm::Result.
  16. #include <LibJS/Runtime/Completion.h>
  17. namespace Wasm {
  18. class Configuration;
  19. struct Interpreter;
  20. struct InstantiationError {
  21. ByteString error { "Unknown error" };
  22. };
  23. struct LinkError {
  24. enum OtherErrors {
  25. InvalidImportedModule,
  26. };
  27. Vector<ByteString> missing_imports;
  28. Vector<OtherErrors> other_errors;
  29. };
  30. AK_TYPEDEF_DISTINCT_NUMERIC_GENERAL(u64, FunctionAddress, Arithmetic, Comparison, Increment);
  31. AK_TYPEDEF_DISTINCT_NUMERIC_GENERAL(u64, ExternAddress, Arithmetic, Comparison, Increment);
  32. AK_TYPEDEF_DISTINCT_NUMERIC_GENERAL(u64, TableAddress, Arithmetic, Comparison, Increment);
  33. AK_TYPEDEF_DISTINCT_NUMERIC_GENERAL(u64, GlobalAddress, Arithmetic, Comparison, Increment);
  34. AK_TYPEDEF_DISTINCT_NUMERIC_GENERAL(u64, ElementAddress, Arithmetic, Comparison, Increment);
  35. AK_TYPEDEF_DISTINCT_NUMERIC_GENERAL(u64, DataAddress, Arithmetic, Comparison, Increment);
  36. AK_TYPEDEF_DISTINCT_NUMERIC_GENERAL(u64, MemoryAddress, Arithmetic, Comparison, Increment);
  37. // FIXME: These should probably be made generic/virtual if/when we decide to do something more
  38. // fancy than just a dumb interpreter.
  39. class Reference {
  40. public:
  41. struct Null {
  42. ValueType type;
  43. };
  44. struct Func {
  45. FunctionAddress address;
  46. };
  47. struct Extern {
  48. ExternAddress address;
  49. };
  50. using RefType = Variant<Null, Func, Extern>;
  51. explicit Reference(RefType ref)
  52. : m_ref(move(ref))
  53. {
  54. }
  55. explicit Reference()
  56. : m_ref(Reference::Null { ValueType(ValueType::Kind::FunctionReference) })
  57. {
  58. }
  59. auto& ref() const { return m_ref; }
  60. private:
  61. RefType m_ref;
  62. };
  63. class Value {
  64. public:
  65. Value()
  66. : m_value(u128())
  67. {
  68. }
  69. template<typename T>
  70. requires(sizeof(T) == sizeof(u64)) explicit Value(T raw_value)
  71. : m_value(u128(bit_cast<i64>(raw_value), 0))
  72. {
  73. }
  74. template<typename T>
  75. requires(sizeof(T) == sizeof(u32)) explicit Value(T raw_value)
  76. : m_value(u128(static_cast<i64>(bit_cast<i32>(raw_value)), 0))
  77. {
  78. }
  79. template<typename T>
  80. requires(sizeof(T) == sizeof(u8) && Signed<T>) explicit Value(T raw_value)
  81. : m_value(u128(static_cast<i64>(bit_cast<i8>(raw_value)), 0))
  82. {
  83. }
  84. template<typename T>
  85. requires(sizeof(T) == sizeof(u8) && Unsigned<T>) explicit Value(T raw_value)
  86. : m_value(u128(static_cast<u64>(bit_cast<u8>(raw_value)), 0))
  87. {
  88. }
  89. template<typename T>
  90. requires(sizeof(T) == sizeof(u16) && Signed<T>) explicit Value(T raw_value)
  91. : m_value(u128(static_cast<i64>(bit_cast<i16>(raw_value)), 0))
  92. {
  93. }
  94. template<typename T>
  95. requires(sizeof(T) == sizeof(u16) && Unsigned<T>) explicit Value(T raw_value)
  96. : m_value(u128(static_cast<u64>(bit_cast<u16>(raw_value)), 0))
  97. {
  98. }
  99. explicit Value(Reference ref)
  100. {
  101. // Reference variant is encoded in the high storage of the u128:
  102. // 0: funcref
  103. // 1: externref
  104. // 2: null funcref
  105. // 3: null externref
  106. ref.ref().visit(
  107. [&](Reference::Func const& func) { m_value = u128(bit_cast<u64>(func.address), 0); },
  108. [&](Reference::Extern const& func) { m_value = u128(bit_cast<u64>(func.address), 1); },
  109. [&](Reference::Null const& null) { m_value = u128(0, null.type.kind() == ValueType::Kind::FunctionReference ? 2 : 3); });
  110. }
  111. template<SameAs<u128> T>
  112. explicit Value(T raw_value)
  113. : m_value(raw_value)
  114. {
  115. }
  116. ALWAYS_INLINE Value(Value const& value) = default;
  117. ALWAYS_INLINE Value(Value&& value) = default;
  118. ALWAYS_INLINE Value& operator=(Value&& value) = default;
  119. ALWAYS_INLINE Value& operator=(Value const& value) = default;
  120. template<typename T>
  121. ALWAYS_INLINE T to() const
  122. {
  123. if constexpr (IsSame<T, u128>) {
  124. return m_value;
  125. }
  126. if constexpr (IsSame<T, u32>) {
  127. u32 low = m_value.low() & 0xFFFFFFFF;
  128. return low;
  129. }
  130. if constexpr (IsSame<T, i32>) {
  131. u32 low = m_value.low() & 0xFFFFFFFF;
  132. return bit_cast<i32>(low);
  133. }
  134. if constexpr (IsSame<T, u64>) {
  135. return bit_cast<u64>(m_value.low());
  136. }
  137. if constexpr (IsSame<T, i64>) {
  138. return bit_cast<i64>(m_value.low());
  139. }
  140. if constexpr (IsSame<T, f32>) {
  141. u32 low = m_value.low() & 0xFFFFFFFF;
  142. return bit_cast<f32>(low);
  143. }
  144. if constexpr (IsSame<T, f64>) {
  145. return bit_cast<f64>(m_value.low());
  146. }
  147. if constexpr (IsSame<T, Reference>) {
  148. switch (m_value.high()) {
  149. case 0:
  150. return Reference { Reference::Func(bit_cast<FunctionAddress>(m_value.low())) };
  151. case 1:
  152. return Reference { Reference::Extern(bit_cast<ExternAddress>(m_value.low())) };
  153. case 2:
  154. return Reference { Reference::Null(ValueType(ValueType::Kind::FunctionReference)) };
  155. case 3:
  156. return Reference { Reference::Null(ValueType(ValueType::Kind::ExternReference)) };
  157. default:
  158. VERIFY_NOT_REACHED();
  159. }
  160. }
  161. VERIFY_NOT_REACHED();
  162. }
  163. auto& value() const { return m_value; }
  164. private:
  165. u128 m_value;
  166. };
  167. struct Trap {
  168. ByteString reason;
  169. };
  170. // A variant of Result that does not include external reasons for error (JS::Completion, for now).
  171. class PureResult {
  172. public:
  173. explicit PureResult(Vector<Value> values)
  174. : m_result(move(values))
  175. {
  176. }
  177. PureResult(Trap trap)
  178. : m_result(move(trap))
  179. {
  180. }
  181. auto is_trap() const { return m_result.has<Trap>(); }
  182. auto& values() const { return m_result.get<Vector<Value>>(); }
  183. auto& values() { return m_result.get<Vector<Value>>(); }
  184. auto& trap() const { return m_result.get<Trap>(); }
  185. auto& trap() { return m_result.get<Trap>(); }
  186. private:
  187. friend class Result;
  188. explicit PureResult(Variant<Vector<Value>, Trap>&& result)
  189. : m_result(move(result))
  190. {
  191. }
  192. Variant<Vector<Value>, Trap> m_result;
  193. };
  194. class Result {
  195. public:
  196. explicit Result(Vector<Value> values)
  197. : m_result(move(values))
  198. {
  199. }
  200. Result(Trap trap)
  201. : m_result(move(trap))
  202. {
  203. }
  204. Result(JS::Completion completion)
  205. : m_result(move(completion))
  206. {
  207. VERIFY(m_result.get<JS::Completion>().is_abrupt());
  208. }
  209. Result(PureResult&& result)
  210. : m_result(result.m_result.downcast<decltype(m_result)>())
  211. {
  212. }
  213. auto is_trap() const { return m_result.has<Trap>(); }
  214. auto is_completion() const { return m_result.has<JS::Completion>(); }
  215. auto& values() const { return m_result.get<Vector<Value>>(); }
  216. auto& values() { return m_result.get<Vector<Value>>(); }
  217. auto& trap() const { return m_result.get<Trap>(); }
  218. auto& trap() { return m_result.get<Trap>(); }
  219. auto& completion() { return m_result.get<JS::Completion>(); }
  220. auto& completion() const { return m_result.get<JS::Completion>(); }
  221. PureResult assert_wasm_result() &&
  222. {
  223. VERIFY(!is_completion());
  224. return PureResult(move(m_result).downcast<Vector<Value>, Trap>());
  225. }
  226. private:
  227. Variant<Vector<Value>, Trap, JS::Completion> m_result;
  228. };
  229. using ExternValue = Variant<FunctionAddress, TableAddress, MemoryAddress, GlobalAddress>;
  230. class ExportInstance {
  231. public:
  232. explicit ExportInstance(ByteString name, ExternValue value)
  233. : m_name(move(name))
  234. , m_value(move(value))
  235. {
  236. }
  237. auto& name() const { return m_name; }
  238. auto& value() const { return m_value; }
  239. private:
  240. ByteString m_name;
  241. ExternValue m_value;
  242. };
  243. class ModuleInstance {
  244. public:
  245. explicit ModuleInstance(
  246. Vector<FunctionType> types, Vector<FunctionAddress> function_addresses, Vector<TableAddress> table_addresses,
  247. Vector<MemoryAddress> memory_addresses, Vector<GlobalAddress> global_addresses, Vector<DataAddress> data_addresses,
  248. Vector<ExportInstance> exports)
  249. : m_types(move(types))
  250. , m_functions(move(function_addresses))
  251. , m_tables(move(table_addresses))
  252. , m_memories(move(memory_addresses))
  253. , m_globals(move(global_addresses))
  254. , m_datas(move(data_addresses))
  255. , m_exports(move(exports))
  256. {
  257. }
  258. ModuleInstance() = default;
  259. auto& types() const { return m_types; }
  260. auto& functions() const { return m_functions; }
  261. auto& tables() const { return m_tables; }
  262. auto& memories() const { return m_memories; }
  263. auto& globals() const { return m_globals; }
  264. auto& elements() const { return m_elements; }
  265. auto& datas() const { return m_datas; }
  266. auto& exports() const { return m_exports; }
  267. auto& types() { return m_types; }
  268. auto& functions() { return m_functions; }
  269. auto& tables() { return m_tables; }
  270. auto& memories() { return m_memories; }
  271. auto& globals() { return m_globals; }
  272. auto& elements() { return m_elements; }
  273. auto& datas() { return m_datas; }
  274. auto& exports() { return m_exports; }
  275. private:
  276. Vector<FunctionType> m_types;
  277. Vector<FunctionAddress> m_functions;
  278. Vector<TableAddress> m_tables;
  279. Vector<MemoryAddress> m_memories;
  280. Vector<GlobalAddress> m_globals;
  281. Vector<ElementAddress> m_elements;
  282. Vector<DataAddress> m_datas;
  283. Vector<ExportInstance> m_exports;
  284. };
  285. class WasmFunction {
  286. public:
  287. explicit WasmFunction(FunctionType const& type, ModuleInstance const& module, CodeSection::Code const& code)
  288. : m_type(type)
  289. , m_module(module)
  290. , m_code(code)
  291. {
  292. }
  293. auto& type() const { return m_type; }
  294. auto& module() const { return m_module; }
  295. auto& code() const { return m_code; }
  296. private:
  297. FunctionType m_type;
  298. ModuleInstance const& m_module;
  299. CodeSection::Code const& m_code;
  300. };
  301. class HostFunction {
  302. public:
  303. explicit HostFunction(AK::Function<Result(Configuration&, Vector<Value>&)> function, FunctionType const& type, ByteString name)
  304. : m_function(move(function))
  305. , m_type(type)
  306. , m_name(move(name))
  307. {
  308. }
  309. auto& function() { return m_function; }
  310. auto& type() const { return m_type; }
  311. auto& name() const { return m_name; }
  312. private:
  313. AK::Function<Result(Configuration&, Vector<Value>&)> m_function;
  314. FunctionType m_type;
  315. ByteString m_name;
  316. };
  317. using FunctionInstance = Variant<WasmFunction, HostFunction>;
  318. class TableInstance {
  319. public:
  320. explicit TableInstance(TableType const& type, Vector<Reference> elements)
  321. : m_elements(move(elements))
  322. , m_type(type)
  323. {
  324. }
  325. auto& elements() const { return m_elements; }
  326. auto& elements() { return m_elements; }
  327. auto& type() const { return m_type; }
  328. bool grow(u32 size_to_grow, Reference const& fill_value)
  329. {
  330. if (size_to_grow == 0)
  331. return true;
  332. size_t new_size = m_elements.size() + size_to_grow;
  333. if (auto max = m_type.limits().max(); max.has_value()) {
  334. if (max.value() < new_size)
  335. return false;
  336. }
  337. if (new_size >= NumericLimits<u32>::max()) {
  338. return false;
  339. }
  340. auto previous_size = m_elements.size();
  341. if (m_elements.try_resize(new_size).is_error())
  342. return false;
  343. for (size_t i = previous_size; i < m_elements.size(); ++i)
  344. m_elements[i] = fill_value;
  345. return true;
  346. }
  347. private:
  348. Vector<Reference> m_elements;
  349. TableType m_type;
  350. };
  351. class MemoryInstance {
  352. public:
  353. static ErrorOr<MemoryInstance> create(MemoryType const& type)
  354. {
  355. MemoryInstance instance { type };
  356. if (!instance.grow(type.limits().min() * Constants::page_size, GrowType::No))
  357. return Error::from_string_literal("Failed to grow to requested size");
  358. return { move(instance) };
  359. }
  360. auto& type() const { return m_type; }
  361. auto size() const { return m_size; }
  362. auto& data() const { return m_data; }
  363. auto& data() { return m_data; }
  364. enum class InhibitGrowCallback {
  365. No,
  366. Yes,
  367. };
  368. enum class GrowType {
  369. No,
  370. Yes,
  371. };
  372. bool grow(size_t size_to_grow, GrowType grow_type = GrowType::Yes, InhibitGrowCallback inhibit_callback = InhibitGrowCallback::No)
  373. {
  374. if (size_to_grow == 0)
  375. return true;
  376. u64 new_size = m_data.size() + size_to_grow;
  377. // Can't grow past 2^16 pages.
  378. if (new_size >= Constants::page_size * 65536)
  379. return false;
  380. if (auto max = m_type.limits().max(); max.has_value()) {
  381. if (max.value() * Constants::page_size < new_size)
  382. return false;
  383. }
  384. auto previous_size = m_size;
  385. if (m_data.try_resize(new_size).is_error())
  386. return false;
  387. m_size = new_size;
  388. // The spec requires that we zero out everything on grow
  389. __builtin_memset(m_data.offset_pointer(previous_size), 0, size_to_grow);
  390. // NOTE: This exists because wasm-js-api wants to execute code after a successful grow,
  391. // See [this issue](https://github.com/WebAssembly/spec/issues/1635) for more details.
  392. if (inhibit_callback == InhibitGrowCallback::No && successful_grow_hook)
  393. successful_grow_hook();
  394. if (grow_type == GrowType::Yes) {
  395. // Grow the memory's type. We do this when encountering a `memory.grow`.
  396. //
  397. // See relevant spec link:
  398. // https://www.w3.org/TR/wasm-core-2/#growing-memories%E2%91%A0
  399. m_type = MemoryType { Limits(m_type.limits().min() + size_to_grow / Constants::page_size, m_type.limits().max()) };
  400. }
  401. return true;
  402. }
  403. Function<void()> successful_grow_hook;
  404. private:
  405. explicit MemoryInstance(MemoryType const& type)
  406. : m_type(type)
  407. {
  408. }
  409. MemoryType m_type;
  410. size_t m_size { 0 };
  411. ByteBuffer m_data;
  412. };
  413. class GlobalInstance {
  414. public:
  415. explicit GlobalInstance(Value value, bool is_mutable, ValueType type)
  416. : m_mutable(is_mutable)
  417. , m_value(value)
  418. , m_type(type)
  419. {
  420. }
  421. auto is_mutable() const { return m_mutable; }
  422. auto& value() const { return m_value; }
  423. GlobalType type() const { return { m_type, is_mutable() }; }
  424. void set_value(Value value)
  425. {
  426. VERIFY(is_mutable());
  427. m_value = move(value);
  428. }
  429. private:
  430. bool m_mutable { false };
  431. Value m_value;
  432. ValueType m_type;
  433. };
  434. class DataInstance {
  435. public:
  436. explicit DataInstance(Vector<u8> data)
  437. : m_data(move(data))
  438. {
  439. }
  440. size_t size() const { return m_data.size(); }
  441. Vector<u8>& data() { return m_data; }
  442. Vector<u8> const& data() const { return m_data; }
  443. private:
  444. Vector<u8> m_data;
  445. };
  446. class ElementInstance {
  447. public:
  448. explicit ElementInstance(ValueType type, Vector<Reference> references)
  449. : m_type(move(type))
  450. , m_references(move(references))
  451. {
  452. }
  453. auto& type() const { return m_type; }
  454. auto& references() const { return m_references; }
  455. private:
  456. ValueType m_type;
  457. Vector<Reference> m_references;
  458. };
  459. class Store {
  460. public:
  461. Store() = default;
  462. Optional<FunctionAddress> allocate(ModuleInstance&, CodeSection::Code const&, TypeIndex);
  463. Optional<FunctionAddress> allocate(HostFunction&&);
  464. Optional<TableAddress> allocate(TableType const&);
  465. Optional<MemoryAddress> allocate(MemoryType const&);
  466. Optional<DataAddress> allocate_data(Vector<u8>);
  467. Optional<GlobalAddress> allocate(GlobalType const&, Value);
  468. Optional<ElementAddress> allocate(ValueType const&, Vector<Reference>);
  469. FunctionInstance* get(FunctionAddress);
  470. TableInstance* get(TableAddress);
  471. MemoryInstance* get(MemoryAddress);
  472. GlobalInstance* get(GlobalAddress);
  473. DataInstance* get(DataAddress);
  474. ElementInstance* get(ElementAddress);
  475. private:
  476. Vector<FunctionInstance> m_functions;
  477. Vector<TableInstance> m_tables;
  478. Vector<MemoryInstance> m_memories;
  479. Vector<GlobalInstance> m_globals;
  480. Vector<ElementInstance> m_elements;
  481. Vector<DataInstance> m_datas;
  482. };
  483. class Label {
  484. public:
  485. explicit Label(size_t arity, InstructionPointer continuation, size_t stack_height)
  486. : m_arity(arity)
  487. , m_stack_height(stack_height)
  488. , m_continuation(continuation)
  489. {
  490. }
  491. auto continuation() const { return m_continuation; }
  492. auto arity() const { return m_arity; }
  493. auto stack_height() const { return m_stack_height; }
  494. private:
  495. size_t m_arity { 0 };
  496. size_t m_stack_height { 0 };
  497. InstructionPointer m_continuation { 0 };
  498. };
  499. class Frame {
  500. public:
  501. explicit Frame(ModuleInstance const& module, Vector<Value> locals, Expression const& expression, size_t arity)
  502. : m_module(module)
  503. , m_locals(move(locals))
  504. , m_expression(expression)
  505. , m_arity(arity)
  506. {
  507. }
  508. auto& module() const { return m_module; }
  509. auto& locals() const { return m_locals; }
  510. auto& locals() { return m_locals; }
  511. auto& expression() const { return m_expression; }
  512. auto arity() const { return m_arity; }
  513. auto label_index() const { return m_label_index; }
  514. auto& label_index() { return m_label_index; }
  515. private:
  516. ModuleInstance const& m_module;
  517. Vector<Value> m_locals;
  518. Expression const& m_expression;
  519. size_t m_arity { 0 };
  520. size_t m_label_index { 0 };
  521. };
  522. using InstantiationResult = AK::ErrorOr<NonnullOwnPtr<ModuleInstance>, InstantiationError>;
  523. class AbstractMachine {
  524. public:
  525. explicit AbstractMachine() = default;
  526. // Validate a module; permanently sets the module's validity status.
  527. ErrorOr<void, ValidationError> validate(Module&);
  528. // Load and instantiate a module, and link it into this interpreter.
  529. InstantiationResult instantiate(Module const&, Vector<ExternValue>);
  530. Result invoke(FunctionAddress, Vector<Value>);
  531. Result invoke(Interpreter&, FunctionAddress, Vector<Value>);
  532. auto& store() const { return m_store; }
  533. auto& store() { return m_store; }
  534. void enable_instruction_count_limit() { m_should_limit_instruction_count = true; }
  535. private:
  536. Optional<InstantiationError> allocate_all_initial_phase(Module const&, ModuleInstance&, Vector<ExternValue>&, Vector<Value>& global_values, Vector<FunctionAddress>& own_functions);
  537. Optional<InstantiationError> allocate_all_final_phase(Module const&, ModuleInstance&, Vector<Vector<Reference>>& elements);
  538. Store m_store;
  539. StackInfo m_stack_info;
  540. bool m_should_limit_instruction_count { false };
  541. };
  542. class Linker {
  543. public:
  544. struct Name {
  545. ByteString module;
  546. ByteString name;
  547. ImportSection::Import::ImportDesc type;
  548. };
  549. explicit Linker(Module const& module)
  550. : m_module(module)
  551. {
  552. }
  553. // Link a module, the import 'module name' is ignored with this.
  554. void link(ModuleInstance const&);
  555. // Link a bunch of qualified values, also matches 'module name'.
  556. void link(HashMap<Name, ExternValue> const&);
  557. auto& unresolved_imports()
  558. {
  559. populate();
  560. return m_unresolved_imports;
  561. }
  562. AK::ErrorOr<Vector<ExternValue>, LinkError> finish();
  563. private:
  564. void populate();
  565. Module const& m_module;
  566. HashMap<Name, ExternValue> m_resolved_imports;
  567. HashTable<Name> m_unresolved_imports;
  568. Vector<Name> m_ordered_imports;
  569. Optional<LinkError> m_error;
  570. };
  571. }
  572. template<>
  573. struct AK::Traits<Wasm::Linker::Name> : public AK::DefaultTraits<Wasm::Linker::Name> {
  574. static constexpr bool is_trivial() { return false; }
  575. static unsigned hash(Wasm::Linker::Name const& entry) { return pair_int_hash(entry.module.hash(), entry.name.hash()); }
  576. static bool equals(Wasm::Linker::Name const& a, Wasm::Linker::Name const& b) { return a.name == b.name && a.module == b.module; }
  577. };