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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 | 80 |
81 void OS::Setup() { | 81 void OS::Setup() { |
82 // Seed the random number generator. | 82 // Seed the random number generator. |
83 // Convert the current time to a 64-bit integer first, before converting it | 83 // Convert the current time to a 64-bit integer first, before converting it |
84 // to an unsigned. Going directly can cause an overflow and the seed to be | 84 // to an unsigned. Going directly can cause an overflow and the seed to be |
85 // set to all ones. The seed will be identical for different instances that | 85 // set to all ones. The seed will be identical for different instances that |
86 // call this setup code within the same millisecond. | 86 // call this setup code within the same millisecond. |
87 uint64_t seed = static_cast<uint64_t>(TimeCurrentMillis()); | 87 uint64_t seed = static_cast<uint64_t>(TimeCurrentMillis()); |
88 srandom(static_cast<unsigned int>(seed)); | 88 srandom(static_cast<unsigned int>(seed)); |
89 limit_mutex = CreateMutex(); | 89 limit_mutex = CreateMutex(); |
| 90 |
| 91 #ifdef __arm__ |
| 92 // When running on ARM hardware check that the EABI used by V8 and |
| 93 // by the C code is the same. |
| 94 bool hard_float = OS::ArmUsingHardFloat(); |
| 95 if (hard_float) { |
| 96 #if !USE_EABI_HARDFLOAT |
| 97 PrintF("ERROR: Binary compiled with -mfloat-abi=hard but without " |
| 98 "-DUSE_EABI_HARDFLOAT\n"); |
| 99 exit(1); |
| 100 #endif |
| 101 } else { |
| 102 #if USE_EABI_HARDFLOAT |
| 103 PrintF("ERROR: Binary not compiled with -mfloat-abi=hard but with " |
| 104 "-DUSE_EABI_HARDFLOAT\n"); |
| 105 exit(1); |
| 106 #endif |
| 107 } |
| 108 #endif |
90 } | 109 } |
91 | 110 |
92 | 111 |
93 uint64_t OS::CpuFeaturesImpliedByPlatform() { | 112 uint64_t OS::CpuFeaturesImpliedByPlatform() { |
94 #if (defined(__VFP_FP__) && !defined(__SOFTFP__)) | 113 #if (defined(__VFP_FP__) && !defined(__SOFTFP__)) |
95 // Here gcc is telling us that we are on an ARM and gcc is assuming | 114 // Here gcc is telling us that we are on an ARM and gcc is assuming |
96 // that we have VFP3 instructions. If gcc can assume it then so can | 115 // that we have VFP3 instructions. If gcc can assume it then so can |
97 // we. VFPv3 implies ARMv7, see ARM DDI 0406B, page A1-6. | 116 // we. VFPv3 implies ARMv7, see ARM DDI 0406B, page A1-6. |
98 return 1u << VFP3 | 1u << ARMv7; | 117 return 1u << VFP3 | 1u << ARMv7; |
99 #elif CAN_USE_ARMV7_INSTRUCTIONS | 118 #elif CAN_USE_ARMV7_INSTRUCTIONS |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 what = search_string; | 154 what = search_string; |
136 } | 155 } |
137 } | 156 } |
138 } | 157 } |
139 fclose(f); | 158 fclose(f); |
140 | 159 |
141 // Did not find string in the proc file. | 160 // Did not find string in the proc file. |
142 return false; | 161 return false; |
143 } | 162 } |
144 | 163 |
| 164 |
145 bool OS::ArmCpuHasFeature(CpuFeature feature) { | 165 bool OS::ArmCpuHasFeature(CpuFeature feature) { |
146 const char* search_string = NULL; | 166 const char* search_string = NULL; |
147 // Simple detection of VFP at runtime for Linux. | 167 // Simple detection of VFP at runtime for Linux. |
148 // It is based on /proc/cpuinfo, which reveals hardware configuration | 168 // It is based on /proc/cpuinfo, which reveals hardware configuration |
149 // to user-space applications. According to ARM (mid 2009), no similar | 169 // to user-space applications. According to ARM (mid 2009), no similar |
150 // facility is universally available on the ARM architectures, | 170 // facility is universally available on the ARM architectures, |
151 // so it's up to individual OSes to provide such. | 171 // so it's up to individual OSes to provide such. |
152 switch (feature) { | 172 switch (feature) { |
153 case VFP3: | 173 case VFP3: |
154 search_string = "vfpv3"; | 174 search_string = "vfpv3"; |
(...skipping 15 matching lines...) Expand all Loading... |
170 // available on architectures with vfpv3. | 190 // available on architectures with vfpv3. |
171 // Checking neon on its own is not enough as it is possible to have neon | 191 // Checking neon on its own is not enough as it is possible to have neon |
172 // without vfp. | 192 // without vfp. |
173 if (CPUInfoContainsString("vfp") && CPUInfoContainsString("neon")) { | 193 if (CPUInfoContainsString("vfp") && CPUInfoContainsString("neon")) { |
174 return true; | 194 return true; |
175 } | 195 } |
176 } | 196 } |
177 | 197 |
178 return false; | 198 return false; |
179 } | 199 } |
| 200 |
| 201 |
| 202 // Simple helper function to detect whether the C code is compiled with |
| 203 // option -mfloat-abi=hard. The register d0 is loaded with 1.0 and the register |
| 204 // pair r0, r1 is loaded with 0.0. If -mfloat-abi=hard is pased to GCC then |
| 205 // calling this will return 1.0 and otherwise 0.0. |
| 206 static void ArmUsingHardFloatHelper() { |
| 207 asm("mov r0, #0"); |
| 208 asm("mov r1, #0"); |
| 209 asm("movt r1, #16368"); |
| 210 asm("vmov d0, r0, r1"); |
| 211 asm("mov r0, #0"); |
| 212 asm("mov r1, #0"); |
| 213 } |
| 214 |
| 215 |
| 216 bool OS::ArmUsingHardFloat() { |
| 217 // Cast helper function from returning void to returning double. |
| 218 typedef double (*F)(); |
| 219 F f = FUNCTION_CAST<F>(FUNCTION_ADDR(ArmUsingHardFloatHelper)); |
| 220 return f() == 1.0; |
| 221 } |
180 #endif // def __arm__ | 222 #endif // def __arm__ |
181 | 223 |
182 | 224 |
183 #ifdef __mips__ | 225 #ifdef __mips__ |
184 bool OS::MipsCpuHasFeature(CpuFeature feature) { | 226 bool OS::MipsCpuHasFeature(CpuFeature feature) { |
185 const char* search_string = NULL; | 227 const char* search_string = NULL; |
186 const char* file_name = "/proc/cpuinfo"; | 228 const char* file_name = "/proc/cpuinfo"; |
187 // Simple detection of FPU at runtime for Linux. | 229 // Simple detection of FPU at runtime for Linux. |
188 // It is based on /proc/cpuinfo, which reveals hardware configuration | 230 // It is based on /proc/cpuinfo, which reveals hardware configuration |
189 // to user-space applications. According to MIPS (early 2010), no similar | 231 // to user-space applications. According to MIPS (early 2010), no similar |
(...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1083 | 1125 |
1084 void Sampler::Stop() { | 1126 void Sampler::Stop() { |
1085 ASSERT(IsActive()); | 1127 ASSERT(IsActive()); |
1086 SignalSender::RemoveActiveSampler(this); | 1128 SignalSender::RemoveActiveSampler(this); |
1087 SetActive(false); | 1129 SetActive(false); |
1088 } | 1130 } |
1089 | 1131 |
1090 #endif // ENABLE_LOGGING_AND_PROFILING | 1132 #endif // ENABLE_LOGGING_AND_PROFILING |
1091 | 1133 |
1092 } } // namespace v8::internal | 1134 } } // namespace v8::internal |
OLD | NEW |