1use enum_iterator::Sequence;
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, Clone, Debug, PartialEq, Eq, Hash, Sequence, RkyvSerialize, RkyvDeserialize, Archive,
12)]
13#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
14#[cfg_attr(feature = "artifact-size", derive(loupe::MemoryUsage))]
15#[rkyv(derive(Debug, Hash, PartialEq, Eq), compare(PartialEq))]
16#[repr(u16)]
17pub enum LibCall {
18 CeilF32,
20
21 CeilF64,
23
24 FloorF32,
26
27 FloorF64,
29
30 NearestF32,
32
33 NearestF64,
35
36 TruncF32,
38
39 TruncF64,
41
42 Memory32Size,
44
45 ImportedMemory32Size,
47
48 TableCopy,
50
51 TableInit,
53
54 TableFill,
56
57 TableSize,
59
60 ImportedTableSize,
62
63 TableGet,
65
66 ImportedTableGet,
68
69 TableSet,
71
72 ImportedTableSet,
74
75 TableGrow,
77
78 ImportedTableGrow,
80
81 FuncRef,
83
84 ElemDrop,
86
87 Memory32Copy,
89
90 ImportedMemory32Copy,
92
93 Memory32Fill,
95
96 ImportedMemory32Fill,
98
99 Memory32Init,
101
102 DataDrop,
104
105 RaiseTrap,
107
108 Probestack,
111
112 Memory32AtomicWait32,
114
115 ImportedMemory32AtomicWait32,
117
118 Memory32AtomicWait64,
120
121 ImportedMemory32AtomicWait64,
123
124 Memory32AtomicNotify,
126
127 ImportedMemory32AtomicNotify,
129
130 Throw,
132
133 AllocException,
135 ReadExnRef,
137 LibunwindExceptionIntoExnRef,
139
140 EHPersonality,
142 EHPersonality2,
144
145 DebugUsize,
147 DebugStr,
149}
150
151impl LibCall {
152 pub fn to_function_name(&self) -> &str {
154 match self {
155 Self::CeilF32 => "wasmer_vm_f32_ceil",
156 Self::CeilF64 => "wasmer_vm_f64_ceil",
157 Self::FloorF32 => "wasmer_vm_f32_floor",
158 Self::FloorF64 => "wasmer_vm_f64_floor",
159 Self::NearestF32 => "wasmer_vm_f32_nearest",
160 Self::NearestF64 => "wasmer_vm_f64_nearest",
161 Self::TruncF32 => "wasmer_vm_f32_trunc",
162 Self::TruncF64 => "wasmer_vm_f64_trunc",
163 Self::Memory32Size => "wasmer_vm_memory32_size",
164 Self::ImportedMemory32Size => "wasmer_vm_imported_memory32_size",
165 Self::TableCopy => "wasmer_vm_table_copy",
166 Self::TableInit => "wasmer_vm_table_init",
167 Self::TableFill => "wasmer_vm_table_fill",
168 Self::TableSize => "wasmer_vm_table_size",
169 Self::ImportedTableSize => "wasmer_vm_imported_table_size",
170 Self::TableGet => "wasmer_vm_table_get",
171 Self::ImportedTableGet => "wasmer_vm_imported_table_get",
172 Self::TableSet => "wasmer_vm_table_set",
173 Self::ImportedTableSet => "wasmer_vm_imported_table_set",
174 Self::TableGrow => "wasmer_vm_table_grow",
175 Self::ImportedTableGrow => "wasmer_vm_imported_table_grow",
176 Self::FuncRef => "wasmer_vm_func_ref",
177 Self::ElemDrop => "wasmer_vm_elem_drop",
178 Self::Memory32Copy => "wasmer_vm_memory32_copy",
179 Self::ImportedMemory32Copy => "wasmer_vm_imported_memory32_copy",
180 Self::Memory32Fill => "wasmer_vm_memory32_fill",
181 Self::ImportedMemory32Fill => "wasmer_vm_imported_memory32_fill",
182 Self::Memory32Init => "wasmer_vm_memory32_init",
183 Self::DataDrop => "wasmer_vm_data_drop",
184 Self::RaiseTrap => "wasmer_vm_raise_trap",
185 #[cfg(target_vendor = "apple")]
188 Self::Probestack => "_wasmer_vm_probestack",
189 #[cfg(not(target_vendor = "apple"))]
190 Self::Probestack => "wasmer_vm_probestack",
191 Self::Memory32AtomicWait32 => "wasmer_vm_memory32_atomic_wait32",
192 Self::ImportedMemory32AtomicWait32 => "wasmer_vm_imported_memory32_atomic_wait32",
193 Self::Memory32AtomicWait64 => "wasmer_vm_memory32_atomic_wait64",
194 Self::ImportedMemory32AtomicWait64 => "wasmer_vm_imported_memory32_atomic_wait64",
195 Self::Memory32AtomicNotify => "wasmer_vm_memory32_atomic_notify",
196 Self::ImportedMemory32AtomicNotify => "wasmer_vm_imported_memory32_atomic_notify",
197 Self::Throw => "wasmer_vm_throw",
198 Self::EHPersonality => "wasmer_eh_personality",
199 Self::EHPersonality2 => "wasmer_eh_personality2",
200 Self::AllocException => "wasmer_vm_alloc_exception",
201 Self::ReadExnRef => "wasmer_vm_read_exnref",
202 Self::LibunwindExceptionIntoExnRef => "wasmer_vm_exception_into_exnref",
203 Self::DebugUsize => "wasmer_vm_dbg_usize",
204 Self::DebugStr => "wasmer_vm_dbg_str",
205 }
206 }
207}
208
209impl fmt::Display for LibCall {
210 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
211 fmt::Debug::fmt(self, f)
212 }
213}