mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 08:47:57 +00:00
Update wasmtime to 0.29.0 (#9552)
* Start
* Move to ctx
* Make it compile for now
* More work
* Get rid off state-holder
* Use less Refcells
* 🤦
* Don't use RefCell
* Use names for parameters
* Fixes after merge
* Fixes after merge
* Review feedback
* FMT
This commit is contained in:
@@ -40,7 +40,7 @@ fn memory_consumption_compiled() {
|
||||
|
||||
let runtime = mk_test_runtime(WasmExecutionMethod::Compiled, 1024);
|
||||
|
||||
let instance = runtime.new_instance().unwrap();
|
||||
let mut instance = runtime.new_instance().unwrap();
|
||||
let heap_base = instance
|
||||
.get_global_const("__heap_base")
|
||||
.expect("`__heap_base` is valid")
|
||||
|
||||
@@ -467,7 +467,7 @@ test_wasm_execution!(returns_mutable_static);
|
||||
fn returns_mutable_static(wasm_method: WasmExecutionMethod) {
|
||||
let runtime = mk_test_runtime(wasm_method, 1024);
|
||||
|
||||
let instance = runtime.new_instance().unwrap();
|
||||
let mut instance = runtime.new_instance().unwrap();
|
||||
let res = instance.call_export("returns_mutable_static", &[0]).unwrap();
|
||||
assert_eq!(33, u64::decode(&mut &res[..]).unwrap());
|
||||
|
||||
@@ -482,7 +482,7 @@ test_wasm_execution!(returns_mutable_static_bss);
|
||||
fn returns_mutable_static_bss(wasm_method: WasmExecutionMethod) {
|
||||
let runtime = mk_test_runtime(wasm_method, 1024);
|
||||
|
||||
let instance = runtime.new_instance().unwrap();
|
||||
let mut instance = runtime.new_instance().unwrap();
|
||||
let res = instance.call_export("returns_mutable_static_bss", &[0]).unwrap();
|
||||
assert_eq!(1, u64::decode(&mut &res[..]).unwrap());
|
||||
|
||||
@@ -508,7 +508,7 @@ fn restoration_of_globals(wasm_method: WasmExecutionMethod) {
|
||||
const REQUIRED_MEMORY_PAGES: u64 = 32;
|
||||
|
||||
let runtime = mk_test_runtime(wasm_method, REQUIRED_MEMORY_PAGES);
|
||||
let instance = runtime.new_instance().unwrap();
|
||||
let mut instance = runtime.new_instance().unwrap();
|
||||
|
||||
// On the first invocation we allocate approx. 768KB (75%) of stack and then trap.
|
||||
let res = instance.call_export("allocates_huge_stack_array", &true.encode());
|
||||
@@ -522,7 +522,7 @@ fn restoration_of_globals(wasm_method: WasmExecutionMethod) {
|
||||
test_wasm_execution!(interpreted_only heap_is_reset_between_calls);
|
||||
fn heap_is_reset_between_calls(wasm_method: WasmExecutionMethod) {
|
||||
let runtime = mk_test_runtime(wasm_method, 1024);
|
||||
let instance = runtime.new_instance().unwrap();
|
||||
let mut instance = runtime.new_instance().unwrap();
|
||||
|
||||
let heap_base = instance
|
||||
.get_global_const("__heap_base")
|
||||
|
||||
@@ -163,7 +163,7 @@ impl WasmExecutor {
|
||||
where
|
||||
F: FnOnce(
|
||||
AssertUnwindSafe<&Arc<dyn WasmModule>>,
|
||||
AssertUnwindSafe<&dyn WasmInstance>,
|
||||
AssertUnwindSafe<&mut dyn WasmInstance>,
|
||||
Option<&RuntimeVersion>,
|
||||
AssertUnwindSafe<&mut dyn Externalities>,
|
||||
) -> Result<Result<R>>,
|
||||
@@ -217,7 +217,7 @@ impl WasmExecutor {
|
||||
.new_instance()
|
||||
.map_err(|e| format!("Failed to create instance: {:?}", e))?;
|
||||
|
||||
let instance = AssertUnwindSafe(instance);
|
||||
let mut instance = AssertUnwindSafe(instance);
|
||||
let mut ext = AssertUnwindSafe(ext);
|
||||
let module = AssertUnwindSafe(module);
|
||||
|
||||
@@ -283,7 +283,7 @@ impl CodeExecutor for WasmExecutor {
|
||||
runtime_code,
|
||||
ext,
|
||||
false,
|
||||
|module, instance, _onchain_version, mut ext| {
|
||||
|module, mut instance, _onchain_version, mut ext| {
|
||||
with_externalities_safe(&mut **ext, move || {
|
||||
preregister_builtin_ext(module.clone());
|
||||
instance.call_export(method, data).map(NativeOrEncoded::Encoded)
|
||||
@@ -438,7 +438,7 @@ impl RuntimeSpawn for RuntimeInstanceSpawn {
|
||||
// pool of instances should be used.
|
||||
//
|
||||
// https://github.com/paritytech/substrate/issues/7354
|
||||
let instance =
|
||||
let mut instance =
|
||||
module.new_instance().expect("Failed to create new instance from module");
|
||||
|
||||
instance
|
||||
@@ -525,7 +525,7 @@ impl<D: NativeExecutionDispatch + 'static> CodeExecutor for NativeElseWasmExecut
|
||||
runtime_code,
|
||||
ext,
|
||||
false,
|
||||
|module, instance, onchain_version, mut ext| {
|
||||
|module, mut instance, onchain_version, mut ext| {
|
||||
let onchain_version =
|
||||
onchain_version.ok_or_else(|| Error::ApiError("Unknown version".into()))?;
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ impl VersionedRuntime {
|
||||
where
|
||||
F: FnOnce(
|
||||
&Arc<dyn WasmModule>,
|
||||
&dyn WasmInstance,
|
||||
&mut dyn WasmInstance,
|
||||
Option<&RuntimeVersion>,
|
||||
&mut dyn Externalities,
|
||||
) -> Result<R, Error>,
|
||||
@@ -90,12 +90,12 @@ impl VersionedRuntime {
|
||||
|
||||
match instance {
|
||||
Some((index, mut locked)) => {
|
||||
let (instance, new_inst) = locked
|
||||
let (mut instance, new_inst) = locked
|
||||
.take()
|
||||
.map(|r| Ok((r, false)))
|
||||
.unwrap_or_else(|| self.module.new_instance().map(|i| (i, true)))?;
|
||||
|
||||
let result = f(&self.module, &*instance, self.version.as_ref(), ext);
|
||||
let result = f(&self.module, &mut *instance, self.version.as_ref(), ext);
|
||||
if let Err(e) = &result {
|
||||
if new_inst {
|
||||
log::warn!(
|
||||
@@ -129,9 +129,9 @@ impl VersionedRuntime {
|
||||
log::warn!(target: "wasm-runtime", "Ran out of free WASM instances");
|
||||
|
||||
// Allocate a new instance
|
||||
let instance = self.module.new_instance()?;
|
||||
let mut instance = self.module.new_instance()?;
|
||||
|
||||
f(&self.module, &*instance, self.version.as_ref(), ext)
|
||||
f(&self.module, &mut *instance, self.version.as_ref(), ext)
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -213,7 +213,7 @@ impl RuntimeCache {
|
||||
where
|
||||
F: FnOnce(
|
||||
&Arc<dyn WasmModule>,
|
||||
&dyn WasmInstance,
|
||||
&mut dyn WasmInstance,
|
||||
Option<&RuntimeVersion>,
|
||||
&mut dyn Externalities,
|
||||
) -> Result<R, Error>,
|
||||
|
||||
Reference in New Issue
Block a user