line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Wasm::Wasmtime::Memory; |
2
|
|
|
|
|
|
|
|
3
|
16
|
|
|
16
|
|
3850
|
use strict; |
|
16
|
|
|
|
|
35
|
|
|
16
|
|
|
|
|
524
|
|
4
|
16
|
|
|
16
|
|
83
|
use warnings; |
|
16
|
|
|
|
|
31
|
|
|
16
|
|
|
|
|
385
|
|
5
|
16
|
|
|
16
|
|
255
|
use 5.008004; |
|
16
|
|
|
|
|
57
|
|
6
|
16
|
|
|
16
|
|
99
|
use base qw( Wasm::Wasmtime::Extern ); |
|
16
|
|
|
|
|
34
|
|
|
16
|
|
|
|
|
2503
|
|
7
|
16
|
|
|
16
|
|
125
|
use Ref::Util qw( is_ref is_plain_arrayref ); |
|
16
|
|
|
|
|
39
|
|
|
16
|
|
|
|
|
796
|
|
8
|
16
|
|
|
16
|
|
118
|
use Wasm::Wasmtime::FFI; |
|
16
|
|
|
|
|
40
|
|
|
16
|
|
|
|
|
1560
|
|
9
|
16
|
|
|
16
|
|
122
|
use Wasm::Wasmtime::Store; |
|
16
|
|
|
|
|
31
|
|
|
16
|
|
|
|
|
496
|
|
10
|
16
|
|
|
16
|
|
106
|
use Wasm::Wasmtime::MemoryType; |
|
16
|
|
|
|
|
36
|
|
|
16
|
|
|
|
|
481
|
|
11
|
16
|
|
|
16
|
|
101
|
use constant is_memory => 1; |
|
16
|
|
|
|
|
31
|
|
|
16
|
|
|
|
|
1042
|
|
12
|
16
|
|
|
16
|
|
114
|
use constant kind => 'memory'; |
|
16
|
|
|
|
|
31
|
|
|
16
|
|
|
|
|
7761
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# ABSTRACT: Wasmtime memory class |
15
|
|
|
|
|
|
|
our $VERSION = '0.21'; # 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__ |