1use enum_iterator::IntoEnumIterator;
2use rkyv::{Archive, Deserialize as RkyvDeserialize, Serialize as RkyvSerialize};
3#[cfg(feature = "enable-serde")]
4use serde::{Deserialize, Serialize};
5use std::fmt;
6
7#[derive(
11 Copy,
12 Clone,
13 Debug,
14 PartialEq,
15 Eq,
16 Hash,
17 IntoEnumIterator,
18 RkyvSerialize,
19 RkyvDeserialize,
20 Archive,
21)]
22#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
23#[cfg_attr(feature = "artifact-size", derive(loupe::MemoryUsage))]
24#[rkyv(derive(Debug), compare(PartialEq))]
25#[repr(u16)]
26pub enum LibCall {
27 CeilF32,
29
30 CeilF64,
32
33 FloorF32,
35
36 FloorF64,
38
39 NearestF32,
41
42 NearestF64,
44
45 TruncF32,
47
48 TruncF64,
50
51 Memory32Size,
53
54 ImportedMemory32Size,
56
57 TableCopy,
59
60 TableInit,
62
63 TableFill,
65
66 TableSize,
68
69 ImportedTableSize,
71
72 TableGet,
74
75 ImportedTableGet,
77
78 TableSet,
80
81 ImportedTableSet,
83
84 TableGrow,
86
87 ImportedTableGrow,
89
90 FuncRef,
92
93 ElemDrop,
95
96 Memory32Copy,
98
99 ImportedMemory32Copy,
101
102 Memory32Fill,
104
105 ImportedMemory32Fill,
107
108 Memory32Init,
110
111 DataDrop,
113
114 RaiseTrap,
116
117 Probestack,
120
121 Memory32AtomicWait32,
123
124 ImportedMemory32AtomicWait32,
126
127 Memory32AtomicWait64,
129
130 ImportedMemory32AtomicWait64,
132
133 Memory32AtomicNotify,
135
136 ImportedMemory32AtomicNotify,
138}
139
140impl LibCall {
141 pub fn to_function_name(&self) -> &str {
143 match self {
144 Self::CeilF32 => "wasmer_vm_f32_ceil",
145 Self::CeilF64 => "wasmer_vm_f64_ceil",
146 Self::FloorF32 => "wasmer_vm_f32_floor",
147 Self::FloorF64 => "wasmer_vm_f64_floor",
148 Self::NearestF32 => "wasmer_vm_f32_nearest",
149 Self::NearestF64 => "wasmer_vm_f64_nearest",
150 Self::TruncF32 => "wasmer_vm_f32_trunc",
151 Self::TruncF64 => "wasmer_vm_f64_trunc",
152 Self::Memory32Size => "wasmer_vm_memory32_size",
153 Self::ImportedMemory32Size => "wasmer_vm_imported_memory32_size",
154 Self::TableCopy => "wasmer_vm_table_copy",
155 Self::TableInit => "wasmer_vm_table_init",
156 Self::TableFill => "wasmer_vm_table_fill",
157 Self::TableSize => "wasmer_vm_table_size",
158 Self::ImportedTableSize => "wasmer_vm_imported_table_size",
159 Self::TableGet => "wasmer_vm_table_get",
160 Self::ImportedTableGet => "wasmer_vm_imported_table_get",
161 Self::TableSet => "wasmer_vm_table_set",
162 Self::ImportedTableSet => "wasmer_vm_imported_table_set",
163 Self::TableGrow => "wasmer_vm_table_grow",
164 Self::ImportedTableGrow => "wasmer_vm_imported_table_grow",
165 Self::FuncRef => "wasmer_vm_func_ref",
166 Self::ElemDrop => "wasmer_vm_elem_drop",
167 Self::Memory32Copy => "wasmer_vm_memory32_copy",
168 Self::ImportedMemory32Copy => "wasmer_vm_imported_memory32_copy",
169 Self::Memory32Fill => "wasmer_vm_memory32_fill",
170 Self::ImportedMemory32Fill => "wasmer_vm_imported_memory32_fill",
171 Self::Memory32Init => "wasmer_vm_memory32_init",
172 Self::DataDrop => "wasmer_vm_data_drop",
173 Self::RaiseTrap => "wasmer_vm_raise_trap",
174 #[cfg(target_vendor = "apple")]
177 Self::Probestack => "_wasmer_vm_probestack",
178 #[cfg(not(target_vendor = "apple"))]
179 Self::Probestack => "wasmer_vm_probestack",
180 Self::Memory32AtomicWait32 => "wasmer_vm_memory32_atomic_wait32",
181 Self::ImportedMemory32AtomicWait32 => "wasmer_vm_imported_memory32_atomic_wait32",
182 Self::Memory32AtomicWait64 => "wasmer_vm_memory32_atomic_wait64",
183 Self::ImportedMemory32AtomicWait64 => "wasmer_vm_imported_memory32_atomic_wait64",
184 Self::Memory32AtomicNotify => "wasmer_vm_memory32_atomic_notify",
185 Self::ImportedMemory32AtomicNotify => "wasmer_vm_imported_memory32_atomic_notify",
186 }
187 }
188}
189
190impl fmt::Display for LibCall {
191 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
192 fmt::Debug::fmt(self, f)
193 }
194}