Skip to content

Commit

Permalink
Revert "[vm] Align heap allocations to 2GB regions in comp ptr mode"
Browse files Browse the repository at this point in the history
This reverts commit d10d17c.

Reason for revert: Broke Mac builds

Original change's description:
> [vm] Align heap allocations to 2GB regions in comp ptr mode
>
> This only handles the POSIX case. The Windows case will work exactly the
> same as this, so I want to get this reviewed before I start porting it
> to windows.
>
> TEST=Manual testing. I'll update the unit tests once it's ported.
>
> Bug: #45059
> Change-Id: I0bc0eddd95101fc2fddfe5668488670e741af586
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/183142
> Reviewed-by: Ryan Macnak <rmacnak@google.com>
> Commit-Queue: Liam Appelbe <liama@google.com>

Bug: #45059
Change-Id: I840c31ead015f60bca32b551c8f8d31fa75ad645
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/186101
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
  • Loading branch information
mraleph committed Feb 21, 2021
1 parent b7849ab commit 0ed3fb3
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 232 deletions.
1 change: 0 additions & 1 deletion runtime/vm/dart.cc
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,6 @@ char* Dart::Cleanup() {
IsolateGroupReloadContext::SetFileModifiedCallback(NULL);
Service::SetEmbedderStreamCallbacks(NULL, NULL);
#endif // !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME)
VirtualMemory::Cleanup();
return NULL;
}

Expand Down
5 changes: 0 additions & 5 deletions runtime/vm/heap/pages.cc
Original file line number Diff line number Diff line change
Expand Up @@ -392,11 +392,6 @@ OldPage* PageSpace::AllocateLargePage(intptr_t size, OldPage::PageType type) {
if (page == nullptr) {
IncreaseCapacityInWordsLocked(-page_size_in_words);
return nullptr;
} else {
intptr_t actual_size_in_words = page->memory_->size() >> kWordSizeLog2;
if (actual_size_in_words != page_size_in_words) {
IncreaseCapacityInWordsLocked(actual_size_in_words - page_size_in_words);
}
}
if (is_exec) {
AddExecPageLocked(page);
Expand Down
4 changes: 0 additions & 4 deletions runtime/vm/object.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2499,12 +2499,8 @@ void Object::InitializeObject(uword address, intptr_t class_id, intptr_t size) {
// If the size is greater than both kNewAllocatableSize and
// kAllocatablePageSize, the object must have been allocated to a new
// large page, which must already have been zero initialized by the OS.
#if defined(DART_COMPRESSED_POINTERS)
needs_init = true;
#else
needs_init = Heap::IsAllocatableInNewSpace(size) ||
Heap::IsAllocatableViaFreeLists(size);
#endif
} else {
initial_value = static_cast<uword>(null_);
needs_init = true;
Expand Down
13 changes: 6 additions & 7 deletions runtime/vm/virtual_memory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,12 @@ void VirtualMemory::Truncate(intptr_t new_size) {
ASSERT(new_size <= size());
if (reserved_.size() ==
region_.size()) { // Don't create holes in reservation.
if (FreeSubSegment(reinterpret_cast<void*>(start() + new_size),
size() - new_size)) {
reserved_.set_size(new_size);
if (AliasOffset() != 0) {
FreeSubSegment(reinterpret_cast<void*>(alias_.start() + new_size),
alias_.size() - new_size);
}
FreeSubSegment(reinterpret_cast<void*>(start() + new_size),
size() - new_size);
reserved_.set_size(new_size);
if (AliasOffset() != 0) {
FreeSubSegment(reinterpret_cast<void*>(alias_.start() + new_size),
alias_.size() - new_size);
}
}
region_.Subregion(region_, 0, new_size);
Expand Down
3 changes: 1 addition & 2 deletions runtime/vm/virtual_memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class VirtualMemory {
intptr_t AliasOffset() const { return alias_.start() - region_.start(); }

static void Init();
static void Cleanup();

// Returns true if dual mapping is enabled.
static bool DualMappingEnabled();
Expand Down Expand Up @@ -88,7 +87,7 @@ class VirtualMemory {

// Free a sub segment. On operating systems that support it this
// can give back the virtual memory to the system. Returns true on success.
static bool FreeSubSegment(void* address, intptr_t size);
static void FreeSubSegment(void* address, intptr_t size);

// These constructors are only used internally when reserving new virtual
// spaces. They do not reserve any virtual address space on their own.
Expand Down
5 changes: 1 addition & 4 deletions runtime/vm/virtual_memory_fuchsia.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ void VirtualMemory::Init() {
page_size_ = CalculatePageSize();
}

void VirtualMemory::Cleanup() {}

static void Unmap(zx_handle_t vmar, uword start, uword end) {
ASSERT(start <= end);
const uword size = end - start;
Expand Down Expand Up @@ -176,11 +174,10 @@ VirtualMemory::~VirtualMemory() {
}
}

bool VirtualMemory::FreeSubSegment(void* address, intptr_t size) {
void VirtualMemory::FreeSubSegment(void* address, intptr_t size) {
const uword start = reinterpret_cast<uword>(address);
Unmap(zx_vmar_root_self(), start, start + size);
LOG_INFO("zx_vmar_unmap(0x%p, 0x%lx) success\n", address, size);
return true;
}

void VirtualMemory::Protect(void* address, intptr_t size, Protection mode) {
Expand Down
Loading

0 comments on commit 0ed3fb3

Please sign in to comment.