line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Wasm::Wasmtime::Config; |
2
|
|
|
|
|
|
|
|
3
|
27
|
|
|
27
|
|
442076
|
use strict; |
|
27
|
|
|
|
|
69
|
|
|
27
|
|
|
|
|
764
|
|
4
|
27
|
|
|
27
|
|
136
|
use warnings; |
|
27
|
|
|
|
|
51
|
|
|
27
|
|
|
|
|
623
|
|
5
|
27
|
|
|
27
|
|
551
|
use 5.008004; |
|
27
|
|
|
|
|
129
|
|
6
|
27
|
|
|
27
|
|
1022
|
use Wasm::Wasmtime::FFI; |
|
27
|
|
|
|
|
117
|
|
|
27
|
|
|
|
|
22981
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# ABSTRACT: Global configuration for Wasm::Wasmtime::Engine |
9
|
|
|
|
|
|
|
our $VERSION = '0.21'; # VERSION |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
$ffi_prefix = 'wasm_config_'; |
13
|
|
|
|
|
|
|
$ffi->load_custom_type('::PtrObject' => 'wasm_config_t' => __PACKAGE__); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
$ffi->attach( new => [] => 'wasm_config_t' ); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
_generate_destroy(); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
foreach my $prop (qw( |
22
|
|
|
|
|
|
|
cranelift_debug_verifier |
23
|
|
|
|
|
|
|
debug_info |
24
|
|
|
|
|
|
|
interruptable |
25
|
|
|
|
|
|
|
wasm_bulk_memory |
26
|
|
|
|
|
|
|
wasm_reference_types |
27
|
|
|
|
|
|
|
wasm_multi_value |
28
|
|
|
|
|
|
|
wasm_simd |
29
|
|
|
|
|
|
|
wasm_threads |
30
|
|
|
|
|
|
|
)) |
31
|
|
|
|
|
|
|
{ |
32
|
|
|
|
|
|
|
$ffi->attach( [ "wasmtime_config_${prop}_set" => $prop ] => [ 'wasm_config_t', 'bool' ] => sub { |
33
|
|
|
|
|
|
|
my($xsub, $self, $value) = @_; |
34
|
|
|
|
|
|
|
$xsub->($self, $value); |
35
|
|
|
|
|
|
|
$self; |
36
|
|
|
|
|
|
|
}); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
foreach my $prop (qw( |
40
|
|
|
|
|
|
|
max_wasm_stack |
41
|
|
|
|
|
|
|
)) |
42
|
|
|
|
|
|
|
{ |
43
|
|
|
|
|
|
|
$ffi->attach( [ "wasmtime_config_${prop}_set" => $prop ] => [ 'wasm_config_t', 'size_t' ] => sub { |
44
|
|
|
|
|
|
|
my($xsub, $self, $value) = @_; |
45
|
|
|
|
|
|
|
$xsub->($self, $value); |
46
|
|
|
|
|
|
|
$self; |
47
|
|
|
|
|
|
|
}); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
outer: |
52
|
|
|
|
|
|
|
foreach my $prop (qw( static_memory_maximum_size static_memory_guard_size dynamic_memory_guard_size )) |
53
|
|
|
|
|
|
|
{ |
54
|
|
|
|
|
|
|
$ffi->attach( [ "wasmtime_config_${prop}_set" => $prop ] => [ 'wasm_config_t', 'uint64' ] => 'void' => sub { |
55
|
|
|
|
|
|
|
my($xsub, $self, $value) = @_; |
56
|
|
|
|
|
|
|
$xsub->($self, $value); |
57
|
|
|
|
|
|
|
$self; |
58
|
|
|
|
|
|
|
}); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
my %strategy = ( |
63
|
|
|
|
|
|
|
auto => 0, |
64
|
|
|
|
|
|
|
cranelift => 1, |
65
|
|
|
|
|
|
|
lightbeam => 2, |
66
|
|
|
|
|
|
|
); |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
$ffi->attach( [ 'wasmtime_config_strategy_set' => 'strategy' ] => [ 'wasm_config_t', 'uint8' ] => 'wasmtime_error_t' => sub { |
69
|
|
|
|
|
|
|
my($xsub, $self, $value) = @_; |
70
|
|
|
|
|
|
|
if(defined $strategy{$value}) |
71
|
|
|
|
|
|
|
{ |
72
|
|
|
|
|
|
|
if(my $error = $xsub->($self, $strategy{$value})) |
73
|
|
|
|
|
|
|
{ |
74
|
|
|
|
|
|
|
Carp::croak($error->message); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
else |
78
|
|
|
|
|
|
|
{ |
79
|
|
|
|
|
|
|
Carp::croak("unknown strategy: $value"); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
$self; |
82
|
|
|
|
|
|
|
}); |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
my %cranelift_opt_level = ( |
86
|
|
|
|
|
|
|
none => 0, |
87
|
|
|
|
|
|
|
speed => 1, |
88
|
|
|
|
|
|
|
speed_and_size => 2, |
89
|
|
|
|
|
|
|
); |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
$ffi->attach( ['wasmtime_config_cranelift_opt_level_set' => 'cranelift_opt_level' ] => ['wasm_config_t', 'uint8' ] => sub { |
92
|
|
|
|
|
|
|
my($xsub, $self, $value) = @_; |
93
|
|
|
|
|
|
|
if(defined $cranelift_opt_level{$value}) |
94
|
|
|
|
|
|
|
{ |
95
|
|
|
|
|
|
|
$xsub->($self, $cranelift_opt_level{$value}); |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
else |
98
|
|
|
|
|
|
|
{ |
99
|
|
|
|
|
|
|
Carp::croak("unknown cranelift_opt_level: $value"); |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
$self; |
102
|
|
|
|
|
|
|
}); |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
my %profiler = ( |
106
|
|
|
|
|
|
|
none => 0, |
107
|
|
|
|
|
|
|
jitdump => 1, |
108
|
|
|
|
|
|
|
vtune => 2, |
109
|
|
|
|
|
|
|
); |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
$ffi->attach( ['wasmtime_config_profiler_set' => 'profiler' ] => ['wasm_config_t', 'uint8'] => 'wasmtime_error_t' => sub { |
112
|
|
|
|
|
|
|
my($xsub, $self, $value) = @_; |
113
|
|
|
|
|
|
|
if(defined $profiler{$value}) |
114
|
|
|
|
|
|
|
{ |
115
|
|
|
|
|
|
|
if(my $error = $xsub->($self, $profiler{$value})) |
116
|
|
|
|
|
|
|
{ |
117
|
|
|
|
|
|
|
Carp::croak($error->message); |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
else |
121
|
|
|
|
|
|
|
{ |
122
|
|
|
|
|
|
|
Carp::croak("unknown profiler: $value"); |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
$self; |
125
|
|
|
|
|
|
|
}); |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
$ffi->attach( [ 'wasmtime_config_cache_config_load' => 'cache_config_load' ] => [ 'wasm_config_t', 'string' ] => sub { |
129
|
|
|
|
|
|
|
my($xsub, $self, $value) = @_; |
130
|
|
|
|
|
|
|
Carp::croak("undef passed in as cache config") unless defined $value; |
131
|
|
|
|
|
|
|
$xsub->($self, $value); |
132
|
|
|
|
|
|
|
$self; |
133
|
|
|
|
|
|
|
}); |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
$ffi->attach( [ 'wasmtime_config_cache_config_load' => 'cache_config_default' ] => [ 'wasm_config_t', 'string' ] => sub { |
136
|
|
|
|
|
|
|
my($xsub, $self) = @_; |
137
|
|
|
|
|
|
|
$xsub->($self, undef); |
138
|
|
|
|
|
|
|
$self; |
139
|
|
|
|
|
|
|
}); |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
1; |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
__END__ |