line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Wasm::Wasmtime::WasiInstance; |
2
|
|
|
|
|
|
|
|
3
|
10
|
|
|
10
|
|
579
|
use strict; |
|
10
|
|
|
|
|
22
|
|
|
10
|
|
|
|
|
298
|
|
4
|
10
|
|
|
10
|
|
44
|
use warnings; |
|
10
|
|
|
|
|
22
|
|
|
10
|
|
|
|
|
230
|
|
5
|
10
|
|
|
10
|
|
157
|
use 5.008004; |
|
10
|
|
|
|
|
36
|
|
6
|
10
|
|
|
10
|
|
63
|
use Wasm::Wasmtime::FFI; |
|
10
|
|
|
|
|
50
|
|
|
10
|
|
|
|
|
1013
|
|
7
|
10
|
|
|
10
|
|
79
|
use Wasm::Wasmtime::Store; |
|
10
|
|
|
|
|
22
|
|
|
10
|
|
|
|
|
270
|
|
8
|
10
|
|
|
10
|
|
504
|
use Wasm::Wasmtime::Trap; |
|
10
|
|
|
|
|
26
|
|
|
10
|
|
|
|
|
320
|
|
9
|
10
|
|
|
10
|
|
3938
|
use Wasm::Wasmtime::WasiConfig; |
|
10
|
|
|
|
|
31
|
|
|
10
|
|
|
|
|
2326
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# ABSTRACT: WASI instance class |
12
|
|
|
|
|
|
|
our $VERSION = '0.21'; # VERSION |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
$ffi_prefix = 'wasi_instance_'; |
16
|
|
|
|
|
|
|
$ffi->load_custom_type('::PtrObject' => 'wasi_instance_t' => __PACKAGE__); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
$ffi->attach( new => ['wasm_store_t', 'string', 'wasi_config_t', 'opaque*'] => 'wasi_instance_t' => sub { |
20
|
|
|
|
|
|
|
my $xsub = shift; |
21
|
|
|
|
|
|
|
my $class = shift; |
22
|
|
|
|
|
|
|
my $store = shift; |
23
|
|
|
|
|
|
|
my $name = shift; |
24
|
|
|
|
|
|
|
my $config = defined $_[0] && ref($_[0]) eq 'Wasm::Wasmtime::WasiConfig' ? shift : Wasm::Wasmtime::WasiConfig->new; |
25
|
|
|
|
|
|
|
my $trap; |
26
|
|
|
|
|
|
|
my $instance = $xsub->($store, $name, $config, \$trap); |
27
|
|
|
|
|
|
|
delete $config->{ptr}; |
28
|
|
|
|
|
|
|
unless($instance) |
29
|
|
|
|
|
|
|
{ |
30
|
|
|
|
|
|
|
if($trap) |
31
|
|
|
|
|
|
|
{ |
32
|
|
|
|
|
|
|
die Wasm::Wasmtime::Trap->new($trap); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
Carp::croak("failed to create wasi instance"); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
$instance; |
37
|
|
|
|
|
|
|
}); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# TODO: bind_import |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
_generate_destroy(); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
__END__ |