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 Linux goes here. For the POSIX-compatible | 5 // Platform-specific code for Linux 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 <pthread.h> | 8 #include <pthread.h> |
9 #include <semaphore.h> | 9 #include <semaphore.h> |
10 #include <signal.h> | 10 #include <signal.h> |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 return new PosixMemoryMappedFile(file, memory, size); | 175 return new PosixMemoryMappedFile(file, memory, size); |
176 } | 176 } |
177 | 177 |
178 | 178 |
179 PosixMemoryMappedFile::~PosixMemoryMappedFile() { | 179 PosixMemoryMappedFile::~PosixMemoryMappedFile() { |
180 if (memory_) OS::Free(memory_, size_); | 180 if (memory_) OS::Free(memory_, size_); |
181 fclose(file_); | 181 fclose(file_); |
182 } | 182 } |
183 | 183 |
184 | 184 |
185 void OS::LogSharedLibraryAddresses(Isolate* isolate) { | 185 std::vector<OS::SharedLibraryAddress> OS::GetSharedLibraryAddresses() { |
| 186 std::vector<SharedLibraryAddress> result; |
186 // This function assumes that the layout of the file is as follows: | 187 // This function assumes that the layout of the file is as follows: |
187 // hex_start_addr-hex_end_addr rwxp <unused data> [binary_file_name] | 188 // hex_start_addr-hex_end_addr rwxp <unused data> [binary_file_name] |
188 // If we encounter an unexpected situation we abort scanning further entries. | 189 // If we encounter an unexpected situation we abort scanning further entries. |
189 FILE* fp = fopen("/proc/self/maps", "r"); | 190 FILE* fp = fopen("/proc/self/maps", "r"); |
190 if (fp == NULL) return; | 191 if (fp == NULL) return result; |
191 | 192 |
192 // Allocate enough room to be able to store a full file name. | 193 // Allocate enough room to be able to store a full file name. |
193 const int kLibNameLen = FILENAME_MAX + 1; | 194 const int kLibNameLen = FILENAME_MAX + 1; |
194 char* lib_name = reinterpret_cast<char*>(malloc(kLibNameLen)); | 195 char* lib_name = reinterpret_cast<char*>(malloc(kLibNameLen)); |
195 | 196 |
196 // This loop will terminate once the scanning hits an EOF. | 197 // This loop will terminate once the scanning hits an EOF. |
197 while (true) { | 198 while (true) { |
198 uintptr_t start, end; | 199 uintptr_t start, end; |
199 char attr_r, attr_w, attr_x, attr_p; | 200 char attr_r, attr_w, attr_x, attr_p; |
200 // Parse the addresses and permission bits at the beginning of the line. | 201 // Parse the addresses and permission bits at the beginning of the line. |
(...skipping 19 matching lines...) Expand all Loading... |
220 | 221 |
221 // Drop the newline character read by fgets. We do not need to check | 222 // Drop the newline character read by fgets. We do not need to check |
222 // for a zero-length string because we know that we at least read the | 223 // for a zero-length string because we know that we at least read the |
223 // '/' or '[' character. | 224 // '/' or '[' character. |
224 lib_name[strlen(lib_name) - 1] = '\0'; | 225 lib_name[strlen(lib_name) - 1] = '\0'; |
225 } else { | 226 } else { |
226 // No library name found, just record the raw address range. | 227 // No library name found, just record the raw address range. |
227 snprintf(lib_name, kLibNameLen, | 228 snprintf(lib_name, kLibNameLen, |
228 "%08" V8PRIxPTR "-%08" V8PRIxPTR, start, end); | 229 "%08" V8PRIxPTR "-%08" V8PRIxPTR, start, end); |
229 } | 230 } |
230 LOG(isolate, SharedLibraryEvent(lib_name, start, end)); | 231 result.push_back(SharedLibraryAddress(lib_name, start, end)); |
231 } else { | 232 } else { |
232 // Entry not describing executable data. Skip to end of line to set up | 233 // Entry not describing executable data. Skip to end of line to set up |
233 // reading the next entry. | 234 // reading the next entry. |
234 do { | 235 do { |
235 c = getc(fp); | 236 c = getc(fp); |
236 } while ((c != EOF) && (c != '\n')); | 237 } while ((c != EOF) && (c != '\n')); |
237 if (c == EOF) break; | 238 if (c == EOF) break; |
238 } | 239 } |
239 } | 240 } |
240 free(lib_name); | 241 free(lib_name); |
241 fclose(fp); | 242 fclose(fp); |
| 243 return result; |
242 } | 244 } |
243 | 245 |
244 | 246 |
245 void OS::SignalCodeMovingGC() { | 247 void OS::SignalCodeMovingGC() { |
246 // Support for ll_prof.py. | 248 // Support for ll_prof.py. |
247 // | 249 // |
248 // The Linux profiler built into the kernel logs all mmap's with | 250 // The Linux profiler built into the kernel logs all mmap's with |
249 // PROT_EXEC so that analysis tools can properly attribute ticks. We | 251 // PROT_EXEC so that analysis tools can properly attribute ticks. We |
250 // do a mmap with a name known by ll_prof.py and immediately munmap | 252 // do a mmap with a name known by ll_prof.py and immediately munmap |
251 // it. This injects a GC marker into the stream of events generated | 253 // it. This injects a GC marker into the stream of events generated |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 #endif | 422 #endif |
421 return munmap(base, size) == 0; | 423 return munmap(base, size) == 0; |
422 } | 424 } |
423 | 425 |
424 | 426 |
425 bool VirtualMemory::HasLazyCommits() { | 427 bool VirtualMemory::HasLazyCommits() { |
426 return true; | 428 return true; |
427 } | 429 } |
428 | 430 |
429 } } // namespace v8::internal | 431 } } // namespace v8::internal |
OLD | NEW |