Files
sdk/runtime/vm/virtual_memory.cc
T
Ryan Macnak 9764a9f037 -Setup heap page for precompiled instructions to make heap verifier etc happy.
-Pre-mark instructions when writing the snapshot.
-Write the megamorphic miss function to the snapshot.
-Add missing ExceptionHandlers for megamorphic miss code.
-Add missing C++ entry points.
-Relocate Function and Code entry_points_ when reading precompiled snapshot.
-Don't try to load a script again when running from a precompiled snapshot.

R=asiva@google.com

Review URL: https://codereview.chromium.org//1336763002 .
2015-09-16 11:22:57 -07:00

40 lines
1.3 KiB
C++

// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#include "vm/virtual_memory.h"
#include "platform/assert.h"
#include "platform/utils.h"
namespace dart {
bool VirtualMemory::InSamePage(uword address0, uword address1) {
return (Utils::RoundDown(address0, PageSize()) ==
Utils::RoundDown(address1, PageSize()));
}
void VirtualMemory::Truncate(intptr_t new_size, bool try_unmap) {
ASSERT((new_size & (PageSize() - 1)) == 0);
ASSERT(new_size <= size());
if (try_unmap &&
(reserved_size_ == size()) && /* Don't create holes in reservation. */
FreeSubSegment(reinterpret_cast<void*>(start() + new_size),
size() - new_size)) {
reserved_size_ = new_size;
}
region_.Subregion(region_, 0, new_size);
}
VirtualMemory* VirtualMemory::ForInstructionsSnapshot(void* pointer,
uword size) {
// Memory for precompilated instructions was allocated by the embedder, so
// create a VirtualMemory without allocating.
MemoryRegion region(pointer, size);
return new VirtualMemory(region);
}
} // namespace dart