| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Platform-specific code for Cygwin goes here. For the POSIX-compatible | 5 // Platform-specific code for Cygwin goes here. For the POSIX-compatible |
| 6 // parts, the implementation is in platform-posix.cc. | 6 // parts, the implementation is in platform-posix.cc. |
| 7 | 7 |
| 8 #include <errno.h> | 8 #include <errno.h> |
| 9 #include <pthread.h> | 9 #include <pthread.h> |
| 10 #include <semaphore.h> | 10 #include <semaphore.h> |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 return new PosixMemoryMappedFile(file, memory, size); | 99 return new PosixMemoryMappedFile(file, memory, size); |
| 100 } | 100 } |
| 101 | 101 |
| 102 | 102 |
| 103 PosixMemoryMappedFile::~PosixMemoryMappedFile() { | 103 PosixMemoryMappedFile::~PosixMemoryMappedFile() { |
| 104 if (memory_) munmap(memory_, size_); | 104 if (memory_) munmap(memory_, size_); |
| 105 fclose(file_); | 105 fclose(file_); |
| 106 } | 106 } |
| 107 | 107 |
| 108 | 108 |
| 109 void OS::LogSharedLibraryAddresses(Isolate* isolate) { | 109 std::vector<OS::SharedLibraryAddress> OS::GetSharedLibraryAddresses() { |
| 110 std::vector<SharedLibraryAddresses> result; |
| 110 // This function assumes that the layout of the file is as follows: | 111 // This function assumes that the layout of the file is as follows: |
| 111 // hex_start_addr-hex_end_addr rwxp <unused data> [binary_file_name] | 112 // hex_start_addr-hex_end_addr rwxp <unused data> [binary_file_name] |
| 112 // If we encounter an unexpected situation we abort scanning further entries. | 113 // If we encounter an unexpected situation we abort scanning further entries. |
| 113 FILE* fp = fopen("/proc/self/maps", "r"); | 114 FILE* fp = fopen("/proc/self/maps", "r"); |
| 114 if (fp == NULL) return; | 115 if (fp == NULL) return result; |
| 115 | 116 |
| 116 // Allocate enough room to be able to store a full file name. | 117 // Allocate enough room to be able to store a full file name. |
| 117 const int kLibNameLen = FILENAME_MAX + 1; | 118 const int kLibNameLen = FILENAME_MAX + 1; |
| 118 char* lib_name = reinterpret_cast<char*>(malloc(kLibNameLen)); | 119 char* lib_name = reinterpret_cast<char*>(malloc(kLibNameLen)); |
| 119 | 120 |
| 120 // This loop will terminate once the scanning hits an EOF. | 121 // This loop will terminate once the scanning hits an EOF. |
| 121 while (true) { | 122 while (true) { |
| 122 uintptr_t start, end; | 123 uintptr_t start, end; |
| 123 char attr_r, attr_w, attr_x, attr_p; | 124 char attr_r, attr_w, attr_x, attr_p; |
| 124 // Parse the addresses and permission bits at the beginning of the line. | 125 // Parse the addresses and permission bits at the beginning of the line. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 143 | 144 |
| 144 // Drop the newline character read by fgets. We do not need to check | 145 // Drop the newline character read by fgets. We do not need to check |
| 145 // for a zero-length string because we know that we at least read the | 146 // for a zero-length string because we know that we at least read the |
| 146 // '/' character. | 147 // '/' character. |
| 147 lib_name[strlen(lib_name) - 1] = '\0'; | 148 lib_name[strlen(lib_name) - 1] = '\0'; |
| 148 } else { | 149 } else { |
| 149 // No library name found, just record the raw address range. | 150 // No library name found, just record the raw address range. |
| 150 snprintf(lib_name, kLibNameLen, | 151 snprintf(lib_name, kLibNameLen, |
| 151 "%08" V8PRIxPTR "-%08" V8PRIxPTR, start, end); | 152 "%08" V8PRIxPTR "-%08" V8PRIxPTR, start, end); |
| 152 } | 153 } |
| 153 LOG(isolate, SharedLibraryEvent(lib_name, start, end)); | 154 result.push_back(SharedLibraryAddress(lib_name, start, end)); |
| 154 } else { | 155 } else { |
| 155 // Entry not describing executable data. Skip to end of line to set up | 156 // Entry not describing executable data. Skip to end of line to set up |
| 156 // reading the next entry. | 157 // reading the next entry. |
| 157 do { | 158 do { |
| 158 c = getc(fp); | 159 c = getc(fp); |
| 159 } while ((c != EOF) && (c != '\n')); | 160 } while ((c != EOF) && (c != '\n')); |
| 160 if (c == EOF) break; | 161 if (c == EOF) break; |
| 161 } | 162 } |
| 162 } | 163 } |
| 163 free(lib_name); | 164 free(lib_name); |
| 164 fclose(fp); | 165 fclose(fp); |
| 166 return result; |
| 165 } | 167 } |
| 166 | 168 |
| 167 | 169 |
| 168 void OS::SignalCodeMovingGC() { | 170 void OS::SignalCodeMovingGC() { |
| 169 // Nothing to do on Cygwin. | 171 // Nothing to do on Cygwin. |
| 170 } | 172 } |
| 171 | 173 |
| 172 | 174 |
| 173 // The VirtualMemory implementation is taken from platform-win32.cc. | 175 // The VirtualMemory implementation is taken from platform-win32.cc. |
| 174 // The mmap-based virtual memory implementation as it is used on most posix | 176 // The mmap-based virtual memory implementation as it is used on most posix |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 return VirtualFree(base, 0, MEM_RELEASE) != 0; | 321 return VirtualFree(base, 0, MEM_RELEASE) != 0; |
| 320 } | 322 } |
| 321 | 323 |
| 322 | 324 |
| 323 bool VirtualMemory::HasLazyCommits() { | 325 bool VirtualMemory::HasLazyCommits() { |
| 324 // TODO(alph): implement for the platform. | 326 // TODO(alph): implement for the platform. |
| 325 return false; | 327 return false; |
| 326 } | 328 } |
| 327 | 329 |
| 328 } } // namespace v8::internal | 330 } } // namespace v8::internal |
| OLD | NEW |