summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWasm/Constants.h
blob: 4c76a79fdecce386ddedbc53c9636de31bcc9341 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
 * Copyright (c) 2021, Ali Mohammad Pur <mpfard@serenityos.org>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <AK/Types.h>

namespace Wasm::Constants {

// Value
static constexpr auto i32_tag = 0x7f;
static constexpr auto i64_tag = 0x7e;
static constexpr auto f32_tag = 0x7d;
static constexpr auto f64_tag = 0x7c;
static constexpr auto function_reference_tag = 0x70;
static constexpr auto extern_reference_tag = 0x6f;

// Function
static constexpr auto function_signature_tag = 0x60;

// Global
static constexpr auto const_tag = 0x00;
static constexpr auto var_tag = 0x01;

// Block
static constexpr auto empty_block_tag = 0x40;

// Import section
static constexpr auto extern_function_tag = 0x00;
static constexpr auto extern_table_tag = 0x01;
static constexpr auto extern_memory_tag = 0x02;
static constexpr auto extern_global_tag = 0x03;

static constexpr auto page_size = 64 * KiB;

// Implementation-defined limits
// These are not concretely defined by the spec, so the values are only defined by us.
static constexpr auto minimum_stack_space_to_keep_free = 256 * KiB; // Note: Value is arbitrary and chosen by testing with ASAN
static constexpr auto max_allowed_executed_instructions_per_call = 256 * 1024 * 1024;
static constexpr auto max_allowed_vector_size = 2 * MiB;
static constexpr auto max_allowed_function_locals_per_type = 420; // Note: VERY arbitrary.

}