MCPcopy Create free account
hub / github.com/WasmEdge/WasmEdge / proxyTableGetFuncSymbol

Method proxyTableGetFuncSymbol

lib/executor/engine/proxy.cpp:607–648  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

605}
606
607Expect<void *> Executor::proxyTableGetFuncSymbol(
608 Runtime::StackManager &StackMgr, const uint32_t TableIdx,
609 const uint32_t FuncTypeIdx, const uint32_t FuncIdx) noexcept {
610 const auto *TabInst = getTabInstByIdx(StackMgr, TableIdx);
611 assuming(TabInst);
612
613 if (unlikely(FuncIdx >= TabInst->getSize())) {
614 return Unexpect(ErrCode::Value::UndefinedElement);
615 }
616
617 auto Ref = TabInst->getRefAddr(FuncIdx);
618 assuming(Ref);
619 if (unlikely(Ref->isNull())) {
620 return Unexpect(ErrCode::Value::UninitializedElement);
621 }
622
623 const auto *ModInst = StackMgr.getModule();
624 assuming(ModInst);
625 const auto &ExpDefType = **ModInst->getType(FuncTypeIdx);
626 const auto *FuncInst = retrieveFuncRef(*Ref);
627 assuming(FuncInst);
628 bool IsMatch = false;
629 if (FuncInst->getModule()) {
630 IsMatch = AST::TypeMatcher::matchType(
631 ModInst->getTypeList(), *ExpDefType.getTypeIndex(),
632 FuncInst->getModule()->getTypeList(), FuncInst->getTypeIndex());
633 } else {
634 // Independent host module instance case. Matching the composite type
635 // directly.
636 IsMatch = AST::TypeMatcher::matchType(
637 ModInst->getTypeList(), ExpDefType.getCompositeType(),
638 FuncInst->getHostFunc().getDefinedType().getCompositeType());
639 }
640 if (!IsMatch) {
641 return Unexpect(ErrCode::Value::IndirectCallTypeMismatch);
642 }
643
644 if (unlikely(!FuncInst->isCompiledFunction())) {
645 return nullptr;
646 }
647 return FuncInst->getSymbol().get();
648}
649
650Expect<void *> Executor::proxyRefGetFuncSymbol(Runtime::StackManager &,
651 const RefVariant Ref) noexcept {

Callers

nothing calls this directly

Calls 12

unlikelyFunction · 0.85
UnexpectFunction · 0.85
retrieveFuncRefFunction · 0.85
getRefAddrMethod · 0.80
isNullMethod · 0.80
getTypeListMethod · 0.80
isCompiledFunctionMethod · 0.80
getSizeMethod · 0.45
getModuleMethod · 0.45
getTypeMethod · 0.45
getTypeIndexMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected