| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 return n; | 178 return n; |
| 179 } | 179 } |
| 180 } | 180 } |
| 181 | 181 |
| 182 | 182 |
| 183 void OS::StrNCpy(Vector<char> dest, const char* src, size_t n) { | 183 void OS::StrNCpy(Vector<char> dest, const char* src, size_t n) { |
| 184 strncpy(dest.start(), src, n); | 184 strncpy(dest.start(), src, n); |
| 185 } | 185 } |
| 186 | 186 |
| 187 | 187 |
| 188 void OS::WcsCpy(Vector<wchar_t> dest, const wchar_t* src) { | |
| 189 wcscpy(dest.start(), src); | |
| 190 } | |
| 191 | |
| 192 | |
| 193 char *OS::StrDup(const char* str) { | 188 char *OS::StrDup(const char* str) { |
| 194 return strdup(str); | 189 return strdup(str); |
| 195 } | 190 } |
| 196 | 191 |
| 197 | 192 |
| 198 double OS::nan_value() { | 193 double OS::nan_value() { |
| 199 return NAN; | 194 return NAN; |
| 200 } | 195 } |
| 201 | 196 |
| 202 | 197 |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fileno(file), 0); | 297 mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fileno(file), 0); |
| 303 return new PosixMemoryMappedFile(file, memory, size); | 298 return new PosixMemoryMappedFile(file, memory, size); |
| 304 } | 299 } |
| 305 | 300 |
| 306 | 301 |
| 307 PosixMemoryMappedFile::~PosixMemoryMappedFile() { | 302 PosixMemoryMappedFile::~PosixMemoryMappedFile() { |
| 308 if (memory_) munmap(memory_, size_); | 303 if (memory_) munmap(memory_, size_); |
| 309 fclose(file_); | 304 fclose(file_); |
| 310 } | 305 } |
| 311 | 306 |
| 307 |
| 312 #ifdef ENABLE_LOGGING_AND_PROFILING | 308 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 313 static unsigned StringToLongLong(char* buffer) { | 309 static unsigned StringToLong(char* buffer) { |
| 314 return static_cast<unsigned>(strtoll(buffer, NULL, 16)); // NOLINT | 310 return static_cast<unsigned>(strtol(buffer, NULL, 16)); // NOLINT |
| 315 } | 311 } |
| 312 #endif |
| 316 | 313 |
| 317 #endif | |
| 318 | 314 |
| 319 void OS::LogSharedLibraryAddresses() { | 315 void OS::LogSharedLibraryAddresses() { |
| 320 #ifdef ENABLE_LOGGING_AND_PROFILING | 316 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 321 static const int MAP_LENGTH = 1024; | 317 static const int MAP_LENGTH = 1024; |
| 322 int fd = open("/proc/self/maps", O_RDONLY); | 318 int fd = open("/proc/self/maps", O_RDONLY); |
| 323 if (fd < 0) return; | 319 if (fd < 0) return; |
| 324 while (true) { | 320 while (true) { |
| 325 char addr_buffer[11]; | 321 char addr_buffer[11]; |
| 326 addr_buffer[0] = '0'; | 322 addr_buffer[0] = '0'; |
| 327 addr_buffer[1] = 'x'; | 323 addr_buffer[1] = 'x'; |
| 328 addr_buffer[10] = 0; | 324 addr_buffer[10] = 0; |
| 329 int result = read(fd, addr_buffer + 2, 8); | 325 int result = read(fd, addr_buffer + 2, 8); |
| 330 if (result < 8) break; | 326 if (result < 8) break; |
| 331 unsigned start = StringToLongLong(addr_buffer); | 327 unsigned start = StringToLong(addr_buffer); |
| 332 result = read(fd, addr_buffer + 2, 1); | 328 result = read(fd, addr_buffer + 2, 1); |
| 333 if (result < 1) break; | 329 if (result < 1) break; |
| 334 if (addr_buffer[2] != '-') break; | 330 if (addr_buffer[2] != '-') break; |
| 335 result = read(fd, addr_buffer + 2, 8); | 331 result = read(fd, addr_buffer + 2, 8); |
| 336 if (result < 8) break; | 332 if (result < 8) break; |
| 337 unsigned end = StringToLongLong(addr_buffer); | 333 unsigned end = StringToLong(addr_buffer); |
| 338 char buffer[MAP_LENGTH]; | 334 char buffer[MAP_LENGTH]; |
| 339 int bytes_read = -1; | 335 int bytes_read = -1; |
| 340 do { | 336 do { |
| 341 bytes_read++; | 337 bytes_read++; |
| 342 if (bytes_read >= MAP_LENGTH - 1) | 338 if (bytes_read >= MAP_LENGTH - 1) |
| 343 break; | 339 break; |
| 344 result = read(fd, buffer + bytes_read, 1); | 340 result = read(fd, buffer + bytes_read, 1); |
| 345 if (result < 1) break; | 341 if (result < 1) break; |
| 346 } while (buffer[bytes_read] != '\n'); | 342 } while (buffer[bytes_read] != '\n'); |
| 347 buffer[bytes_read] = 0; | 343 buffer[bytes_read] = 0; |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 688 } | 684 } |
| 689 | 685 |
| 690 // This sampler is no longer the active sampler. | 686 // This sampler is no longer the active sampler. |
| 691 active_sampler_ = NULL; | 687 active_sampler_ = NULL; |
| 692 active_ = false; | 688 active_ = false; |
| 693 } | 689 } |
| 694 | 690 |
| 695 #endif // ENABLE_LOGGING_AND_PROFILING | 691 #endif // ENABLE_LOGGING_AND_PROFILING |
| 696 | 692 |
| 697 } } // namespace v8::internal | 693 } } // namespace v8::internal |
| OLD | NEW |