Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Restore previous version of ext_sandbox_invoke #236

Merged
merged 3 commits into from
Jun 25, 2018
Merged
Show file tree
Hide file tree
Changes from 2 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
286 changes: 286 additions & 0 deletions demo/runtime/wasm/Cargo.lock

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
286 changes: 286 additions & 0 deletions polkadot/runtime/wasm/Cargo.lock

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
20 changes: 19 additions & 1 deletion substrate/executor/src/wasm_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,25 @@ impl_function_executor!(this: FunctionExecutor<'e, E>,
this.sandbox_store.instance_teardown(instance_idx)?;
Ok(())
},
ext_sandbox_invoke(instance_idx: u32, export_ptr: *const u8, export_len: usize, args_ptr: *const u8, args_len: usize, return_val_ptr: *const u8, return_val_len: usize, state: usize) -> u32 => {
ext_sandbox_invoke(instance_idx: u32, export_ptr: *const u8, export_len: usize, state: usize) -> u32 => {
trace!(target: "runtime-sandbox", "invoke, instance_idx={}", instance_idx);
let export = this.memory.get(export_ptr, export_len as usize)
.map_err(|_| DummyUserError)
.and_then(|b|
String::from_utf8(b)
.map_err(|_| DummyUserError)
)?;

let instance = this.sandbox_store.instance(instance_idx)?;
let result = instance.invoke(&export, &[], this, state);
match result {
Ok(None) => Ok(sandbox_primitives::ERR_OK),
Ok(_) => unimplemented!(),
Err(_) => Ok(sandbox_primitives::ERR_EXECUTION),
}
},
// TODO: Remove the old 'ext_sandbox_invoke' and rename this to it.
ext_sandbox_invoke_poc2(instance_idx: u32, export_ptr: *const u8, export_len: usize, args_ptr: *const u8, args_len: usize, return_val_ptr: *const u8, return_val_len: usize, state: usize) -> u32 => {
use codec::Slicable;

trace!(target: "runtime-sandbox", "invoke, instance_idx={}", instance_idx);
Expand Down
Binary file not shown.
Binary file not shown.
5 changes: 3 additions & 2 deletions substrate/runtime-sandbox/without_std.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ mod ffi {
imports_len: usize,
state: usize,
) -> u32;
pub fn ext_sandbox_invoke(
// TODO: Rename it back to 'ext_sandbox_invoke'.
pub fn ext_sandbox_invoke_poc2(
instance_idx: u32,
export_ptr: *const u8,
export_len: usize,
Expand Down Expand Up @@ -271,7 +272,7 @@ impl<T> Instance<T> {
let mut return_val = vec![0u8; sandbox_primitives::ReturnValue::ENCODED_MAX_SIZE];

let result = unsafe {
ffi::ext_sandbox_invoke(
ffi::ext_sandbox_invoke_poc2(
self.instance_idx,
name.as_ptr(),
name.len(),
Expand Down
Loading