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 FreeBSD goes here. For the POSIX-compatible | 5 // Platform-specific code for FreeBSD 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 if (memory_) munmap(memory_, size_); | 113 if (memory_) munmap(memory_, size_); |
114 fclose(file_); | 114 fclose(file_); |
115 } | 115 } |
116 | 116 |
117 | 117 |
118 static unsigned StringToLong(char* buffer) { | 118 static unsigned StringToLong(char* buffer) { |
119 return static_cast<unsigned>(strtol(buffer, NULL, 16)); // NOLINT | 119 return static_cast<unsigned>(strtol(buffer, NULL, 16)); // NOLINT |
120 } | 120 } |
121 | 121 |
122 | 122 |
123 void OS::LogSharedLibraryAddresses(Isolate* isolate) { | 123 std::vector<OS::SharedLibraryAddress> OS::GetSharedLibraryAddresses() { |
| 124 std::vector<SharedLibraryAddress> result; |
124 static const int MAP_LENGTH = 1024; | 125 static const int MAP_LENGTH = 1024; |
125 int fd = open("/proc/self/maps", O_RDONLY); | 126 int fd = open("/proc/self/maps", O_RDONLY); |
126 if (fd < 0) return; | 127 if (fd < 0) return result; |
127 while (true) { | 128 while (true) { |
128 char addr_buffer[11]; | 129 char addr_buffer[11]; |
129 addr_buffer[0] = '0'; | 130 addr_buffer[0] = '0'; |
130 addr_buffer[1] = 'x'; | 131 addr_buffer[1] = 'x'; |
131 addr_buffer[10] = 0; | 132 addr_buffer[10] = 0; |
132 int result = read(fd, addr_buffer + 2, 8); | 133 int result = read(fd, addr_buffer + 2, 8); |
133 if (result < 8) break; | 134 if (result < 8) break; |
134 unsigned start = StringToLong(addr_buffer); | 135 unsigned start = StringToLong(addr_buffer); |
135 result = read(fd, addr_buffer + 2, 1); | 136 result = read(fd, addr_buffer + 2, 1); |
136 if (result < 1) break; | 137 if (result < 1) break; |
(...skipping 10 matching lines...) Expand all Loading... |
147 result = read(fd, buffer + bytes_read, 1); | 148 result = read(fd, buffer + bytes_read, 1); |
148 if (result < 1) break; | 149 if (result < 1) break; |
149 } while (buffer[bytes_read] != '\n'); | 150 } while (buffer[bytes_read] != '\n'); |
150 buffer[bytes_read] = 0; | 151 buffer[bytes_read] = 0; |
151 // Ignore mappings that are not executable. | 152 // Ignore mappings that are not executable. |
152 if (buffer[3] != 'x') continue; | 153 if (buffer[3] != 'x') continue; |
153 char* start_of_path = index(buffer, '/'); | 154 char* start_of_path = index(buffer, '/'); |
154 // There may be no filename in this line. Skip to next. | 155 // There may be no filename in this line. Skip to next. |
155 if (start_of_path == NULL) continue; | 156 if (start_of_path == NULL) continue; |
156 buffer[bytes_read] = 0; | 157 buffer[bytes_read] = 0; |
157 LOG(isolate, SharedLibraryEvent(start_of_path, start, end)); | 158 result.push_back(SharedLibraryAddress(start_of_path, start, end)); |
158 } | 159 } |
159 close(fd); | 160 close(fd); |
| 161 return result; |
160 } | 162 } |
161 | 163 |
162 | 164 |
163 void OS::SignalCodeMovingGC() { | 165 void OS::SignalCodeMovingGC() { |
164 } | 166 } |
165 | 167 |
166 | 168 |
167 | 169 |
168 // Constants used for mmap. | 170 // Constants used for mmap. |
169 static const int kMmapFd = -1; | 171 static const int kMmapFd = -1; |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 return munmap(base, size) == 0; | 297 return munmap(base, size) == 0; |
296 } | 298 } |
297 | 299 |
298 | 300 |
299 bool VirtualMemory::HasLazyCommits() { | 301 bool VirtualMemory::HasLazyCommits() { |
300 // TODO(alph): implement for the platform. | 302 // TODO(alph): implement for the platform. |
301 return false; | 303 return false; |
302 } | 304 } |
303 | 305 |
304 } } // namespace v8::internal | 306 } } // namespace v8::internal |
OLD | NEW |