Skip to content

Commit 9b7fcba

Browse files
committed
Comments
1 parent 8206c26 commit 9b7fcba

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

stdlib/tools/swift-reflection-test/swift-reflection-test.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,9 @@ static
208208
const void *PipeMemoryReader_readBytes(void *Context, swift_addr_t Address,
209209
uint64_t Size, void **outFreeContext) {
210210
PipeMemoryReader *Reader = (PipeMemoryReader *)Context;
211-
212211
PipeMemoryReaderPage *Page = Reader->Pages;
212+
213+
// Try to find an existing page with the requested bytes
213214
while (Page != NULL) {
214215
if (Page->BaseAddress <= Address
215216
&& (Page->BaseAddress + Page->Size >= Address + Size)) {
@@ -218,6 +219,7 @@ const void *PipeMemoryReader_readBytes(void *Context, swift_addr_t Address,
218219
Page = Page->Next;
219220
}
220221

222+
// If none, fetch page(s) from the target
221223
if (Page == NULL) {
222224
static uint64_t PageSize = 4 * 1024;
223225
uintptr_t TargetAddress = Address - (Address % PageSize);
@@ -241,6 +243,7 @@ const void *PipeMemoryReader_readBytes(void *Context, swift_addr_t Address,
241243
Page = NewPage;
242244
}
243245

246+
// We have a page: Copy bytes from it to satisfy the request
244247
assert(Page->BaseAddress <= Address);
245248
assert(Page->BaseAddress + Page->Size >= Address + Size);
246249
void *Buf = malloc(Size);

0 commit comments

Comments
 (0)