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 OpenBSD and NetBSD goes here. For the | 5 // Platform-specific code for OpenBSD and NetBSD goes here. For the |
6 // POSIX-compatible parts, the implementation is in platform-posix.cc. | 6 // POSIX-compatible 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 return new PosixMemoryMappedFile(file, memory, size); | 106 return new PosixMemoryMappedFile(file, memory, size); |
107 } | 107 } |
108 | 108 |
109 | 109 |
110 PosixMemoryMappedFile::~PosixMemoryMappedFile() { | 110 PosixMemoryMappedFile::~PosixMemoryMappedFile() { |
111 if (memory_) OS::Free(memory_, size_); | 111 if (memory_) OS::Free(memory_, size_); |
112 fclose(file_); | 112 fclose(file_); |
113 } | 113 } |
114 | 114 |
115 | 115 |
116 void OS::LogSharedLibraryAddresses(Isolate* isolate) { | 116 std::vector<OS::SharedLibraryAddress> OS::GetSharedLibraryAddresses() { |
| 117 std::vector<SharedLibraryAddress> result; |
117 // This function assumes that the layout of the file is as follows: | 118 // This function assumes that the layout of the file is as follows: |
118 // hex_start_addr-hex_end_addr rwxp <unused data> [binary_file_name] | 119 // hex_start_addr-hex_end_addr rwxp <unused data> [binary_file_name] |
119 // If we encounter an unexpected situation we abort scanning further entries. | 120 // If we encounter an unexpected situation we abort scanning further entries. |
120 FILE* fp = fopen("/proc/self/maps", "r"); | 121 FILE* fp = fopen("/proc/self/maps", "r"); |
121 if (fp == NULL) return; | 122 if (fp == NULL) return result; |
122 | 123 |
123 // Allocate enough room to be able to store a full file name. | 124 // Allocate enough room to be able to store a full file name. |
124 const int kLibNameLen = FILENAME_MAX + 1; | 125 const int kLibNameLen = FILENAME_MAX + 1; |
125 char* lib_name = reinterpret_cast<char*>(malloc(kLibNameLen)); | 126 char* lib_name = reinterpret_cast<char*>(malloc(kLibNameLen)); |
126 | 127 |
127 // This loop will terminate once the scanning hits an EOF. | 128 // This loop will terminate once the scanning hits an EOF. |
128 while (true) { | 129 while (true) { |
129 uintptr_t start, end; | 130 uintptr_t start, end; |
130 char attr_r, attr_w, attr_x, attr_p; | 131 char attr_r, attr_w, attr_x, attr_p; |
131 // Parse the addresses and permission bits at the beginning of the line. | 132 // Parse the addresses and permission bits at the beginning of the line. |
(...skipping 18 matching lines...) Expand all Loading... |
150 | 151 |
151 // Drop the newline character read by fgets. We do not need to check | 152 // Drop the newline character read by fgets. We do not need to check |
152 // for a zero-length string because we know that we at least read the | 153 // for a zero-length string because we know that we at least read the |
153 // '/' character. | 154 // '/' character. |
154 lib_name[strlen(lib_name) - 1] = '\0'; | 155 lib_name[strlen(lib_name) - 1] = '\0'; |
155 } else { | 156 } else { |
156 // No library name found, just record the raw address range. | 157 // No library name found, just record the raw address range. |
157 snprintf(lib_name, kLibNameLen, | 158 snprintf(lib_name, kLibNameLen, |
158 "%08" V8PRIxPTR "-%08" V8PRIxPTR, start, end); | 159 "%08" V8PRIxPTR "-%08" V8PRIxPTR, start, end); |
159 } | 160 } |
160 LOG(isolate, SharedLibraryEvent(lib_name, start, end)); | 161 result.push_back(SharedLibraryAddress(lib_name, start, end)); |
161 } else { | 162 } else { |
162 // Entry not describing executable data. Skip to end of line to set up | 163 // Entry not describing executable data. Skip to end of line to set up |
163 // reading the next entry. | 164 // reading the next entry. |
164 do { | 165 do { |
165 c = getc(fp); | 166 c = getc(fp); |
166 } while ((c != EOF) && (c != '\n')); | 167 } while ((c != EOF) && (c != '\n')); |
167 if (c == EOF) break; | 168 if (c == EOF) break; |
168 } | 169 } |
169 } | 170 } |
170 free(lib_name); | 171 free(lib_name); |
171 fclose(fp); | 172 fclose(fp); |
| 173 return result; |
172 } | 174 } |
173 | 175 |
174 | 176 |
175 void OS::SignalCodeMovingGC() { | 177 void OS::SignalCodeMovingGC() { |
176 // Support for ll_prof.py. | 178 // Support for ll_prof.py. |
177 // | 179 // |
178 // The Linux profiler built into the kernel logs all mmap's with | 180 // The Linux profiler built into the kernel logs all mmap's with |
179 // PROT_EXEC so that analysis tools can properly attribute ticks. We | 181 // PROT_EXEC so that analysis tools can properly attribute ticks. We |
180 // do a mmap with a name known by ll_prof.py and immediately munmap | 182 // do a mmap with a name known by ll_prof.py and immediately munmap |
181 // it. This injects a GC marker into the stream of events generated | 183 // it. This injects a GC marker into the stream of events generated |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 return munmap(base, size) == 0; | 328 return munmap(base, size) == 0; |
327 } | 329 } |
328 | 330 |
329 | 331 |
330 bool VirtualMemory::HasLazyCommits() { | 332 bool VirtualMemory::HasLazyCommits() { |
331 // TODO(alph): implement for the platform. | 333 // TODO(alph): implement for the platform. |
332 return false; | 334 return false; |
333 } | 335 } |
334 | 336 |
335 } } // namespace v8::internal | 337 } } // namespace v8::internal |
OLD | NEW |