@@ -4,16 +4,23 @@ use std::ptr::NonNull;
4
4
use std:: sync:: Arc ;
5
5
use target_lexicon:: { OperatingSystem , PointerWidth } ;
6
6
use wasmer_compiler:: Target ;
7
- use wasmer_engine:: Tunables as BaseTunables ;
7
+ use wasmer_engine:: Tunables ;
8
8
use wasmer_vm:: MemoryError ;
9
9
use wasmer_vm:: {
10
10
LinearMemory , LinearTable , Memory , MemoryStyle , Table , TableStyle , VMMemoryDefinition ,
11
11
VMTableDefinition ,
12
12
} ;
13
13
14
14
/// Tunable parameters for WebAssembly compilation.
15
+ /// This is the reference implementation of the `Tunables` trait,
16
+ /// used by default.
17
+ ///
18
+ /// You can use this as a template for creating a custom Tunables
19
+ /// implementation or use composition to wrap your Tunables around
20
+ /// this one. The later approach is demonstrated in the
21
+ /// tunables-limit-memory example.
15
22
#[ derive( Clone ) ]
16
- pub struct Tunables {
23
+ pub struct BaseTunables {
17
24
/// For static heaps, the size in wasm pages of the heap protected by bounds checking.
18
25
pub static_memory_bound : Pages ,
19
26
@@ -24,8 +31,8 @@ pub struct Tunables {
24
31
pub dynamic_memory_offset_guard_size : u64 ,
25
32
}
26
33
27
- impl Tunables {
28
- /// Get the `Tunables ` for a specific Target
34
+ impl BaseTunables {
35
+ /// Get the `BaseTunables ` for a specific Target
29
36
pub fn for_target ( target : & Target ) -> Self {
30
37
let triple = target. triple ( ) ;
31
38
let pointer_width: PointerWidth = triple. pointer_width ( ) . unwrap ( ) ;
@@ -61,7 +68,7 @@ impl Tunables {
61
68
}
62
69
}
63
70
64
- impl BaseTunables for Tunables {
71
+ impl Tunables for BaseTunables {
65
72
/// Get a `MemoryStyle` for the provided `MemoryType`
66
73
fn memory_style ( & self , memory : & MemoryType ) -> MemoryStyle {
67
74
// A heap with a maximum that doesn't exceed the static memory bound specified by the
@@ -148,7 +155,7 @@ mod tests {
148
155
149
156
#[ test]
150
157
fn memory_style ( ) {
151
- let tunables = Tunables {
158
+ let tunables = BaseTunables {
152
159
static_memory_bound : Pages ( 2048 ) ,
153
160
static_memory_offset_guard_size : 128 ,
154
161
dynamic_memory_offset_guard_size : 256 ,
0 commit comments