Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wasmedge 0.13.5 #2002

Merged
merged 6 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
10 changes: 9 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,15 @@ if (NOT DEFINED CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "")
endif ()

set(HUNTER_CONFIGURATION_TYPES ${CMAKE_BUILD_TYPE} CACHE STRING "")
if(NOT ${CMAKE_BUILD_TYPE} MATCHES "^(Debug|Release|RelWithDebInfo)$")
fatal_error("CMAKE_BUILD_TYPE is set to ${CMAKE_BUILD_TYPE} but should be one of [Debug, Release, RelWithDebInfo]")
endif()

if(${CMAKE_BUILD_TYPE} MATCHES "^RelWithDebInfo$")
set(HUNTER_CONFIGURATION_TYPES "Release" CACHE STRING "")
else()
set(HUNTER_CONFIGURATION_TYPES "${CMAKE_BUILD_TYPE}" CACHE STRING "")
turuslan marked this conversation as resolved.
Show resolved Hide resolved
endif()

set(CMAKE_TOOLCHAIN_FILE
"${CMAKE_SOURCE_DIR}/cmake/toolchain/cxx20.cmake"
Expand Down
3 changes: 2 additions & 1 deletion cmake/Hunter/config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ hunter_config(
if ("${WASM_COMPILER}" STREQUAL "WasmEdge")
hunter_config(
WasmEdge
VERSION 0.14.0-alpha.1-qdrvm4
URL https://github.com/qdrvm/WasmEdge/archive/refs/tags/0.13.5-qdrvm1.zip
SHA1 3637f5df6892a762606393940539c0dcb6e9c022
CMAKE_ARGS
WASMEDGE_BUILD_STATIC_LIB=ON
WASMEDGE_BUILD_SHARED_LIB=OFF
Expand Down
35 changes: 15 additions & 20 deletions core/runtime/wasm_edge/module_factory_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,26 +77,21 @@ namespace kagome::runtime::wasm_edge {
}

static outcome::result<WasmValue> convertValue(WasmEdge_Value v) {
if (WasmEdge_ValTypeIsEqual(v.Type, WasmEdge_ValTypeGenI32())) {
return WasmEdge_ValueGetI32(v);
}
if (WasmEdge_ValTypeIsEqual(v.Type, WasmEdge_ValTypeGenI64())) {
return WasmEdge_ValueGetI64(v);
}
if (WasmEdge_ValTypeIsEqual(v.Type, WasmEdge_ValTypeGenF32())) {
return WasmEdge_ValueGetF32(v);
}
if (WasmEdge_ValTypeIsEqual(v.Type, WasmEdge_ValTypeGenF64())) {
return WasmEdge_ValueGetF64(v);
}
if (WasmEdge_ValTypeIsEqual(v.Type, WasmEdge_ValTypeGenV128())) {
return Error::INVALID_VALUE_TYPE;
}
if (WasmEdge_ValTypeIsEqual(v.Type, WasmEdge_ValTypeGenFuncRef())) {
return Error::INVALID_VALUE_TYPE;
}
if (WasmEdge_ValTypeIsEqual(v.Type, WasmEdge_ValTypeGenExternRef())) {
return Error::INVALID_VALUE_TYPE;
switch (v.Type) {
case WasmEdge_ValType_I32:
return WasmEdge_ValueGetI32(v);
case WasmEdge_ValType_I64:
return WasmEdge_ValueGetI64(v);
case WasmEdge_ValType_F32:
return WasmEdge_ValueGetF32(v);
case WasmEdge_ValType_F64:
return WasmEdge_ValueGetF64(v);
case WasmEdge_ValType_V128:
return Error::INVALID_VALUE_TYPE;
case WasmEdge_ValType_FuncRef:
return Error::INVALID_VALUE_TYPE;
case WasmEdge_ValType_ExternRef:
return Error::INVALID_VALUE_TYPE;
}
BOOST_UNREACHABLE_RETURN({});
}
Expand Down
19 changes: 8 additions & 11 deletions core/runtime/wasm_edge/register_host_api.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,32 +20,32 @@ namespace kagome::runtime::wasm_edge {

template <>
WasmEdge_ValType get_wasm_type<int32_t>() {
return WasmEdge_ValTypeGenI32();
return WasmEdge_ValType_I32;
}

template <>
WasmEdge_ValType get_wasm_type<uint32_t>() {
return WasmEdge_ValTypeGenI32();
return WasmEdge_ValType_I32;
}

template <>
WasmEdge_ValType get_wasm_type<int64_t>() {
return WasmEdge_ValTypeGenI64();
return WasmEdge_ValType_I64;
}

template <>
WasmEdge_ValType get_wasm_type<uint64_t>() {
return WasmEdge_ValTypeGenI64();
return WasmEdge_ValType_I64;
}

template <>
WasmEdge_ValType get_wasm_type<float>() {
return WasmEdge_ValTypeGenF32();
return WasmEdge_ValType_F32;
}

template <>
WasmEdge_ValType get_wasm_type<double>() {
return WasmEdge_ValTypeGenF64();
return WasmEdge_ValType_F64;
}

template <typename T>
Expand Down Expand Up @@ -158,10 +158,7 @@ namespace kagome::runtime::wasm_edge {
WasmEdge_FunctionTypeDelete(type);

auto name_str = WasmEdge_StringCreateByBuffer(name.data(), name.size());
WasmEdge_ModuleInstanceAddFunction(
module,
name_str,
instance);
WasmEdge_ModuleInstanceAddFunction(module, name_str, instance);
WasmEdge_StringDelete(name_str);
}

Expand Down Expand Up @@ -204,7 +201,7 @@ namespace kagome::runtime::wasm_edge {
std::string_view name,
std::span<WasmEdge_ValType> rets,
std::span<WasmEdge_ValType> args) {
register_method(stub, module, (void*)name.data(), name, rets, args);
register_method(stub, module, (void *)name.data(), name, rets, args);
}

#define REGISTER_HOST_METHOD(Ret, name, ...) \
Expand Down
6 changes: 4 additions & 2 deletions core/utils/pool_handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ namespace kagome {
~PoolHandler() = default;

void start() {
started_ = true;
is_active_.store(true);
}

Expand All @@ -43,8 +44,8 @@ namespace kagome {
void execute(F &&func) {
if (is_active_.load(std::memory_order_acquire)) {
ioc_->post(std::forward<F>(func));
} else {
throw std::logic_error{"PoolHandler lost callback"};
} else if (not started_) {
throw std::logic_error{"PoolHandler lost callback before start()"};
}
}

Expand All @@ -62,6 +63,7 @@ namespace kagome {

private:
std::atomic_bool is_active_;
std::atomic_bool started_ = false;
std::shared_ptr<boost::asio::io_context> ioc_;
};

Expand Down
Loading