Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(161)

Unified Diff: src/platform-win32.cc

Issue 347223004: Remove dependency from platform.h implementations on isolate (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/platform-posix.cc ('k') | src/utils/random-number-generator.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
« no previous file with comments | « src/platform-posix.cc ('k') | src/utils/random-number-generator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698