Constants.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 v128_tag = 0x7b;
  15. static constexpr auto function_reference_tag = 0x70;
  16. static constexpr auto extern_reference_tag = 0x6f;
  17. // Function
  18. static constexpr auto function_signature_tag = 0x60;
  19. // Global
  20. static constexpr auto const_tag = 0x00;
  21. static constexpr auto var_tag = 0x01;
  22. // Block
  23. static constexpr auto empty_block_tag = 0x40;
  24. // Import section
  25. static constexpr auto extern_function_tag = 0x00;
  26. static constexpr auto extern_table_tag = 0x01;
  27. static constexpr auto extern_memory_tag = 0x02;
  28. static constexpr auto extern_global_tag = 0x03;
  29. static constexpr auto page_size = 64 * KiB;
  30. // Implementation-defined limits
  31. // These are not concretely defined by the spec, so the values are only defined by us.
  32. static constexpr auto minimum_stack_space_to_keep_free = 256 * KiB; // Note: Value is arbitrary and chosen by testing with ASAN
  33. static constexpr auto max_allowed_executed_instructions_per_call = 256 * 1024 * 1024;
  34. static constexpr auto max_allowed_vector_size = 500 * MiB;
  35. static constexpr auto max_allowed_function_locals_per_type = 42069; // Note: VERY arbitrary.
  36. }