| 491 | } |
| 492 | |
| 493 | Expect<RefVariant> |
| 494 | Executor::arrayNewData(Runtime::StackManager &StackMgr, const uint32_t TypeIdx, |
| 495 | const uint32_t DataIdx, const uint32_t Start, |
| 496 | const uint32_t Length) const noexcept { |
| 497 | const auto &VType = getArrayStorageTypeByIdx(StackMgr, TypeIdx); |
| 498 | const uint32_t BSize = VType.getBitWidth() / 8; |
| 499 | auto *DataInst = getDataInstByIdx(StackMgr, DataIdx); |
| 500 | assuming(DataInst); |
| 501 | if (static_cast<uint64_t>(Start) + static_cast<uint64_t>(Length) * BSize > |
| 502 | DataInst->getData().size()) { |
| 503 | return Unexpect(ErrCode::Value::MemoryOutOfBounds); |
| 504 | } |
| 505 | Runtime::Instance::ModuleInstance *ModInst = |
| 506 | const_cast<Runtime::Instance::ModuleInstance *>(StackMgr.getModule()); |
| 507 | std::vector<ValVariant> Args; |
| 508 | Args.reserve(Length); |
| 509 | for (uint32_t Idx = 0; Idx < Length; Idx++) { |
| 510 | // The value has been packed. |
| 511 | Args.push_back(DataInst->loadValue(Start + Idx * BSize, BSize)); |
| 512 | } |
| 513 | WasmEdge::Runtime::Instance::ArrayInstance *Inst = |
| 514 | ModInst->newArray(TypeIdx, std::move(Args)); |
| 515 | return RefVariant(Inst->getDefType(), Inst); |
| 516 | } |
| 517 | |
| 518 | Expect<RefVariant> |
| 519 | Executor::arrayNewElem(Runtime::StackManager &StackMgr, const uint32_t TypeIdx, |
nothing calls this directly
no test coverage detected