OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |