| 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 } | 90 } |
| 91 | 91 |
| 92 | 92 |
| 93 uint64_t OS::CpuFeaturesImpliedByPlatform() { | 93 uint64_t OS::CpuFeaturesImpliedByPlatform() { |
| 94 #if (defined(__VFP_FP__) && !defined(__SOFTFP__)) | 94 #if (defined(__VFP_FP__) && !defined(__SOFTFP__)) |
| 95 // Here gcc is telling us that we are on an ARM and gcc is assuming that we | 95 // Here gcc is telling us that we are on an ARM and gcc is assuming that we |
| 96 // have VFP3 instructions. If gcc can assume it then so can we. | 96 // have VFP3 instructions. If gcc can assume it then so can we. |
| 97 return 1u << VFP3; | 97 return 1u << VFP3; |
| 98 #elif CAN_USE_ARMV7_INSTRUCTIONS | 98 #elif CAN_USE_ARMV7_INSTRUCTIONS |
| 99 return 1u << ARMv7; | 99 return 1u << ARMv7; |
| 100 #elif(defined(__mips_hard_float) && __mips_hard_float != 0) |
| 101 // Here gcc is telling us that we are on an MIPS and gcc is assuming that we |
| 102 // have FPU instructions. If gcc can assume it then so can we. |
| 103 return 1u << FPU; |
| 100 #else | 104 #else |
| 101 return 0; // Linux runs on anything. | 105 return 0; // Linux runs on anything. |
| 102 #endif | 106 #endif |
| 103 } | 107 } |
| 104 | 108 |
| 105 | 109 |
| 106 #ifdef __arm__ | 110 #ifdef __arm__ |
| 107 static bool CPUInfoContainsString(const char * search_string) { | 111 static bool CPUInfoContainsString(const char * search_string) { |
| 108 const char* file_name = "/proc/cpuinfo"; | 112 const char* file_name = "/proc/cpuinfo"; |
| 109 // This is written as a straight shot one pass parser | 113 // This is written as a straight shot one pass parser |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 if (CPUInfoContainsString("vfp") && CPUInfoContainsString("neon")) { | 172 if (CPUInfoContainsString("vfp") && CPUInfoContainsString("neon")) { |
| 169 return true; | 173 return true; |
| 170 } | 174 } |
| 171 } | 175 } |
| 172 | 176 |
| 173 return false; | 177 return false; |
| 174 } | 178 } |
| 175 #endif // def __arm__ | 179 #endif // def __arm__ |
| 176 | 180 |
| 177 | 181 |
| 182 #ifdef __mips__ |
| 183 bool OS::MipsCpuHasFeature(CpuFeature feature) { |
| 184 const char* search_string = NULL; |
| 185 const char* file_name = "/proc/cpuinfo"; |
| 186 // Simple detection of FPU at runtime for Linux. |
| 187 // It is based on /proc/cpuinfo, which reveals hardware configuration |
| 188 // to user-space applications. According to MIPS (early 2010), no similar |
| 189 // facility is universally available on the MIPS architectures, |
| 190 // so it's up to individual OSes to provide such. |
| 191 // |
| 192 // This is written as a straight shot one pass parser |
| 193 // and not using STL string and ifstream because, |
| 194 // on Linux, it's reading from a (non-mmap-able) |
| 195 // character special device. |
| 196 |
| 197 switch (feature) { |
| 198 case FPU: |
| 199 search_string = "FPU"; |
| 200 break; |
| 201 default: |
| 202 UNREACHABLE(); |
| 203 } |
| 204 |
| 205 FILE* f = NULL; |
| 206 const char* what = search_string; |
| 207 |
| 208 if (NULL == (f = fopen(file_name, "r"))) |
| 209 return false; |
| 210 |
| 211 int k; |
| 212 while (EOF != (k = fgetc(f))) { |
| 213 if (k == *what) { |
| 214 ++what; |
| 215 while ((*what != '\0') && (*what == fgetc(f))) { |
| 216 ++what; |
| 217 } |
| 218 if (*what == '\0') { |
| 219 fclose(f); |
| 220 return true; |
| 221 } else { |
| 222 what = search_string; |
| 223 } |
| 224 } |
| 225 } |
| 226 fclose(f); |
| 227 |
| 228 // Did not find string in the proc file. |
| 229 return false; |
| 230 } |
| 231 #endif // def __mips__ |
| 232 |
| 233 |
| 178 int OS::ActivationFrameAlignment() { | 234 int OS::ActivationFrameAlignment() { |
| 179 #ifdef V8_TARGET_ARCH_ARM | 235 #ifdef V8_TARGET_ARCH_ARM |
| 180 // On EABI ARM targets this is required for fp correctness in the | 236 // On EABI ARM targets this is required for fp correctness in the |
| 181 // runtime system. | 237 // runtime system. |
| 182 return 8; | 238 return 8; |
| 183 #elif V8_TARGET_ARCH_MIPS | 239 #elif V8_TARGET_ARCH_MIPS |
| 184 return 8; | 240 return 8; |
| 185 #endif | 241 #endif |
| 186 // With gcc 4.4 the tree vectorization optimizer can generate code | 242 // With gcc 4.4 the tree vectorization optimizer can generate code |
| 187 // that requires 16 byte alignment such as movdqa on x86. | 243 // that requires 16 byte alignment such as movdqa on x86. |
| 188 return 16; | 244 return 16; |
| 189 } | 245 } |
| 190 | 246 |
| 191 | 247 |
| 192 void OS::ReleaseStore(volatile AtomicWord* ptr, AtomicWord value) { | 248 void OS::ReleaseStore(volatile AtomicWord* ptr, AtomicWord value) { |
| 193 #if defined(V8_TARGET_ARCH_ARM) && defined(__arm__) | 249 #if (defined(V8_TARGET_ARCH_ARM) && defined(__arm__)) || \ |
| 194 // Only use on ARM hardware. | 250 (defined(V8_TARGET_ARCH_MIPS) && defined(__mips__)) |
| 251 // Only use on ARM or MIPS hardware. |
| 195 MemoryBarrier(); | 252 MemoryBarrier(); |
| 196 #else | 253 #else |
| 197 __asm__ __volatile__("" : : : "memory"); | 254 __asm__ __volatile__("" : : : "memory"); |
| 198 // An x86 store acts as a release barrier. | 255 // An x86 store acts as a release barrier. |
| 199 #endif | 256 #endif |
| 200 *ptr = value; | 257 *ptr = value; |
| 201 } | 258 } |
| 202 | 259 |
| 203 | 260 |
| 204 const char* OS::LocalTimezone(double time) { | 261 const char* OS::LocalTimezone(double time) { |
| (...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 853 #if (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ <= 3)) | 910 #if (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ <= 3)) |
| 854 sample->pc = reinterpret_cast<Address>(mcontext.gregs[R15]); | 911 sample->pc = reinterpret_cast<Address>(mcontext.gregs[R15]); |
| 855 sample->sp = reinterpret_cast<Address>(mcontext.gregs[R13]); | 912 sample->sp = reinterpret_cast<Address>(mcontext.gregs[R13]); |
| 856 sample->fp = reinterpret_cast<Address>(mcontext.gregs[R11]); | 913 sample->fp = reinterpret_cast<Address>(mcontext.gregs[R11]); |
| 857 #else | 914 #else |
| 858 sample->pc = reinterpret_cast<Address>(mcontext.arm_pc); | 915 sample->pc = reinterpret_cast<Address>(mcontext.arm_pc); |
| 859 sample->sp = reinterpret_cast<Address>(mcontext.arm_sp); | 916 sample->sp = reinterpret_cast<Address>(mcontext.arm_sp); |
| 860 sample->fp = reinterpret_cast<Address>(mcontext.arm_fp); | 917 sample->fp = reinterpret_cast<Address>(mcontext.arm_fp); |
| 861 #endif | 918 #endif |
| 862 #elif V8_HOST_ARCH_MIPS | 919 #elif V8_HOST_ARCH_MIPS |
| 863 // Implement this on MIPS. | 920 sample.pc = reinterpret_cast<Address>(mcontext.pc); |
| 864 UNIMPLEMENTED(); | 921 sample.sp = reinterpret_cast<Address>(mcontext.gregs[29]); |
| 922 sample.fp = reinterpret_cast<Address>(mcontext.gregs[30]); |
| 865 #endif | 923 #endif |
| 866 sampler->SampleStack(sample); | 924 sampler->SampleStack(sample); |
| 867 sampler->Tick(sample); | 925 sampler->Tick(sample); |
| 868 #endif | 926 #endif |
| 869 } | 927 } |
| 870 | 928 |
| 871 | 929 |
| 872 class Sampler::PlatformData : public Malloced { | 930 class Sampler::PlatformData : public Malloced { |
| 873 public: | 931 public: |
| 874 PlatformData() : vm_tid_(GetThreadID()) {} | 932 PlatformData() : vm_tid_(GetThreadID()) {} |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1053 | 1111 |
| 1054 void Sampler::Stop() { | 1112 void Sampler::Stop() { |
| 1055 ASSERT(IsActive()); | 1113 ASSERT(IsActive()); |
| 1056 SignalSender::RemoveActiveSampler(this); | 1114 SignalSender::RemoveActiveSampler(this); |
| 1057 SetActive(false); | 1115 SetActive(false); |
| 1058 } | 1116 } |
| 1059 | 1117 |
| 1060 #endif // ENABLE_LOGGING_AND_PROFILING | 1118 #endif // ENABLE_LOGGING_AND_PROFILING |
| 1061 | 1119 |
| 1062 } } // namespace v8::internal | 1120 } } // namespace v8::internal |
| OLD | NEW |