Skip to content

Commit 4a52ebb

Browse files
authored
Bump to 7.0.0 (#136)
Also add a binding for `wasmtime_store_limiter`
1 parent e655f68 commit 4a52ebb

File tree

7 files changed

+95
-37
lines changed

7 files changed

+95
-37
lines changed

ci/download-wasmtime.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import urllib.request
1111
import zipfile
1212

13-
WASMTIME_VERSION = "v6.0.0"
13+
WASMTIME_VERSION = "v7.0.0"
1414

1515

1616
def main(platform, arch):

rust/Cargo.lock

Lines changed: 23 additions & 34 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/bindgen/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ heck = { version = "0.4", features = ["unicode"] }
1414
wit-component = "0.6"
1515
wit-parser = "0.6"
1616
indexmap = "1.0"
17-
wasmtime-environ = { version = "6.0.0", features = ['component-model'] }
17+
wasmtime-environ = { version = "7.0.0", features = ['component-model'] }
1818
wit-bindgen = { workspace = true, features = ['default'] }
1919

2020
[features]

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
with open("README.md", "r") as fh:
77
long_description = fh.read()
88

9-
version = "6.0.0"
9+
version = "7.0.0"
1010

1111
# Give unique version numbers to all commits so our publication-on-each commit
1212
# works on main

tests/test_store.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,27 @@ def test_fuel(self):
5555
assert(store.consume_fuel(1) == 1)
5656
with self.assertRaises(WasmtimeError):
5757
store.consume_fuel(2)
58+
59+
def test_limits(self):
60+
store = Store()
61+
Memory(store, MemoryType(Limits(1, None)))
62+
63+
store = Store()
64+
store.set_limits(memory_size=0)
65+
with self.assertRaises(WasmtimeError):
66+
Memory(store, MemoryType(Limits(1, None)))
67+
store.set_limits(memory_size=100000)
68+
Memory(store, MemoryType(Limits(1, None)))
69+
70+
store = Store()
71+
store.set_limits(table_elements=1)
72+
Table(store, TableType(ValType.funcref(), Limits(1, None)), None)
73+
with self.assertRaises(WasmtimeError):
74+
Table(store, TableType(ValType.funcref(), Limits(2, None)), None)
75+
76+
store = Store()
77+
store.set_limits(memory_size=200000)
78+
mem = Memory(store, MemoryType(Limits(1, None)))
79+
mem.grow(store, 1)
80+
with self.assertRaises(WasmtimeError):
81+
mem.grow(store, 100)

wasmtime/_bindings.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1959,6 +1959,12 @@ def wasi_config_inherit_stderr(config: Any) -> None:
19591959
def wasi_config_preopen_dir(config: Any, path: Any, guest_path: Any) -> bool:
19601960
return _wasi_config_preopen_dir(config, path, guest_path) # type: ignore
19611961

1962+
_wasi_config_preopen_socket = dll.wasi_config_preopen_socket
1963+
_wasi_config_preopen_socket.restype = c_bool
1964+
_wasi_config_preopen_socket.argtypes = [POINTER(wasi_config_t), c_uint32, POINTER(c_char)]
1965+
def wasi_config_preopen_socket(config: Any, fd_num: Any, host_port: Any) -> bool:
1966+
return _wasi_config_preopen_socket(config, fd_num, host_port) # type: ignore
1967+
19621968
class wasmtime_error(Structure):
19631969
pass
19641970

@@ -2207,6 +2213,12 @@ def wasmtime_store_new(engine: Any, data: Any, finalizer: Any) -> ctypes._Pointe
22072213
def wasmtime_store_context(store: Any) -> ctypes._Pointer:
22082214
return _wasmtime_store_context(store) # type: ignore
22092215

2216+
_wasmtime_store_limiter = dll.wasmtime_store_limiter
2217+
_wasmtime_store_limiter.restype = None
2218+
_wasmtime_store_limiter.argtypes = [POINTER(wasmtime_store_t), c_int64, c_int64, c_int64, c_int64, c_int64]
2219+
def wasmtime_store_limiter(store: Any, memory_size: Any, table_elements: Any, instances: Any, tables: Any, memories: Any) -> None:
2220+
return _wasmtime_store_limiter(store, memory_size, table_elements, instances, tables, memories) # type: ignore
2221+
22102222
_wasmtime_store_delete = dll.wasmtime_store_delete
22112223
_wasmtime_store_delete.restype = None
22122224
_wasmtime_store_delete.argtypes = [POINTER(wasmtime_store_t)]

wasmtime/_store.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,39 @@ def set_epoch_deadline(self, ticks_after_current: int) -> None:
111111
"""
112112
ffi.wasmtime_context_set_epoch_deadline(self._context, ticks_after_current)
113113

114+
def set_limits(self,
115+
memory_size: int = -1,
116+
table_elements: int = -1,
117+
instances: int = -1,
118+
tables: int = -1,
119+
memories: int = -1) -> None:
120+
"""
121+
Configures the limits of various items within this store.
122+
123+
* `memory_size` - the maximum size, in bytes, that linear memory is
124+
allowed to consume within this store. Setting this to a lower value
125+
will cause instantiation to fail if a module needs more memory.
126+
Additionally the `memory.grow` instruction will return -1 once this
127+
threshold is reached.
128+
129+
* `table_elements` - the maximum number of elements that can be stored
130+
within tables in this store. Currently each table element takes 8
131+
bytes.
132+
133+
* `instances` - the maximum number of WebAssembly instances that can
134+
be created.
135+
136+
* `tables` - the maximum number of WebAssembly tables that can
137+
be created.
138+
139+
* `memories` - the maximum number of WebAssembly linear memories that
140+
can be created.
141+
142+
If any limit is negative then the limit will not be set as a part of
143+
this invocation and it will be ignored.
144+
"""
145+
ffi.wasmtime_store_limiter(self._ptr, memory_size, table_elements, instances, tables, memories)
146+
114147
def __del__(self) -> None:
115148
if hasattr(self, '_ptr'):
116149
ffi.wasmtime_store_delete(self._ptr)

0 commit comments

Comments
 (0)