| 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 } | 87 } |
| 88 | 88 |
| 89 | 89 |
| 90 uint64_t OS::CpuFeaturesImpliedByPlatform() { | 90 uint64_t OS::CpuFeaturesImpliedByPlatform() { |
| 91 #if (defined(__VFP_FP__) && !defined(__SOFTFP__)) | 91 #if (defined(__VFP_FP__) && !defined(__SOFTFP__)) |
| 92 // Here gcc is telling us that we are on an ARM and gcc is assuming that we | 92 // Here gcc is telling us that we are on an ARM and gcc is assuming that we |
| 93 // have VFP3 instructions. If gcc can assume it then so can we. | 93 // have VFP3 instructions. If gcc can assume it then so can we. |
| 94 return 1u << VFP3; | 94 return 1u << VFP3; |
| 95 #elif CAN_USE_ARMV7_INSTRUCTIONS | 95 #elif CAN_USE_ARMV7_INSTRUCTIONS |
| 96 return 1u << ARMv7; | 96 return 1u << ARMv7; |
| 97 #elif(defined(__mips_hard_float) && __mips_hard_float != 0) |
| 98 // Here gcc is telling us that we are on an MIPS and gcc is assuming that we |
| 99 // have FPU instructions. If gcc can assume it then so can we. |
| 100 return 1u << FPU; |
| 97 #else | 101 #else |
| 98 return 0; // Linux runs on anything. | 102 return 0; // Linux runs on anything. |
| 99 #endif | 103 #endif |
| 100 } | 104 } |
| 101 | 105 |
| 102 | 106 |
| 103 #ifdef __arm__ | 107 #ifdef __arm__ |
| 104 static bool CPUInfoContainsString(const char * search_string) { | 108 static bool CPUInfoContainsString(const char * search_string) { |
| 105 const char* file_name = "/proc/cpuinfo"; | 109 const char* file_name = "/proc/cpuinfo"; |
| 106 // This is written as a straight shot one pass parser | 110 // This is written as a straight shot one pass parser |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 if (CPUInfoContainsString("vfp") && CPUInfoContainsString("neon")) { | 169 if (CPUInfoContainsString("vfp") && CPUInfoContainsString("neon")) { |
| 166 return true; | 170 return true; |
| 167 } | 171 } |
| 168 } | 172 } |
| 169 | 173 |
| 170 return false; | 174 return false; |
| 171 } | 175 } |
| 172 #endif // def __arm__ | 176 #endif // def __arm__ |
| 173 | 177 |
| 174 | 178 |
| 179 #ifdef __mips__ |
| 180 bool OS::MipsCpuHasFeature(CpuFeature feature) { |
| 181 const char* search_string = NULL; |
| 182 const char* file_name = "/proc/cpuinfo"; |
| 183 // Simple detection of FPU at runtime for Linux. |
| 184 // It is based on /proc/cpuinfo, which reveals hardware configuration |
| 185 // to user-space applications. According to MIPS (early 2010), no similar |
| 186 // facility is universally available on the MIPS architectures, |
| 187 // so it's up to individual OSes to provide such. |
| 188 // |
| 189 // This is written as a straight shot one pass parser |
| 190 // and not using STL string and ifstream because, |
| 191 // on Linux, it's reading from a (non-mmap-able) |
| 192 // character special device. |
| 193 |
| 194 switch (feature) { |
| 195 case FPU: |
| 196 search_string = "FPU"; |
| 197 break; |
| 198 default: |
| 199 UNREACHABLE(); |
| 200 } |
| 201 |
| 202 FILE* f = NULL; |
| 203 const char* what = search_string; |
| 204 |
| 205 if (NULL == (f = fopen(file_name, "r"))) |
| 206 return false; |
| 207 |
| 208 int k; |
| 209 while (EOF != (k = fgetc(f))) { |
| 210 if (k == *what) { |
| 211 ++what; |
| 212 while ((*what != '\0') && (*what == fgetc(f))) { |
| 213 ++what; |
| 214 } |
| 215 if (*what == '\0') { |
| 216 fclose(f); |
| 217 return true; |
| 218 } else { |
| 219 what = search_string; |
| 220 } |
| 221 } |
| 222 } |
| 223 fclose(f); |
| 224 |
| 225 // Did not find string in the proc file. |
| 226 return false; |
| 227 } |
| 228 #endif // def __mips__ |
| 229 |
| 230 |
| 175 int OS::ActivationFrameAlignment() { | 231 int OS::ActivationFrameAlignment() { |
| 176 #ifdef V8_TARGET_ARCH_ARM | 232 #ifdef V8_TARGET_ARCH_ARM |
| 177 // On EABI ARM targets this is required for fp correctness in the | 233 // On EABI ARM targets this is required for fp correctness in the |
| 178 // runtime system. | 234 // runtime system. |
| 179 return 8; | 235 return 8; |
| 180 #elif V8_TARGET_ARCH_MIPS | 236 #elif V8_TARGET_ARCH_MIPS |
| 181 return 8; | 237 return 8; |
| 182 #endif | 238 #endif |
| 183 // With gcc 4.4 the tree vectorization optimizer can generate code | 239 // With gcc 4.4 the tree vectorization optimizer can generate code |
| 184 // that requires 16 byte alignment such as movdqa on x86. | 240 // that requires 16 byte alignment such as movdqa on x86. |
| 185 return 16; | 241 return 16; |
| 186 } | 242 } |
| 187 | 243 |
| 188 | 244 |
| 189 void OS::ReleaseStore(volatile AtomicWord* ptr, AtomicWord value) { | 245 void OS::ReleaseStore(volatile AtomicWord* ptr, AtomicWord value) { |
| 190 #if defined(V8_TARGET_ARCH_ARM) && defined(__arm__) | 246 #if (defined(V8_TARGET_ARCH_ARM) && defined(__arm__)) || \ |
| 191 // Only use on ARM hardware. | 247 (defined(V8_TARGET_ARCH_MIPS) && defined(__mips__)) |
| 248 // Only use on ARM or MIPS hardware. |
| 192 MemoryBarrier(); | 249 MemoryBarrier(); |
| 193 #else | 250 #else |
| 194 __asm__ __volatile__("" : : : "memory"); | 251 __asm__ __volatile__("" : : : "memory"); |
| 195 // An x86 store acts as a release barrier. | 252 // An x86 store acts as a release barrier. |
| 196 #endif | 253 #endif |
| 197 *ptr = value; | 254 *ptr = value; |
| 198 } | 255 } |
| 199 | 256 |
| 200 | 257 |
| 201 const char* OS::LocalTimezone(double time) { | 258 const char* OS::LocalTimezone(double time) { |
| (...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 826 #if (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ <= 3)) | 883 #if (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ <= 3)) |
| 827 sample->pc = reinterpret_cast<Address>(mcontext.gregs[R15]); | 884 sample->pc = reinterpret_cast<Address>(mcontext.gregs[R15]); |
| 828 sample->sp = reinterpret_cast<Address>(mcontext.gregs[R13]); | 885 sample->sp = reinterpret_cast<Address>(mcontext.gregs[R13]); |
| 829 sample->fp = reinterpret_cast<Address>(mcontext.gregs[R11]); | 886 sample->fp = reinterpret_cast<Address>(mcontext.gregs[R11]); |
| 830 #else | 887 #else |
| 831 sample->pc = reinterpret_cast<Address>(mcontext.arm_pc); | 888 sample->pc = reinterpret_cast<Address>(mcontext.arm_pc); |
| 832 sample->sp = reinterpret_cast<Address>(mcontext.arm_sp); | 889 sample->sp = reinterpret_cast<Address>(mcontext.arm_sp); |
| 833 sample->fp = reinterpret_cast<Address>(mcontext.arm_fp); | 890 sample->fp = reinterpret_cast<Address>(mcontext.arm_fp); |
| 834 #endif | 891 #endif |
| 835 #elif V8_HOST_ARCH_MIPS | 892 #elif V8_HOST_ARCH_MIPS |
| 836 // Implement this on MIPS. | 893 sample.pc = reinterpret_cast<Address>(mcontext.pc); |
| 837 UNIMPLEMENTED(); | 894 sample.sp = reinterpret_cast<Address>(mcontext.gregs[29]); |
| 895 sample.fp = reinterpret_cast<Address>(mcontext.gregs[30]); |
| 838 #endif | 896 #endif |
| 839 active_sampler_->SampleStack(sample); | 897 active_sampler_->SampleStack(sample); |
| 840 active_sampler_->Tick(sample); | 898 active_sampler_->Tick(sample); |
| 841 #endif | 899 #endif |
| 842 } | 900 } |
| 843 | 901 |
| 844 | 902 |
| 845 class Sampler::PlatformData : public Malloced { | 903 class Sampler::PlatformData : public Malloced { |
| 846 public: | 904 public: |
| 847 enum SleepInterval { | 905 enum SleepInterval { |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 975 } | 1033 } |
| 976 | 1034 |
| 977 // This sampler is no longer the active sampler. | 1035 // This sampler is no longer the active sampler. |
| 978 active_sampler_ = NULL; | 1036 active_sampler_ = NULL; |
| 979 } | 1037 } |
| 980 | 1038 |
| 981 | 1039 |
| 982 #endif // ENABLE_LOGGING_AND_PROFILING | 1040 #endif // ENABLE_LOGGING_AND_PROFILING |
| 983 | 1041 |
| 984 } } // namespace v8::internal | 1042 } } // namespace v8::internal |
| OLD | NEW |