From ed14012712f0fca0464d3a6bc04a711d4cc72084 Mon Sep 17 00:00:00 2001 From: Zoltan Herczeg Date: Mon, 18 May 2026 09:52:51 +0000 Subject: [PATCH] Rework default function types Make it part of the Store. Types are allocated when needed, and also reused by TypeStore which reduces memory consumption. --- src/runtime/ComponentInstance.cpp | 9 +- src/runtime/ComponentInstance.h | 8 +- src/runtime/DefinedFunctionTypes.h | 342 ----------------------------- src/runtime/ObjectType.h | 4 +- src/runtime/Store.cpp | 215 ++++++++++++++++++ src/runtime/Store.h | 40 ++++ src/shell/Shell.cpp | 53 +++-- src/wasi/WASI.cpp | 6 +- src/wasi/WASI.h | 4 +- src/wasi/WASI02.cpp | 42 ++-- src/wasi/WASI02.h | 3 +- 11 files changed, 316 insertions(+), 410 deletions(-) delete mode 100644 src/runtime/DefinedFunctionTypes.h diff --git a/src/runtime/ComponentInstance.cpp b/src/runtime/ComponentInstance.cpp index d1494a2e0..fbd9534c2 100644 --- a/src/runtime/ComponentInstance.cpp +++ b/src/runtime/ComponentInstance.cpp @@ -16,7 +16,6 @@ #include "Walrus.h" #include "runtime/ComponentInstance.h" -#include "runtime/DefinedFunctionTypes.h" #include "runtime/Instance.h" #include "runtime/Global.h" #include "runtime/Memory.h" @@ -507,7 +506,7 @@ ComponentInstance* ComponentInstance::InstantiateContext::instantiate(Component* break; } case ComponentDeclaration::CanonResourceDrop: { - instance->m_coreFuncs.push_back(CanonFunction::createCanonFunction(m_store, m_functionTypes[DefinedFunctionTypes::I32R], CanonFunction::ResourceDrop)); + instance->m_coreFuncs.push_back(CanonFunction::createCanonFunction(m_store, m_store->getDefinedFunctionType(Store::I32R), CanonFunction::ResourceDrop)); break; } case ComponentDeclaration::ImportKind: { @@ -540,7 +539,7 @@ ComponentInstance* ComponentInstance::InstantiateContext::instantiate(Component* #ifdef ENABLE_WASI if (!success && external.sort == ComponentSort::Instance) { - ComponentInstance* importedInstance = wasi02LoadInstance(m_store, m_functionTypes, external.name); + ComponentInstance* importedInstance = wasi02LoadInstance(m_store, external.name); if (importedInstance != nullptr) { instance->m_instances.push_back(importedInstance); success = true; @@ -565,9 +564,9 @@ ComponentInstance* ComponentInstance::InstantiateContext::instantiate(Component* return instance; } -ComponentInstance* ComponentInstance::instantiate(ExecutionState& state, Store* store, DefinedFunctionTypes& functionTypes, Component* component) +ComponentInstance* ComponentInstance::instantiate(ExecutionState& state, Store* store, Component* component) { - InstantiateContext context(state, store, functionTypes); + InstantiateContext context(state, store); return context.instantiate(component, nullptr, nullptr); } diff --git a/src/runtime/ComponentInstance.h b/src/runtime/ComponentInstance.h index 867851a1a..63762d755 100644 --- a/src/runtime/ComponentInstance.h +++ b/src/runtime/ComponentInstance.h @@ -331,15 +331,13 @@ class ComponentResourceRep : public ComponentResource { }; }; -class DefinedFunctionTypes; - class ComponentInstance : public Object { #ifdef ENABLE_WASI friend class ComponentInstanceWasi02; #endif /* ENABLE_WASI */ public: - static ComponentInstance* instantiate(ExecutionState& state, Store* store, DefinedFunctionTypes& functionTypes, Component* component); + static ComponentInstance* instantiate(ExecutionState& state, Store* store, Component* component); ~ComponentInstance(); @@ -376,10 +374,9 @@ class ComponentInstance : public Object { class InstantiateContext { public: - InstantiateContext(ExecutionState& state, Store* store, DefinedFunctionTypes& functionTypes) + InstantiateContext(ExecutionState& state, Store* store) : m_state(state) , m_store(store) - , m_functionTypes(functionTypes) { } @@ -388,7 +385,6 @@ class ComponentInstance : public Object { private: ExecutionState& m_state; Store* m_store; - DefinedFunctionTypes& m_functionTypes; }; static constexpr uint32_t FirstHandleIndex = 1; diff --git a/src/runtime/DefinedFunctionTypes.h b/src/runtime/DefinedFunctionTypes.h deleted file mode 100644 index 683d82f09..000000000 --- a/src/runtime/DefinedFunctionTypes.h +++ /dev/null @@ -1,342 +0,0 @@ -/* - * Copyright (c) 2023-present Samsung Electronics Co., Ltd - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __WalrusDefinedFunctionTypes__ -#define __WalrusDefinedFunctionTypes__ - -#include "Walrus.h" - -namespace Walrus { - -class DefinedFunctionTypes { - MAKE_STACK_ALLOCATED(); - -public: - enum Index : uint8_t { - // The R is meant to represent the results, after R are the result types. - NONE = 0, - I32R, - I32I32R, - I32I32I32I32R, - I32_RI32, - I32I32_RI32, - I32I64I32_RI32, - I32I32I32_RI32, - I32I32I32I32_RI32, - I32I64I32I32_RI32, - I32I64I64I32_RI32, - I32I32I32I32I32_RI32, - I32I32I32I64I32_RI32, - I32I32I32I32I32I32_RI32, - I32I32I32I32I64I64I32_RI32, - I32I32I32I32I32I64I64I32I32_RI32, - RI32, - I64R, - F32R, - F64R, - I32F32R, - F64F64R, - INVALID, - INDEX_NUM, - }; - - DefinedFunctionTypes() - { - m_vector.reserve(INDEX_NUM); - size_t index = 0; - - FunctionType* functionType; - TypeVector* param; - TypeVector* result; - - { - // NONE - functionType = new FunctionType(0, 0, 0, 0); - functionType->initDone(); - m_vector[index++] = functionType; - } - { - // I32R - functionType = new FunctionType(1, 0, 0, 0); - param = functionType->initParam(); - param->setType(0, Value::Type::I32); - functionType->initDone(); - m_vector[index++] = functionType; - } - { - // I32I32R - functionType = new FunctionType(2, 0, 0, 0); - param = functionType->initParam(); - param->setType(0, Value::Type::I32); - param->setType(1, Value::Type::I32); - functionType->initDone(); - m_vector[index++] = functionType; - } - { - // I32I32I32I32R - functionType = new FunctionType(4, 0, 0, 0); - param = functionType->initParam(); - param->setType(0, Value::Type::I32); - param->setType(1, Value::Type::I32); - param->setType(2, Value::Type::I32); - param->setType(3, Value::Type::I32); - functionType->initDone(); - m_vector[index++] = functionType; - } - { - // I32_RI32 - functionType = new FunctionType(1, 0, 1, 0); - param = functionType->initParam(); - result = functionType->initResult(); - param->setType(0, Value::Type::I32); - result->setType(0, Value::Type::I32); - functionType->initDone(); - m_vector[index++] = functionType; - } - { - // I32I32_RI32 - functionType = new FunctionType(2, 0, 1, 0); - param = functionType->initParam(); - result = functionType->initResult(); - param->setType(0, Value::Type::I32); - param->setType(1, Value::Type::I32); - result->setType(0, Value::Type::I32); - functionType->initDone(); - m_vector[index++] = functionType; - } - { - // I32I64I32_RI32 - functionType = new FunctionType(3, 0, 1, 0); - param = functionType->initParam(); - result = functionType->initResult(); - param->setType(0, Value::Type::I32); - param->setType(1, Value::Type::I64); - param->setType(2, Value::Type::I32); - result->setType(0, Value::Type::I32); - functionType->initDone(); - m_vector[index++] = functionType; - } - { - // I32I32I32_RI32 - functionType = new FunctionType(3, 0, 1, 0); - param = functionType->initParam(); - result = functionType->initResult(); - param->setType(0, Value::Type::I32); - param->setType(1, Value::Type::I32); - param->setType(2, Value::Type::I32); - result->setType(0, Value::Type::I32); - functionType->initDone(); - m_vector[index++] = functionType; - } - { - // I32I32I32I32_RI32 - functionType = new FunctionType(4, 0, 1, 0); - param = functionType->initParam(); - result = functionType->initResult(); - param->setType(0, Value::Type::I32); - param->setType(1, Value::Type::I32); - param->setType(2, Value::Type::I32); - param->setType(3, Value::Type::I32); - result->setType(0, Value::Type::I32); - functionType->initDone(); - m_vector[index++] = functionType; - } - { - // I32I64I32I32_RI32 - functionType = new FunctionType(4, 0, 1, 0); - param = functionType->initParam(); - result = functionType->initResult(); - param->setType(0, Value::Type::I32); - param->setType(1, Value::Type::I64); - param->setType(2, Value::Type::I32); - param->setType(3, Value::Type::I32); - result->setType(0, Value::Type::I32); - functionType->initDone(); - m_vector[index++] = functionType; - } - { - // I32I64I64I32_RI32 - functionType = new FunctionType(4, 0, 1, 0); - param = functionType->initParam(); - result = functionType->initResult(); - param->setType(0, Value::Type::I32); - param->setType(1, Value::Type::I64); - param->setType(2, Value::Type::I64); - param->setType(3, Value::Type::I32); - result->setType(0, Value::Type::I32); - functionType->initDone(); - m_vector[index++] = functionType; - } - { - // I32I32I32I32I32_RI32 - functionType = new FunctionType(5, 0, 1, 0); - param = functionType->initParam(); - result = functionType->initResult(); - param->setType(0, Value::Type::I32); - param->setType(1, Value::Type::I32); - param->setType(2, Value::Type::I32); - param->setType(3, Value::Type::I32); - param->setType(4, Value::Type::I32); - result->setType(0, Value::Type::I32); - functionType->initDone(); - m_vector[index++] = functionType; - } - { - // I32I32I32I64I32_RI32 - functionType = new FunctionType(5, 0, 1, 0); - param = functionType->initParam(); - result = functionType->initResult(); - param->setType(0, Value::Type::I32); - param->setType(1, Value::Type::I32); - param->setType(2, Value::Type::I32); - param->setType(3, Value::Type::I64); - param->setType(4, Value::Type::I32); - result->setType(0, Value::Type::I32); - functionType->initDone(); - m_vector[index++] = functionType; - } - { - // I32I32I32I32I32I32_RI32 - functionType = new FunctionType(6, 0, 1, 0); - param = functionType->initParam(); - result = functionType->initResult(); - param->setType(0, Value::Type::I32); - param->setType(1, Value::Type::I32); - param->setType(2, Value::Type::I32); - param->setType(3, Value::Type::I32); - param->setType(4, Value::Type::I32); - param->setType(5, Value::Type::I32); - result->setType(0, Value::Type::I32); - functionType->initDone(); - m_vector[index++] = functionType; - } - { - // I32I32I32I32I32I64I64I32_RI32 - functionType = new FunctionType(7, 0, 1, 0); - param = functionType->initParam(); - result = functionType->initResult(); - param->setType(0, Value::Type::I32); - param->setType(1, Value::Type::I32); - param->setType(2, Value::Type::I32); - param->setType(3, Value::Type::I32); - param->setType(4, Value::Type::I64); - param->setType(5, Value::Type::I64); - param->setType(6, Value::Type::I32); - result->setType(0, Value::Type::I32); - functionType->initDone(); - m_vector[index++] = functionType; - } - { - // I32I32I32I32I32I64I64I32I32_RI32 - functionType = new FunctionType(9, 0, 1, 0); - param = functionType->initParam(); - result = functionType->initResult(); - param->setType(0, Value::Type::I32); - param->setType(1, Value::Type::I32); - param->setType(2, Value::Type::I32); - param->setType(3, Value::Type::I32); - param->setType(4, Value::Type::I32); - param->setType(5, Value::Type::I64); - param->setType(6, Value::Type::I64); - param->setType(7, Value::Type::I32); - param->setType(8, Value::Type::I32); - result->setType(0, Value::Type::I32); - functionType->initDone(); - m_vector[index++] = functionType; - } - { - // RI32 - functionType = new FunctionType(0, 0, 1, 0); - result = functionType->initResult(); - result->setType(0, Value::Type::I32); - functionType->initDone(); - m_vector[index++] = functionType; - } - { - // I64 - functionType = new FunctionType(1, 0, 0, 0); - param = functionType->initParam(); - param->setType(0, Value::Type::I64); - functionType->initDone(); - m_vector[index++] = functionType; - } - { - // F32 - functionType = new FunctionType(1, 0, 0, 0); - param = functionType->initParam(); - param->setType(0, Value::Type::F32); - functionType->initDone(); - m_vector[index++] = functionType; - } - { - // F64 - functionType = new FunctionType(1, 0, 0, 0); - param = functionType->initParam(); - param->setType(0, Value::Type::F64); - functionType->initDone(); - m_vector[index++] = functionType; - } - { - // I32F32 - functionType = new FunctionType(2, 0, 0, 0); - param = functionType->initParam(); - param->setType(0, Value::Type::I32); - param->setType(1, Value::Type::F32); - functionType->initDone(); - m_vector[index++] = functionType; - } - { - // F64F64 - functionType = new FunctionType(2, 0, 0, 0); - param = functionType->initParam(); - param->setType(0, Value::Type::F64); - param->setType(1, Value::Type::F64); - functionType->initDone(); - m_vector[index++] = functionType; - } - { - // INVALID - functionType = new FunctionType(1, 0, 0, 0); - param = functionType->initParam(); - // Temporary types cannot be used as params - param->setType(0, Value::Type::Void); - functionType->initDone(); - m_vector[index++] = functionType; - } - - ASSERT(index == INDEX_NUM); - } - - ~DefinedFunctionTypes() - { - for (size_t i = 0; i < m_vector.size(); i++) { - delete m_vector[i]; - } - } - - FunctionType* operator[](const size_t idx) - { - ASSERT(idx < m_vector.size()); - return m_vector[idx]->asFunction(); - } - -private: - CompositeTypeVector m_vector; -}; - -} // namespace Walrus - -#endif //__WalrusDefinedFunctionTypes__ diff --git a/src/runtime/ObjectType.h b/src/runtime/ObjectType.h index 6e1b3676e..abc5f0b76 100644 --- a/src/runtime/ObjectType.h +++ b/src/runtime/ObjectType.h @@ -169,7 +169,7 @@ class FunctionType : public CompositeType { FunctionType(size_t paramTypesCount, size_t paramRefsCount, size_t resultTypesCount, size_t resultRefsCount) - : CompositeType(ObjectType::FunctionKind, false, nullptr) + : CompositeType(ObjectType::FunctionKind, true, nullptr) , m_paramTypes(paramTypesCount, paramRefsCount) , m_resultTypes(resultTypesCount, resultRefsCount) , m_paramStackSize(0) @@ -178,7 +178,7 @@ class FunctionType : public CompositeType { } FunctionType(Value::Type type) - : CompositeType(ObjectType::FunctionKind, false, nullptr) + : CompositeType(ObjectType::FunctionKind, true, nullptr) , m_paramTypes(0, 0) , m_resultTypes(1, 0) , m_paramStackSize(0) diff --git a/src/runtime/Store.cpp b/src/runtime/Store.cpp index 55a91123c..f0ce2450b 100644 --- a/src/runtime/Store.cpp +++ b/src/runtime/Store.cpp @@ -41,6 +41,7 @@ static const FunctionType g_defaultFunctionTypes[] = { Store::Store(Engine* engine) : m_engine(engine) { + memset(m_definedFuncTypes, 0, sizeof(m_definedFuncTypes)); #ifdef ENABLE_GC GC_INIT(); #endif /* ENABLE_GC */ @@ -48,6 +49,13 @@ Store::Store(Engine* engine) Store::~Store() { + for (size_t i = 0; i < FUNC_TYPES_NUM; i++) { + FunctionType* type = m_definedFuncTypes[i]; + if (type != nullptr) { + TypeStore::ReleaseRef(type->subTypeList()); + } + } + // deallocate Modules and Instances for (size_t i = 0; i < m_instances.size(); i++) { Instance::freeInstance(m_instances[i]); @@ -123,4 +131,211 @@ ComponentInstance* Store::findComponentInstance(std::string& name) return it->second; } +FunctionType* Store::createDefinedFunctionType(DefinedFunctionType type) +{ + const CompositeType** noIndex = reinterpret_cast(TypeStore::NoIndex); + FunctionType* functionType; + TypeVector* param; + TypeVector* result; + + switch (type) { + case NONE: + functionType = new FunctionType(0, 0, 0, 0, true, noIndex); + break; + case I32R: + functionType = new FunctionType(1, 0, 0, 0, true, noIndex); + param = functionType->initParam(); + param->setType(0, Value::Type::I32); + break; + case I32I32R: + functionType = new FunctionType(2, 0, 0, 0, true, noIndex); + param = functionType->initParam(); + param->setType(0, Value::Type::I32); + param->setType(1, Value::Type::I32); + break; + case I32I32I32I32R: + functionType = new FunctionType(4, 0, 0, 0, true, noIndex); + param = functionType->initParam(); + param->setType(0, Value::Type::I32); + param->setType(1, Value::Type::I32); + param->setType(2, Value::Type::I32); + param->setType(3, Value::Type::I32); + break; + case I32_RI32: + functionType = new FunctionType(1, 0, 1, 0, true, noIndex); + param = functionType->initParam(); + result = functionType->initResult(); + param->setType(0, Value::Type::I32); + result->setType(0, Value::Type::I32); + break; + case I32I32_RI32: + functionType = new FunctionType(2, 0, 1, 0, true, noIndex); + param = functionType->initParam(); + result = functionType->initResult(); + param->setType(0, Value::Type::I32); + param->setType(1, Value::Type::I32); + result->setType(0, Value::Type::I32); + break; + case I32I64I32_RI32: + functionType = new FunctionType(3, 0, 1, 0, true, noIndex); + param = functionType->initParam(); + result = functionType->initResult(); + param->setType(0, Value::Type::I32); + param->setType(1, Value::Type::I64); + param->setType(2, Value::Type::I32); + result->setType(0, Value::Type::I32); + break; + case I32I32I32_RI32: + functionType = new FunctionType(3, 0, 1, 0, true, noIndex); + param = functionType->initParam(); + result = functionType->initResult(); + param->setType(0, Value::Type::I32); + param->setType(1, Value::Type::I32); + param->setType(2, Value::Type::I32); + result->setType(0, Value::Type::I32); + break; + case I32I32I32I32_RI32: + functionType = new FunctionType(4, 0, 1, 0, true, noIndex); + param = functionType->initParam(); + result = functionType->initResult(); + param->setType(0, Value::Type::I32); + param->setType(1, Value::Type::I32); + param->setType(2, Value::Type::I32); + param->setType(3, Value::Type::I32); + result->setType(0, Value::Type::I32); + break; + case I32I64I32I32_RI32: + functionType = new FunctionType(4, 0, 1, 0, true, noIndex); + param = functionType->initParam(); + result = functionType->initResult(); + param->setType(0, Value::Type::I32); + param->setType(1, Value::Type::I64); + param->setType(2, Value::Type::I32); + param->setType(3, Value::Type::I32); + result->setType(0, Value::Type::I32); + break; + case I32I64I64I32_RI32: + functionType = new FunctionType(4, 0, 1, 0, true, noIndex); + param = functionType->initParam(); + result = functionType->initResult(); + param->setType(0, Value::Type::I32); + param->setType(1, Value::Type::I64); + param->setType(2, Value::Type::I64); + param->setType(3, Value::Type::I32); + result->setType(0, Value::Type::I32); + break; + case I32I32I32I32I32_RI32: + functionType = new FunctionType(5, 0, 1, 0, true, noIndex); + param = functionType->initParam(); + result = functionType->initResult(); + param->setType(0, Value::Type::I32); + param->setType(1, Value::Type::I32); + param->setType(2, Value::Type::I32); + param->setType(3, Value::Type::I32); + param->setType(4, Value::Type::I32); + result->setType(0, Value::Type::I32); + break; + case I32I32I32I64I32_RI32: + functionType = new FunctionType(5, 0, 1, 0, true, noIndex); + param = functionType->initParam(); + result = functionType->initResult(); + param->setType(0, Value::Type::I32); + param->setType(1, Value::Type::I32); + param->setType(2, Value::Type::I32); + param->setType(3, Value::Type::I64); + param->setType(4, Value::Type::I32); + result->setType(0, Value::Type::I32); + break; + case I32I32I32I32I32I32_RI32: + functionType = new FunctionType(6, 0, 1, 0, true, noIndex); + param = functionType->initParam(); + result = functionType->initResult(); + param->setType(0, Value::Type::I32); + param->setType(1, Value::Type::I32); + param->setType(2, Value::Type::I32); + param->setType(3, Value::Type::I32); + param->setType(4, Value::Type::I32); + param->setType(5, Value::Type::I32); + result->setType(0, Value::Type::I32); + break; + case I32I32I32I32I64I64I32_RI32: + functionType = new FunctionType(7, 0, 1, 0, true, noIndex); + param = functionType->initParam(); + result = functionType->initResult(); + param->setType(0, Value::Type::I32); + param->setType(1, Value::Type::I32); + param->setType(2, Value::Type::I32); + param->setType(3, Value::Type::I32); + param->setType(4, Value::Type::I64); + param->setType(5, Value::Type::I64); + param->setType(6, Value::Type::I32); + result->setType(0, Value::Type::I32); + break; + case I32I32I32I32I32I64I64I32I32_RI32: + functionType = new FunctionType(9, 0, 1, 0, true, noIndex); + param = functionType->initParam(); + result = functionType->initResult(); + param->setType(0, Value::Type::I32); + param->setType(1, Value::Type::I32); + param->setType(2, Value::Type::I32); + param->setType(3, Value::Type::I32); + param->setType(4, Value::Type::I32); + param->setType(5, Value::Type::I64); + param->setType(6, Value::Type::I64); + param->setType(7, Value::Type::I32); + param->setType(8, Value::Type::I32); + result->setType(0, Value::Type::I32); + break; + case RI32: + functionType = new FunctionType(0, 0, 1, 0, true, noIndex); + result = functionType->initResult(); + result->setType(0, Value::Type::I32); + break; + case I64R: + functionType = new FunctionType(1, 0, 0, 0, true, noIndex); + param = functionType->initParam(); + param->setType(0, Value::Type::I64); + break; + case F32R: + functionType = new FunctionType(1, 0, 0, 0, true, noIndex); + param = functionType->initParam(); + param->setType(0, Value::Type::F32); + break; + case F64R: + functionType = new FunctionType(1, 0, 0, 0, true, noIndex); + param = functionType->initParam(); + param->setType(0, Value::Type::F64); + break; + case I32F32R: + functionType = new FunctionType(2, 0, 0, 0, true, noIndex); + param = functionType->initParam(); + param->setType(0, Value::Type::I32); + param->setType(1, Value::Type::F32); + break; + case F64F64R: + functionType = new FunctionType(2, 0, 0, 0, true, noIndex); + param = functionType->initParam(); + param->setType(0, Value::Type::F64); + param->setType(1, Value::Type::F64); + break; + default: + ASSERT(type == INVALID); + functionType = new FunctionType(1, 0, 0, 0, true, noIndex); + param = functionType->initParam(); + // Temporary types cannot be used as params + param->setType(0, Value::Type::Void); + break; + } + + functionType->initDone(); + + Vector typeList; + typeList.push_back(functionType); + m_typeStore.updateTypes(typeList); + functionType = typeList[0]->asFunction(); + + m_definedFuncTypes[type] = functionType; + return functionType; +} + } // namespace Walrus diff --git a/src/runtime/Store.h b/src/runtime/Store.h index ceb56831e..c9e23c3ba 100644 --- a/src/runtime/Store.h +++ b/src/runtime/Store.h @@ -56,6 +56,34 @@ struct Waiter { class Store { public: + enum DefinedFunctionType : uint8_t { + // The R is meant to represent the results, after R are the result types. + NONE = 0, + I32R, + I32I32R, + I32I32I32I32R, + I32_RI32, + I32I32_RI32, + I32I64I32_RI32, + I32I32I32_RI32, + I32I32I32I32_RI32, + I32I64I32I32_RI32, + I32I64I64I32_RI32, + I32I32I32I32I32_RI32, + I32I32I32I64I32_RI32, + I32I32I32I32I32I32_RI32, + I32I32I32I32I64I64I32_RI32, + I32I32I32I32I32I64I64I32I32_RI32, + RI32, + I64R, + F32R, + F64R, + I32F32R, + F64F64R, + INVALID, + FUNC_TYPES_NUM, + }; + class ComponentContext { MAKE_STACK_ALLOCATED() @@ -96,6 +124,14 @@ class Store { static void finalize(); static FunctionType* getDefaultFunctionType(Value::Type type); + FunctionType* getDefinedFunctionType(DefinedFunctionType type) + { + if (m_definedFuncTypes[type] != nullptr) { + return m_definedFuncTypes[type]; + } + return createDefinedFunctionType(type); + } + void appendModule(Module* module) { m_modules.push_back(module); @@ -143,9 +179,13 @@ class Store { ComponentInstance* findComponentInstance(std::string& name); private: + FunctionType* createDefinedFunctionType(DefinedFunctionType type); + Engine* m_engine; TypeStore m_typeStore; + FunctionType* m_definedFuncTypes[FUNC_TYPES_NUM]; + Vector m_modules; Vector m_instances; Vector m_components; diff --git a/src/shell/Shell.cpp b/src/shell/Shell.cpp index fa181f81c..2fc594a93 100644 --- a/src/shell/Shell.cpp +++ b/src/shell/Shell.cpp @@ -20,7 +20,6 @@ #include "runtime/Global.h" #include "runtime/Tag.h" #include "runtime/Trap.h" -#include "runtime/DefinedFunctionTypes.h" #include "parser/WASMParser.h" #include "parser/WASMComponentParser.h" @@ -155,7 +154,7 @@ static ExternalValue* findExternalValue(size_t value) return externalValues.back(); } -static Trap::TrapResult executeWASM(Store* store, const std::string& filename, const std::vector& src, DefinedFunctionTypes& functionTypes, +static Trap::TrapResult executeWASM(Store* store, const std::string& filename, const std::vector& src, std::map* registeredInstanceMap = nullptr) { auto parseResult = WASMParser::parseBinary(store, filename, src.data(), src.size(), s_JITFlags, s_FeatureFlags); @@ -196,7 +195,7 @@ static Trap::TrapResult executeWASM(Store* store, const std::string& filename, c auto import = importTypes[i]; if (import->moduleName() == "spectest") { if (import->fieldName() == "print") { - auto ft = functionTypes[DefinedFunctionTypes::NONE]; + auto ft = store->getDefinedFunctionType(Store::NONE); importValues.push_back(ImportedFunction::createImportedFunction( store, ft, @@ -204,7 +203,7 @@ static Trap::TrapResult executeWASM(Store* store, const std::string& filename, c }, nullptr)); } else if (import->fieldName() == "print_i32") { - auto ft = functionTypes[DefinedFunctionTypes::I32R]; + auto ft = store->getDefinedFunctionType(Store::I32R); importValues.push_back(ImportedFunction::createImportedFunction( store, ft, @@ -213,7 +212,7 @@ static Trap::TrapResult executeWASM(Store* store, const std::string& filename, c }, nullptr)); } else if (import->fieldName() == "print_i64") { - auto ft = functionTypes[DefinedFunctionTypes::I64R]; + auto ft = store->getDefinedFunctionType(Store::I64R); importValues.push_back(ImportedFunction::createImportedFunction( store, ft, @@ -222,7 +221,7 @@ static Trap::TrapResult executeWASM(Store* store, const std::string& filename, c }, nullptr)); } else if (import->fieldName() == "print_f32") { - auto ft = functionTypes[DefinedFunctionTypes::F32R]; + auto ft = store->getDefinedFunctionType(Store::F32R); importValues.push_back(ImportedFunction::createImportedFunction( store, ft, @@ -231,7 +230,7 @@ static Trap::TrapResult executeWASM(Store* store, const std::string& filename, c }, nullptr)); } else if (import->fieldName() == "print_f64") { - auto ft = functionTypes[DefinedFunctionTypes::F64R]; + auto ft = store->getDefinedFunctionType(Store::F64R); importValues.push_back(ImportedFunction::createImportedFunction( store, ft, @@ -240,7 +239,7 @@ static Trap::TrapResult executeWASM(Store* store, const std::string& filename, c }, nullptr)); } else if (import->fieldName() == "print_i32_f32") { - auto ft = functionTypes[DefinedFunctionTypes::I32F32R]; + auto ft = store->getDefinedFunctionType(Store::I32F32R); importValues.push_back(ImportedFunction::createImportedFunction( store, ft, @@ -250,7 +249,7 @@ static Trap::TrapResult executeWASM(Store* store, const std::string& filename, c }, nullptr)); } else if (import->fieldName() == "print_f64_f64") { - auto ft = functionTypes[DefinedFunctionTypes::F64F64R]; + auto ft = store->getDefinedFunctionType(Store::F64F64R); importValues.push_back(ImportedFunction::createImportedFunction( store, ft, @@ -273,7 +272,7 @@ static Trap::TrapResult executeWASM(Store* store, const std::string& filename, c importValues.push_back(Memory::createMemory(store, 1 * Memory::s_memoryPageSize, 2 * Memory::s_memoryPageSize, false, false)); } else { // import wrong value for test - auto ft = functionTypes[DefinedFunctionTypes::INVALID]; + auto ft = store->getDefinedFunctionType(Store::INVALID); importValues.push_back(ImportedFunction::createImportedFunction( store, ft, @@ -285,7 +284,7 @@ static Trap::TrapResult executeWASM(Store* store, const std::string& filename, c } else if (import->moduleName() == "wasi_snapshot_preview1") { WASI::WasiFuncInfo* wasiImportFunc = WASI::find(import->fieldName()); if (wasiImportFunc) { - FunctionType* ft = functionTypes[wasiImportFunc->functionType]; + FunctionType* ft = store->getDefinedFunctionType(wasiImportFunc->functionType); if (ft->equals(import->functionType())) { importValues.push_back(WasiFunction::createWasiFunction( store, @@ -370,7 +369,7 @@ static Trap::TrapResult executeWASM(Store* store, const std::string& filename, c &data); } -static Trap::TrapResult executeWASMComponent(Store* store, DefinedFunctionTypes& functionTypes, const std::string& filename, const std::vector& src) +static Trap::TrapResult executeWASMComponent(Store* store, const std::string& filename, const std::vector& src) { std::pair, std::string> parseResult = WASMComponentParser::parseBinary(store, filename, src.data(), src.size()); if (!parseResult.second.empty()) { @@ -382,13 +381,12 @@ static Trap::TrapResult executeWASMComponent(Store* store, DefinedFunctionTypes& struct RunData { Component* component; Store* store; - DefinedFunctionTypes& functionTypes; - } data = { parseResult.first.value(), store, functionTypes }; + } data = { parseResult.first.value(), store }; Walrus::Trap trap; return trap.run([](ExecutionState& state, void* d) { RunData* data = reinterpret_cast(d); - ComponentInstance* instance = ComponentInstance::instantiate(state, data->store, data->functionTypes, data->component); + ComponentInstance* instance = ComponentInstance::instantiate(state, data->store, data->component); for (auto& it : instance->type()->exports()) { if (it.sort == ComponentSort::Instance && it.name == "wasi:cli/run@0.2.6") { instance = instance->getInstance(it.exportIndex); @@ -850,7 +848,7 @@ static Instance* fetchInstance(wabt::Var& moduleVar, std::map return registeredInstanceMap[moduleVar.name()]; } -static void executeWAST(Store* store, const std::string& filename, const std::vector& src, DefinedFunctionTypes& functionTypes) +static void executeWAST(Store* store, const std::string& filename, const std::vector& src) { wabt::Errors errors; wabt::Features features; @@ -870,7 +868,7 @@ static void executeWAST(Store* store, const std::string& filename, const std::ve result = WriteBinaryComponent(&stream, component.get(), writeBinaryOptions); if (wabt::Succeeded(result)) { - auto trapResult = executeWASMComponent(store, functionTypes, filename, stream.output_buffer().data); + auto trapResult = executeWASMComponent(store, filename, stream.output_buffer().data); if (trapResult.exception) { std::string& errorMessage = trapResult.exception->message(); printf("Error: %s\n", errorMessage.c_str()); @@ -909,7 +907,7 @@ static void executeWAST(Store* store, const std::string& filename, const std::ve case wabt::CommandType::ScriptModule: { auto* moduleCommand = static_cast(command.get()); auto buf = readModuleData(&moduleCommand->module); - auto trapResult = executeWASM(store, filename, buf->data, functionTypes, ®isteredInstanceMap); + auto trapResult = executeWASM(store, filename, buf->data, ®isteredInstanceMap); if (trapResult.exception) { std::string& errorMessage = trapResult.exception->message(); printf("Error: %s\n", errorMessage.c_str()); @@ -990,7 +988,7 @@ static void executeWAST(Store* store, const std::string& filename, const std::ve RELEASE_ASSERT_NOT_REACHED(); } auto buf = readModuleData(&tsm->module); - auto trapResult = executeWASM(store, filename, buf->data, functionTypes, ®isteredInstanceMap); + auto trapResult = executeWASM(store, filename, buf->data, ®isteredInstanceMap); RELEASE_ASSERT(trapResult.exception); std::string& s = trapResult.exception->message(); if (s.find(assertModuleUninstantiable->text) != 0) { @@ -1038,7 +1036,7 @@ static void executeWAST(Store* store, const std::string& filename, const std::ve } else { buf = dsm->data; } - auto trapResult = executeWASM(store, filename, buf, functionTypes); + auto trapResult = executeWASM(store, filename, buf); if (trapResult.exception == nullptr) { printf("Execute WASM returned nullptr (in wabt::CommandType::AssertInvalid case)\n"); printf("Expected exception:%s\n", assertModuleInvalid->text.data()); @@ -1069,7 +1067,7 @@ static void executeWAST(Store* store, const std::string& filename, const std::ve } else { buf = dsm->data; } - auto trapResult = executeWASM(store, filename, buf, functionTypes); + auto trapResult = executeWASM(store, filename, buf); if (trapResult.exception == nullptr) { printf("Execute WASM returned nullptr (in wabt::CommandType::AssertUnlinkable case)\n"); printf("Expected exception:%s\n", assertUnlinkable->text.data()); @@ -1105,7 +1103,7 @@ static void executeWAST(Store* store, const std::string& filename, const std::ve } } -static void runExports(Store* store, const std::string& filename, const std::vector& src, std::string& exportToRun, DefinedFunctionTypes& functionTypes) +static void runExports(Store* store, const std::string& filename, const std::vector& src, std::string& exportToRun) { auto parseResult = WASMParser::parseBinary(store, filename, src.data(), src.size(), s_JITFlags); if (!parseResult.second.empty()) { @@ -1124,7 +1122,7 @@ static void runExports(Store* store, const std::string& filename, const std::vec if (import->moduleName() == "wasi_snapshot_preview1") { Walrus::WASI::WasiFuncInfo* wasiImportFunc = WASI::find(import->fieldName()); if (wasiImportFunc != nullptr) { - FunctionType* ft = functionTypes[wasiImportFunc->functionType]; + FunctionType* ft = store->getDefinedFunctionType(wasiImportFunc->functionType); if (ft->equals(import->functionType())) { importValues.push_back(WasiFunction::createWasiFunction( store, @@ -1310,7 +1308,6 @@ int main(int argc, const char* argv[]) Engine* engine = new Engine(); Store* store = new Store(engine); - DefinedFunctionTypes functionTypes; ParseOptions options; parseArguments(argc, argv, options); @@ -1369,16 +1366,16 @@ int main(int argc, const char* argv[]) } if (endsWith(filePath, "wasm")) { if (!options.exportToRun.empty()) { - runExports(store, filePath, buf, options.exportToRun, functionTypes); + runExports(store, filePath, buf, options.exportToRun); } else if (wabt::ReadBinaryIsComponent(buf.data(), buf.size())) { - auto trapResult = executeWASMComponent(store, functionTypes, filePath, buf); + auto trapResult = executeWASMComponent(store, filePath, buf); if (trapResult.exception) { fprintf(stderr, "Uncaught Exception: %s\n", trapResult.exception->message().data()); result = -1; break; } } else { - auto trapResult = executeWASM(store, filePath, buf, functionTypes); + auto trapResult = executeWASM(store, filePath, buf); if (trapResult.exception) { fprintf(stderr, "Uncaught Exception: %s\n", trapResult.exception->message().data()); result = -1; @@ -1386,7 +1383,7 @@ int main(int argc, const char* argv[]) } } } else if (endsWith(filePath, "wat") || endsWith(filePath, "wast")) { - executeWAST(store, filePath, buf, functionTypes); + executeWAST(store, filePath, buf); } } else { printf("Cannot open file %s\n", filePath.data()); diff --git a/src/wasi/WASI.cpp b/src/wasi/WASI.cpp index e097c0799..c4cbaf297 100644 --- a/src/wasi/WASI.cpp +++ b/src/wasi/WASI.cpp @@ -84,9 +84,9 @@ void WASI::initialize(uvwasi_t* uvwasi) g_uvwasi = uvwasi; // fill wasi function table -#define WASI_FUNC_TABLE(NAME, FUNCTYPE) \ - g_wasiFunctions[WasiFuncIndex::NAME##FUNC].name = #NAME; \ - g_wasiFunctions[WasiFuncIndex::NAME##FUNC].functionType = DefinedFunctionTypes::FUNCTYPE; \ +#define WASI_FUNC_TABLE(NAME, FUNCTYPE) \ + g_wasiFunctions[WasiFuncIndex::NAME##FUNC].name = #NAME; \ + g_wasiFunctions[WasiFuncIndex::NAME##FUNC].functionType = Store::FUNCTYPE; \ g_wasiFunctions[WasiFuncIndex::NAME##FUNC].ptr = &WASI::NAME; FOR_EACH_WASI_FUNC(WASI_FUNC_TABLE) #undef WASI_FUNC_TABLE diff --git a/src/wasi/WASI.h b/src/wasi/WASI.h index bfd0ac0eb..8e81114dc 100644 --- a/src/wasi/WASI.h +++ b/src/wasi/WASI.h @@ -22,7 +22,7 @@ #include "Walrus.h" #include "runtime/Function.h" #include "runtime/ObjectType.h" -#include "runtime/DefinedFunctionTypes.h" +#include "runtime/Store.h" #include namespace Walrus { @@ -161,7 +161,7 @@ class WASI { struct WasiFuncInfo { std::string name; - DefinedFunctionTypes::Index functionType; + Store::DefinedFunctionType functionType; WasiFunction::WasiFunctionCallback ptr; }; diff --git a/src/wasi/WASI02.cpp b/src/wasi/WASI02.cpp index 37119e4ed..4ad9a4d2d 100644 --- a/src/wasi/WASI02.cpp +++ b/src/wasi/WASI02.cpp @@ -18,7 +18,6 @@ #include "wasi/WASI02.h" #include "runtime/ComponentInstance.h" -#include "runtime/DefinedFunctionTypes.h" #include "runtime/Memory.h" #include "runtime/Store.h" @@ -150,9 +149,8 @@ class LiftedWasiFunction : public LiftedFunction { class ComponentInstanceWasi02 { public: - ComponentInstanceWasi02(Store* store, DefinedFunctionTypes& functionTypes) + ComponentInstanceWasi02(Store* store) : m_store(store) - , m_functionTypes(functionTypes) , m_type(nullptr) { } @@ -167,12 +165,16 @@ class ComponentInstanceWasi02 { ComponentInstance* loadInstance(const char* name, size_t length); private: + FunctionType* getType(Store::DefinedFunctionType type) + { + return m_store->getDefinedFunctionType(type); + } + static void aliasExport(ComponentInstance* instance, const char* name, ComponentRefCounted* type); static void addExport(ComponentInstance* instance, const char* name, LiftedWasiFunction::Type type, FunctionType* functionType); ComponentInstance* getInstance(const char* name, const char* postfix, size_t postfixLength); Store* m_store; - DefinedFunctionTypes& m_functionTypes; ComponentType* m_type; }; @@ -199,7 +201,7 @@ ComponentInstance* ComponentInstanceWasi02::getInstance(const char* name, const memcpy(buffer, name, length); memcpy(buffer + length, postfix, postfixLength); std::string str(buffer, length + postfixLength); - return wasi02LoadInstance(m_store, m_functionTypes, str); + return wasi02LoadInstance(m_store, str); } static bool compareName(const char* name, size_t length, const char* expected) @@ -250,7 +252,7 @@ ComponentInstance* ComponentInstanceWasi02::loadInstance(const char* name, size_ m_type = new ComponentType(ComponentType::ComponentTypeKind); ComponentInstance* instance = ComponentInstance::createInstance(m_store, m_type); m_type->pushType(new ComponentTypeResource(false, ComponentTypeResource::NotDefined)); /* 0 */ - addExport(instance, "[method]pollable.block", LiftedWasiFunction::ioPollableBlock02, m_functionTypes[DefinedFunctionTypes::I32R]); + addExport(instance, "[method]pollable.block", LiftedWasiFunction::ioPollableBlock02, getType(Store::I32R)); return instance; } if (compareName(name, length, "streams")) { @@ -265,11 +267,11 @@ ComponentInstance* ComponentInstanceWasi02::loadInstance(const char* name, size_ ComponentInstance* pollIntance = getInstance("wasi:io/poll@0.2.", postfix, postfixLength); instance->m_instances.push_back(pollIntance); aliasExport(instance, "pollable", pollIntance->type()->getType(0)); /* 3 */ - addExport(instance, "[method]output-stream.check-write", LiftedWasiFunction::ioOutputStreamCheckWrite02, m_functionTypes[DefinedFunctionTypes::I32I32R]); - addExport(instance, "[method]output-stream.write", LiftedWasiFunction::ioOutputStreamWrite02, m_functionTypes[DefinedFunctionTypes::I32I32I32I32R]); - addExport(instance, "[method]output-stream.blocking-write-and-flush", LiftedWasiFunction::ioOutputStreamBlockingWriteAndFlush02, m_functionTypes[DefinedFunctionTypes::I32I32I32I32R]); - addExport(instance, "[method]output-stream.blocking-flush", LiftedWasiFunction::ioOutputStreamBlockingFlush02, m_functionTypes[DefinedFunctionTypes::I32I32R]); - addExport(instance, "[method]output-stream.subscribe", LiftedWasiFunction::ioOutputStreamSubscribe02, m_functionTypes[DefinedFunctionTypes::I32_RI32]); + addExport(instance, "[method]output-stream.check-write", LiftedWasiFunction::ioOutputStreamCheckWrite02, getType(Store::I32I32R)); + addExport(instance, "[method]output-stream.write", LiftedWasiFunction::ioOutputStreamWrite02, getType(Store::I32I32I32I32R)); + addExport(instance, "[method]output-stream.blocking-write-and-flush", LiftedWasiFunction::ioOutputStreamBlockingWriteAndFlush02, getType(Store::I32I32I32I32R)); + addExport(instance, "[method]output-stream.blocking-flush", LiftedWasiFunction::ioOutputStreamBlockingFlush02, getType(Store::I32I32R)); + addExport(instance, "[method]output-stream.subscribe", LiftedWasiFunction::ioOutputStreamSubscribe02, getType(Store::I32_RI32)); return instance; } return nullptr; @@ -282,7 +284,7 @@ ComponentInstance* ComponentInstanceWasi02::loadInstance(const char* name, size_ if (compareName(name, length, "exit")) { m_type = new ComponentType(ComponentType::ComponentTypeKind); ComponentInstance* instance = ComponentInstance::createInstance(m_store, m_type); - addExport(instance, "exit", LiftedWasiFunction::cliExit02, m_functionTypes[DefinedFunctionTypes::I32R]); + addExport(instance, "exit", LiftedWasiFunction::cliExit02, getType(Store::I32R)); return instance; } if (compareName(name, length, "stdin")) { @@ -292,7 +294,7 @@ ComponentInstance* ComponentInstanceWasi02::loadInstance(const char* name, size_ ComponentInstance* streamsIntance = getInstance("wasi:io/streams@0.2.", postfix, postfixLength); instance->m_instances.push_back(streamsIntance); aliasExport(instance, "input-stream", streamsIntance->type()->getType(0)); /* 0 */ - addExport(instance, "get-stdin", LiftedWasiFunction::cliGetStdin02, m_functionTypes[DefinedFunctionTypes::RI32]); + addExport(instance, "get-stdin", LiftedWasiFunction::cliGetStdin02, getType(Store::RI32)); return instance; } if (compareName(name, length, "stdout")) { @@ -302,7 +304,7 @@ ComponentInstance* ComponentInstanceWasi02::loadInstance(const char* name, size_ ComponentInstance* streamsIntance = getInstance("wasi:io/streams@0.2.", postfix, postfixLength); instance->m_instances.push_back(streamsIntance); aliasExport(instance, "output-stream", streamsIntance->type()->getType(1)); /* 0 */ - addExport(instance, "get-stdout", LiftedWasiFunction::cliGetStdout02, m_functionTypes[DefinedFunctionTypes::RI32]); + addExport(instance, "get-stdout", LiftedWasiFunction::cliGetStdout02, getType(Store::RI32)); return instance; } if (compareName(name, length, "stderr")) { @@ -312,7 +314,7 @@ ComponentInstance* ComponentInstanceWasi02::loadInstance(const char* name, size_ ComponentInstance* streamsIntance = getInstance("wasi:io/streams@0.2.", postfix, postfixLength); instance->m_instances.push_back(streamsIntance); aliasExport(instance, "output-stream", streamsIntance->type()->getType(1)); /* 0 */ - addExport(instance, "get-stderr", LiftedWasiFunction::cliGetStderr02, m_functionTypes[DefinedFunctionTypes::RI32]); + addExport(instance, "get-stderr", LiftedWasiFunction::cliGetStderr02, getType(Store::RI32)); return instance; } if (compareName(name, length, "terminal-input")) { @@ -334,7 +336,7 @@ ComponentInstance* ComponentInstanceWasi02::loadInstance(const char* name, size_ ComponentInstance* inputIntance = getInstance("wasi:cli/terminal-input@0.2.", postfix, postfixLength); instance->m_instances.push_back(inputIntance); aliasExport(instance, "terminal-input", inputIntance->type()->getType(0)); /* 0 */ - addExport(instance, "get-terminal-stdin", LiftedWasiFunction::cliGetTerminalStdin02, m_functionTypes[DefinedFunctionTypes::I32R]); + addExport(instance, "get-terminal-stdin", LiftedWasiFunction::cliGetTerminalStdin02, getType(Store::I32R)); return instance; } if (compareName(name, length, "terminal-stdout")) { @@ -344,7 +346,7 @@ ComponentInstance* ComponentInstanceWasi02::loadInstance(const char* name, size_ ComponentInstance* outputIntance = getInstance("wasi:cli/terminal-output@0.2.", postfix, postfixLength); instance->m_instances.push_back(outputIntance); aliasExport(instance, "terminal-output", outputIntance->type()->getType(0)); /* 0 */ - addExport(instance, "get-terminal-stdout", LiftedWasiFunction::cliGetTerminalStdout02, m_functionTypes[DefinedFunctionTypes::I32R]); + addExport(instance, "get-terminal-stdout", LiftedWasiFunction::cliGetTerminalStdout02, getType(Store::I32R)); return instance; } if (compareName(name, length, "terminal-stderr")) { @@ -354,7 +356,7 @@ ComponentInstance* ComponentInstanceWasi02::loadInstance(const char* name, size_ ComponentInstance* outputIntance = getInstance("wasi:cli/terminal-output@0.2.", postfix, postfixLength); instance->m_instances.push_back(outputIntance); aliasExport(instance, "terminal-output", outputIntance->type()->getType(0)); /* 0 */ - addExport(instance, "get-terminal-stderr", LiftedWasiFunction::cliGetTerminalStderr02, m_functionTypes[DefinedFunctionTypes::I32R]); + addExport(instance, "get-terminal-stderr", LiftedWasiFunction::cliGetTerminalStderr02, getType(Store::I32R)); return instance; } return nullptr; @@ -362,14 +364,14 @@ ComponentInstance* ComponentInstanceWasi02::loadInstance(const char* name, size_ return nullptr; } -ComponentInstance* wasi02LoadInstance(Store* store, DefinedFunctionTypes& functionTypes, std::string& name) +ComponentInstance* wasi02LoadInstance(Store* store, std::string& name) { ComponentInstance* instance = store->findComponentInstance(name); if (instance != nullptr) { return instance; } - ComponentInstanceWasi02 instanceCreator(store, functionTypes); + ComponentInstanceWasi02 instanceCreator(store); instance = instanceCreator.loadInstance(name.data(), name.length()); store->registerComponentInstance(name, instance); return instance; diff --git a/src/wasi/WASI02.h b/src/wasi/WASI02.h index 76510d2d1..fa758aa05 100644 --- a/src/wasi/WASI02.h +++ b/src/wasi/WASI02.h @@ -25,12 +25,11 @@ namespace Walrus { class ComponentInstance; -class DefinedFunctionTypes; class CanonOptions; class ComponentHandle; class LiftedWasiFunction; -ComponentInstance* wasi02LoadInstance(Store* store, DefinedFunctionTypes& functionTypes, std::string& name); +ComponentInstance* wasi02LoadInstance(Store* store, std::string& name); const FunctionType* getWasiFunctionType(LiftedWasiFunction* function); void callWasiFunction(ExecutionState& state, Value* argv, Value* result, LiftedWasiFunction* function, CanonOptions* options); bool dropWasiResource(ExecutionState& state, ComponentHandle* handle);