| OLD | NEW |
| 1 // Copyright 2006-2011 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2011 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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 | 172 |
| 173 | 173 |
| 174 void OS::Free(void* buf, const size_t length) { | 174 void OS::Free(void* buf, const size_t length) { |
| 175 // TODO(1240712): munmap has a return value which is ignored here. | 175 // TODO(1240712): munmap has a return value which is ignored here. |
| 176 int result = munmap(buf, length); | 176 int result = munmap(buf, length); |
| 177 USE(result); | 177 USE(result); |
| 178 ASSERT(result == 0); | 178 ASSERT(result == 0); |
| 179 } | 179 } |
| 180 | 180 |
| 181 | 181 |
| 182 #ifdef ENABLE_HEAP_PROTECTION | |
| 183 | |
| 184 void OS::Protect(void* address, size_t size) { | |
| 185 UNIMPLEMENTED(); | |
| 186 } | |
| 187 | |
| 188 | |
| 189 void OS::Unprotect(void* address, size_t size, bool is_executable) { | |
| 190 UNIMPLEMENTED(); | |
| 191 } | |
| 192 | |
| 193 #endif | |
| 194 | |
| 195 | |
| 196 void OS::Sleep(int milliseconds) { | 182 void OS::Sleep(int milliseconds) { |
| 197 unsigned int ms = static_cast<unsigned int>(milliseconds); | 183 unsigned int ms = static_cast<unsigned int>(milliseconds); |
| 198 usleep(1000 * ms); | 184 usleep(1000 * ms); |
| 199 } | 185 } |
| 200 | 186 |
| 201 | 187 |
| 202 void OS::Abort() { | 188 void OS::Abort() { |
| 203 // Redirect to std abort to signal abnormal program termination. | 189 // Redirect to std abort to signal abnormal program termination. |
| 204 abort(); | 190 abort(); |
| 205 } | 191 } |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 return new PosixMemoryMappedFile(file, memory, size); | 243 return new PosixMemoryMappedFile(file, memory, size); |
| 258 } | 244 } |
| 259 | 245 |
| 260 | 246 |
| 261 PosixMemoryMappedFile::~PosixMemoryMappedFile() { | 247 PosixMemoryMappedFile::~PosixMemoryMappedFile() { |
| 262 if (memory_) munmap(memory_, size_); | 248 if (memory_) munmap(memory_, size_); |
| 263 fclose(file_); | 249 fclose(file_); |
| 264 } | 250 } |
| 265 | 251 |
| 266 | 252 |
| 267 #ifdef ENABLE_LOGGING_AND_PROFILING | |
| 268 static unsigned StringToLong(char* buffer) { | 253 static unsigned StringToLong(char* buffer) { |
| 269 return static_cast<unsigned>(strtol(buffer, NULL, 16)); // NOLINT | 254 return static_cast<unsigned>(strtol(buffer, NULL, 16)); // NOLINT |
| 270 } | 255 } |
| 271 #endif | |
| 272 | 256 |
| 273 | 257 |
| 274 void OS::LogSharedLibraryAddresses() { | 258 void OS::LogSharedLibraryAddresses() { |
| 275 #ifdef ENABLE_LOGGING_AND_PROFILING | |
| 276 static const int MAP_LENGTH = 1024; | 259 static const int MAP_LENGTH = 1024; |
| 277 int fd = open("/proc/self/maps", O_RDONLY); | 260 int fd = open("/proc/self/maps", O_RDONLY); |
| 278 if (fd < 0) return; | 261 if (fd < 0) return; |
| 279 while (true) { | 262 while (true) { |
| 280 char addr_buffer[11]; | 263 char addr_buffer[11]; |
| 281 addr_buffer[0] = '0'; | 264 addr_buffer[0] = '0'; |
| 282 addr_buffer[1] = 'x'; | 265 addr_buffer[1] = 'x'; |
| 283 addr_buffer[10] = 0; | 266 addr_buffer[10] = 0; |
| 284 int result = read(fd, addr_buffer + 2, 8); | 267 int result = read(fd, addr_buffer + 2, 8); |
| 285 if (result < 8) break; | 268 if (result < 8) break; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 302 buffer[bytes_read] = 0; | 285 buffer[bytes_read] = 0; |
| 303 // Ignore mappings that are not executable. | 286 // Ignore mappings that are not executable. |
| 304 if (buffer[3] != 'x') continue; | 287 if (buffer[3] != 'x') continue; |
| 305 char* start_of_path = index(buffer, '/'); | 288 char* start_of_path = index(buffer, '/'); |
| 306 // There may be no filename in this line. Skip to next. | 289 // There may be no filename in this line. Skip to next. |
| 307 if (start_of_path == NULL) continue; | 290 if (start_of_path == NULL) continue; |
| 308 buffer[bytes_read] = 0; | 291 buffer[bytes_read] = 0; |
| 309 LOG(i::Isolate::Current(), SharedLibraryEvent(start_of_path, start, end)); | 292 LOG(i::Isolate::Current(), SharedLibraryEvent(start_of_path, start, end)); |
| 310 } | 293 } |
| 311 close(fd); | 294 close(fd); |
| 312 #endif | |
| 313 } | 295 } |
| 314 | 296 |
| 315 | 297 |
| 316 void OS::SignalCodeMovingGC() { | 298 void OS::SignalCodeMovingGC() { |
| 317 } | 299 } |
| 318 | 300 |
| 319 | 301 |
| 320 int OS::StackWalk(Vector<OS::StackFrame> frames) { | 302 int OS::StackWalk(Vector<OS::StackFrame> frames) { |
| 321 int frames_size = frames.length(); | 303 int frames_size = frames.length(); |
| 322 ScopedVector<void*> addresses(frames_size); | 304 ScopedVector<void*> addresses(frames_size); |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 583 to--; | 565 to--; |
| 584 } | 566 } |
| 585 } | 567 } |
| 586 | 568 |
| 587 | 569 |
| 588 Semaphore* OS::CreateSemaphore(int count) { | 570 Semaphore* OS::CreateSemaphore(int count) { |
| 589 return new OpenBSDSemaphore(count); | 571 return new OpenBSDSemaphore(count); |
| 590 } | 572 } |
| 591 | 573 |
| 592 | 574 |
| 593 #ifdef ENABLE_LOGGING_AND_PROFILING | |
| 594 | |
| 595 static pthread_t GetThreadID() { | 575 static pthread_t GetThreadID() { |
| 596 pthread_t thread_id = pthread_self(); | 576 pthread_t thread_id = pthread_self(); |
| 597 return thread_id; | 577 return thread_id; |
| 598 } | 578 } |
| 599 | 579 |
| 600 | 580 |
| 601 class Sampler::PlatformData : public Malloced { | 581 class Sampler::PlatformData : public Malloced { |
| 602 public: | 582 public: |
| 603 PlatformData() : vm_tid_(GetThreadID()) {} | 583 PlatformData() : vm_tid_(GetThreadID()) {} |
| 604 | 584 |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 811 SignalSender::AddActiveSampler(this); | 791 SignalSender::AddActiveSampler(this); |
| 812 } | 792 } |
| 813 | 793 |
| 814 | 794 |
| 815 void Sampler::Stop() { | 795 void Sampler::Stop() { |
| 816 ASSERT(IsActive()); | 796 ASSERT(IsActive()); |
| 817 SignalSender::RemoveActiveSampler(this); | 797 SignalSender::RemoveActiveSampler(this); |
| 818 SetActive(false); | 798 SetActive(false); |
| 819 } | 799 } |
| 820 | 800 |
| 821 #endif // ENABLE_LOGGING_AND_PROFILING | |
| 822 | 801 |
| 823 } } // namespace v8::internal | 802 } } // namespace v8::internal |
| OLD | NEW |