| Index: src/platform-win32.cc
|
| diff --git a/src/platform-win32.cc b/src/platform-win32.cc
|
| index b1e6478bc8c25bbed9698a9670247c7efc7a126c..9fe3e1411245ea929bd2ec0129985b3b46fb02b3 100644
|
| --- a/src/platform-win32.cc
|
| +++ b/src/platform-win32.cc
|
| @@ -19,8 +19,9 @@
|
|
|
| #include "src/v8.h"
|
|
|
| -#include "src/isolate-inl.h"
|
| +#include "src/base/lazy-instance.h"
|
| #include "src/platform.h"
|
| +#include "src/utils/random-number-generator.h"
|
|
|
| #ifdef _MSC_VER
|
|
|
| @@ -708,31 +709,33 @@ size_t OS::AllocateAlignment() {
|
| }
|
|
|
|
|
| +static base::LazyInstance<RandomNumberGenerator>::type
|
| + platform_random_number_generator = LAZY_INSTANCE_INITIALIZER;
|
| +
|
| +
|
| +void OS::SetRandomSeed(int64_t seed) {
|
| + platform_random_number_generator.Pointer()->SetSeed(seed);
|
| +}
|
| +
|
| +
|
| void* OS::GetRandomMmapAddr() {
|
| - Isolate* isolate = Isolate::UncheckedCurrent();
|
| - // Note that the current isolate isn't set up in a call path via
|
| - // CpuFeatures::Probe. We don't care about randomization in this case because
|
| - // the code page is immediately freed.
|
| - if (isolate != NULL) {
|
| - // 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
|
| + // 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 intptr_t kAllocationRandomAddressMin = 0x0000000080000000;
|
| - static const intptr_t kAllocationRandomAddressMax = 0x000003FFFFFF0000;
|
| + static const intptr_t kAllocationRandomAddressMin = 0x0000000080000000;
|
| + static const intptr_t kAllocationRandomAddressMax = 0x000003FFFFFF0000;
|
| #else
|
| - static const intptr_t kAllocationRandomAddressMin = 0x04000000;
|
| - static const intptr_t kAllocationRandomAddressMax = 0x3FFF0000;
|
| + static const intptr_t kAllocationRandomAddressMin = 0x04000000;
|
| + static const intptr_t kAllocationRandomAddressMax = 0x3FFF0000;
|
| #endif
|
| - uintptr_t address =
|
| - (isolate->random_number_generator()->NextInt() << kPageSizeBits) |
|
| - kAllocationRandomAddressMin;
|
| - address &= kAllocationRandomAddressMax;
|
| - return reinterpret_cast<void *>(address);
|
| - }
|
| - return NULL;
|
| + uintptr_t address =
|
| + (platform_random_number_generator.Pointer()->NextInt() << kPageSizeBits) |
|
| + kAllocationRandomAddressMin;
|
| + address &= kAllocationRandomAddressMax;
|
| + return reinterpret_cast<void *>(address);
|
| }
|
|
|
|
|
|
|