OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #ifndef RUNTIME_PLATFORM_GLOBALS_H_ | 5 #ifndef RUNTIME_PLATFORM_GLOBALS_H_ |
6 #define RUNTIME_PLATFORM_GLOBALS_H_ | 6 #define RUNTIME_PLATFORM_GLOBALS_H_ |
7 | 7 |
8 // __STDC_FORMAT_MACROS has to be defined before including <inttypes.h> to | 8 // __STDC_FORMAT_MACROS has to be defined before including <inttypes.h> to |
9 // enable platform independent printf format specifiers. | 9 // enable platform independent printf format specifiers. |
10 #ifndef __STDC_FORMAT_MACROS | 10 #ifndef __STDC_FORMAT_MACROS |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 // http://www.agner.org/optimize/calling_conventions.pdf | 205 // http://www.agner.org/optimize/calling_conventions.pdf |
206 // or with gcc, run: "echo | gcc -E -dM -" | 206 // or with gcc, run: "echo | gcc -E -dM -" |
207 #if defined(_M_X64) || defined(__x86_64__) | 207 #if defined(_M_X64) || defined(__x86_64__) |
208 #define HOST_ARCH_X64 1 | 208 #define HOST_ARCH_X64 1 |
209 #define ARCH_IS_64_BIT 1 | 209 #define ARCH_IS_64_BIT 1 |
210 #define kFpuRegisterSize 16 | 210 #define kFpuRegisterSize 16 |
211 typedef simd128_value_t fpu_register_t; | 211 typedef simd128_value_t fpu_register_t; |
212 #elif defined(_M_IX86) || defined(__i386__) | 212 #elif defined(_M_IX86) || defined(__i386__) |
213 #define HOST_ARCH_IA32 1 | 213 #define HOST_ARCH_IA32 1 |
214 #define ARCH_IS_32_BIT 1 | 214 #define ARCH_IS_32_BIT 1 |
215 #if defined(TARGET_ARCH_MIPS) | |
216 #define kFpuRegisterSize 8 | |
217 typedef double fpu_register_t; | |
218 #else | |
219 #define kFpuRegisterSize 16 | 215 #define kFpuRegisterSize 16 |
220 typedef simd128_value_t fpu_register_t; | 216 typedef simd128_value_t fpu_register_t; |
221 #endif | |
222 #elif defined(__ARMEL__) | 217 #elif defined(__ARMEL__) |
223 #define HOST_ARCH_ARM 1 | 218 #define HOST_ARCH_ARM 1 |
224 #define ARCH_IS_32_BIT 1 | 219 #define ARCH_IS_32_BIT 1 |
225 #define kFpuRegisterSize 16 | 220 #define kFpuRegisterSize 16 |
226 // Mark the fact that we have defined simd_value_t. | 221 // Mark the fact that we have defined simd_value_t. |
227 #define SIMD_VALUE_T_ | 222 #define SIMD_VALUE_T_ |
228 typedef struct { | 223 typedef struct { |
229 union { | 224 union { |
230 uint32_t u; | 225 uint32_t u; |
231 float f; | 226 float f; |
232 } data_[4]; | 227 } data_[4]; |
233 } simd_value_t; | 228 } simd_value_t; |
234 typedef simd_value_t fpu_register_t; | 229 typedef simd_value_t fpu_register_t; |
235 #define simd_value_safe_load(addr) (*reinterpret_cast<simd_value_t*>(addr)) | 230 #define simd_value_safe_load(addr) (*reinterpret_cast<simd_value_t*>(addr)) |
236 #define simd_value_safe_store(addr, value) \ | 231 #define simd_value_safe_store(addr, value) \ |
237 do { \ | 232 do { \ |
238 reinterpret_cast<simd_value_t*>(addr)->data_[0] = value.data_[0]; \ | 233 reinterpret_cast<simd_value_t*>(addr)->data_[0] = value.data_[0]; \ |
239 reinterpret_cast<simd_value_t*>(addr)->data_[1] = value.data_[1]; \ | 234 reinterpret_cast<simd_value_t*>(addr)->data_[1] = value.data_[1]; \ |
240 reinterpret_cast<simd_value_t*>(addr)->data_[2] = value.data_[2]; \ | 235 reinterpret_cast<simd_value_t*>(addr)->data_[2] = value.data_[2]; \ |
241 reinterpret_cast<simd_value_t*>(addr)->data_[3] = value.data_[3]; \ | 236 reinterpret_cast<simd_value_t*>(addr)->data_[3] = value.data_[3]; \ |
242 } while (0) | 237 } while (0) |
243 | 238 |
244 #elif defined(__MIPSEL__) | |
245 #define HOST_ARCH_MIPS 1 | |
246 #define ARCH_IS_32_BIT 1 | |
247 #define kFpuRegisterSize 8 | |
248 typedef double fpu_register_t; | |
249 #elif defined(__MIPSEB__) | |
250 #error Big-endian MIPS is not supported by Dart. Try passing -EL to your \ | |
251 compiler. | |
252 #elif defined(__aarch64__) | 239 #elif defined(__aarch64__) |
253 #define HOST_ARCH_ARM64 1 | 240 #define HOST_ARCH_ARM64 1 |
254 #define ARCH_IS_64_BIT 1 | 241 #define ARCH_IS_64_BIT 1 |
255 #define kFpuRegisterSize 16 | 242 #define kFpuRegisterSize 16 |
256 typedef simd128_value_t fpu_register_t; | 243 typedef simd128_value_t fpu_register_t; |
257 #else | 244 #else |
258 #error Architecture was not detected as supported by Dart. | 245 #error Architecture was not detected as supported by Dart. |
259 #endif | 246 #endif |
260 | 247 |
261 // DART_FORCE_INLINE strongly hints to the compiler that a function should | 248 // DART_FORCE_INLINE strongly hints to the compiler that a function should |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 #endif | 296 #endif |
310 | 297 |
311 #ifdef _MSC_VER | 298 #ifdef _MSC_VER |
312 #define DART_PRETTY_FUNCTION __FUNCSIG__ | 299 #define DART_PRETTY_FUNCTION __FUNCSIG__ |
313 #elif __GNUC__ | 300 #elif __GNUC__ |
314 #define DART_PRETTY_FUNCTION __PRETTY_FUNCTION__ | 301 #define DART_PRETTY_FUNCTION __PRETTY_FUNCTION__ |
315 #else | 302 #else |
316 #error Automatic compiler detection failed. | 303 #error Automatic compiler detection failed. |
317 #endif | 304 #endif |
318 | 305 |
319 #if !defined(TARGET_ARCH_MIPS) && !defined(TARGET_ARCH_ARM) && \ | 306 #if !defined(TARGET_ARCH_ARM) && !defined(TARGET_ARCH_X64) && \ |
320 !defined(TARGET_ARCH_X64) && !defined(TARGET_ARCH_IA32) && \ | 307 !defined(TARGET_ARCH_IA32) && !defined(TARGET_ARCH_ARM64) && \ |
321 !defined(TARGET_ARCH_ARM64) && !defined(TARGET_ARCH_DBC) | 308 !defined(TARGET_ARCH_DBC) |
322 // No target architecture specified pick the one matching the host architecture. | 309 // No target architecture specified pick the one matching the host architecture. |
323 #if defined(HOST_ARCH_MIPS) | 310 #if defined(HOST_ARCH_ARM) |
324 #define TARGET_ARCH_MIPS 1 | |
325 #elif defined(HOST_ARCH_ARM) | |
326 #define TARGET_ARCH_ARM 1 | 311 #define TARGET_ARCH_ARM 1 |
327 #elif defined(HOST_ARCH_X64) | 312 #elif defined(HOST_ARCH_X64) |
328 #define TARGET_ARCH_X64 1 | 313 #define TARGET_ARCH_X64 1 |
329 #elif defined(HOST_ARCH_IA32) | 314 #elif defined(HOST_ARCH_IA32) |
330 #define TARGET_ARCH_IA32 1 | 315 #define TARGET_ARCH_IA32 1 |
331 #elif defined(HOST_ARCH_ARM64) | 316 #elif defined(HOST_ARCH_ARM64) |
332 #define TARGET_ARCH_ARM64 1 | 317 #define TARGET_ARCH_ARM64 1 |
333 #else | 318 #else |
334 #error Automatic target architecture detection failed. | 319 #error Automatic target architecture detection failed. |
335 #endif | 320 #endif |
336 #endif | 321 #endif |
337 | 322 |
338 // Verify that host and target architectures match, we cannot | 323 // Verify that host and target architectures match, we cannot |
339 // have a 64 bit Dart VM generating 32 bit code or vice-versa. | 324 // have a 64 bit Dart VM generating 32 bit code or vice-versa. |
340 #if defined(TARGET_ARCH_X64) || defined(TARGET_ARCH_ARM64) | 325 #if defined(TARGET_ARCH_X64) || defined(TARGET_ARCH_ARM64) |
341 #if !defined(ARCH_IS_64_BIT) | 326 #if !defined(ARCH_IS_64_BIT) |
342 #error Mismatched Host/Target architectures. | 327 #error Mismatched Host/Target architectures. |
343 #endif | 328 #endif |
344 #elif defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_ARM) || \ | 329 #elif defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_ARM) |
345 defined(TARGET_ARCH_MIPS) | |
346 #if !defined(ARCH_IS_32_BIT) | 330 #if !defined(ARCH_IS_32_BIT) |
347 #error Mismatched Host/Target architectures. | 331 #error Mismatched Host/Target architectures. |
348 #endif | 332 #endif |
349 #endif | 333 #endif |
350 | 334 |
351 // Determine whether we will be using the simulator. | 335 // Determine whether we will be using the simulator. |
352 #if defined(TARGET_ARCH_IA32) | 336 #if defined(TARGET_ARCH_IA32) |
353 // No simulator used. | 337 // No simulator used. |
354 #elif defined(TARGET_ARCH_X64) | 338 #elif defined(TARGET_ARCH_X64) |
355 // No simulator used. | 339 // No simulator used. |
356 #elif defined(TARGET_ARCH_ARM) | 340 #elif defined(TARGET_ARCH_ARM) |
357 #if !defined(HOST_ARCH_ARM) | 341 #if !defined(HOST_ARCH_ARM) |
358 #define USING_SIMULATOR 1 | 342 #define USING_SIMULATOR 1 |
359 #endif | 343 #endif |
360 | 344 |
361 #elif defined(TARGET_ARCH_ARM64) | 345 #elif defined(TARGET_ARCH_ARM64) |
362 #if !defined(HOST_ARCH_ARM64) | 346 #if !defined(HOST_ARCH_ARM64) |
363 #define USING_SIMULATOR 1 | 347 #define USING_SIMULATOR 1 |
364 #endif | 348 #endif |
365 | 349 |
366 #elif defined(TARGET_ARCH_MIPS) | |
367 #if !defined(HOST_ARCH_MIPS) | |
368 #define USING_SIMULATOR 1 | |
369 #endif | |
370 | |
371 #elif defined(TARGET_ARCH_DBC) | 350 #elif defined(TARGET_ARCH_DBC) |
372 #define USING_SIMULATOR 1 | 351 #define USING_SIMULATOR 1 |
373 | 352 |
374 #else | 353 #else |
375 #error Unknown architecture. | 354 #error Unknown architecture. |
376 #endif | 355 #endif |
377 | 356 |
378 // Disable background threads by default on armv5te. The relevant | 357 // Disable background threads by default on armv5te. The relevant |
379 // implementations are uniprocessors. | 358 // implementations are uniprocessors. |
380 #if !defined(TARGET_ARCH_ARM_5TE) | 359 #if !defined(TARGET_ARCH_ARM_5TE) |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
656 template <class D, class S> | 635 template <class D, class S> |
657 inline D bit_copy(const S& source) { | 636 inline D bit_copy(const S& source) { |
658 D destination; | 637 D destination; |
659 // This use of memcpy is safe: source and destination cannot overlap. | 638 // This use of memcpy is safe: source and destination cannot overlap. |
660 memcpy(&destination, reinterpret_cast<const void*>(&source), | 639 memcpy(&destination, reinterpret_cast<const void*>(&source), |
661 sizeof(destination)); | 640 sizeof(destination)); |
662 return destination; | 641 return destination; |
663 } | 642 } |
664 | 643 |
665 | 644 |
666 #if defined(HOST_ARCH_ARM) || defined(HOST_ARCH_MIPS) || \ | 645 #if defined(HOST_ARCH_ARM) || defined(HOST_ARCH_ARM64) |
667 defined(HOST_ARCH_ARM64) | |
668 // Similar to bit_copy and bit_cast, but does take the type from the argument. | 646 // Similar to bit_copy and bit_cast, but does take the type from the argument. |
669 template <typename T> | 647 template <typename T> |
670 static inline T ReadUnaligned(const T* ptr) { | 648 static inline T ReadUnaligned(const T* ptr) { |
671 T value; | 649 T value; |
672 memcpy(reinterpret_cast<void*>(&value), reinterpret_cast<const void*>(ptr), | 650 memcpy(reinterpret_cast<void*>(&value), reinterpret_cast<const void*>(ptr), |
673 sizeof(value)); | 651 sizeof(value)); |
674 return value; | 652 return value; |
675 } | 653 } |
676 | 654 |
677 | 655 |
678 // Similar to bit_copy and bit_cast, but does take the type from the argument. | 656 // Similar to bit_copy and bit_cast, but does take the type from the argument. |
679 template <typename T> | 657 template <typename T> |
680 static inline void StoreUnaligned(T* ptr, T value) { | 658 static inline void StoreUnaligned(T* ptr, T value) { |
681 memcpy(reinterpret_cast<void*>(ptr), reinterpret_cast<const void*>(&value), | 659 memcpy(reinterpret_cast<void*>(ptr), reinterpret_cast<const void*>(&value), |
682 sizeof(value)); | 660 sizeof(value)); |
683 } | 661 } |
684 #else // !(HOST_ARCH_ARM || HOST_ARCH_MIPS || HOST_ARCH_ARM64) | 662 #else // !(HOST_ARCH_ARM || HOST_ARCH_ARM64) |
685 // Similar to bit_copy and bit_cast, but does take the type from the argument. | 663 // Similar to bit_copy and bit_cast, but does take the type from the argument. |
686 template <typename T> | 664 template <typename T> |
687 static inline T ReadUnaligned(const T* ptr) { | 665 static inline T ReadUnaligned(const T* ptr) { |
688 return *ptr; | 666 return *ptr; |
689 } | 667 } |
690 | 668 |
691 | 669 |
692 // Similar to bit_copy and bit_cast, but does take the type from the argument. | 670 // Similar to bit_copy and bit_cast, but does take the type from the argument. |
693 template <typename T> | 671 template <typename T> |
694 static inline void StoreUnaligned(T* ptr, T value) { | 672 static inline void StoreUnaligned(T* ptr, T value) { |
695 *ptr = value; | 673 *ptr = value; |
696 } | 674 } |
697 #endif // !(HOST_ARCH_ARM || HOST_ARCH_MIPS || HOST_ARCH_ARM64) | 675 #endif // !(HOST_ARCH_ARM || HOST_ARCH_ARM64) |
698 | 676 |
699 | 677 |
700 // On Windows the reentrent version of strtok is called | 678 // On Windows the reentrent version of strtok is called |
701 // strtok_s. Unify on the posix name strtok_r. | 679 // strtok_s. Unify on the posix name strtok_r. |
702 #if defined(HOST_OS_WINDOWS) | 680 #if defined(HOST_OS_WINDOWS) |
703 #define snprintf _snprintf | 681 #define snprintf _snprintf |
704 #define strtok_r strtok_s | 682 #define strtok_r strtok_s |
705 #endif | 683 #endif |
706 | 684 |
707 #if !defined(HOST_OS_WINDOWS) | 685 #if !defined(HOST_OS_WINDOWS) |
(...skipping 29 matching lines...) Expand all Loading... |
737 // tag in the ICData and check it when recreating the flow graph in | 715 // tag in the ICData and check it when recreating the flow graph in |
738 // optimizing compiler. Enable it for other modes (product, release) if needed | 716 // optimizing compiler. Enable it for other modes (product, release) if needed |
739 // for debugging. | 717 // for debugging. |
740 #if defined(DEBUG) | 718 #if defined(DEBUG) |
741 #define TAG_IC_DATA | 719 #define TAG_IC_DATA |
742 #endif | 720 #endif |
743 | 721 |
744 } // namespace dart | 722 } // namespace dart |
745 | 723 |
746 #endif // RUNTIME_PLATFORM_GLOBALS_H_ | 724 #endif // RUNTIME_PLATFORM_GLOBALS_H_ |
OLD | NEW |