This is an automated email from the ASF dual-hosted git repository.

mssun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-teaclave.git


The following commit(s) were added to refs/heads/master by this push:
     new ffa32bc  Add deinstantiate for WAMR executor (#518)
ffa32bc is described below

commit ffa32bcc353d8f767659eb1948cd22aae9306135
Author: Hongbo <[email protected]>
AuthorDate: Fri Jul 2 13:11:32 2021 -0700

    Add deinstantiate for WAMR executor (#518)
---
 README.md            |  1 +
 docs/README.md       |  1 +
 executor/src/wamr.rs | 10 ++++++++--
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index fa4d187..7230c70 100644
--- a/README.md
+++ b/README.md
@@ -40,6 +40,7 @@ platform, making computation on privacy-sensitive data safe 
and simple.
 - [Write Functions in Python](docs/functions-in-python.md)
 - [How to Add Built-in Functions](docs/builtin-functions.md)
 - [Deploying Teaclave on Azure Confidential Computing 
VM](docs/azure-confidential-computing.md)
+- [Executing WebAssembly in Teaclave](docs/executing-wasm.md)
 
 ### Design
 
diff --git a/docs/README.md b/docs/README.md
index e7f7c55..d916123 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -10,6 +10,7 @@ permalink: /docs/
 - [Function in Python](functions-in-python.md)
 - [How to Add Built-in Functions](builtin-functions.md)
 - [Deploying Teaclave on Azure Confidential Computing 
VM](azure-confidential-computing.md)
+- [Executing WebAssembly in Teaclave](executing-wasm.md)
 
 ## Design
 
diff --git a/executor/src/wamr.rs b/executor/src/wamr.rs
index f569b14..8c43e38 100644
--- a/executor/src/wamr.rs
+++ b/executor/src/wamr.rs
@@ -88,6 +88,8 @@ extern "C" {
 
     fn wasm_runtime_get_exception(module_inst: *const c_void) -> *const c_char;
 
+    fn wasm_runtime_deinstantiate(module_inst: *const c_void);
+
 }
 
 #[derive(Default)]
@@ -225,7 +227,7 @@ impl TeaclaveExecutor for WAMicroRuntime {
             .map(|addr| unsafe { wasm_runtime_module_free(module_instance, 
*addr) });
         unsafe { wasm_runtime_module_free(module_instance, func_argv) };
 
-        if result {
+        let result = if result {
             let rv = wasm_argv[0] as c_int;
             log::debug!(
                 "IN WAMicroRuntime::execute after `wasm_runtime_call_wasm`, 
{:?}",
@@ -236,7 +238,11 @@ impl TeaclaveExecutor for WAMicroRuntime {
             let error = unsafe { 
CStr::from_ptr(wasm_runtime_get_exception(module_instance)) };
             log::debug!("WAMR ERROR: {:?}", error);
             Ok(error.to_str().unwrap().to_string())
-        }
+        };
+
+        unsafe { wasm_runtime_deinstantiate(module_instance) };
+
+        result
     }
 }
 

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to