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

Side by Side Diff: src/platform-cygwin.cc

Issue 23548024: Introduce a RandonNumberGenerator class. Refactor the random/private_random uses in Isolate/Context. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: REBASE Created 7 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/platform.h ('k') | src/platform-freebsd.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 // Use a multiple of 64k to prevent committing unused memory. 229 // Use a multiple of 64k to prevent committing unused memory.
230 // Note: This does not guarantee RWX regions will be within the 230 // Note: This does not guarantee RWX regions will be within the
231 // range kAllocationRandomAddressMin to kAllocationRandomAddressMax 231 // range kAllocationRandomAddressMin to kAllocationRandomAddressMax
232 #ifdef V8_HOST_ARCH_64_BIT 232 #ifdef V8_HOST_ARCH_64_BIT
233 static const intptr_t kAllocationRandomAddressMin = 0x0000000080000000; 233 static const intptr_t kAllocationRandomAddressMin = 0x0000000080000000;
234 static const intptr_t kAllocationRandomAddressMax = 0x000003FFFFFF0000; 234 static const intptr_t kAllocationRandomAddressMax = 0x000003FFFFFF0000;
235 #else 235 #else
236 static const intptr_t kAllocationRandomAddressMin = 0x04000000; 236 static const intptr_t kAllocationRandomAddressMin = 0x04000000;
237 static const intptr_t kAllocationRandomAddressMax = 0x3FFF0000; 237 static const intptr_t kAllocationRandomAddressMax = 0x3FFF0000;
238 #endif 238 #endif
239 uintptr_t address = (V8::RandomPrivate(isolate) << kPageSizeBits) 239 uintptr_t address =
240 | kAllocationRandomAddressMin; 240 (isolate->random_number_generator()->NextInt() << kPageSizeBits) |
241 kAllocationRandomAddressMin;
241 address &= kAllocationRandomAddressMax; 242 address &= kAllocationRandomAddressMax;
242 return reinterpret_cast<void *>(address); 243 return reinterpret_cast<void *>(address);
243 } 244 }
244 return NULL; 245 return NULL;
245 } 246 }
246 247
247 248
248 static void* RandomizedVirtualAlloc(size_t size, int action, int protection) { 249 static void* RandomizedVirtualAlloc(size_t size, int action, int protection) {
249 LPVOID base = NULL; 250 LPVOID base = NULL;
250 251
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 bool VirtualMemory::ReleaseRegion(void* base, size_t size) { 360 bool VirtualMemory::ReleaseRegion(void* base, size_t size) {
360 return VirtualFree(base, 0, MEM_RELEASE) != 0; 361 return VirtualFree(base, 0, MEM_RELEASE) != 0;
361 } 362 }
362 363
363 364
364 bool VirtualMemory::HasLazyCommits() { 365 bool VirtualMemory::HasLazyCommits() {
365 // TODO(alph): implement for the platform. 366 // TODO(alph): implement for the platform.
366 return false; 367 return false;
367 } 368 }
368 369
369
370 void OS::SetUp() {
371 // Seed the random number generator.
372 // Convert the current time to a 64-bit integer first, before converting it
373 // to an unsigned. Going directly can cause an overflow and the seed to be
374 // set to all ones. The seed will be identical for different instances that
375 // call this setup code within the same millisecond.
376 uint64_t seed = static_cast<uint64_t>(TimeCurrentMillis());
377 srandom(static_cast<unsigned int>(seed));
378 }
379
380
381 } } // namespace v8::internal 370 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/platform.h ('k') | src/platform-freebsd.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698