Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 75 void OS::ProtectCode(void* address, const size_t size) { | 75 void OS::ProtectCode(void* address, const size_t size) { |
| 76 mprotect(address, size, PROT_READ | PROT_EXEC); | 76 mprotect(address, size, PROT_READ | PROT_EXEC); |
| 77 } | 77 } |
| 78 | 78 |
| 79 | 79 |
| 80 // Create guard pages. | 80 // Create guard pages. |
| 81 void OS::Guard(void* address, const size_t size) { | 81 void OS::Guard(void* address, const size_t size) { |
| 82 mprotect(address, size, PROT_NONE); | 82 mprotect(address, size, PROT_NONE); |
| 83 } | 83 } |
| 84 #endif // __CYGWIN__ | 84 #endif // __CYGWIN__ |
| 85 | 85 |
|
Vyacheslav Egorov (Chromium)
2011/10/10 14:13:14
one more new line required
| |
| 86 void* OS::GetRandomMmapAddr() { | |
| 87 Isolate* isolate = Isolate::UncheckedCurrent(); | |
| 88 // Note that the current isolate isn't set up in a call path via | |
| 89 // CpuFeatures::Probe. We don't care about randomization in this case because | |
| 90 // the code page is immediately freed. | |
| 91 if (isolate != NULL) { | |
| 92 #ifdef V8_TARGET_ARCH_X64 | |
| 93 uint64_t rnd1 = V8::RandomPrivate(isolate); | |
| 94 uint64_t rnd2 = V8::RandomPrivate(isolate); | |
| 95 uint64_t raw_addr = (rnd1 << 32) ^ rnd2; | |
| 96 // Currently available CPUs have 48 bits of virtual addressing. Truncate | |
| 97 // the hint address to 46 bits to give the kernel a fighting chance of | |
| 98 // fulfilling our placement request. | |
| 99 raw_addr &= V8_UINT64_C(0x3ffffffff000); | |
| 100 #else | |
| 101 uint32_t raw_addr = V8::RandomPrivate(isolate); | |
| 102 // The range 0x20000000 - 0x60000000 is relatively unpopulated across a | |
| 103 // variety of ASLR modes (PAE kernel, NX compat mode, etc) and on macos | |
| 104 // 10.6 and 10.7. | |
| 105 raw_addr &= 0x3ffff000; | |
| 106 raw_addr += 0x20000000; | |
| 107 #endif | |
| 108 return reinterpret_cast<void*>(raw_addr); | |
| 109 } | |
| 110 return NULL; | |
| 111 } | |
| 112 | |
| 86 | 113 |
| 87 // ---------------------------------------------------------------------------- | 114 // ---------------------------------------------------------------------------- |
| 88 // Math functions | 115 // Math functions |
| 89 | 116 |
| 90 double modulo(double x, double y) { | 117 double modulo(double x, double y) { |
| 91 return fmod(x, y); | 118 return fmod(x, y); |
| 92 } | 119 } |
| 93 | 120 |
| 94 | 121 |
| 95 double OS::nan_value() { | 122 double OS::nan_value() { |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 457 return ntohl(value); | 484 return ntohl(value); |
| 458 } | 485 } |
| 459 | 486 |
| 460 | 487 |
| 461 Socket* OS::CreateSocket() { | 488 Socket* OS::CreateSocket() { |
| 462 return new POSIXSocket(); | 489 return new POSIXSocket(); |
| 463 } | 490 } |
| 464 | 491 |
| 465 | 492 |
| 466 } } // namespace v8::internal | 493 } } // namespace v8::internal |
| OLD | NEW |