line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Wasm::Wasmtime::Memory; |
2
|
|
|
|
|
|
|
|
3
|
16
|
|
|
16
|
|
3671
|
use strict; |
|
16
|
|
|
|
|
45
|
|
|
16
|
|
|
|
|
494
|
|
4
|
16
|
|
|
16
|
|
91
|
use warnings; |
|
16
|
|
|
|
|
36
|
|
|
16
|
|
|
|
|
365
|
|
5
|
16
|
|
|
16
|
|
252
|
use 5.008004; |
|
16
|
|
|
|
|
61
|
|
6
|
16
|
|
|
16
|
|
98
|
use base qw( Wasm::Wasmtime::Extern ); |
|
16
|
|
|
|
|
42
|
|
|
16
|
|
|
|
|
2315
|
|
7
|
16
|
|
|
16
|
|
110
|
use Ref::Util qw( is_ref is_plain_arrayref ); |
|
16
|
|
|
|
|
45
|
|
|
16
|
|
|
|
|
887
|
|
8
|
16
|
|
|
16
|
|
114
|
use Wasm::Wasmtime::FFI; |
|
16
|
|
|
|
|
32
|
|
|
16
|
|
|
|
|
1671
|
|
9
|
16
|
|
|
16
|
|
120
|
use Wasm::Wasmtime::Store; |
|
16
|
|
|
|
|
32
|
|
|
16
|
|
|
|
|
452
|
|
10
|
16
|
|
|
16
|
|
102
|
use Wasm::Wasmtime::MemoryType; |
|
16
|
|
|
|
|
39
|
|
|
16
|
|
|
|
|
542
|
|
11
|
16
|
|
|
16
|
|
120
|
use constant is_memory => 1; |
|
16
|
|
|
|
|
32
|
|
|
16
|
|
|
|
|
1057
|
|
12
|
16
|
|
|
16
|
|
107
|
use constant kind => 'memory'; |
|
16
|
|
|
|
|
49
|
|
|
16
|
|
|
|
|
7833
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# ABSTRACT: Wasmtime memory class |
15
|
|
|
|
|
|
|
our $VERSION = '0.23'; # VERSION |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
$ffi_prefix = 'wasm_memory_'; |
19
|
|
|
|
|
|
|
$ffi->load_custom_type('::PtrObject' => 'wasm_memory_t' => __PACKAGE__); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
$ffi->attach( new => ['wasm_store_t', 'wasm_memorytype_t'] => 'wasm_memory_t' => sub { |
23
|
|
|
|
|
|
|
my $xsub = shift; |
24
|
|
|
|
|
|
|
my $class = shift; |
25
|
|
|
|
|
|
|
if(is_ref $_[0]) |
26
|
|
|
|
|
|
|
{ |
27
|
|
|
|
|
|
|
my($store, $memorytype) = @_; |
28
|
|
|
|
|
|
|
$memorytype = Wasm::Wasmtime::MemoryType->new($memorytype) |
29
|
|
|
|
|
|
|
if is_plain_arrayref $memorytype; |
30
|
|
|
|
|
|
|
return $xsub->($store, $memorytype); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
else |
33
|
|
|
|
|
|
|
{ |
34
|
|
|
|
|
|
|
my($ptr, $owner) = @_; |
35
|
|
|
|
|
|
|
return bless { |
36
|
|
|
|
|
|
|
ptr => $ptr, |
37
|
|
|
|
|
|
|
owner => $owner, |
38
|
|
|
|
|
|
|
}, $class; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
}); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
$ffi->attach( type => ['wasm_memory_t'] => 'wasm_memorytype_t' => sub { |
44
|
|
|
|
|
|
|
my($xsub, $self) = @_; |
45
|
|
|
|
|
|
|
my $type = $xsub->($self); |
46
|
|
|
|
|
|
|
$type->{owner} = $self->{owner} || $self if $type; |
47
|
|
|
|
|
|
|
$type; |
48
|
|
|
|
|
|
|
}); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
$ffi->attach( data => ['wasm_memory_t'] => 'opaque' => sub { |
52
|
|
|
|
|
|
|
my($xsub, $self) = @_; |
53
|
|
|
|
|
|
|
$xsub->($self); |
54
|
|
|
|
|
|
|
}); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
$ffi->attach( data_size => ['wasm_memory_t'] => 'size_t' => sub { |
58
|
|
|
|
|
|
|
my($xsub, $self) = @_; |
59
|
|
|
|
|
|
|
$xsub->($self); |
60
|
|
|
|
|
|
|
}); |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
$ffi->attach( size => ['wasm_memory_t'] => 'uint32' => sub { |
64
|
|
|
|
|
|
|
my($xsub, $self) = @_; |
65
|
|
|
|
|
|
|
$xsub->($self); |
66
|
|
|
|
|
|
|
}); |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
$ffi->attach( grow => ['wasm_memory_t', 'uint32'] => 'bool' => sub { |
70
|
|
|
|
|
|
|
my($xsub, $self, $delta) = @_; |
71
|
|
|
|
|
|
|
$xsub->($self, $delta); |
72
|
|
|
|
|
|
|
}); |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
__PACKAGE__->_cast(3); |
75
|
|
|
|
|
|
|
_generate_destroy(); |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
__END__ |