| 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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 | 162 |
| 163 | 163 |
| 164 void OS::Free(void* address, const size_t size) { | 164 void OS::Free(void* address, const size_t size) { |
| 165 // TODO(1240712): munmap has a return value which is ignored here. | 165 // TODO(1240712): munmap has a return value which is ignored here. |
| 166 int result = munmap(address, size); | 166 int result = munmap(address, size); |
| 167 USE(result); | 167 USE(result); |
| 168 ASSERT(result == 0); | 168 ASSERT(result == 0); |
| 169 } | 169 } |
| 170 | 170 |
| 171 | 171 |
| 172 #ifdef ENABLE_HEAP_PROTECTION | |
| 173 | |
| 174 void OS::Protect(void* address, size_t size) { | |
| 175 UNIMPLEMENTED(); | |
| 176 } | |
| 177 | |
| 178 | |
| 179 void OS::Unprotect(void* address, size_t size, bool is_executable) { | |
| 180 UNIMPLEMENTED(); | |
| 181 } | |
| 182 | |
| 183 #endif | |
| 184 | |
| 185 | |
| 186 void OS::Sleep(int milliseconds) { | 172 void OS::Sleep(int milliseconds) { |
| 187 usleep(1000 * milliseconds); | 173 usleep(1000 * milliseconds); |
| 188 } | 174 } |
| 189 | 175 |
| 190 | 176 |
| 191 void OS::Abort() { | 177 void OS::Abort() { |
| 192 // Redirect to std abort to signal abnormal program termination | 178 // Redirect to std abort to signal abnormal program termination |
| 193 abort(); | 179 abort(); |
| 194 } | 180 } |
| 195 | 181 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 } | 227 } |
| 242 | 228 |
| 243 | 229 |
| 244 PosixMemoryMappedFile::~PosixMemoryMappedFile() { | 230 PosixMemoryMappedFile::~PosixMemoryMappedFile() { |
| 245 if (memory_) munmap(memory_, size_); | 231 if (memory_) munmap(memory_, size_); |
| 246 fclose(file_); | 232 fclose(file_); |
| 247 } | 233 } |
| 248 | 234 |
| 249 | 235 |
| 250 void OS::LogSharedLibraryAddresses() { | 236 void OS::LogSharedLibraryAddresses() { |
| 251 #ifdef ENABLE_LOGGING_AND_PROFILING | |
| 252 unsigned int images_count = _dyld_image_count(); | 237 unsigned int images_count = _dyld_image_count(); |
| 253 for (unsigned int i = 0; i < images_count; ++i) { | 238 for (unsigned int i = 0; i < images_count; ++i) { |
| 254 const mach_header* header = _dyld_get_image_header(i); | 239 const mach_header* header = _dyld_get_image_header(i); |
| 255 if (header == NULL) continue; | 240 if (header == NULL) continue; |
| 256 #if V8_HOST_ARCH_X64 | 241 #if V8_HOST_ARCH_X64 |
| 257 uint64_t size; | 242 uint64_t size; |
| 258 char* code_ptr = getsectdatafromheader_64( | 243 char* code_ptr = getsectdatafromheader_64( |
| 259 reinterpret_cast<const mach_header_64*>(header), | 244 reinterpret_cast<const mach_header_64*>(header), |
| 260 SEG_TEXT, | 245 SEG_TEXT, |
| 261 SECT_TEXT, | 246 SECT_TEXT, |
| 262 &size); | 247 &size); |
| 263 #else | 248 #else |
| 264 unsigned int size; | 249 unsigned int size; |
| 265 char* code_ptr = getsectdatafromheader(header, SEG_TEXT, SECT_TEXT, &size); | 250 char* code_ptr = getsectdatafromheader(header, SEG_TEXT, SECT_TEXT, &size); |
| 266 #endif | 251 #endif |
| 267 if (code_ptr == NULL) continue; | 252 if (code_ptr == NULL) continue; |
| 268 const uintptr_t slide = _dyld_get_image_vmaddr_slide(i); | 253 const uintptr_t slide = _dyld_get_image_vmaddr_slide(i); |
| 269 const uintptr_t start = reinterpret_cast<uintptr_t>(code_ptr) + slide; | 254 const uintptr_t start = reinterpret_cast<uintptr_t>(code_ptr) + slide; |
| 270 LOG(Isolate::Current(), | 255 LOG(Isolate::Current(), |
| 271 SharedLibraryEvent(_dyld_get_image_name(i), start, start + size)); | 256 SharedLibraryEvent(_dyld_get_image_name(i), start, start + size)); |
| 272 } | 257 } |
| 273 #endif // ENABLE_LOGGING_AND_PROFILING | |
| 274 } | 258 } |
| 275 | 259 |
| 276 | 260 |
| 277 void OS::SignalCodeMovingGC() { | 261 void OS::SignalCodeMovingGC() { |
| 278 } | 262 } |
| 279 | 263 |
| 280 | 264 |
| 281 uint64_t OS::CpuFeaturesImpliedByPlatform() { | 265 uint64_t OS::CpuFeaturesImpliedByPlatform() { |
| 282 // MacOSX requires all these to install so we can assume they are present. | 266 // MacOSX requires all these to install so we can assume they are present. |
| 283 // These constants are defined by the CPUid instructions. | 267 // These constants are defined by the CPUid instructions. |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 637 ts.tv_nsec = (timeout % 1000000) * 1000; | 621 ts.tv_nsec = (timeout % 1000000) * 1000; |
| 638 return semaphore_timedwait(semaphore_, ts) != KERN_OPERATION_TIMED_OUT; | 622 return semaphore_timedwait(semaphore_, ts) != KERN_OPERATION_TIMED_OUT; |
| 639 } | 623 } |
| 640 | 624 |
| 641 | 625 |
| 642 Semaphore* OS::CreateSemaphore(int count) { | 626 Semaphore* OS::CreateSemaphore(int count) { |
| 643 return new MacOSSemaphore(count); | 627 return new MacOSSemaphore(count); |
| 644 } | 628 } |
| 645 | 629 |
| 646 | 630 |
| 647 #ifdef ENABLE_LOGGING_AND_PROFILING | |
| 648 | |
| 649 class Sampler::PlatformData : public Malloced { | 631 class Sampler::PlatformData : public Malloced { |
| 650 public: | 632 public: |
| 651 PlatformData() : profiled_thread_(mach_thread_self()) {} | 633 PlatformData() : profiled_thread_(mach_thread_self()) {} |
| 652 | 634 |
| 653 ~PlatformData() { | 635 ~PlatformData() { |
| 654 // Deallocate Mach port for thread. | 636 // Deallocate Mach port for thread. |
| 655 mach_port_deallocate(mach_task_self(), profiled_thread_); | 637 mach_port_deallocate(mach_task_self(), profiled_thread_); |
| 656 } | 638 } |
| 657 | 639 |
| 658 thread_act_t profiled_thread() { return profiled_thread_; } | 640 thread_act_t profiled_thread() { return profiled_thread_; } |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 814 SamplerThread::AddActiveSampler(this); | 796 SamplerThread::AddActiveSampler(this); |
| 815 } | 797 } |
| 816 | 798 |
| 817 | 799 |
| 818 void Sampler::Stop() { | 800 void Sampler::Stop() { |
| 819 ASSERT(IsActive()); | 801 ASSERT(IsActive()); |
| 820 SamplerThread::RemoveActiveSampler(this); | 802 SamplerThread::RemoveActiveSampler(this); |
| 821 SetActive(false); | 803 SetActive(false); |
| 822 } | 804 } |
| 823 | 805 |
| 824 #endif // ENABLE_LOGGING_AND_PROFILING | |
| 825 | 806 |
| 826 } } // namespace v8::internal | 807 } } // namespace v8::internal |
| OLD | NEW |