| OLD | NEW |
| 1 // Copyright 2006-2011 the V8 project authors. All rights reserved. | 1 // Copyright 2006-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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 } | 225 } |
| 226 | 226 |
| 227 | 227 |
| 228 PosixMemoryMappedFile::~PosixMemoryMappedFile() { | 228 PosixMemoryMappedFile::~PosixMemoryMappedFile() { |
| 229 if (memory_) munmap(memory_, size_); | 229 if (memory_) munmap(memory_, size_); |
| 230 fclose(file_); | 230 fclose(file_); |
| 231 } | 231 } |
| 232 | 232 |
| 233 | 233 |
| 234 void OS::LogSharedLibraryAddresses() { | 234 void OS::LogSharedLibraryAddresses() { |
| 235 #ifdef ENABLE_LOGGING_AND_PROFILING | |
| 236 // This function assumes that the layout of the file is as follows: | 235 // This function assumes that the layout of the file is as follows: |
| 237 // hex_start_addr-hex_end_addr rwxp <unused data> [binary_file_name] | 236 // hex_start_addr-hex_end_addr rwxp <unused data> [binary_file_name] |
| 238 // If we encounter an unexpected situation we abort scanning further entries. | 237 // If we encounter an unexpected situation we abort scanning further entries. |
| 239 FILE* fp = fopen("/proc/self/maps", "r"); | 238 FILE* fp = fopen("/proc/self/maps", "r"); |
| 240 if (fp == NULL) return; | 239 if (fp == NULL) return; |
| 241 | 240 |
| 242 // Allocate enough room to be able to store a full file name. | 241 // Allocate enough room to be able to store a full file name. |
| 243 const int kLibNameLen = FILENAME_MAX + 1; | 242 const int kLibNameLen = FILENAME_MAX + 1; |
| 244 char* lib_name = reinterpret_cast<char*>(malloc(kLibNameLen)); | 243 char* lib_name = reinterpret_cast<char*>(malloc(kLibNameLen)); |
| 245 | 244 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 // Entry not describing executable data. Skip to end of line to setup | 281 // Entry not describing executable data. Skip to end of line to setup |
| 283 // reading the next entry. | 282 // reading the next entry. |
| 284 do { | 283 do { |
| 285 c = getc(fp); | 284 c = getc(fp); |
| 286 } while ((c != EOF) && (c != '\n')); | 285 } while ((c != EOF) && (c != '\n')); |
| 287 if (c == EOF) break; | 286 if (c == EOF) break; |
| 288 } | 287 } |
| 289 } | 288 } |
| 290 free(lib_name); | 289 free(lib_name); |
| 291 fclose(fp); | 290 fclose(fp); |
| 292 #endif | |
| 293 } | 291 } |
| 294 | 292 |
| 295 | 293 |
| 296 void OS::SignalCodeMovingGC() { | 294 void OS::SignalCodeMovingGC() { |
| 297 // Nothing to do on Cygwin. | 295 // Nothing to do on Cygwin. |
| 298 } | 296 } |
| 299 | 297 |
| 300 | 298 |
| 301 int OS::StackWalk(Vector<OS::StackFrame> frames) { | 299 int OS::StackWalk(Vector<OS::StackFrame> frames) { |
| 302 // Not supported on Cygwin. | 300 // Not supported on Cygwin. |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 CHECK(result == -1 && errno == EINTR); // Signal caused spurious wakeup. | 565 CHECK(result == -1 && errno == EINTR); // Signal caused spurious wakeup. |
| 568 } | 566 } |
| 569 } | 567 } |
| 570 | 568 |
| 571 | 569 |
| 572 Semaphore* OS::CreateSemaphore(int count) { | 570 Semaphore* OS::CreateSemaphore(int count) { |
| 573 return new CygwinSemaphore(count); | 571 return new CygwinSemaphore(count); |
| 574 } | 572 } |
| 575 | 573 |
| 576 | 574 |
| 577 #ifdef ENABLE_LOGGING_AND_PROFILING | |
| 578 | |
| 579 // ---------------------------------------------------------------------------- | 575 // ---------------------------------------------------------------------------- |
| 580 // Cygwin profiler support. | 576 // Cygwin profiler support. |
| 581 // | 577 // |
| 582 // On Cygwin we use the same sampler implementation as on win32. | 578 // On Cygwin we use the same sampler implementation as on win32. |
| 583 | 579 |
| 584 class Sampler::PlatformData : public Malloced { | 580 class Sampler::PlatformData : public Malloced { |
| 585 public: | 581 public: |
| 586 // Get a handle to the calling thread. This is the thread that we are | 582 // Get a handle to the calling thread. This is the thread that we are |
| 587 // going to profile. We need to make a copy of the handle because we are | 583 // going to profile. We need to make a copy of the handle because we are |
| 588 // going to use it in the sampler thread. Using GetThreadHandle() will | 584 // going to use it in the sampler thread. Using GetThreadHandle() will |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 745 SamplerThread::AddActiveSampler(this); | 741 SamplerThread::AddActiveSampler(this); |
| 746 } | 742 } |
| 747 | 743 |
| 748 | 744 |
| 749 void Sampler::Stop() { | 745 void Sampler::Stop() { |
| 750 ASSERT(IsActive()); | 746 ASSERT(IsActive()); |
| 751 SamplerThread::RemoveActiveSampler(this); | 747 SamplerThread::RemoveActiveSampler(this); |
| 752 SetActive(false); | 748 SetActive(false); |
| 753 } | 749 } |
| 754 | 750 |
| 755 #endif // ENABLE_LOGGING_AND_PROFILING | |
| 756 | 751 |
| 757 } } // namespace v8::internal | 752 } } // namespace v8::internal |
| 758 | |
| OLD | NEW |