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 @@
39.0.0
40.0.0
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 = "v39.0.0"
WASMTIME_VERSION = "v40.0.0"


def main(platform, arch):
Expand Down
14 changes: 9 additions & 5 deletions tests/test_shared_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@

from wasmtime import *

def engine_with_shared_memory() -> Engine:
config = Config()
config.shared_memory = True
return Engine(config)

class TestSharedMemory(unittest.TestCase):
def test_new(self):
engine = Store().engine
engine = engine_with_shared_memory()
memory_type = MemoryType(Limits(1, 2), is_64=False, shared=True)
assert(not memory_type.is_64)
shared_memory = SharedMemory(engine, memory_type)
Expand All @@ -18,7 +22,7 @@ def test_new(self):
self.assertTrue(isinstance(shared_memory.type(), MemoryType))

def test_grow(self):
engine = Store().engine
engine = engine_with_shared_memory()
memory_type = MemoryType(Limits(1, 2), shared=True)
shared_memory = SharedMemory(engine, memory_type)
assert(shared_memory.grow(1) == 1)
Expand All @@ -27,7 +31,7 @@ def test_grow(self):
shared_memory.grow(1)

def test_errors(self):
engine = Store().engine
engine = engine_with_shared_memory()
ty = MemoryType(Limits(1, 2), shared=True)
with self.assertRaises(AttributeError):
SharedMemory(1, ty) # type: ignore
Expand All @@ -44,13 +48,13 @@ def test_shared_memory_type_works_if_min_max_i64_is_set(self):
assert(ty.limits.min == 0x100000000)
assert(ty.limits.max == 0x100000000)
assert(ty.is_64)

def test_shared_memory_type_fails_if_is_too_large(self):
with self.assertRaises(WasmtimeError):
MemoryType(Limits(1, 0x100000000), shared=True)

def test_memory_type_has_to_be_shared(self):
engine = Store().engine
engine = engine_with_shared_memory()
ty = MemoryType(Limits(1, 2))
with self.assertRaises(WasmtimeError):
SharedMemory(engine, ty)
18 changes: 15 additions & 3 deletions wasmtime/_bindings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2087,6 +2087,12 @@ def wasmtime_config_max_wasm_stack_set(arg0: Any, arg1: Any) -> None:
def wasmtime_config_wasm_threads_set(arg0: Any, arg1: Any) -> None:
return _wasmtime_config_wasm_threads_set(arg0, arg1) # type: ignore

_wasmtime_config_shared_memory_set = dll.wasmtime_config_shared_memory_set
_wasmtime_config_shared_memory_set.restype = None
_wasmtime_config_shared_memory_set.argtypes = [ctypes.POINTER(wasm_config_t), ctypes.c_bool]
def wasmtime_config_shared_memory_set(arg0: Any, arg1: Any) -> None:
return _wasmtime_config_shared_memory_set(arg0, arg1) # type: ignore

_wasmtime_config_wasm_tail_call_set = dll.wasmtime_config_wasm_tail_call_set
_wasmtime_config_wasm_tail_call_set.restype = None
_wasmtime_config_wasm_tail_call_set.argtypes = [ctypes.POINTER(wasm_config_t), ctypes.c_bool]
Expand Down Expand Up @@ -3318,9 +3324,9 @@ class wasmtime_guestprofiler_modules(ctypes.Structure):

_wasmtime_guestprofiler_new = dll.wasmtime_guestprofiler_new
_wasmtime_guestprofiler_new.restype = ctypes.POINTER(wasmtime_guestprofiler_t)
_wasmtime_guestprofiler_new.argtypes = [ctypes.POINTER(wasm_name_t), ctypes.c_uint64, ctypes.POINTER(wasmtime_guestprofiler_modules_t), ctypes.c_size_t]
def wasmtime_guestprofiler_new(module_name: Any, interval_nanos: Any, modules: Any, modules_len: Any) -> ctypes._Pointer:
return _wasmtime_guestprofiler_new(module_name, interval_nanos, modules, modules_len) # type: ignore
_wasmtime_guestprofiler_new.argtypes = [ctypes.POINTER(wasm_engine_t), ctypes.POINTER(wasm_name_t), ctypes.c_uint64, ctypes.POINTER(wasmtime_guestprofiler_modules_t), ctypes.c_size_t]
def wasmtime_guestprofiler_new(engine: Any, module_name: Any, interval_nanos: Any, modules: Any, modules_len: Any) -> ctypes._Pointer:
return _wasmtime_guestprofiler_new(engine, module_name, interval_nanos, modules, modules_len) # type: ignore

_wasmtime_guestprofiler_sample = dll.wasmtime_guestprofiler_sample
_wasmtime_guestprofiler_sample.restype = None
Expand Down Expand Up @@ -3966,6 +3972,12 @@ def wasmtime_component_func_type_clone(ty: Any) -> ctypes._Pointer:
def wasmtime_component_func_type_delete(ty: Any) -> None:
return _wasmtime_component_func_type_delete(ty) # type: ignore

_wasmtime_component_func_type_async = dll.wasmtime_component_func_type_async
_wasmtime_component_func_type_async.restype = ctypes.c_bool
_wasmtime_component_func_type_async.argtypes = [ctypes.POINTER(wasmtime_component_func_type_t)]
def wasmtime_component_func_type_async(ty: Any) -> bool:
return _wasmtime_component_func_type_async(ty) # type: ignore

_wasmtime_component_func_type_param_count = dll.wasmtime_component_func_type_param_count
_wasmtime_component_func_type_param_count.restype = ctypes.c_size_t
_wasmtime_component_func_type_param_count.argtypes = [ctypes.POINTER(wasmtime_component_func_type_t)]
Expand Down
11 changes: 11 additions & 0 deletions wasmtime/_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,3 +278,14 @@ def parallel_compilation(self, enable: bool) -> None:
if not isinstance(enable, bool):
raise TypeError('expected a bool')
ffi.wasmtime_config_parallel_compilation_set(self.ptr(), enable)

@setter_property
def shared_memory(self, enable: bool) -> None:
"""
Configures whether shared memories can be created.

This is disabled by default.
"""
if not isinstance(enable, bool):
raise TypeError('expected a bool')
ffi.wasmtime_config_shared_memory_set(self.ptr(), enable)