Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add wasmtime 0.28.0 to ci #118

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ jobs:
- tag: static
- tag: "5.37"
- tag: "5.36"
# - tag: "5.36"
# wasmtime: "v0.28.0"
- tag: "5.36"
wasmtime: "v0.28.0"
- tag: "5.36"
wasmtime: "v0.29.0"
- tag: "5.34"
- tag: "5.32"
- tag: "5.30"
Expand Down
13 changes: 13 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
Revision history for {{$dist->name}},

{{$NEXT}}
- Deprecate gc method from Wasm::Wasmtime::Store. $store->context->gc
should be called instead (gh#118)
- Deprecate get_one_by_name method from Wasm::Wasmtime::Linker (gh#118)
- Added Wasm::Wasmtime::Context class (gh#118)
- Added Wasm::Wasmtime::ModuleType class (gh#118)
- Wasm::Wasmtime::Module::Imports renamed to Wasm::Wasmtime::ModuleType::Imports (gh#118)
- Wasm::Wasmtime::Module::Exports renamed to Wasm::Wasmtime::ModuleType::Exports (gh#118)
- Passing Wasm::Wasmtime::Store into Wasm::Wasmtime::Instance->new is deprecated
pass $store->context instead (gh#118)
- Wasm::Wasmtime::Memory method grow throws an exception instead of returning
a false value on error (gh#118)
- Wasm::Memory method grow throws an exception instead of returning a false
value on error (gh#118)

0.23 2022-11-04 06:33:12 -0600
- removed wasmtime_config_max_instances_set from Wasm::Wasmtime::Config
Expand Down
8 changes: 4 additions & 4 deletions author.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ pod_coverage:
- Wasm::Wasmtime::Caller#new
- Wasm::Wasmtime::Instance::Exports#new
- Wasm::Wasmtime::Instance::Exports#can
- Wasm::Wasmtime::Module::Exports#new
- Wasm::Wasmtime::Module::Exports#can
- Wasm::Wasmtime::Module::Imports#new
- Wasm::Wasmtime::Module::Imports#can
- Wasm::Wasmtime::ModuleType::Exports#new
- Wasm::Wasmtime::ModuleType::Exports#can
- Wasm::Wasmtime::ModuleType::Imports#new
- Wasm::Wasmtime::ModuleType::Imports#can
- Wasm::Memory#new
- Test2::Plugin::Wasm
6 changes: 3 additions & 3 deletions dist.ini
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ diag_preamble = | diag "Wasm::Wasmtime::FFI->_lib = $_" for Wasm::Wasmtime
diag_preamble = | };
diag_preamble = | diag "error requiring Wasm::Wasmtime::FFI: $@" if $@;
diag_preamble = | };
;diag_preamble = | spacer();
;diag_preamble = | require Wasm::Wasmtime::FFI;
;diag_preamble = | diag "is 0.23.0? = ", Wasm::Wasmtime::FFI::_v0_23_0();
diag_preamble = | spacer();
diag_preamble = | require Wasm::Wasmtime::FFI;
diag_preamble = | diag "is _ver = ", Wasm::Wasmtime::FFI::_ver();
diag_preamble = | };

[Author::Plicease::Core]
Expand Down
6 changes: 6 additions & 0 deletions examples/synopsis/context.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
use strict;
use warnings;
use Wasm::Wasmtime;

my $store = Wasm::Wasmtime::Store->new;
my $context = $store->context;
2 changes: 1 addition & 1 deletion examples/synopsis/exporttype.pl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
});


my($foo, $bar) = @{ $module->exports };
my($foo, $bar) = @{ $module->type->exports };

print $foo->name, "\n"; # foo
print $foo->type->kind, "\n"; # func
Expand Down
4 changes: 2 additions & 2 deletions examples/synopsis/externtype.pl
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
)
});

my $foo = $module->exports->foo;
my $foo = $module->type->exports->foo;
print $foo->kind, "\n"; # functype

my $bar = $module->exports->bar;
my $bar = $module->type->exports->bar;
print $bar->kind, "\n"; # memorytype
2 changes: 1 addition & 1 deletion examples/synopsis/func1.pl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
)
});

my $instance = Wasm::Wasmtime::Instance->new($module, $store);
my $instance = Wasm::Wasmtime::Instance->new($module, $store->context);
my $add = $instance->exports->add;
print $add->call(1,2), "\n"; # 3
4 changes: 2 additions & 2 deletions examples/synopsis/func2.pl
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
});

my $hello = Wasm::Wasmtime::Func->new(
$store,
$store->context,
Wasm::Wasmtime::FuncType->new([],[]),
sub { print "hello world!\n" },
);

my $instance = Wasm::Wasmtime::Instance->new($module, $store, [$hello]);
my $instance = Wasm::Wasmtime::Instance->new($module, $store->context, [$hello]);
$instance->exports->run->call(); # hello world!

2 changes: 1 addition & 1 deletion examples/synopsis/importtype.pl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
)
});

my $hello = $module->imports->[0];
my $hello = $module->type->imports->[0];

print $hello->module, "\n"; # xx
print $hello->name, "\n"; # hello
Expand Down
2 changes: 1 addition & 1 deletion examples/synopsis/instance.pl
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

my $store = Wasm::Wasmtime::Store->new;
my $module = Wasm::Wasmtime::Module->new($store->engine, wat => '(module)');
my $instance = Wasm::Wasmtime::Instance->new($module, $store, []);
my $instance = Wasm::Wasmtime::Instance->new($module, $store->context, []);
2 changes: 1 addition & 1 deletion examples/synopsis/instance_exports.pl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
)
});

my $instance = Wasm::Wasmtime::Instance->new($module, $store);
my $instance = Wasm::Wasmtime::Instance->new($module, $store->context);

my $exports = $instance->exports;

Expand Down
2 changes: 1 addition & 1 deletion examples/synopsis/module_exports.pl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
)
});

my $exports = $module->exports; # Wasm::Wasmtime::Module::Exports
my $exports = $module->type->exports; # Wasm::Wasmtime::Module::Exports

my $type1 = $exports->add; # this is the Wasm::Wasmtime::FuncType for add
my $type2 = $exports->{add}; # this is also the Wasm::Wasmtime::FuncType for add
Expand Down
6 changes: 6 additions & 0 deletions examples/synopsis/moduletype.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
use strict;
use warnings;
use Wasm::Wasmtime;

my $module = Wasm::Wasmtime::Module->new( wat => '(module)' );
my $type = $module->type;
4 changes: 2 additions & 2 deletions lib/Wasm.pm
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ sub import

my $module = Wasm::Wasmtime::Module->new($linker->store->engine, @module);

foreach my $import (@{ $module->imports })
foreach my $import (@{ $module->type->imports })
{

my $module = $import->module;
Expand Down Expand Up @@ -447,7 +447,7 @@ sub import
$linker->define_instance($package, $instance);
$WASM{$package} = "$file";

my @me = @{ $module->exports };
my @me = @{ $module->type->exports };
my @ie = @{ $instance->exports };

my @function_names;
Expand Down
2 changes: 2 additions & 0 deletions lib/Wasm/Wasmtime.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use warnings;
use 5.008004;
use Wasm::Wasmtime::Caller;
use Wasm::Wasmtime::Config;
use Wasm::Wasmtime::Context;
use Wasm::Wasmtime::Engine;
use Wasm::Wasmtime::ExportType;
use Wasm::Wasmtime::Extern;
Expand All @@ -17,6 +18,7 @@ use Wasm::Wasmtime::ImportType;
use Wasm::Wasmtime::Instance;
use Wasm::Wasmtime::Linker;
use Wasm::Wasmtime::Module;
use Wasm::Wasmtime::ModuleType;
use Wasm::Wasmtime::Store;
use Wasm::Wasmtime::TableType;
use Wasm::Wasmtime::Trap;
Expand Down
2 changes: 1 addition & 1 deletion lib/Wasm/Wasmtime/Config.pm
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Create a new instance of the config class.

$ffi->attach( new => [] => 'wasm_config_t' );

_generate_destroy();
#_generate_destroy();

=head1 METHODS

Expand Down
44 changes: 44 additions & 0 deletions lib/Wasm/Wasmtime/Context.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package Wasm::Wasmtime::Context;

use strict;
use warnings;
use 5.008004;
use Wasm::Wasmtime::FFI;
use Wasm::Wasmtime::Store;

# ABSTRACT: Wasmtime context class
# VERSION

$ffi_prefix = 'wasmtime_context_';

=head1 SYNOPSIS

# EXAMPLE: examples/synopsis/context.pl

=head1 DESCRIPTION

A wasmtime context object.

=head1 METHODS

=head2 gc

Garbage collects C<externref>s that are used by this context. Any
C<externref>s that are discovered to be unreachable by other code or objects
will have their finalizers run.

=cut

if(_ver ne '0.27.0')
{
$ffi->attach( gc => ['wasmtime_context_t'] );
}
else
{
$ffi->attach( [ wasmtime_store_gc => 'gc' ] => ['wasm_store_t'] => sub {
my($xsub, $self) = @_;
$xsub->($self->{store});
});
}

1;
52 changes: 39 additions & 13 deletions lib/Wasm/Wasmtime/FFI.pm
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,18 @@ This is a private class used internally by L<Wasm::Wasmtime> classes.

=cut

our @EXPORT = qw( $ffi $ffi_prefix _generate_vec_class _generate_destroy );
our @EXPORT = qw( $ffi $ffi_prefix _generate_vec_class _generate_destroy _ver );

sub _lib
{
return $ENV{WASM_WASMTIME_FFI} if defined $ENV{WASM_WASMTIME_FFI};
my @symbols = (
# 0.19.0
'wasmtime_func_as_funcref',
#'wasmtime_func_as_funcref', # removed in 0.28.0
# 0.20.0 / 0.21.0
'wasmtime_module_serialize',
'wasmtime_module_deserialize',
'wasmtime_store_gc',
#'wasmtime_store_gc', # removed in 0.28.0
## 0.23.0
'wasmtime_config_consume_fuel_set',
#'wasmtime_config_max_instances_set', # removed in 0.27.0
Expand All @@ -63,7 +63,7 @@ sub _lib
}

our $ffi_prefix = 'wasm_';
our $ffi = FFI::Platypus->new( api => 1 );
our $ffi = FFI::Platypus->new( api => 2 );
FFI::C->ffi($ffi);
$ffi->lib(__PACKAGE__->_lib);
$ffi->mangler(sub {
Expand All @@ -72,6 +72,19 @@ $ffi->mangler(sub {
return $ffi_prefix . $name;
});

if($ffi->find_symbol('wasmtime_config_wasm_multi_memory_set'))
{
constant->import(_ver => '0.29.0');
}
elsif($ffi->find_symbol('wasmtime_store_gc'))
{
constant->import(_ver => '0.27.0');
}
else
{
constant->import(_ver => '0.28.0');
}

{ package Wasm::Wasmtime::Vec;
use FFI::Platypus::Record;
record_layout_1(
Expand Down Expand Up @@ -168,20 +181,33 @@ sub _wrapper_destroy

sub _generate_destroy
{
my %arg = @_;
my $caller = caller;
my $type = lc $caller;
if($type =~ /::linker$/)
{
$type = 'wasmtime_linker_t';
}
elsif($type =~ /::wasi/)
my $type;
if(defined $arg{type})
{
$type =~ s/^.*::wasi(.*)$/wasi_${1}_t/g;
$type = $arg{type};
}
else
{
$type =~ s/^.*:://;
$type = "wasm_${type}_t";
$type = lc $caller;
if($type =~ /::linker$/)
{
$type = 'wasmtime_linker_t';
}
elsif($type =~ /::wasi/)
{
$type =~ s/^.*::wasi(.*)$/wasi_${1}_t/g;
}
elsif($type =~ /::moduletype/)
{
$type = 'wasmtime_moduletype_t';
}
else
{
$type =~ s/^.*:://;
$type = "wasm_${type}_t";
}
}
$ffi->attach( [ delete => join('::', $caller, 'DESTROY') ] => [ $type ] => \&_wrapper_destroy);
}
Expand Down
Loading