| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 return new PosixMemoryMappedFile(file, memory, size); | 245 return new PosixMemoryMappedFile(file, memory, size); |
| 246 } | 246 } |
| 247 | 247 |
| 248 | 248 |
| 249 PosixMemoryMappedFile::~PosixMemoryMappedFile() { | 249 PosixMemoryMappedFile::~PosixMemoryMappedFile() { |
| 250 if (memory_) munmap(memory_, size_); | 250 if (memory_) munmap(memory_, size_); |
| 251 fclose(file_); | 251 fclose(file_); |
| 252 } | 252 } |
| 253 | 253 |
| 254 | 254 |
| 255 #ifdef ENABLE_LOGGING_AND_PROFILING | |
| 256 static unsigned StringToLong(char* buffer) { | 255 static unsigned StringToLong(char* buffer) { |
| 257 return static_cast<unsigned>(strtol(buffer, NULL, 16)); // NOLINT | 256 return static_cast<unsigned>(strtol(buffer, NULL, 16)); // NOLINT |
| 258 } | 257 } |
| 259 #endif | |
| 260 | 258 |
| 261 | 259 |
| 262 void OS::LogSharedLibraryAddresses() { | 260 void OS::LogSharedLibraryAddresses() { |
| 263 #ifdef ENABLE_LOGGING_AND_PROFILING | |
| 264 static const int MAP_LENGTH = 1024; | 261 static const int MAP_LENGTH = 1024; |
| 265 int fd = open("/proc/self/maps", O_RDONLY); | 262 int fd = open("/proc/self/maps", O_RDONLY); |
| 266 if (fd < 0) return; | 263 if (fd < 0) return; |
| 267 while (true) { | 264 while (true) { |
| 268 char addr_buffer[11]; | 265 char addr_buffer[11]; |
| 269 addr_buffer[0] = '0'; | 266 addr_buffer[0] = '0'; |
| 270 addr_buffer[1] = 'x'; | 267 addr_buffer[1] = 'x'; |
| 271 addr_buffer[10] = 0; | 268 addr_buffer[10] = 0; |
| 272 int result = read(fd, addr_buffer + 2, 8); | 269 int result = read(fd, addr_buffer + 2, 8); |
| 273 if (result < 8) break; | 270 if (result < 8) break; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 290 buffer[bytes_read] = 0; | 287 buffer[bytes_read] = 0; |
| 291 // Ignore mappings that are not executable. | 288 // Ignore mappings that are not executable. |
| 292 if (buffer[3] != 'x') continue; | 289 if (buffer[3] != 'x') continue; |
| 293 char* start_of_path = index(buffer, '/'); | 290 char* start_of_path = index(buffer, '/'); |
| 294 // There may be no filename in this line. Skip to next. | 291 // There may be no filename in this line. Skip to next. |
| 295 if (start_of_path == NULL) continue; | 292 if (start_of_path == NULL) continue; |
| 296 buffer[bytes_read] = 0; | 293 buffer[bytes_read] = 0; |
| 297 LOG(i::Isolate::Current(), SharedLibraryEvent(start_of_path, start, end)); | 294 LOG(i::Isolate::Current(), SharedLibraryEvent(start_of_path, start, end)); |
| 298 } | 295 } |
| 299 close(fd); | 296 close(fd); |
| 300 #endif | |
| 301 } | 297 } |
| 302 | 298 |
| 303 | 299 |
| 304 void OS::SignalCodeMovingGC() { | 300 void OS::SignalCodeMovingGC() { |
| 305 } | 301 } |
| 306 | 302 |
| 307 | 303 |
| 308 int OS::StackWalk(Vector<OS::StackFrame> frames) { | 304 int OS::StackWalk(Vector<OS::StackFrame> frames) { |
| 309 int frames_size = frames.length(); | 305 int frames_size = frames.length(); |
| 310 ScopedVector<void*> addresses(frames_size); | 306 ScopedVector<void*> addresses(frames_size); |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 CHECK(result == -1 && errno == EINTR); // Signal caused spurious wakeup. | 563 CHECK(result == -1 && errno == EINTR); // Signal caused spurious wakeup. |
| 568 } | 564 } |
| 569 } | 565 } |
| 570 | 566 |
| 571 | 567 |
| 572 Semaphore* OS::CreateSemaphore(int count) { | 568 Semaphore* OS::CreateSemaphore(int count) { |
| 573 return new FreeBSDSemaphore(count); | 569 return new FreeBSDSemaphore(count); |
| 574 } | 570 } |
| 575 | 571 |
| 576 | 572 |
| 577 #ifdef ENABLE_LOGGING_AND_PROFILING | |
| 578 | |
| 579 static pthread_t GetThreadID() { | 573 static pthread_t GetThreadID() { |
| 580 pthread_t thread_id = pthread_self(); | 574 pthread_t thread_id = pthread_self(); |
| 581 return thread_id; | 575 return thread_id; |
| 582 } | 576 } |
| 583 | 577 |
| 584 | 578 |
| 585 class Sampler::PlatformData : public Malloced { | 579 class Sampler::PlatformData : public Malloced { |
| 586 public: | 580 public: |
| 587 PlatformData() : vm_tid_(GetThreadID()) {} | 581 PlatformData() : vm_tid_(GetThreadID()) {} |
| 588 | 582 |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 796 SignalSender::AddActiveSampler(this); | 790 SignalSender::AddActiveSampler(this); |
| 797 } | 791 } |
| 798 | 792 |
| 799 | 793 |
| 800 void Sampler::Stop() { | 794 void Sampler::Stop() { |
| 801 ASSERT(IsActive()); | 795 ASSERT(IsActive()); |
| 802 SignalSender::RemoveActiveSampler(this); | 796 SignalSender::RemoveActiveSampler(this); |
| 803 SetActive(false); | 797 SetActive(false); |
| 804 } | 798 } |
| 805 | 799 |
| 806 #endif // ENABLE_LOGGING_AND_PROFILING | |
| 807 | 800 |
| 808 } } // namespace v8::internal | 801 } } // namespace v8::internal |
| OLD | NEW |