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 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 } | 459 } |
460 | 460 |
461 | 461 |
462 PosixMemoryMappedFile::~PosixMemoryMappedFile() { | 462 PosixMemoryMappedFile::~PosixMemoryMappedFile() { |
463 if (memory_) munmap(memory_, size_); | 463 if (memory_) munmap(memory_, size_); |
464 fclose(file_); | 464 fclose(file_); |
465 } | 465 } |
466 | 466 |
467 | 467 |
468 void OS::LogSharedLibraryAddresses() { | 468 void OS::LogSharedLibraryAddresses() { |
469 #ifdef ENABLE_LOGGING_AND_PROFILING | |
470 // This function assumes that the layout of the file is as follows: | 469 // This function assumes that the layout of the file is as follows: |
471 // hex_start_addr-hex_end_addr rwxp <unused data> [binary_file_name] | 470 // hex_start_addr-hex_end_addr rwxp <unused data> [binary_file_name] |
472 // If we encounter an unexpected situation we abort scanning further entries. | 471 // If we encounter an unexpected situation we abort scanning further entries. |
473 FILE* fp = fopen("/proc/self/maps", "r"); | 472 FILE* fp = fopen("/proc/self/maps", "r"); |
474 if (fp == NULL) return; | 473 if (fp == NULL) return; |
475 | 474 |
476 // Allocate enough room to be able to store a full file name. | 475 // Allocate enough room to be able to store a full file name. |
477 const int kLibNameLen = FILENAME_MAX + 1; | 476 const int kLibNameLen = FILENAME_MAX + 1; |
478 char* lib_name = reinterpret_cast<char*>(malloc(kLibNameLen)); | 477 char* lib_name = reinterpret_cast<char*>(malloc(kLibNameLen)); |
479 | 478 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 // Entry not describing executable data. Skip to end of line to setup | 515 // Entry not describing executable data. Skip to end of line to setup |
517 // reading the next entry. | 516 // reading the next entry. |
518 do { | 517 do { |
519 c = getc(fp); | 518 c = getc(fp); |
520 } while ((c != EOF) && (c != '\n')); | 519 } while ((c != EOF) && (c != '\n')); |
521 if (c == EOF) break; | 520 if (c == EOF) break; |
522 } | 521 } |
523 } | 522 } |
524 free(lib_name); | 523 free(lib_name); |
525 fclose(fp); | 524 fclose(fp); |
526 #endif | |
527 } | 525 } |
528 | 526 |
529 | 527 |
530 static const char kGCFakeMmap[] = "/tmp/__v8_gc__"; | 528 static const char kGCFakeMmap[] = "/tmp/__v8_gc__"; |
531 | 529 |
532 | 530 |
533 void OS::SignalCodeMovingGC() { | 531 void OS::SignalCodeMovingGC() { |
534 #ifdef ENABLE_LOGGING_AND_PROFILING | |
535 // Support for ll_prof.py. | 532 // Support for ll_prof.py. |
536 // | 533 // |
537 // The Linux profiler built into the kernel logs all mmap's with | 534 // The Linux profiler built into the kernel logs all mmap's with |
538 // PROT_EXEC so that analysis tools can properly attribute ticks. We | 535 // PROT_EXEC so that analysis tools can properly attribute ticks. We |
539 // do a mmap with a name known by ll_prof.py and immediately munmap | 536 // do a mmap with a name known by ll_prof.py and immediately munmap |
540 // it. This injects a GC marker into the stream of events generated | 537 // it. This injects a GC marker into the stream of events generated |
541 // by the kernel and allows us to synchronize V8 code log and the | 538 // by the kernel and allows us to synchronize V8 code log and the |
542 // kernel log. | 539 // kernel log. |
543 int size = sysconf(_SC_PAGESIZE); | 540 int size = sysconf(_SC_PAGESIZE); |
544 FILE* f = fopen(kGCFakeMmap, "w+"); | 541 FILE* f = fopen(kGCFakeMmap, "w+"); |
545 void* addr = mmap(NULL, size, PROT_READ | PROT_EXEC, MAP_PRIVATE, | 542 void* addr = mmap(NULL, size, PROT_READ | PROT_EXEC, MAP_PRIVATE, |
546 fileno(f), 0); | 543 fileno(f), 0); |
547 ASSERT(addr != MAP_FAILED); | 544 ASSERT(addr != MAP_FAILED); |
548 munmap(addr, size); | 545 munmap(addr, size); |
549 fclose(f); | 546 fclose(f); |
550 #endif | |
551 } | 547 } |
552 | 548 |
553 | 549 |
554 int OS::StackWalk(Vector<OS::StackFrame> frames) { | 550 int OS::StackWalk(Vector<OS::StackFrame> frames) { |
555 // backtrace is a glibc extension. | 551 // backtrace is a glibc extension. |
556 #ifdef __GLIBC__ | 552 #ifdef __GLIBC__ |
557 int frames_size = frames.length(); | 553 int frames_size = frames.length(); |
558 ScopedVector<void*> addresses(frames_size); | 554 ScopedVector<void*> addresses(frames_size); |
559 | 555 |
560 int frames_count = backtrace(addresses.start(), frames_size); | 556 int frames_count = backtrace(addresses.start(), frames_size); |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
835 CHECK(result == -1 && errno == EINTR); // Signal caused spurious wakeup. | 831 CHECK(result == -1 && errno == EINTR); // Signal caused spurious wakeup. |
836 } | 832 } |
837 } | 833 } |
838 | 834 |
839 | 835 |
840 Semaphore* OS::CreateSemaphore(int count) { | 836 Semaphore* OS::CreateSemaphore(int count) { |
841 return new LinuxSemaphore(count); | 837 return new LinuxSemaphore(count); |
842 } | 838 } |
843 | 839 |
844 | 840 |
845 #ifdef ENABLE_LOGGING_AND_PROFILING | |
846 | |
847 #if !defined(__GLIBC__) && (defined(__arm__) || defined(__thumb__)) | 841 #if !defined(__GLIBC__) && (defined(__arm__) || defined(__thumb__)) |
848 // Android runs a fairly new Linux kernel, so signal info is there, | 842 // Android runs a fairly new Linux kernel, so signal info is there, |
849 // but the C library doesn't have the structs defined. | 843 // but the C library doesn't have the structs defined. |
850 | 844 |
851 struct sigcontext { | 845 struct sigcontext { |
852 uint32_t trap_no; | 846 uint32_t trap_no; |
853 uint32_t error_code; | 847 uint32_t error_code; |
854 uint32_t oldmask; | 848 uint32_t oldmask; |
855 uint32_t gregs[16]; | 849 uint32_t gregs[16]; |
856 uint32_t arm_cpsr; | 850 uint32_t arm_cpsr; |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1124 SignalSender::AddActiveSampler(this); | 1118 SignalSender::AddActiveSampler(this); |
1125 } | 1119 } |
1126 | 1120 |
1127 | 1121 |
1128 void Sampler::Stop() { | 1122 void Sampler::Stop() { |
1129 ASSERT(IsActive()); | 1123 ASSERT(IsActive()); |
1130 SignalSender::RemoveActiveSampler(this); | 1124 SignalSender::RemoveActiveSampler(this); |
1131 SetActive(false); | 1125 SetActive(false); |
1132 } | 1126 } |
1133 | 1127 |
1134 #endif // ENABLE_LOGGING_AND_PROFILING | |
1135 | 1128 |
1136 } } // namespace v8::internal | 1129 } } // namespace v8::internal |
OLD | NEW |