Skip to content
Merged
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
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
37.0.0
38.0.0
58 changes: 30 additions & 28 deletions ci/cbindgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# with lots of extra an unnecessary boilerplate.

from pycparser import c_ast, parse_file

import sys

class Visitor(c_ast.NodeVisitor):
def __init__(self):
Expand Down Expand Up @@ -252,36 +252,38 @@ def type_name(ty, ptr=False, typing=False):
raise RuntimeError("unknown {}".format(ty))


ast = parse_file(
'./wasmtime/include/wasmtime.h',
use_cpp=True,
cpp_path='gcc',
cpp_args=[
'-E',
'-I./wasmtime/include',
'-D__attribute__(x)=',
'-D__asm__(x)=',
'-D__asm(x)=',
'-D__volatile__(x)=',
'-D_Static_assert(x, y)=',
'-Dstatic_assert(x, y)=',
'-D__restrict=',
'-D__restrict__=',
'-D__extension__=',
'-D__inline__=',
'-D__signed=',
'-D__builtin_va_list=int',
]
)

v = Visitor()
v.visit(ast)
def run():
ast = parse_file(
'./wasmtime/include/wasmtime.h',
use_cpp=True,
cpp_path='gcc',
cpp_args=[
'-E',
'-I./wasmtime/include',
'-D__attribute__(x)=',
'-D__asm__(x)=',
'-D__asm(x)=',
'-D__volatile__(x)=',
'-D_Static_assert(x, y)=',
'-Dstatic_assert(x, y)=',
'-D__restrict=',
'-D__restrict__=',
'-D__extension__=',
'-D__inline__=',
'-D__signed=',
'-D__builtin_va_list=int',
]
)

v = Visitor()
v.visit(ast)
return v.ret

if __name__ == "__main__":
with open("wasmtime/_bindings.py", "w") as f:
f.write(v.ret)
else:
f.write(run())
elif sys.platform == 'linux':
with open("wasmtime/_bindings.py", "r") as f:
contents = f.read()
if contents != v.ret:
if contents != run():
raise RuntimeError("bindings need an update, run this script")
2 changes: 1 addition & 1 deletion ci/download-wasmtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

# set to "dev" to download the latest or pick a tag from
# https://github.com/bytecodealliance/wasmtime/tags
WASMTIME_VERSION = "v37.0.2"
WASMTIME_VERSION = "v38.0.1"


def main(platform, arch):
Expand Down
16 changes: 8 additions & 8 deletions rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ heck = { version = "0.4", features = ["unicode"] }
wit-parser = "0.239.0"
wit-component = "0.239.0"
indexmap = "2.0"
wasmtime-environ = { version = "37.0.0", features = ['component-model', 'compile'] }
wasmtime-environ = { version = "38.0.0", features = ['component-model', 'compile'] }
wit-bindgen = "0.46.0"
wit-bindgen-core = "0.46.0"

Expand Down
49 changes: 32 additions & 17 deletions rust/src/bindgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,17 +198,32 @@ impl WasmtimePy {
}
Trampoline::Transcoder { .. } => unimplemented!(),
Trampoline::AlwaysTrap => unimplemented!(),
Trampoline::ResourceNew(idx) => {
self.resource_trampolines
.push((trampoline_index, Trampoline::ResourceNew(*idx)));
Trampoline::ResourceNew { ty, instance } => {
self.resource_trampolines.push((
trampoline_index,
Trampoline::ResourceNew {
ty: *ty,
instance: *instance,
},
));
}
Trampoline::ResourceRep(idx) => {
self.resource_trampolines
.push((trampoline_index, Trampoline::ResourceRep(*idx)));
Trampoline::ResourceRep { ty, instance } => {
self.resource_trampolines.push((
trampoline_index,
Trampoline::ResourceRep {
ty: *ty,
instance: *instance,
},
));
}
Trampoline::ResourceDrop(idx) => {
self.resource_trampolines
.push((trampoline_index, Trampoline::ResourceDrop(*idx)));
Trampoline::ResourceDrop { ty, instance } => {
self.resource_trampolines.push((
trampoline_index,
Trampoline::ResourceDrop {
ty: *ty,
instance: *instance,
},
));
}
Trampoline::ResourceEnterCall => unimplemented!(),
Trampoline::ResourceExitCall => unimplemented!(),
Expand Down Expand Up @@ -248,8 +263,8 @@ impl WasmtimePy {
Trampoline::PrepareCall { .. } => unimplemented!(),
Trampoline::SyncStartCall { .. } => unimplemented!(),
Trampoline::AsyncStartCall { .. } => unimplemented!(),
Trampoline::ContextGet(_) => unimplemented!(),
Trampoline::ContextSet(_) => unimplemented!(),
Trampoline::ContextGet { .. } => unimplemented!(),
Trampoline::ContextSet { .. } => unimplemented!(),
Trampoline::BackpressureInc { .. } => unimplemented!(),
Trampoline::BackpressureDec { .. } => unimplemented!(),
}
Expand Down Expand Up @@ -615,7 +630,7 @@ impl<'a> Instantiator<'a> {
for (tid, trampoline) in self.gen.resource_trampolines.iter() {
let tidx = tid.as_u32();
match trampoline {
Trampoline::ResourceNew(rid) => {
Trampoline::ResourceNew { ty: rid, .. } => {
let resource_id = rid.as_u32();
let handle_add = &format!("_handle_add_{resource_id}");
uwriteln!(self.gen.init, "def _resource_new_{resource_id}(rep):");
Expand All @@ -631,7 +646,7 @@ impl<'a> Instantiator<'a> {
"trampoline{tidx} = wasmtime.Func(store, _resource_new_{resource_id}_ty, _resource_new_{resource_id})"
)
}
Trampoline::ResourceDrop(rid) => {
Trampoline::ResourceDrop { ty: rid, .. } => {
let resource_id = rid.as_u32();
uwriteln!(self.gen.init, "def _resource_drop_{resource_id}(rep):");
self.gen.init.indent();
Expand All @@ -646,7 +661,7 @@ impl<'a> Instantiator<'a> {
"trampoline{tidx} = wasmtime.Func(store, _resource_drop_{resource_id}_ty, _resource_drop_{resource_id})"
);
}
Trampoline::ResourceRep(rid) => {
Trampoline::ResourceRep { ty: rid, .. } => {
let resource_id = rid.as_u32();
uwriteln!(self.gen.init, "def _resource_rep_{resource_id}(handle):");
self.gen.init.indent();
Expand All @@ -672,9 +687,9 @@ impl<'a> Instantiator<'a> {
.resource_trampolines
.iter()
.map(|(_, trampoline)| match trampoline {
Trampoline::ResourceNew(idx)
| Trampoline::ResourceRep(idx)
| Trampoline::ResourceDrop(idx) => *idx,
Trampoline::ResourceNew { ty, .. }
| Trampoline::ResourceRep { ty, .. }
| Trampoline::ResourceDrop { ty, .. } => *ty,
_ => unreachable!(),
})
.collect::<Vec<_>>();
Expand Down
36 changes: 18 additions & 18 deletions wasmtime/_bindings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2822,15 +2822,15 @@ class wasmtime_anyref(Structure):

_wasmtime_anyref_clone = dll.wasmtime_anyref_clone
_wasmtime_anyref_clone.restype = None
_wasmtime_anyref_clone.argtypes = [POINTER(wasmtime_context_t), POINTER(wasmtime_anyref_t), POINTER(wasmtime_anyref_t)]
def wasmtime_anyref_clone(context: Any, anyref: Any, out: Any) -> None:
return _wasmtime_anyref_clone(context, anyref, out) # type: ignore
_wasmtime_anyref_clone.argtypes = [POINTER(wasmtime_anyref_t), POINTER(wasmtime_anyref_t)]
def wasmtime_anyref_clone(anyref: Any, out: Any) -> None:
return _wasmtime_anyref_clone(anyref, out) # type: ignore

_wasmtime_anyref_unroot = dll.wasmtime_anyref_unroot
_wasmtime_anyref_unroot.restype = None
_wasmtime_anyref_unroot.argtypes = [POINTER(wasmtime_context_t), POINTER(wasmtime_anyref_t)]
def wasmtime_anyref_unroot(context: Any, ref: Any) -> None:
return _wasmtime_anyref_unroot(context, ref) # type: ignore
_wasmtime_anyref_unroot.argtypes = [POINTER(wasmtime_anyref_t)]
def wasmtime_anyref_unroot(ref: Any) -> None:
return _wasmtime_anyref_unroot(ref) # type: ignore

_wasmtime_anyref_from_raw = dll.wasmtime_anyref_from_raw
_wasmtime_anyref_from_raw.restype = None
Expand Down Expand Up @@ -2890,15 +2890,15 @@ def wasmtime_externref_data(context: Any, data: Any) -> int:

_wasmtime_externref_clone = dll.wasmtime_externref_clone
_wasmtime_externref_clone.restype = None
_wasmtime_externref_clone.argtypes = [POINTER(wasmtime_context_t), POINTER(wasmtime_externref_t), POINTER(wasmtime_externref_t)]
def wasmtime_externref_clone(context: Any, ref: Any, out: Any) -> None:
return _wasmtime_externref_clone(context, ref, out) # type: ignore
_wasmtime_externref_clone.argtypes = [POINTER(wasmtime_externref_t), POINTER(wasmtime_externref_t)]
def wasmtime_externref_clone(ref: Any, out: Any) -> None:
return _wasmtime_externref_clone(ref, out) # type: ignore

_wasmtime_externref_unroot = dll.wasmtime_externref_unroot
_wasmtime_externref_unroot.restype = None
_wasmtime_externref_unroot.argtypes = [POINTER(wasmtime_context_t), POINTER(wasmtime_externref_t)]
def wasmtime_externref_unroot(context: Any, ref: Any) -> None:
return _wasmtime_externref_unroot(context, ref) # type: ignore
_wasmtime_externref_unroot.argtypes = [POINTER(wasmtime_externref_t)]
def wasmtime_externref_unroot(ref: Any) -> None:
return _wasmtime_externref_unroot(ref) # type: ignore

_wasmtime_externref_from_raw = dll.wasmtime_externref_from_raw
_wasmtime_externref_from_raw.restype = None
Expand Down Expand Up @@ -2972,15 +2972,15 @@ class wasmtime_val(Structure):

_wasmtime_val_unroot = dll.wasmtime_val_unroot
_wasmtime_val_unroot.restype = None
_wasmtime_val_unroot.argtypes = [POINTER(wasmtime_context_t), POINTER(wasmtime_val_t)]
def wasmtime_val_unroot(context: Any, val: Any) -> None:
return _wasmtime_val_unroot(context, val) # type: ignore
_wasmtime_val_unroot.argtypes = [POINTER(wasmtime_val_t)]
def wasmtime_val_unroot(val: Any) -> None:
return _wasmtime_val_unroot(val) # type: ignore

_wasmtime_val_clone = dll.wasmtime_val_clone
_wasmtime_val_clone.restype = None
_wasmtime_val_clone.argtypes = [POINTER(wasmtime_context_t), POINTER(wasmtime_val_t), POINTER(wasmtime_val_t)]
def wasmtime_val_clone(context: Any, src: Any, dst: Any) -> None:
return _wasmtime_val_clone(context, src, dst) # type: ignore
_wasmtime_val_clone.argtypes = [POINTER(wasmtime_val_t), POINTER(wasmtime_val_t)]
def wasmtime_val_clone(src: Any, dst: Any) -> None:
return _wasmtime_val_clone(src, dst) # type: ignore

class wasmtime_caller(Structure):
pass
Expand Down
2 changes: 1 addition & 1 deletion wasmtime/_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def __call__(self, store: Storelike, *params: Any) -> Any:
raise WasmtimeError._from_ptr(error)
finally:
for i in range(0, params_set):
ffi.wasmtime_val_unroot(store._context(), byref(params_ptr[i]))
ffi.wasmtime_val_unroot(byref(params_ptr[i]))

results = []
for i in range(0, len(result_tys)):
Expand Down
4 changes: 2 additions & 2 deletions wasmtime/_globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def __init__(self, store: Storelike, ty: GlobalType, val: Any):
ty.ptr(),
byref(val),
byref(global_))
ffi.wasmtime_val_unroot(store._context(), byref(val))
ffi.wasmtime_val_unroot(byref(val))
if error:
raise WasmtimeError._from_ptr(error)
self._global = global_
Expand Down Expand Up @@ -57,7 +57,7 @@ def set_value(self, store: Storelike, val: Any) -> None:
"""
val = Val._convert_to_raw(store, self.type(store).content, val)
error = ffi.wasmtime_global_set(store._context(), byref(self._global), byref(val))
ffi.wasmtime_val_unroot(store._context(), byref(val))
ffi.wasmtime_val_unroot(byref(val))
if error:
raise WasmtimeError._from_ptr(error)

Expand Down
6 changes: 3 additions & 3 deletions wasmtime/_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def __init__(self, store: Store, ty: TableType, init: Any):

table = ffi.wasmtime_table_t()
error = ffi.wasmtime_table_new(store._context(), ty.ptr(), byref(init_val), byref(table))
ffi.wasmtime_val_unroot(store._context(), byref(init_val))
ffi.wasmtime_val_unroot(byref(init_val))
if error:
raise WasmtimeError._from_ptr(error)
self._table = table
Expand Down Expand Up @@ -53,7 +53,7 @@ def grow(self, store: Storelike, amt: int, init: Any) -> int:
init_val = Val._convert_to_raw(store, self.type(store).element, init)
prev = c_uint64(0)
error = ffi.wasmtime_table_grow(store._context(), byref(self._table), c_uint64(amt), byref(init_val), byref(prev))
ffi.wasmtime_val_unroot(store._context(), byref(init_val))
ffi.wasmtime_val_unroot(byref(init_val))
if error:
raise WasmtimeError._from_ptr(error)
return prev.value
Expand Down Expand Up @@ -96,7 +96,7 @@ def set(self, store: Store, idx: int, val: Any) -> None:
"""
value = Val._convert_to_raw(store, self.type(store).element, val)
error = ffi.wasmtime_table_set(store._context(), byref(self._table), idx, byref(value))
ffi.wasmtime_val_unroot(store._context(), byref(value))
ffi.wasmtime_val_unroot(byref(value))
if error:
raise WasmtimeError._from_ptr(error)

Expand Down
2 changes: 1 addition & 1 deletion wasmtime/_value.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def _from_raw(cls, store: 'Storelike', raw: wasmtime_val_t, owned: bool = True)
raise WasmtimeError("Unkown `wasmtime_valkind_t`: {}".format(raw.kind))

if owned:
wasmtime_val_unroot(store._context(), byref(raw))
wasmtime_val_unroot(byref(raw))

return Val(raw.kind, val)

Expand Down