| 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 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 if (0 == munmap(address(), size())) address_ = MAP_FAILED; | 335 if (0 == munmap(address(), size())) address_ = MAP_FAILED; |
| 336 } | 336 } |
| 337 } | 337 } |
| 338 | 338 |
| 339 | 339 |
| 340 bool VirtualMemory::IsReserved() { | 340 bool VirtualMemory::IsReserved() { |
| 341 return address_ != MAP_FAILED; | 341 return address_ != MAP_FAILED; |
| 342 } | 342 } |
| 343 | 343 |
| 344 | 344 |
| 345 bool VirtualMemory::Commit(void* address, size_t size, bool executable) { | 345 bool VirtualMemory::Guard(void* address) { |
| 346 int prot = PROT_READ | PROT_WRITE | (executable ? PROT_EXEC : 0); | 346 OS::Guard(address, OS::CommitPageSize()); |
| 347 if (MAP_FAILED == mmap(address, size, prot, | 347 return true; |
| 348 MAP_PRIVATE | MAP_ANON | MAP_FIXED, | 348 } |
| 349 kMmapFd, kMmapFdOffset)) { | 349 |
| 350 |
| 351 void* VirtualMemory::ReserveRegion(size_t size) { |
| 352 void* result = mmap(OS::GetRandomMmapAddr(), |
| 353 size, |
| 354 PROT_NONE, |
| 355 MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE, |
| 356 kMmapFd, |
| 357 kMmapFdOffset); |
| 358 |
| 359 if (result == MAP_FAILED) return NULL; |
| 360 |
| 361 return result; |
| 362 } |
| 363 |
| 364 |
| 365 bool VirtualMemory::CommitRegion(void* base, size_t size, bool is_executable) { |
| 366 int prot = PROT_READ | PROT_WRITE | (is_executable ? PROT_EXEC : 0); |
| 367 if (MAP_FAILED == mmap(base, |
| 368 size, |
| 369 prot, |
| 370 MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, |
| 371 kMmapFd, |
| 372 kMmapFdOffset)) { |
| 350 return false; | 373 return false; |
| 351 } | 374 } |
| 352 | 375 |
| 353 UpdateAllocatedSpaceLimits(address, size); | 376 UpdateAllocatedSpaceLimits(address, size); |
| 354 return true; | 377 return true; |
| 355 } | 378 } |
| 356 | 379 |
| 357 | 380 |
| 358 bool VirtualMemory::Uncommit(void* address, size_t size) { | 381 bool VirtualMemory::Uncommit(void* address, size_t size) { |
| 359 return mmap(address, size, PROT_NONE, | 382 return mmap(address, size, PROT_NONE, |
| (...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 791 } | 814 } |
| 792 | 815 |
| 793 | 816 |
| 794 void Sampler::Stop() { | 817 void Sampler::Stop() { |
| 795 ASSERT(IsActive()); | 818 ASSERT(IsActive()); |
| 796 SignalSender::RemoveActiveSampler(this); | 819 SignalSender::RemoveActiveSampler(this); |
| 797 SetActive(false); | 820 SetActive(false); |
| 798 } | 821 } |
| 799 | 822 |
| 800 } } // namespace v8::internal | 823 } } // namespace v8::internal |
| OLD | NEW |