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 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
694 kMmapFd, | 694 kMmapFd, |
695 kMmapFdOffset) != MAP_FAILED; | 695 kMmapFdOffset) != MAP_FAILED; |
696 } | 696 } |
697 | 697 |
698 | 698 |
699 bool VirtualMemory::ReleaseRegion(void* base, size_t size) { | 699 bool VirtualMemory::ReleaseRegion(void* base, size_t size) { |
700 return munmap(base, size) == 0; | 700 return munmap(base, size) == 0; |
701 } | 701 } |
702 | 702 |
703 | 703 |
| 704 bool VirtualMemory::CommittedPhysicalSizeInRegion( |
| 705 void* base, size_t size, size_t* physical) { |
| 706 const size_t page_size = sysconf(_SC_PAGESIZE); |
| 707 base = reinterpret_cast<void*>( |
| 708 reinterpret_cast<intptr_t>(base) & ~(page_size - 1)); |
| 709 const size_t pages = (size + page_size - 1) / page_size; |
| 710 ScopedVector<unsigned char> buffer(pages); |
| 711 int result = mincore(base, size, buffer.start()); |
| 712 if (result) return false; |
| 713 int resident_pages = 0; |
| 714 for (unsigned i = 0; i < pages; ++i) { |
| 715 resident_pages += buffer[i] & 1; |
| 716 } |
| 717 *physical = resident_pages * page_size; |
| 718 return true; |
| 719 } |
| 720 |
| 721 |
704 class Thread::PlatformData : public Malloced { | 722 class Thread::PlatformData : public Malloced { |
705 public: | 723 public: |
706 PlatformData() : thread_(kNoThread) {} | 724 PlatformData() : thread_(kNoThread) {} |
707 | 725 |
708 pthread_t thread_; // Thread handle for pthread. | 726 pthread_t thread_; // Thread handle for pthread. |
709 }; | 727 }; |
710 | 728 |
711 Thread::Thread(const Options& options) | 729 Thread::Thread(const Options& options) |
712 : data_(new PlatformData()), | 730 : data_(new PlatformData()), |
713 stack_size_(options.stack_size()) { | 731 stack_size_(options.stack_size()) { |
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1287 | 1305 |
1288 | 1306 |
1289 void Sampler::Stop() { | 1307 void Sampler::Stop() { |
1290 ASSERT(IsActive()); | 1308 ASSERT(IsActive()); |
1291 SignalSender::RemoveActiveSampler(this); | 1309 SignalSender::RemoveActiveSampler(this); |
1292 SetActive(false); | 1310 SetActive(false); |
1293 } | 1311 } |
1294 | 1312 |
1295 | 1313 |
1296 } } // namespace v8::internal | 1314 } } // namespace v8::internal |
OLD | NEW |