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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 // Seed the random number generator. | 77 // Seed the random number generator. |
78 // Convert the current time to a 64-bit integer first, before converting it | 78 // Convert the current time to a 64-bit integer first, before converting it |
79 // to an unsigned. Going directly can cause an overflow and the seed to be | 79 // to an unsigned. Going directly can cause an overflow and the seed to be |
80 // set to all ones. The seed will be identical for different instances that | 80 // set to all ones. The seed will be identical for different instances that |
81 // call this setup code within the same millisecond. | 81 // call this setup code within the same millisecond. |
82 uint64_t seed = static_cast<uint64_t>(TimeCurrentMillis()); | 82 uint64_t seed = static_cast<uint64_t>(TimeCurrentMillis()); |
83 srandom(static_cast<unsigned int>(seed)); | 83 srandom(static_cast<unsigned int>(seed)); |
84 } | 84 } |
85 | 85 |
86 | 86 |
| 87 uint64_t OS::CpuFeaturesImpliedByPlatform() { |
| 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 |
| 90 // have VFP3 instructions. If gcc can assume it then so can we. |
| 91 return 1u << VFP3; |
| 92 #else |
| 93 return 0; // Linux runs on anything. |
| 94 #endif |
| 95 } |
| 96 |
| 97 |
87 double OS::nan_value() { | 98 double OS::nan_value() { |
88 return NAN; | 99 return NAN; |
89 } | 100 } |
90 | 101 |
91 | 102 |
92 bool OS::ArmCpuHasFeature(OS::CpuFeature feature) { | 103 #ifdef __arm__ |
| 104 bool OS::ArmCpuHasFeature(CpuFeature feature) { |
93 const char* search_string = NULL; | 105 const char* search_string = NULL; |
94 const char* file_name = "/proc/cpuinfo"; | 106 const char* file_name = "/proc/cpuinfo"; |
95 // Simple detection of VFP at runtime for Linux. | 107 // Simple detection of VFP at runtime for Linux. |
96 // It is based on /proc/cpuinfo, which reveals hardware configuration | 108 // It is based on /proc/cpuinfo, which reveals hardware configuration |
97 // to user-space applications. According to ARM (mid 2009), no similar | 109 // to user-space applications. According to ARM (mid 2009), no similar |
98 // facility is universally available on the ARM architectures, | 110 // facility is universally available on the ARM architectures, |
99 // so it's up to individual OSes to provide such. | 111 // so it's up to individual OSes to provide such. |
100 // | 112 // |
101 // This is written as a straight shot one pass parser | 113 // This is written as a straight shot one pass parser |
102 // and not using STL string and ifstream because, | 114 // and not using STL string and ifstream because, |
103 // on Linux, it's reading from a (non-mmap-able) | 115 // on Linux, it's reading from a (non-mmap-able) |
104 // character special device. | 116 // character special device. |
105 switch (feature) { | 117 switch (feature) { |
106 case VFP: | 118 case VFP3: |
107 search_string = "vfp"; | 119 search_string = "vfp"; |
108 break; | 120 break; |
109 default: | 121 default: |
110 UNREACHABLE(); | 122 UNREACHABLE(); |
111 } | 123 } |
112 | 124 |
113 FILE* f = NULL; | 125 FILE* f = NULL; |
114 const char* what = search_string; | 126 const char* what = search_string; |
115 | 127 |
116 if (NULL == (f = fopen(file_name, "r"))) | 128 if (NULL == (f = fopen(file_name, "r"))) |
(...skipping 12 matching lines...) Expand all Loading... |
129 } else { | 141 } else { |
130 what = search_string; | 142 what = search_string; |
131 } | 143 } |
132 } | 144 } |
133 } | 145 } |
134 fclose(f); | 146 fclose(f); |
135 | 147 |
136 // Did not find string in the proc file. | 148 // Did not find string in the proc file. |
137 return false; | 149 return false; |
138 } | 150 } |
| 151 #endif // def __arm__ |
139 | 152 |
140 | 153 |
141 int OS::ActivationFrameAlignment() { | 154 int OS::ActivationFrameAlignment() { |
142 #ifdef V8_TARGET_ARCH_ARM | 155 #ifdef V8_TARGET_ARCH_ARM |
143 // On EABI ARM targets this is required for fp correctness in the | 156 // On EABI ARM targets this is required for fp correctness in the |
144 // runtime system. | 157 // runtime system. |
145 return 8; | 158 return 8; |
146 #else | 159 #else |
147 // With gcc 4.4 the tree vectorization optimiser can generate code | 160 // With gcc 4.4 the tree vectorization optimiser can generate code |
148 // that requires 16 byte alignment such as movdqa on x86. | 161 // that requires 16 byte alignment such as movdqa on x86. |
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
791 | 804 |
792 // This sampler is no longer the active sampler. | 805 // This sampler is no longer the active sampler. |
793 active_sampler_ = NULL; | 806 active_sampler_ = NULL; |
794 active_ = false; | 807 active_ = false; |
795 } | 808 } |
796 | 809 |
797 | 810 |
798 #endif // ENABLE_LOGGING_AND_PROFILING | 811 #endif // ENABLE_LOGGING_AND_PROFILING |
799 | 812 |
800 } } // namespace v8::internal | 813 } } // namespace v8::internal |
OLD | NEW |