[Memory] Move GetRandomMmapAddr from base::OS platform to v8::internal.

- Moves GetRandomMmapAddr from platform to v8::internal allocation
  primitives, in preparation for delegating this to the embedder.
- Adds hint parameters to OS functions that used to use this function.

Bug: chromium:756050
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_chromium_rel_ng
Change-Id: Iad72e6eac9c08a3e22c2cd2b2905623b8e514ae0
Reviewed-on: https://chromium-review.googlesource.com/677777
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Commit-Queue: Bill Budge <bbudge@chromium.org>
Cr-Commit-Position: refs/heads/master@{#48124}
This commit is contained in:
Bill Budge 2017-09-21 16:00:55 -07:00 committed by Commit Bot
parent c9b08c6579
commit d607f1e72d
25 changed files with 148 additions and 167 deletions

View File

@ -6,8 +6,11 @@
#include <stdlib.h> // For free, malloc.
#include "src/base/bits.h"
#include "src/base/lazy-instance.h"
#include "src/base/logging.h"
#include "src/base/platform/platform.h"
#include "src/base/utils/random-number-generator.h"
#include "src/flags.h"
#include "src/utils.h"
#include "src/v8.h"
@ -203,5 +206,104 @@ bool AlignedAllocVirtualMemory(size_t size, size_t alignment, void* hint,
return result->IsReserved();
}
namespace {
struct RNGInitializer {
static void Construct(void* mem) {
auto rng = new (mem) base::RandomNumberGenerator();
int64_t random_seed = FLAG_random_seed;
if (random_seed) {
rng->SetSeed(random_seed);
}
}
};
} // namespace
static base::LazyInstance<base::RandomNumberGenerator, RNGInitializer>::type
random_number_generator = LAZY_INSTANCE_INITIALIZER;
void* GetRandomMmapAddr() {
#if defined(ADDRESS_SANITIZER) || defined(MEMORY_SANITIZER) || \
defined(THREAD_SANITIZER)
// Dynamic tools do not support custom mmap addresses.
return NULL;
#endif
uintptr_t raw_addr;
random_number_generator.Pointer()->NextBytes(&raw_addr, sizeof(raw_addr));
#if V8_OS_POSIX
#if V8_TARGET_ARCH_X64
// Currently available CPUs have 48 bits of virtual addressing. Truncate
// the hint address to 46 bits to give the kernel a fighting chance of
// fulfilling our placement request.
raw_addr &= V8_UINT64_C(0x3ffffffff000);
#elif V8_TARGET_ARCH_PPC64
#if V8_OS_AIX
// AIX: 64 bits of virtual addressing, but we limit address range to:
// a) minimize Segment Lookaside Buffer (SLB) misses and
raw_addr &= V8_UINT64_C(0x3ffff000);
// Use extra address space to isolate the mmap regions.
raw_addr += V8_UINT64_C(0x400000000000);
#elif V8_TARGET_BIG_ENDIAN
// Big-endian Linux: 44 bits of virtual addressing.
raw_addr &= V8_UINT64_C(0x03fffffff000);
#else
// Little-endian Linux: 48 bits of virtual addressing.
raw_addr &= V8_UINT64_C(0x3ffffffff000);
#endif
#elif V8_TARGET_ARCH_S390X
// Linux on Z uses bits 22-32 for Region Indexing, which translates to 42 bits
// of virtual addressing. Truncate to 40 bits to allow kernel chance to
// fulfill request.
raw_addr &= V8_UINT64_C(0xfffffff000);
#elif V8_TARGET_ARCH_S390
// 31 bits of virtual addressing. Truncate to 29 bits to allow kernel chance
// to fulfill request.
raw_addr &= 0x1ffff000;
#else
raw_addr &= 0x3ffff000;
#ifdef __sun
// For our Solaris/illumos mmap hint, we pick a random address in the bottom
// half of the top half of the address space (that is, the third quarter).
// Because we do not MAP_FIXED, this will be treated only as a hint -- the
// system will not fail to mmap() because something else happens to already
// be mapped at our random address. We deliberately set the hint high enough
// to get well above the system's break (that is, the heap); Solaris and
// illumos will try the hint and if that fails allocate as if there were
// no hint at all. The high hint prevents the break from getting hemmed in
// at low values, ceding half of the address space to the system heap.
raw_addr += 0x80000000;
#elif V8_OS_AIX
// The range 0x30000000 - 0xD0000000 is available on AIX;
// choose the upper range.
raw_addr += 0x90000000;
#else
// The range 0x20000000 - 0x60000000 is relatively unpopulated across a
// variety of ASLR modes (PAE kernel, NX compat mode, etc) and on macos
// 10.6 and 10.7.
raw_addr += 0x20000000;
#endif
#endif
#else // V8_OS_WIN
// The address range used to randomize RWX allocations in OS::Allocate
// Try not to map pages into the default range that windows loads DLLs
// Use a multiple of 64k to prevent committing unused memory.
// Note: This does not guarantee RWX regions will be within the
// range kAllocationRandomAddressMin to kAllocationRandomAddressMax
#ifdef V8_HOST_ARCH_64_BIT
static const uintptr_t kAllocationRandomAddressMin = 0x0000000080000000;
static const uintptr_t kAllocationRandomAddressMax = 0x000003FFFFFF0000;
#else
static const uintptr_t kAllocationRandomAddressMin = 0x04000000;
static const uintptr_t kAllocationRandomAddressMax = 0x3FFF0000;
#endif
raw_addr <<= kPageSizeBits;
raw_addr += kAllocationRandomAddressMin;
raw_addr &= kAllocationRandomAddressMax;
#endif // V8_OS_WIN
return reinterpret_cast<void*>(raw_addr);
}
} // namespace internal
} // namespace v8

View File

@ -159,6 +159,9 @@ bool AllocVirtualMemory(size_t size, void* hint, VirtualMemory* result);
bool AlignedAllocVirtualMemory(size_t size, size_t alignment, void* hint,
VirtualMemory* result);
// Generate a random address to be used for hinting mmap().
void* GetRandomMmapAddr();
} // namespace internal
} // namespace v8

View File

@ -485,7 +485,7 @@ class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
virtual void Free(void* data, size_t) { free(data); }
virtual void* Reserve(size_t length) {
return base::OS::ReserveRegion(length, base::OS::GetRandomMmapAddr());
return base::OS::ReserveRegion(length, i::GetRandomMmapAddr());
}
virtual void Free(void* data, size_t length,

View File

@ -205,7 +205,7 @@ std::vector<OS::SharedLibraryAddress> OS::GetSharedLibraryAddresses() {
return result;
}
void OS::SignalCodeMovingGC() {}
void OS::SignalCodeMovingGC(void* hint) {}
} // namespace base
} // namespace v8

View File

@ -220,8 +220,7 @@ std::vector<OS::SharedLibraryAddress> OS::GetSharedLibraryAddresses() {
return result;
}
void OS::SignalCodeMovingGC() {
void OS::SignalCodeMovingGC(void* hint) {
// Nothing to do on Cygwin.
}

View File

@ -183,7 +183,7 @@ std::vector<OS::SharedLibraryAddress> OS::GetSharedLibraryAddresses() {
return result;
}
void OS::SignalCodeMovingGC() {}
void OS::SignalCodeMovingGC(void* hint) {}
} // namespace base
} // namespace v8

View File

@ -140,7 +140,7 @@ std::vector<OS::SharedLibraryAddress> OS::GetSharedLibraryAddresses() {
return std::vector<SharedLibraryAddress>();
}
void OS::SignalCodeMovingGC() {
void OS::SignalCodeMovingGC(void* hint) {
CHECK(false); // TODO(scottmg): Port, https://crbug.com/731217.
}

View File

@ -272,7 +272,7 @@ std::vector<OS::SharedLibraryAddress> OS::GetSharedLibraryAddresses() {
return result;
}
void OS::SignalCodeMovingGC() {
void OS::SignalCodeMovingGC(void* hint) {
// Support for ll_prof.py.
//
// The Linux profiler built into the kernel logs all mmap's with
@ -287,8 +287,8 @@ void OS::SignalCodeMovingGC() {
OS::PrintError("Failed to open %s\n", OS::GetGCFakeMMapFile());
OS::Abort();
}
void* addr = mmap(OS::GetRandomMmapAddr(), size, PROT_READ | PROT_EXEC,
MAP_PRIVATE, fileno(f), 0);
void* addr =
mmap(hint, size, PROT_READ | PROT_EXEC, MAP_PRIVATE, fileno(f), 0);
DCHECK_NE(MAP_FAILED, addr);
OS::Free(addr, size);
fclose(f);

View File

@ -175,7 +175,7 @@ std::vector<OS::SharedLibraryAddress> OS::GetSharedLibraryAddresses() {
return result;
}
void OS::SignalCodeMovingGC() {}
void OS::SignalCodeMovingGC(void* hint) {}
TimezoneCache* OS::CreateTimezoneCache() {
return new PosixDefaultTimezoneCache();

View File

@ -198,8 +198,7 @@ std::vector<OS::SharedLibraryAddress> OS::GetSharedLibraryAddresses() {
return result;
}
void OS::SignalCodeMovingGC() {
void OS::SignalCodeMovingGC(void* hint) {
// Support for ll_prof.py.
//
// The Linux profiler built into the kernel logs all mmap's with
@ -214,9 +213,9 @@ void OS::SignalCodeMovingGC() {
OS::PrintError("Failed to open %s\n", OS::GetGCFakeMMapFile());
OS::Abort();
}
void* addr = mmap(NULL, size, PROT_READ | PROT_EXEC, MAP_PRIVATE,
fileno(f), 0);
DCHECK(addr != MAP_FAILED);
void* addr =
mmap(hint, size, PROT_READ | PROT_EXEC, MAP_PRIVATE, fileno(f), 0);
DCHECK_NE(MAP_FAILED, addr);
OS::Free(addr, size);
fclose(f);
}

View File

@ -150,15 +150,7 @@ void OS::Unprotect(void* address, const size_t size) {
#endif
}
static LazyInstance<RandomNumberGenerator>::type
platform_random_number_generator = LAZY_INSTANCE_INITIALIZER;
void OS::Initialize(int64_t random_seed, bool hard_abort,
const char* const gc_fake_mmap) {
if (random_seed) {
platform_random_number_generator.Pointer()->SetSeed(random_seed);
}
void OS::Initialize(bool hard_abort, const char* const gc_fake_mmap) {
g_hard_abort = hard_abort;
g_gc_fake_mmap = gc_fake_mmap;
}
@ -169,72 +161,6 @@ const char* OS::GetGCFakeMMapFile() {
}
void* OS::GetRandomMmapAddr() {
#if defined(ADDRESS_SANITIZER) || defined(MEMORY_SANITIZER) || \
defined(THREAD_SANITIZER)
// Dynamic tools do not support custom mmap addresses.
return NULL;
#endif
uintptr_t raw_addr;
platform_random_number_generator.Pointer()->NextBytes(&raw_addr,
sizeof(raw_addr));
#if V8_TARGET_ARCH_X64
// Currently available CPUs have 48 bits of virtual addressing. Truncate
// the hint address to 46 bits to give the kernel a fighting chance of
// fulfilling our placement request.
raw_addr &= V8_UINT64_C(0x3ffffffff000);
#elif V8_TARGET_ARCH_PPC64
#if V8_OS_AIX
// AIX: 64 bits of virtual addressing, but we limit address range to:
// a) minimize Segment Lookaside Buffer (SLB) misses and
raw_addr &= V8_UINT64_C(0x3ffff000);
// Use extra address space to isolate the mmap regions.
raw_addr += V8_UINT64_C(0x400000000000);
#elif V8_TARGET_BIG_ENDIAN
// Big-endian Linux: 44 bits of virtual addressing.
raw_addr &= V8_UINT64_C(0x03fffffff000);
#else
// Little-endian Linux: 48 bits of virtual addressing.
raw_addr &= V8_UINT64_C(0x3ffffffff000);
#endif
#elif V8_TARGET_ARCH_S390X
// Linux on Z uses bits 22-32 for Region Indexing, which translates to 42 bits
// of virtual addressing. Truncate to 40 bits to allow kernel chance to
// fulfill request.
raw_addr &= V8_UINT64_C(0xfffffff000);
#elif V8_TARGET_ARCH_S390
// 31 bits of virtual addressing. Truncate to 29 bits to allow kernel chance
// to fulfill request.
raw_addr &= 0x1ffff000;
#else
raw_addr &= 0x3ffff000;
# ifdef __sun
// For our Solaris/illumos mmap hint, we pick a random address in the bottom
// half of the top half of the address space (that is, the third quarter).
// Because we do not MAP_FIXED, this will be treated only as a hint -- the
// system will not fail to mmap() because something else happens to already
// be mapped at our random address. We deliberately set the hint high enough
// to get well above the system's break (that is, the heap); Solaris and
// illumos will try the hint and if that fails allocate as if there were
// no hint at all. The high hint prevents the break from getting hemmed in
// at low values, ceding half of the address space to the system heap.
raw_addr += 0x80000000;
#elif V8_OS_AIX
// The range 0x30000000 - 0xD0000000 is available on AIX;
// choose the upper range.
raw_addr += 0x90000000;
# else
// The range 0x20000000 - 0x60000000 is relatively unpopulated across a
// variety of ASLR modes (PAE kernel, NX compat mode, etc) and on macos
// 10.6 and 10.7.
raw_addr += 0x20000000;
# endif
#endif
return reinterpret_cast<void*>(raw_addr);
}
size_t OS::AllocateAlignment() {
return static_cast<size_t>(sysconf(_SC_PAGESIZE));
}
@ -294,14 +220,13 @@ class PosixMemoryMappedFile final : public OS::MemoryMappedFile {
// static
OS::MemoryMappedFile* OS::MemoryMappedFile::open(const char* name) {
OS::MemoryMappedFile* OS::MemoryMappedFile::open(const char* name, void* hint) {
if (FILE* file = fopen(name, "r+")) {
if (fseek(file, 0, SEEK_END) == 0) {
long size = ftell(file); // NOLINT(runtime/int)
if (size >= 0) {
void* const memory =
mmap(OS::GetRandomMmapAddr(), size, PROT_READ | PROT_WRITE,
MAP_SHARED, fileno(file), 0);
void* const memory = mmap(hint, size, PROT_READ | PROT_WRITE,
MAP_SHARED, fileno(file), 0);
if (memory != MAP_FAILED) {
return new PosixMemoryMappedFile(file, memory, size);
}
@ -314,13 +239,13 @@ OS::MemoryMappedFile* OS::MemoryMappedFile::open(const char* name) {
// static
OS::MemoryMappedFile* OS::MemoryMappedFile::create(const char* name,
OS::MemoryMappedFile* OS::MemoryMappedFile::create(const char* name, void* hint,
size_t size, void* initial) {
if (FILE* file = fopen(name, "w+")) {
size_t result = fwrite(initial, 1, size, file);
if (result == size && !ferror(file)) {
void* memory = mmap(OS::GetRandomMmapAddr(), result,
PROT_READ | PROT_WRITE, MAP_SHARED, fileno(file), 0);
void* memory = mmap(hint, result, PROT_READ | PROT_WRITE, MAP_SHARED,
fileno(file), 0);
if (memory != MAP_FAILED) {
return new PosixMemoryMappedFile(file, memory, result);
}

View File

@ -242,7 +242,7 @@ std::vector<OS::SharedLibraryAddress> OS::GetSharedLibraryAddresses() {
return result;
}
void OS::SignalCodeMovingGC() {}
void OS::SignalCodeMovingGC(void* hint) {}
} // namespace base
} // namespace v8

View File

@ -163,7 +163,7 @@ std::vector<OS::SharedLibraryAddress> OS::GetSharedLibraryAddresses() {
return std::vector<SharedLibraryAddress>();
}
void OS::SignalCodeMovingGC() {}
void OS::SignalCodeMovingGC(void* hint) {}
} // namespace base
} // namespace v8

View File

@ -20,12 +20,10 @@
#include "src/base/win32-headers.h"
#include "src/base/bits.h"
#include "src/base/lazy-instance.h"
#include "src/base/macros.h"
#include "src/base/platform/platform.h"
#include "src/base/platform/time.h"
#include "src/base/timezone-cache.h"
#include "src/base/utils/random-number-generator.h"
// Extra functions for MinGW. Most of these are the _s functions which are in
// the Microsoft Visual Studio C++ CRT.
@ -701,42 +699,10 @@ size_t OS::AllocateAlignment() {
return allocate_alignment;
}
static LazyInstance<RandomNumberGenerator>::type
platform_random_number_generator = LAZY_INSTANCE_INITIALIZER;
void OS::Initialize(int64_t random_seed, bool hard_abort,
const char* const gc_fake_mmap) {
if (random_seed) {
platform_random_number_generator.Pointer()->SetSeed(random_seed);
}
void OS::Initialize(bool hard_abort, const char* const gc_fake_mmap) {
g_hard_abort = hard_abort;
}
void* OS::GetRandomMmapAddr() {
// The address range used to randomize RWX allocations in OS::Allocate
// Try not to map pages into the default range that windows loads DLLs
// Use a multiple of 64k to prevent committing unused memory.
// Note: This does not guarantee RWX regions will be within the
// range kAllocationRandomAddressMin to kAllocationRandomAddressMax
#ifdef V8_HOST_ARCH_64_BIT
static const uintptr_t kAllocationRandomAddressMin = 0x0000000080000000;
static const uintptr_t kAllocationRandomAddressMax = 0x000003FFFFFF0000;
#else
static const uintptr_t kAllocationRandomAddressMin = 0x04000000;
static const uintptr_t kAllocationRandomAddressMax = 0x3FFF0000;
#endif
uintptr_t address;
platform_random_number_generator.Pointer()->NextBytes(&address,
sizeof(address));
address <<= kPageSizeBits;
address += kAllocationRandomAddressMin;
address &= kAllocationRandomAddressMax;
return reinterpret_cast<void *>(address);
}
namespace {
static void* RandomizedVirtualAlloc(size_t size, int action, int protection,
@ -952,7 +918,7 @@ class Win32MemoryMappedFile final : public OS::MemoryMappedFile {
// static
OS::MemoryMappedFile* OS::MemoryMappedFile::open(const char* name) {
OS::MemoryMappedFile* OS::MemoryMappedFile::open(const char* name, void* hint) {
// Open a physical file
HANDLE file = CreateFileA(name, GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
@ -960,7 +926,7 @@ OS::MemoryMappedFile* OS::MemoryMappedFile::open(const char* name) {
DWORD size = GetFileSize(file, NULL);
// Create a file mapping for the physical file
// Create a file mapping for the physical file. Ignore hint on Windows.
HANDLE file_mapping =
CreateFileMapping(file, NULL, PAGE_READWRITE, 0, size, NULL);
if (file_mapping == NULL) return NULL;
@ -972,14 +938,14 @@ OS::MemoryMappedFile* OS::MemoryMappedFile::open(const char* name) {
// static
OS::MemoryMappedFile* OS::MemoryMappedFile::create(const char* name,
OS::MemoryMappedFile* OS::MemoryMappedFile::create(const char* name, void* hint,
size_t size, void* initial) {
// Open a physical file
HANDLE file = CreateFileA(name, GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
OPEN_ALWAYS, 0, NULL);
if (file == NULL) return NULL;
// Create a file mapping for the physical file
// Create a file mapping for the physical file. Ignore hint on Windows.
HANDLE file_mapping = CreateFileMapping(file, NULL, PAGE_READWRITE, 0,
static_cast<DWORD>(size), NULL);
if (file_mapping == NULL) return NULL;
@ -1248,20 +1214,13 @@ std::vector<OS::SharedLibraryAddress> OS::GetSharedLibraryAddresses() {
return LoadSymbols(process_handle);
}
void OS::SignalCodeMovingGC() {
}
#else // __MINGW32__
std::vector<OS::SharedLibraryAddress> OS::GetSharedLibraryAddresses() {
return std::vector<OS::SharedLibraryAddress>();
}
void OS::SignalCodeMovingGC() { }
#endif // __MINGW32__
void OS::SignalCodeMovingGC(void* hint) {}
int OS::ActivationFrameAlignment() {
#ifdef _WIN64

View File

@ -107,12 +107,9 @@ class TimezoneCache;
class V8_BASE_EXPORT OS {
public:
// Initialize the OS class.
// - random_seed: Used for the GetRandomMmapAddress() if non-zero.
// - hard_abort: If true, OS::Abort() will crash instead of aborting.
// - gc_fake_mmap: Name of the file for fake gc mmap used in ll_prof.
static void Initialize(int64_t random_seed,
bool hard_abort,
const char* const gc_fake_mmap);
static void Initialize(bool hard_abort, const char* const gc_fake_mmap);
// Returns the accumulated user time for thread. This routine
// can be used for profiling. The implementation should
@ -191,9 +188,6 @@ class V8_BASE_EXPORT OS {
// Make a region of memory readable and writable.
static void Unprotect(void* address, const size_t size);
// Generate a random address to be used for hinting mmap().
static void* GetRandomMmapAddr();
// Get the Alignment guaranteed by Allocate().
static size_t AllocateAlignment();
@ -237,8 +231,8 @@ class V8_BASE_EXPORT OS {
virtual void* memory() const = 0;
virtual size_t size() const = 0;
static MemoryMappedFile* open(const char* name);
static MemoryMappedFile* create(const char* name, size_t size,
static MemoryMappedFile* open(const char* name, void* hint);
static MemoryMappedFile* create(const char* name, void* hint, size_t size,
void* initial);
};
@ -277,7 +271,7 @@ class V8_BASE_EXPORT OS {
// process that a code moving garbage collection starts. Can do
// nothing, in which case the code objects must not move (e.g., by
// using --never-compact) if accurate profiling is desired.
static void SignalCodeMovingGC();
static void SignalCodeMovingGC(void* hint);
// Support runtime detection of whether the hard float option of the
// EABI is used.

View File

@ -1545,7 +1545,7 @@ Counter* CounterCollection::GetNextCounter() {
void Shell::MapCounters(v8::Isolate* isolate, const char* name) {
counters_file_ = base::OS::MemoryMappedFile::create(
name, sizeof(CounterCollection), &local_counters_);
name, nullptr, sizeof(CounterCollection), &local_counters_);
void* memory = (counters_file_ == NULL) ?
NULL : counters_file_->memory();
if (memory == NULL) {

View File

@ -5392,7 +5392,7 @@ bool Heap::SetUp() {
}
mmap_region_base_ =
reinterpret_cast<uintptr_t>(base::OS::GetRandomMmapAddr()) &
reinterpret_cast<uintptr_t>(v8::internal::GetRandomMmapAddr()) &
~kMmapRegionMask;
// Set up memory allocator.

View File

@ -1521,7 +1521,7 @@ class Heap {
void ReportCodeStatistics(const char* title);
#endif
void* GetRandomMmapAddr() {
void* result = base::OS::GetRandomMmapAddr();
void* result = v8::internal::GetRandomMmapAddr();
#if V8_TARGET_ARCH_X64
#if V8_OS_MACOSX
// The Darwin kernel [as of macOS 10.12.5] does not clean up page
@ -1532,7 +1532,7 @@ class Heap {
// killed. Confine the hint to a 32-bit section of the virtual address
// space. See crbug.com/700928.
uintptr_t offset =
reinterpret_cast<uintptr_t>(base::OS::GetRandomMmapAddr()) &
reinterpret_cast<uintptr_t>(v8::internal::GetRandomMmapAddr()) &
kMmapRegionMask;
result = reinterpret_cast<void*>(mmap_region_base_ + offset);
#endif // V8_OS_MACOSX

View File

@ -122,7 +122,7 @@ bool CodeRange::SetUp(size_t requested) {
requested,
Max(kCodeRangeAreaAlignment,
static_cast<size_t>(base::OS::AllocateAlignment())),
base::OS::GetRandomMmapAddr(), &reservation)) {
v8::internal::GetRandomMmapAddr(), &reservation)) {
return false;
}

View File

@ -1281,7 +1281,7 @@ void Logger::CodeDisableOptEvent(AbstractCode* code,
void Logger::CodeMovingGCEvent() {
if (!is_logging_code_events()) return;
if (!log_->IsEnabled() || !FLAG_ll_prof) return;
base::OS::SignalCodeMovingGC();
base::OS::SignalCodeMovingGC(GetRandomMmapAddr());
}
void Logger::RegExpCodeCreateEvent(AbstractCode* code, String* source) {

View File

@ -66,7 +66,7 @@ void V8::InitializeOncePerProcessImpl() {
FLAG_max_semi_space_size = 1;
}
base::OS::Initialize(FLAG_random_seed, FLAG_hard_abort, FLAG_gc_fake_mmap);
base::OS::Initialize(FLAG_hard_abort, FLAG_gc_fake_mmap);
Isolate::InitializeOncePerProcess();

View File

@ -54,7 +54,7 @@ size_t GetHugeMemoryAmount() {
static size_t huge_memory = 0;
if (!huge_memory) {
for (int i = 0; i < 100; i++) {
huge_memory |= bit_cast<size_t>(v8::base::OS::GetRandomMmapAddr());
huge_memory |= bit_cast<size_t>(v8::internal::GetRandomMmapAddr());
}
// Make it larger than the available address space.
huge_memory *= 2;

View File

@ -37,7 +37,7 @@ namespace internal {
TEST(OSReserveMemory) {
size_t mem_size = 0;
void* mem_addr = OS::ReserveAlignedRegion(1 * MB, OS::AllocateAlignment(),
OS::GetRandomMmapAddr(), &mem_size);
GetRandomMmapAddr(), &mem_size);
CHECK_NE(0, mem_size);
CHECK_NOT_NULL(mem_addr);
size_t block_size = 4 * KB;

View File

@ -37,7 +37,7 @@ namespace internal {
TEST(OSReserveMemory) {
size_t mem_size = 0;
void* mem_addr = OS::ReserveAlignedRegion(1 * MB, OS::AllocateAlignment(),
OS::GetRandomMmapAddr(), &mem_size);
GetRandomMmapAddr(), &mem_size);
CHECK_NE(0, mem_size);
CHECK_NOT_NULL(mem_addr);
size_t block_size = 4 * KB;

View File

@ -99,7 +99,7 @@ TEST_F(HeapTest, ASLR) {
}
if (hints.size() == 1) {
EXPECT_TRUE((*hints.begin()) == nullptr);
EXPECT_TRUE(base::OS::GetRandomMmapAddr() == nullptr);
EXPECT_TRUE(v8::internal::GetRandomMmapAddr() == nullptr);
} else {
// It is unlikely that 1000 random samples will collide to less then 500
// values.