Skip to content

Commit

Permalink
[runtime/vm_runtime] Add even more documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
y committed Nov 23, 2023
1 parent 4f29180 commit 6cff3c3
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/runtime/vm_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,11 @@ impl Runtime {
debug!(target: "runtime::vm_runtime", "Getting {} function", section.name());
let entrypoint = self.instance.exports.get_function(section.name())?;

// Call the entrypoint. On success, `call` returns a WASM [`Value`]. (The
// value may be empty.) This value functions similarly to a UNIX exit code.
// The following section is intended to unwrap the exit code and handle fatal
// errors in the Wasmer runtime. The value itself and the return data of the
// contract are processed later.
debug!(target: "runtime::vm_runtime", "Executing wasm");
let ret = match entrypoint.call(&mut self.store, &[Value::I32(0_i32)]) {
Ok(retvals) => {
Expand All @@ -365,16 +370,16 @@ impl Runtime {

debug!(target: "runtime::vm_runtime", "wasm executed successfully");

// Move the contract's return data into `retdata`.
let env_mut = self.ctx.as_mut(&mut self.store);
env_mut.contract_section = ContractSection::Null;
let retdata = match env_mut.contract_return_data.take() {
Some(retdata) => retdata,
None => Vec::new(),
};

// Determine the return value of the wasm function. At this stage,
// it is assumed that the contract completed successful given
// that validation has been performed above.
// Determine the return value of the contract call. If ret is empty,
// assumed that the contract call was successful.
let retval: i64 = match ret.len() {
0 => {
// Return a success value if there is no return value from
Expand Down

0 comments on commit 6cff3c3

Please sign in to comment.