| 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 uint64_t seed = static_cast<uint64_t>(TimeCurrentMillis()); | 82 uint64_t seed = static_cast<uint64_t>(TimeCurrentMillis()); |
| 83 srandom(static_cast<unsigned int>(seed)); | 83 srandom(static_cast<unsigned int>(seed)); |
| 84 } | 84 } |
| 85 | 85 |
| 86 | 86 |
| 87 uint64_t OS::CpuFeaturesImpliedByPlatform() { | 87 uint64_t OS::CpuFeaturesImpliedByPlatform() { |
| 88 #if (defined(__VFP_FP__) && !defined(__SOFTFP__)) | 88 #if (defined(__VFP_FP__) && !defined(__SOFTFP__)) |
| 89 // Here gcc is telling us that we are on an ARM and gcc is assuming that we | 89 // Here gcc is telling us that we are on an ARM and gcc is assuming that we |
| 90 // have VFP3 instructions. If gcc can assume it then so can we. | 90 // have VFP3 instructions. If gcc can assume it then so can we. |
| 91 return 1u << VFP3; | 91 return 1u << VFP3; |
| 92 #elif CAN_USE_ARMV7_INSTRUCTIONS |
| 93 return 1u << ARMv7; |
| 92 #else | 94 #else |
| 93 return 0; // Linux runs on anything. | 95 return 0; // Linux runs on anything. |
| 94 #endif | 96 #endif |
| 95 } | 97 } |
| 96 | 98 |
| 97 | 99 |
| 98 #ifdef __arm__ | 100 #ifdef __arm__ |
| 99 bool OS::ArmCpuHasFeature(CpuFeature feature) { | 101 bool OS::ArmCpuHasFeature(CpuFeature feature) { |
| 100 const char* search_string = NULL; | 102 const char* search_string = NULL; |
| 101 const char* file_name = "/proc/cpuinfo"; | 103 const char* file_name = "/proc/cpuinfo"; |
| 102 // Simple detection of VFP at runtime for Linux. | 104 // Simple detection of VFP at runtime for Linux. |
| 103 // It is based on /proc/cpuinfo, which reveals hardware configuration | 105 // It is based on /proc/cpuinfo, which reveals hardware configuration |
| 104 // to user-space applications. According to ARM (mid 2009), no similar | 106 // to user-space applications. According to ARM (mid 2009), no similar |
| 105 // facility is universally available on the ARM architectures, | 107 // facility is universally available on the ARM architectures, |
| 106 // so it's up to individual OSes to provide such. | 108 // so it's up to individual OSes to provide such. |
| 107 // | 109 // |
| 108 // This is written as a straight shot one pass parser | 110 // This is written as a straight shot one pass parser |
| 109 // and not using STL string and ifstream because, | 111 // and not using STL string and ifstream because, |
| 110 // on Linux, it's reading from a (non-mmap-able) | 112 // on Linux, it's reading from a (non-mmap-able) |
| 111 // character special device. | 113 // character special device. |
| 112 switch (feature) { | 114 switch (feature) { |
| 113 case VFP3: | 115 case VFP3: |
| 114 search_string = "vfp"; | 116 search_string = "vfp"; |
| 115 break; | 117 break; |
| 118 case ARMv7: |
| 119 search_string = "ARMv7"; |
| 120 break; |
| 116 default: | 121 default: |
| 117 UNREACHABLE(); | 122 UNREACHABLE(); |
| 118 } | 123 } |
| 119 | 124 |
| 120 FILE* f = NULL; | 125 FILE* f = NULL; |
| 121 const char* what = search_string; | 126 const char* what = search_string; |
| 122 | 127 |
| 123 if (NULL == (f = fopen(file_name, "r"))) | 128 if (NULL == (f = fopen(file_name, "r"))) |
| 124 return false; | 129 return false; |
| 125 | 130 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 144 return false; | 149 return false; |
| 145 } | 150 } |
| 146 #endif // def __arm__ | 151 #endif // def __arm__ |
| 147 | 152 |
| 148 | 153 |
| 149 int OS::ActivationFrameAlignment() { | 154 int OS::ActivationFrameAlignment() { |
| 150 #ifdef V8_TARGET_ARCH_ARM | 155 #ifdef V8_TARGET_ARCH_ARM |
| 151 // On EABI ARM targets this is required for fp correctness in the | 156 // On EABI ARM targets this is required for fp correctness in the |
| 152 // runtime system. | 157 // runtime system. |
| 153 return 8; | 158 return 8; |
| 154 #else | 159 #elif V8_TARGET_ARCH_MIPS |
| 160 return 8; |
| 161 #endif |
| 155 // With gcc 4.4 the tree vectorization optimiser can generate code | 162 // With gcc 4.4 the tree vectorization optimiser can generate code |
| 156 // that requires 16 byte alignment such as movdqa on x86. | 163 // that requires 16 byte alignment such as movdqa on x86. |
| 157 return 16; | 164 return 16; |
| 158 #endif | |
| 159 } | 165 } |
| 160 | 166 |
| 161 | 167 |
| 162 const char* OS::LocalTimezone(double time) { | 168 const char* OS::LocalTimezone(double time) { |
| 163 if (isnan(time)) return ""; | 169 if (isnan(time)) return ""; |
| 164 time_t tv = static_cast<time_t>(floor(time/msPerSecond)); | 170 time_t tv = static_cast<time_t>(floor(time/msPerSecond)); |
| 165 struct tm* t = localtime(&tv); | 171 struct tm* t = localtime(&tv); |
| 166 if (NULL == t) return ""; | 172 if (NULL == t) return ""; |
| 167 return t->tm_zone; | 173 return t->tm_zone; |
| 168 } | 174 } |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 // Redirect to std abort to signal abnormal program termination. | 261 // Redirect to std abort to signal abnormal program termination. |
| 256 abort(); | 262 abort(); |
| 257 } | 263 } |
| 258 | 264 |
| 259 | 265 |
| 260 void OS::DebugBreak() { | 266 void OS::DebugBreak() { |
| 261 // TODO(lrn): Introduce processor define for runtime system (!= V8_ARCH_x, | 267 // TODO(lrn): Introduce processor define for runtime system (!= V8_ARCH_x, |
| 262 // which is the architecture of generated code). | 268 // which is the architecture of generated code). |
| 263 #if defined(__arm__) || defined(__thumb__) | 269 #if defined(__arm__) || defined(__thumb__) |
| 264 asm("bkpt 0"); | 270 asm("bkpt 0"); |
| 271 #elif defined(__mips__) |
| 272 asm("break"); |
| 265 #else | 273 #else |
| 266 asm("int $3"); | 274 asm("int $3"); |
| 267 #endif | 275 #endif |
| 268 } | 276 } |
| 269 | 277 |
| 270 | 278 |
| 271 class PosixMemoryMappedFile : public OS::MemoryMappedFile { | 279 class PosixMemoryMappedFile : public OS::MemoryMappedFile { |
| 272 public: | 280 public: |
| 273 PosixMemoryMappedFile(FILE* file, void* memory, int size) | 281 PosixMemoryMappedFile(FILE* file, void* memory, int size) |
| 274 : file_(file), memory_(memory), size_(size) { } | 282 : file_(file), memory_(memory), size_(size) { } |
| (...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 706 // reading Top::thread_id() should not be affected by races. | 714 // reading Top::thread_id() should not be affected by races. |
| 707 if (ThreadManager::HasId() && !ThreadManager::IsArchived() && | 715 if (ThreadManager::HasId() && !ThreadManager::IsArchived() && |
| 708 ThreadManager::CurrentId() == Top::thread_id()) { | 716 ThreadManager::CurrentId() == Top::thread_id()) { |
| 709 return true; | 717 return true; |
| 710 } | 718 } |
| 711 return false; | 719 return false; |
| 712 } | 720 } |
| 713 | 721 |
| 714 | 722 |
| 715 static void ProfilerSignalHandler(int signal, siginfo_t* info, void* context) { | 723 static void ProfilerSignalHandler(int signal, siginfo_t* info, void* context) { |
| 724 #ifndef V8_HOST_ARCH_MIPS |
| 716 USE(info); | 725 USE(info); |
| 717 if (signal != SIGPROF) return; | 726 if (signal != SIGPROF) return; |
| 718 if (active_sampler_ == NULL) return; | 727 if (active_sampler_ == NULL) return; |
| 719 | 728 |
| 720 TickSample sample; | 729 TickSample sample; |
| 721 | 730 |
| 722 // If profiling, we extract the current pc and sp. | 731 // If profiling, we extract the current pc and sp. |
| 723 if (active_sampler_->IsProfiling()) { | 732 if (active_sampler_->IsProfiling()) { |
| 724 // Extracting the sample from the context is extremely machine dependent. | 733 // Extracting the sample from the context is extremely machine dependent. |
| 725 ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context); | 734 ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 736 // An undefined macro evaluates to 0, so this applies to Android's Bionic also. | 745 // An undefined macro evaluates to 0, so this applies to Android's Bionic also. |
| 737 #if (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ <= 3)) | 746 #if (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ <= 3)) |
| 738 sample.pc = reinterpret_cast<Address>(mcontext.gregs[R15]); | 747 sample.pc = reinterpret_cast<Address>(mcontext.gregs[R15]); |
| 739 sample.sp = reinterpret_cast<Address>(mcontext.gregs[R13]); | 748 sample.sp = reinterpret_cast<Address>(mcontext.gregs[R13]); |
| 740 sample.fp = reinterpret_cast<Address>(mcontext.gregs[R11]); | 749 sample.fp = reinterpret_cast<Address>(mcontext.gregs[R11]); |
| 741 #else | 750 #else |
| 742 sample.pc = reinterpret_cast<Address>(mcontext.arm_pc); | 751 sample.pc = reinterpret_cast<Address>(mcontext.arm_pc); |
| 743 sample.sp = reinterpret_cast<Address>(mcontext.arm_sp); | 752 sample.sp = reinterpret_cast<Address>(mcontext.arm_sp); |
| 744 sample.fp = reinterpret_cast<Address>(mcontext.arm_fp); | 753 sample.fp = reinterpret_cast<Address>(mcontext.arm_fp); |
| 745 #endif | 754 #endif |
| 755 #elif V8_HOST_ARCH_MIPS |
| 756 // Implement this on MIPS. |
| 757 UNIMPLEMENTED(); |
| 746 #endif | 758 #endif |
| 747 if (IsVmThread()) | 759 if (IsVmThread()) |
| 748 active_sampler_->SampleStack(&sample); | 760 active_sampler_->SampleStack(&sample); |
| 749 } | 761 } |
| 750 | 762 |
| 751 // We always sample the VM state. | 763 // We always sample the VM state. |
| 752 sample.state = Logger::state(); | 764 sample.state = Logger::state(); |
| 753 | 765 |
| 754 active_sampler_->Tick(&sample); | 766 active_sampler_->Tick(&sample); |
| 767 #endif |
| 755 } | 768 } |
| 756 | 769 |
| 757 | 770 |
| 758 class Sampler::PlatformData : public Malloced { | 771 class Sampler::PlatformData : public Malloced { |
| 759 public: | 772 public: |
| 760 PlatformData() { | 773 PlatformData() { |
| 761 signal_handler_installed_ = false; | 774 signal_handler_installed_ = false; |
| 762 } | 775 } |
| 763 | 776 |
| 764 bool signal_handler_installed_; | 777 bool signal_handler_installed_; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 817 | 830 |
| 818 // This sampler is no longer the active sampler. | 831 // This sampler is no longer the active sampler. |
| 819 active_sampler_ = NULL; | 832 active_sampler_ = NULL; |
| 820 active_ = false; | 833 active_ = false; |
| 821 } | 834 } |
| 822 | 835 |
| 823 | 836 |
| 824 #endif // ENABLE_LOGGING_AND_PROFILING | 837 #endif // ENABLE_LOGGING_AND_PROFILING |
| 825 | 838 |
| 826 } } // namespace v8::internal | 839 } } // namespace v8::internal |
| OLD | NEW |