| 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 | 92 #elif CAN_USE_ARMV7_INSTRUCTIONS |
| 93 return 1u << ARMv7; | 93 return 1u << ARMv7; |
| 94 #elif(defined(__mips_hard_float) && __mips_hard_float != 0) |
| 95 // Here gcc is telling us that we are on an MIPS and gcc is assuming that we |
| 96 // have FPU instructions. If gcc can assume it then so can we. |
| 97 return 1u << FPU; |
| 94 #else | 98 #else |
| 95 return 0; // Linux runs on anything. | 99 return 0; // Linux runs on anything. |
| 96 #endif | 100 #endif |
| 97 } | 101 } |
| 98 | 102 |
| 99 | 103 |
| 100 #ifdef __arm__ | 104 #ifdef __arm__ |
| 101 bool OS::ArmCpuHasFeature(CpuFeature feature) { | 105 bool OS::ArmCpuHasFeature(CpuFeature feature) { |
| 102 const char* search_string = NULL; | 106 const char* search_string = NULL; |
| 103 const char* file_name = "/proc/cpuinfo"; | 107 const char* file_name = "/proc/cpuinfo"; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 } | 148 } |
| 145 } | 149 } |
| 146 fclose(f); | 150 fclose(f); |
| 147 | 151 |
| 148 // Did not find string in the proc file. | 152 // Did not find string in the proc file. |
| 149 return false; | 153 return false; |
| 150 } | 154 } |
| 151 #endif // def __arm__ | 155 #endif // def __arm__ |
| 152 | 156 |
| 153 | 157 |
| 158 #ifdef __mips__ |
| 159 bool OS::MipsCpuHasFeature(CpuFeature feature) { |
| 160 const char* search_string = NULL; |
| 161 const char* file_name = "/proc/cpuinfo"; |
| 162 // Simple detection of FPU at runtime for Linux. |
| 163 // It is based on /proc/cpuinfo, which reveals hardware configuration |
| 164 // to user-space applications. According to MIPS (early 2010), no similar |
| 165 // facility is universally available on the MIPS architectures, |
| 166 // so it's up to individual OSes to provide such. |
| 167 // |
| 168 // This is written as a straight shot one pass parser |
| 169 // and not using STL string and ifstream because, |
| 170 // on Linux, it's reading from a (non-mmap-able) |
| 171 // character special device. |
| 172 switch (feature) { |
| 173 case FPU: |
| 174 search_string = "FPU"; |
| 175 break; |
| 176 default: |
| 177 UNREACHABLE(); |
| 178 } |
| 179 |
| 180 FILE* f = NULL; |
| 181 const char* what = search_string; |
| 182 |
| 183 if (NULL == (f = fopen(file_name, "r"))) |
| 184 return false; |
| 185 |
| 186 int k; |
| 187 while (EOF != (k = fgetc(f))) { |
| 188 if (k == *what) { |
| 189 ++what; |
| 190 while ((*what != '\0') && (*what == fgetc(f))) { |
| 191 ++what; |
| 192 } |
| 193 if (*what == '\0') { |
| 194 fclose(f); |
| 195 return true; |
| 196 } else { |
| 197 what = search_string; |
| 198 } |
| 199 } |
| 200 } |
| 201 fclose(f); |
| 202 |
| 203 // Did not find string in the proc file. |
| 204 return false; |
| 205 } |
| 206 #endif // def __mips__ |
| 207 |
| 208 |
| 154 int OS::ActivationFrameAlignment() { | 209 int OS::ActivationFrameAlignment() { |
| 155 #ifdef V8_TARGET_ARCH_ARM | 210 #ifdef V8_TARGET_ARCH_ARM |
| 156 // On EABI ARM targets this is required for fp correctness in the | 211 // On EABI ARM targets this is required for fp correctness in the |
| 157 // runtime system. | 212 // runtime system. |
| 158 return 8; | 213 return 8; |
| 159 #elif V8_TARGET_ARCH_MIPS | 214 #elif V8_TARGET_ARCH_MIPS |
| 160 return 8; | 215 return 8; |
| 161 #endif | 216 #endif |
| 162 // With gcc 4.4 the tree vectorization optimiser can generate code | 217 // With gcc 4.4 the tree vectorization optimiser can generate code |
| 163 // that requires 16 byte alignment such as movdqa on x86. | 218 // that requires 16 byte alignment such as movdqa on x86. |
| (...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 831 | 886 |
| 832 // This sampler is no longer the active sampler. | 887 // This sampler is no longer the active sampler. |
| 833 active_sampler_ = NULL; | 888 active_sampler_ = NULL; |
| 834 active_ = false; | 889 active_ = false; |
| 835 } | 890 } |
| 836 | 891 |
| 837 | 892 |
| 838 #endif // ENABLE_LOGGING_AND_PROFILING | 893 #endif // ENABLE_LOGGING_AND_PROFILING |
| 839 | 894 |
| 840 } } // namespace v8::internal | 895 } } // namespace v8::internal |
| OLD | NEW |