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 rkyv::CheckBytes,
22)]
23#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
24#[cfg_attr(feature = "artifact-size", derive(loupe::MemoryUsage))]
25#[archive(as = "Self")]
26#[repr(u16)]
27pub enum LibCall {
28 CeilF32,
30
31 CeilF64,
33
34 FloorF32,
36
37 FloorF64,
39
40 NearestF32,
42
43 NearestF64,
45
46 TruncF32,
48
49 TruncF64,
51
52 Memory32Size,
54
55 ImportedMemory32Size,
57
58 TableCopy,
60
61 TableInit,
63
64 TableFill,
66
67 TableSize,
69
70 ImportedTableSize,
72
73 TableGet,
75
76 ImportedTableGet,
78
79 TableSet,
81
82 ImportedTableSet,
84
85 TableGrow,
87
88 ImportedTableGrow,
90
91 FuncRef,
93
94 ElemDrop,
96
97 Memory32Copy,
99
100 ImportedMemory32Copy,
102
103 Memory32Fill,
105
106 ImportedMemory32Fill,
108
109 Memory32Init,
111
112 DataDrop,
114
115 RaiseTrap,
117
118 Probestack,
121
122 Memory32AtomicWait32,
124
125 ImportedMemory32AtomicWait32,
127
128 Memory32AtomicWait64,
130
131 ImportedMemory32AtomicWait64,
133
134 Memory32AtomicNotify,
136
137 ImportedMemory32AtomicNotify,
139}
140
141impl LibCall {
142 pub fn to_function_name(&self) -> &str {
144 match self {
145 Self::CeilF32 => "wasmer_vm_f32_ceil",
146 Self::CeilF64 => "wasmer_vm_f64_ceil",
147 Self::FloorF32 => "wasmer_vm_f32_floor",
148 Self::FloorF64 => "wasmer_vm_f64_floor",
149 Self::NearestF32 => "wasmer_vm_f32_nearest",
150 Self::NearestF64 => "wasmer_vm_f64_nearest",
151 Self::TruncF32 => "wasmer_vm_f32_trunc",
152 Self::TruncF64 => "wasmer_vm_f64_trunc",
153 Self::Memory32Size => "wasmer_vm_memory32_size",
154 Self::ImportedMemory32Size => "wasmer_vm_imported_memory32_size",
155 Self::TableCopy => "wasmer_vm_table_copy",
156 Self::TableInit => "wasmer_vm_table_init",
157 Self::TableFill => "wasmer_vm_table_fill",
158 Self::TableSize => "wasmer_vm_table_size",
159 Self::ImportedTableSize => "wasmer_vm_imported_table_size",
160 Self::TableGet => "wasmer_vm_table_get",
161 Self::ImportedTableGet => "wasmer_vm_imported_table_get",
162 Self::TableSet => "wasmer_vm_table_set",
163 Self::ImportedTableSet => "wasmer_vm_imported_table_set",
164 Self::TableGrow => "wasmer_vm_table_grow",
165 Self::ImportedTableGrow => "wasmer_vm_imported_table_grow",
166 Self::FuncRef => "wasmer_vm_func_ref",
167 Self::ElemDrop => "wasmer_vm_elem_drop",
168 Self::Memory32Copy => "wasmer_vm_memory32_copy",
169 Self::ImportedMemory32Copy => "wasmer_vm_imported_memory32_copy",
170 Self::Memory32Fill => "wasmer_vm_memory32_fill",
171 Self::ImportedMemory32Fill => "wasmer_vm_imported_memory32_fill",
172 Self::Memory32Init => "wasmer_vm_memory32_init",
173 Self::DataDrop => "wasmer_vm_data_drop",
174 Self::RaiseTrap => "wasmer_vm_raise_trap",
175 #[cfg(target_vendor = "apple")]
178 Self::Probestack => "_wasmer_vm_probestack",
179 #[cfg(not(target_vendor = "apple"))]
180 Self::Probestack => "wasmer_vm_probestack",
181 Self::Memory32AtomicWait32 => "wasmer_vm_memory32_atomic_wait32",
182 Self::ImportedMemory32AtomicWait32 => "wasmer_vm_imported_memory32_atomic_wait32",
183 Self::Memory32AtomicWait64 => "wasmer_vm_memory32_atomic_wait64",
184 Self::ImportedMemory32AtomicWait64 => "wasmer_vm_imported_memory32_atomic_wait64",
185 Self::Memory32AtomicNotify => "wasmer_vm_memory32_atomic_notify",
186 Self::ImportedMemory32AtomicNotify => "wasmer_vm_imported_memory32_atomic_notify",
187 }
188 }
189}
190
191impl fmt::Display for LibCall {
192 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
193 fmt::Debug::fmt(self, f)
194 }
195}