Skip to content

Commit

Permalink
Merge branch 'optimize-waitgroup'
Browse files Browse the repository at this point in the history
  • Loading branch information
JothamWong committed Apr 15, 2024
2 parents f0f5e69 + 0984cc4 commit 0b6fee3
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/vm/oogavm-heap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1180,25 +1180,34 @@ function mark(addr) {
mark(parent);
}
break;
case Tag.ARRAY:
case Tag.FRAME:
case Tag.ENVIRONMENT:
case Tag.STRUCT:
const numChildren = getSize(addr) - 1;
const numChildren = getSize(addr) - headerSize;
for (let i = 0; i < numChildren; i++) {
mark(getWord(addr + i + 1));
// no size variable in 3rd word
mark(getWord(addr + i + headerSize));
}
break;
case Tag.UNBUFFERED:
for (let i = 0; i < getUnBufferChannelLength(addr); i++) {
// will only loop once
// 1 for size
mark(getWord(addr + headerSize + 1 + i));
}
break;
case Tag.BUFFERED:
for (let i = 0; i < getBufferChannelLength(addr); i++) {
// 1 for size
mark(getWord(addr + headerSize + 1 + i));
}
break;
case Tag.SLICE:
for (let i = 0; i < getSliceLength(addr); i++) {
mark(getSliceValueAtIndex(addr, i));
}
break;
default:
// no special case for builtins, struct fields
return;
Expand Down Expand Up @@ -1320,6 +1329,13 @@ function updateReferences() {
setWord(curr + i + headerSize + 1, forwardedAddr);
}
break;
case Tag.SLICE:
for (let i = 0; i < getSliceLength(curr); i++) {
const originalChildAddr = getSliceValueAtIndex(curr, i);
const forwardedAddr = getForwardingAddress(originalChildAddr);
setSliceValue(curr, i, forwardedAddr);
}
break;
default:
// no special case for builtins, struct fields
break;
Expand Down

0 comments on commit 0b6fee3

Please sign in to comment.