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