Constants.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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/Types.h>
  8. namespace Wasm::Constants {
  9. // Value
  10. static constexpr auto i32_tag = 0x7f;
  11. static constexpr auto i64_tag = 0x7e;
  12. static constexpr auto f32_tag = 0x7d;
  13. static constexpr auto f64_tag = 0x7c;
  14. static constexpr auto function_reference_tag = 0x70;
  15. static constexpr auto extern_reference_tag = 0x6f;
  16. // Function
  17. static constexpr auto function_signature_tag = 0x60;
  18. // Global
  19. static constexpr auto const_tag = 0x00;
  20. static constexpr auto var_tag = 0x01;
  21. // Block
  22. static constexpr auto empty_block_tag = 0x40;
  23. // Import section
  24. static constexpr auto extern_function_tag = 0x00;
  25. static constexpr auto extern_table_tag = 0x01;
  26. static constexpr auto extern_memory_tag = 0x02;
  27. static constexpr auto extern_global_tag = 0x03;
  28. static constexpr auto page_size = 64 * KiB;
  29. // Implementation-defined limits
  30. // These are not concretely defined by the spec, so the values are only defined by us.
  31. static constexpr auto minimum_stack_space_to_keep_free = 256 * KiB; // Note: Value is arbitrary and chosen by testing with ASAN
  32. static constexpr auto max_allowed_executed_instructions_per_call = 256 * 1024 * 1024;
  33. static constexpr auto max_allowed_vector_size = 500 * MiB;
  34. static constexpr auto max_allowed_function_locals_per_type = 42069; // Note: VERY arbitrary.
  35. }