OLD | NEW |
1 // Copyright (c) 1994-2006 Sun Microsystems Inc. | 1 // Copyright (c) 1994-2006 Sun Microsystems Inc. |
2 // All Rights Reserved. | 2 // All Rights Reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions | 5 // modification, are permitted provided that the following conditions |
6 // are met: | 6 // are met: |
7 // | 7 // |
8 // - Redistributions of source code must retain the above copyright notice, | 8 // - Redistributions of source code must retain the above copyright notice, |
9 // this list of conditions and the following disclaimer. | 9 // this list of conditions and the following disclaimer. |
10 // | 10 // |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 namespace v8 { | 44 namespace v8 { |
45 namespace internal { | 45 namespace internal { |
46 | 46 |
47 #ifdef DEBUG | 47 #ifdef DEBUG |
48 bool CpuFeatures::initialized_ = false; | 48 bool CpuFeatures::initialized_ = false; |
49 #endif | 49 #endif |
50 unsigned CpuFeatures::supported_ = 0; | 50 unsigned CpuFeatures::supported_ = 0; |
51 unsigned CpuFeatures::found_by_runtime_probing_ = 0; | 51 unsigned CpuFeatures::found_by_runtime_probing_ = 0; |
52 | 52 |
53 | 53 |
54 #ifdef __arm__ | 54 // Get the CPU features enabled by the build. For cross compilation the |
| 55 // preprocessor symbols CAN_USE_ARMV7_INSTRUCTIONS and CAN_USE_VFP_INSTRUCTIONS |
| 56 // can be defined to enable ARMv7 and VFPv3 instructions when building the |
| 57 // snapshot. |
55 static uint64_t CpuFeaturesImpliedByCompiler() { | 58 static uint64_t CpuFeaturesImpliedByCompiler() { |
56 uint64_t answer = 0; | 59 uint64_t answer = 0; |
57 #ifdef CAN_USE_ARMV7_INSTRUCTIONS | 60 #ifdef CAN_USE_ARMV7_INSTRUCTIONS |
58 answer |= 1u << ARMv7; | 61 answer |= 1u << ARMv7; |
59 #endif // def CAN_USE_ARMV7_INSTRUCTIONS | 62 #endif // def CAN_USE_ARMV7_INSTRUCTIONS |
| 63 #ifdef CAN_USE_VFP_INSTRUCTIONS |
| 64 answer |= 1u << VFP3 | 1u << ARMv7; |
| 65 #endif // def CAN_USE_VFP_INSTRUCTIONS |
| 66 |
| 67 #ifdef __arm__ |
60 // If the compiler is allowed to use VFP then we can use VFP too in our code | 68 // If the compiler is allowed to use VFP then we can use VFP too in our code |
61 // generation even when generating snapshots. This won't work for cross | 69 // generation even when generating snapshots. This won't work for cross |
62 // compilation. VFPv3 implies ARMv7, see ARM DDI 0406B, page A1-6. | 70 // compilation. VFPv3 implies ARMv7, see ARM DDI 0406B, page A1-6. |
63 #if defined(__VFP_FP__) && !defined(__SOFTFP__) | 71 #if defined(__VFP_FP__) && !defined(__SOFTFP__) |
64 answer |= 1u << VFP3 | 1u << ARMv7; | 72 answer |= 1u << VFP3 | 1u << ARMv7; |
65 #endif // defined(__VFP_FP__) && !defined(__SOFTFP__) | 73 #endif // defined(__VFP_FP__) && !defined(__SOFTFP__) |
66 #ifdef CAN_USE_VFP_INSTRUCTIONS | 74 #endif // def __arm__ |
67 answer |= 1u << VFP3 | 1u << ARMv7; | 75 |
68 #endif // def CAN_USE_VFP_INSTRUCTIONS | |
69 return answer; | 76 return answer; |
70 } | 77 } |
71 #endif // def __arm__ | |
72 | 78 |
73 | 79 |
74 void CpuFeatures::Probe() { | 80 void CpuFeatures::Probe() { |
75 ASSERT(!initialized_); | 81 ASSERT(!initialized_); |
76 #ifdef DEBUG | 82 #ifdef DEBUG |
77 initialized_ = true; | 83 initialized_ = true; |
78 #endif | 84 #endif |
| 85 |
| 86 // Get the features implied by the OS and the compiler settings. This is the |
| 87 // minimal set of features which is also alowed for generated code in the |
| 88 // snapshot. |
| 89 supported_ |= OS::CpuFeaturesImpliedByPlatform(); |
| 90 supported_ |= CpuFeaturesImpliedByCompiler(); |
| 91 |
| 92 if (Serializer::enabled()) { |
| 93 // No probing for features if we might serialize (generate snapshot). |
| 94 return; |
| 95 } |
| 96 |
79 #ifndef __arm__ | 97 #ifndef __arm__ |
80 // For the simulator=arm build, use VFP when FLAG_enable_vfp3 is | 98 // For the simulator=arm build, use VFP when FLAG_enable_vfp3 is |
81 // enabled. VFPv3 implies ARMv7, see ARM DDI 0406B, page A1-6. | 99 // enabled. VFPv3 implies ARMv7, see ARM DDI 0406B, page A1-6. |
82 if (FLAG_enable_vfp3) { | 100 if (FLAG_enable_vfp3) { |
83 supported_ |= 1u << VFP3 | 1u << ARMv7; | 101 supported_ |= 1u << VFP3 | 1u << ARMv7; |
84 } | 102 } |
85 // For the simulator=arm build, use ARMv7 when FLAG_enable_armv7 is enabled | 103 // For the simulator=arm build, use ARMv7 when FLAG_enable_armv7 is enabled |
86 if (FLAG_enable_armv7) { | 104 if (FLAG_enable_armv7) { |
87 supported_ |= 1u << ARMv7; | 105 supported_ |= 1u << ARMv7; |
88 } | 106 } |
89 #else // def __arm__ | 107 #else // def __arm__ |
90 if (Serializer::enabled()) { | 108 // Probe for additional features not already known to be available. |
91 supported_ |= OS::CpuFeaturesImpliedByPlatform(); | 109 if (!IsSupported(VFP3) && OS::ArmCpuHasFeature(VFP3)) { |
92 supported_ |= CpuFeaturesImpliedByCompiler(); | |
93 return; // No features if we might serialize. | |
94 } | |
95 | |
96 if (OS::ArmCpuHasFeature(VFP3)) { | |
97 // This implementation also sets the VFP flags if runtime | 110 // This implementation also sets the VFP flags if runtime |
98 // detection of VFP returns true. VFPv3 implies ARMv7, see ARM DDI | 111 // detection of VFP returns true. VFPv3 implies ARMv7, see ARM DDI |
99 // 0406B, page A1-6. | 112 // 0406B, page A1-6. |
100 supported_ |= 1u << VFP3 | 1u << ARMv7; | 113 supported_ |= 1u << VFP3 | 1u << ARMv7; |
101 found_by_runtime_probing_ |= 1u << VFP3 | 1u << ARMv7; | 114 found_by_runtime_probing_ |= 1u << VFP3 | 1u << ARMv7; |
102 } | 115 } |
103 | 116 |
104 if (OS::ArmCpuHasFeature(ARMv7)) { | 117 if (!IsSupported(ARMv7) && OS::ArmCpuHasFeature(ARMv7)) { |
105 supported_ |= 1u << ARMv7; | 118 supported_ |= 1u << ARMv7; |
106 found_by_runtime_probing_ |= 1u << ARMv7; | 119 found_by_runtime_probing_ |= 1u << ARMv7; |
107 } | 120 } |
108 #endif | 121 #endif |
109 } | 122 } |
110 | 123 |
111 | 124 |
112 // ----------------------------------------------------------------------------- | 125 // ----------------------------------------------------------------------------- |
113 // Implementation of RelocInfo | 126 // Implementation of RelocInfo |
114 | 127 |
(...skipping 2724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2839 | 2852 |
2840 // Since a constant pool was just emitted, move the check offset forward by | 2853 // Since a constant pool was just emitted, move the check offset forward by |
2841 // the standard interval. | 2854 // the standard interval. |
2842 next_buffer_check_ = pc_offset() + kCheckConstInterval; | 2855 next_buffer_check_ = pc_offset() + kCheckConstInterval; |
2843 } | 2856 } |
2844 | 2857 |
2845 | 2858 |
2846 } } // namespace v8::internal | 2859 } } // namespace v8::internal |
2847 | 2860 |
2848 #endif // V8_TARGET_ARCH_ARM | 2861 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |