Commit 4c92b673 authored by vegorov@chromium.org's avatar vegorov@chromium.org

RandomizedVirtualAlloc should check for isolate presence instead of using Isolate::Current()

CpuFeatures::Probe request executable memory before any isolate is initialized and entered.

TBR=erik.corry@gmail.com

Review URL: https://chromiumcodereview.appspot.com/9433051

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@10798 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 283098fd
...@@ -837,22 +837,29 @@ size_t OS::AllocateAlignment() { ...@@ -837,22 +837,29 @@ size_t OS::AllocateAlignment() {
static void* GetRandomAddr() { static void* GetRandomAddr() {
// The address range used to randomize RWX allocations in OS::Allocate Isolate* isolate = Isolate::UncheckedCurrent();
// Try not to map pages into the default range that windows loads DLLs // Note that the current isolate isn't set up in a call path via
// Use a multiple of 64k to prevent committing unused memory. // CpuFeatures::Probe. We don't care about randomization in this case because
// Note: This does not guarantee RWX regions will be within the // the code page is immediately freed.
// range kAllocationRandomAddressMin to kAllocationRandomAddressMax 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
#ifdef V8_HOST_ARCH_64_BIT #ifdef V8_HOST_ARCH_64_BIT
static const intptr_t kAllocationRandomAddressMin = 0x0000000080000000; static const intptr_t kAllocationRandomAddressMin = 0x0000000080000000;
static const intptr_t kAllocationRandomAddressMax = 0x000003FFFFFF0000; static const intptr_t kAllocationRandomAddressMax = 0x000003FFFFFF0000;
#else #else
static const intptr_t kAllocationRandomAddressMin = 0x04000000; static const intptr_t kAllocationRandomAddressMin = 0x04000000;
static const intptr_t kAllocationRandomAddressMax = 0x3FFF0000; static const intptr_t kAllocationRandomAddressMax = 0x3FFF0000;
#endif #endif
uintptr_t address = (V8::RandomPrivate(Isolate::Current()) << kPageSizeBits) uintptr_t address = (V8::RandomPrivate(isolate) << kPageSizeBits)
| kAllocationRandomAddressMin; | kAllocationRandomAddressMin;
address &= kAllocationRandomAddressMax; address &= kAllocationRandomAddressMax;
return reinterpret_cast<void *>(address); return reinterpret_cast<void *>(address);
}
return NULL;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment