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

Method growPage

include/runtime/instance/memory.h:112–142  ·  view source on GitHub ↗

Grow page

Source from the content-addressed store, hash-verified

110
111 /// Grow page
112 bool growPage(const uint64_t Count) noexcept {
113 if (Count == 0) {
114 return true;
115 }
116 uint64_t MaxPageCaped =
117 MemType.getLimit().is32() ? kPageLimit32 : kPageLimit64;
118 const uint64_t Min = MemType.getLimit().getMin();
119 assuming(MaxPageCaped >= Min);
120 if (MemType.getLimit().hasMax()) {
121 const uint64_t Max = MemType.getLimit().getMax();
122 MaxPageCaped = std::min(Max, MaxPageCaped);
123 }
124 if (Count > MaxPageCaped - Min) {
125 return false;
126 }
127 assuming(PageLimit >= Min);
128 if (Count > PageLimit - Min) {
129 spdlog::error("Memory Instance: Memory grow page failed, exceeded "
130 "limited {} page size in configuration.",
131 PageLimit);
132 return false;
133 }
134 if (auto NewPtr = Allocator::resize(DataPtr, Min, Min + Count);
135 NewPtr == nullptr) {
136 return false;
137 } else {
138 DataPtr = NewPtr;
139 }
140 MemType.getLimit().setMin(Min + Count);
141 return true;
142 }
143
144 /// Get slice of Data[Offset : Offset + Length - 1]
145 Expect<Span<Byte>> getBytes(const uint64_t Offset,

Callers 4

runMemoryGrowOpMethod · 0.80
proxyMemGrowMethod · 0.80
TESTFunction · 0.80

Calls 6

is32Method · 0.80
getMinMethod · 0.80
hasMaxMethod · 0.80
getMaxMethod · 0.80
setMinMethod · 0.80
errorFunction · 0.50

Tested by 1

TESTFunction · 0.64