Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions clang/lib/AST/ByteCode/DynamicAllocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,25 @@
using namespace clang;
using namespace clang::interp;

// FIXME: There is a peculiar problem with the way we track pointers
// to blocks and the way we allocate dynamic memory.
//
// When we have code like this:
// while (true) {
// char *buffer = new char[1024];
// delete[] buffer;
// }
//
// We have a local variable 'buffer' pointing to the heap allocated memory.
// When deallocating the memory via delete[], that local variable still
// points to the memory, which means we will create a DeadBlock for it and move
// it over to that block, essentially duplicating the allocation. Moving
// the data is also slow.
//
// However, when we actually try to access the allocation after it has been
// freed, we need the block to still exist (alive or dead) so we can tell
// that it's a dynamic allocation.

DynamicAllocator::~DynamicAllocator() { cleanup(); }

void DynamicAllocator::cleanup() {
Expand Down