Skip to content

Commit 1ccaec7

Browse files
lum1n0usLe Yao
authored andcommitted
dont use smart pointers to transfer vector data
since `wasm_functype_new` will transfer data ownerships of both `params` and `resutls` to the new `wasm_functype_t`, we should not - delete `wasm_valtype_t` of `wasm_valtype_vec_t` - use `wasm_functype_delete` to release members of `wasm_functype_t` a good example will be found here: [multi.c](https://github.com/WebAssembly/wasm-c-api/blob/master/example/multi.c) another thing is the runtime() should return a string as same as the one in envoy.yaml update wamr code release to 0.1-beta Signed-off-by: liam <[email protected]>
1 parent 51c47c4 commit 1ccaec7

File tree

3 files changed

+15
-17
lines changed

3 files changed

+15
-17
lines changed

bazel/external/wamr.BUILD

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ filegroup(
1313
cmake(
1414
name = "libiwasm",
1515
cache_entries = {
16-
"CMAKE_EXPORT_COMPILE_COMMANDS": "On",
1716
"WAMR_BUILD_AOT": "0",
1817
"WAMR_BUILD_SIMD": "0",
18+
"WAMR_BUILD_MULTI_MODULE": "1",
19+
"WAMR_BUILD_LIBC_WASI": "0",
1920
},
2021
lib_source = ":srcs",
2122
out_shared_libs = ["libiwasm.so"],
22-
working_directory = "product-mini/platforms/linux"
2323
)

bazel/repositories.bzl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ def proxy_wasm_cpp_host_repositories():
3939
http_archive(
4040
name = "wamr",
4141
build_file = "@proxy_wasm_cpp_host//bazel/external:wamr.BUILD",
42-
sha256 = "f819b9ec866a12086233e578044dd8297e6be86f0f17807b16124f78a3652d4f",
43-
url = "https://github.com/lum1n0us/wasm-micro-runtime/releases/download/WAMR-01-29-2021/source.zip",
42+
sha256 = "3f9c993cf81a573cd733b7d97fa15ed757351881e502aad22ff873371ee55202",
43+
strip_prefix = "wasm-micro-runtime-0.1-beta",
44+
url = "https://github.com/lum1n0us/wasm-micro-runtime/archive/refs/tags/v0.1-beta.tar.gz",
4445
)
4546

4647
http_archive(

src/wamr/wamr.cc

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ class Wamr : public WasmVm {
5656
public:
5757
Wamr() {}
5858

59-
std::string_view runtime() override { return "wamr"; }
59+
std::string_view runtime() override { return "envoy.wasm.runtime.wamr"; }
6060
std::string_view getPrecompiledSectionName() override { return ""; }
6161

6262
Cloneable cloneable() override { return Cloneable::NotCloneable; }
63-
std::unique_ptr<WasmVm> clone() override { return nullptr; };
63+
std::unique_ptr<WasmVm> clone() override { return nullptr; }
6464

6565
AbiVersion getAbiVersion() override;
6666

@@ -433,9 +433,6 @@ void convertArgsTupleToValTypesImpl(wasm_valtype_vec_t *types, std::index_sequen
433433
auto ps = std::array<wasm_valtype_t *, std::tuple_size<T>::value>{
434434
convertArgToValTypePtr<typename std::tuple_element<I, T>::type>()...};
435435
wasm_valtype_vec_new(types, size, ps.data());
436-
for (auto i = ps.begin(); i < ps.end(); i++) { // TODO(mathetake): better way to handle?
437-
wasm_valtype_delete(*i);
438-
}
439436
}
440437

441438
template <typename T, typename Is = std::make_index_sequence<std::tuple_size<T>::value>>
@@ -444,17 +441,17 @@ void convertArgsTupleToValTypes(wasm_valtype_vec_t *types) {
444441
}
445442

446443
template <typename R, typename T> WasmFunctypePtr newWasmNewFuncType() {
447-
WasmValtypeVec params, results;
448-
convertArgsTupleToValTypes<T>(params.get());
449-
convertArgsTupleToValTypes<std::tuple<R>>(results.get());
450-
return wasm_functype_new(params.get(), results.get());
444+
wasm_valtype_vec_t params, results;
445+
convertArgsTupleToValTypes<T>(&params);
446+
convertArgsTupleToValTypes<std::tuple<R>>(&results);
447+
return wasm_functype_new(&params, &results);
451448
}
452449

453450
template <typename T> WasmFunctypePtr newWasmNewFuncType() {
454-
WasmValtypeVec params, results;
455-
convertArgsTupleToValTypes<T>(params.get());
456-
convertArgsTupleToValTypes<std::tuple<>>(results.get());
457-
return wasm_functype_new(params.get(), results.get());
451+
wasm_valtype_vec_t params, results;
452+
convertArgsTupleToValTypes<T>(&params);
453+
convertArgsTupleToValTypes<std::tuple<>>(&results);
454+
return wasm_functype_new(&params, &results);
458455
}
459456

460457
template <typename... Args>

0 commit comments

Comments
 (0)