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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 double OS::nan_value() { | 87 double OS::nan_value() { |
88 return NAN; | 88 return NAN; |
89 } | 89 } |
90 | 90 |
91 | 91 |
92 bool OS::fgrep_vfp(const char* file_name, const char* string) { | 92 bool OS::ArmCpuHasFeature(OS::CpuFeature feature) { |
| 93 const char* search_string = NULL; |
| 94 const char* file_name = "/proc/cpuinfo"; |
93 // Simple detection of VFP at runtime for Linux. | 95 // Simple detection of VFP at runtime for Linux. |
94 // It is based on /proc/cpuinfo, which reveals hardware configuration | 96 // It is based on /proc/cpuinfo, which reveals hardware configuration |
95 // to user-space applications. According to ARM (mid 2009), no similar | 97 // to user-space applications. According to ARM (mid 2009), no similar |
96 // facility is universally available on the ARM architectures, | 98 // facility is universally available on the ARM architectures, |
97 // so it's up to individual OSes to provide such. | 99 // so it's up to individual OSes to provide such. |
98 // | 100 // |
99 // This is written as a straight shot one pass parser | 101 // This is written as a straight shot one pass parser |
100 // and not using STL string and ifstream because, | 102 // and not using STL string and ifstream because, |
101 // on Linux, it's reading from a (non-mmap-able) | 103 // on Linux, it's reading from a (non-mmap-able) |
102 // character special device. | 104 // character special device. |
| 105 switch (feature) { |
| 106 case VFP: |
| 107 search_string = "vfp"; |
| 108 break; |
| 109 default: |
| 110 UNREACHABLE(); |
| 111 } |
103 | 112 |
104 FILE* f = NULL; | 113 FILE* f = NULL; |
| 114 const char* what = search_string; |
105 | 115 |
106 if (NULL == (f = fopen(file_name, "r"))) | 116 if (NULL == (f = fopen(file_name, "r"))) |
107 return false; | 117 return false; |
108 | 118 |
109 const char* what = string; | |
110 int k; | 119 int k; |
111 while (EOF != (k = fgetc(f))) { | 120 while (EOF != (k = fgetc(f))) { |
112 if (k == *what) { | 121 if (k == *what) { |
113 ++what; | 122 ++what; |
114 while ((*what != '\0') && (*what == fgetc(f))) { | 123 while ((*what != '\0') && (*what == fgetc(f))) { |
115 ++what; | 124 ++what; |
116 } | 125 } |
117 if (*what == '\0') { | 126 if (*what == '\0') { |
118 fclose(f); | 127 fclose(f); |
119 return true; | 128 return true; |
120 } else { | 129 } else { |
121 what = string; | 130 what = search_string; |
122 } | 131 } |
123 } | 132 } |
124 } | 133 } |
125 fclose(f); | 134 fclose(f); |
126 | 135 |
127 // Did not find string in the file file_name. | 136 // Did not find string in the proc file. |
128 return false; | 137 return false; |
129 } | 138 } |
130 | 139 |
131 | 140 |
132 int OS::ActivationFrameAlignment() { | 141 int OS::ActivationFrameAlignment() { |
133 #ifdef V8_TARGET_ARCH_ARM | 142 #ifdef V8_TARGET_ARCH_ARM |
134 // On EABI ARM targets this is required for fp correctness in the | 143 // On EABI ARM targets this is required for fp correctness in the |
135 // runtime system. | 144 // runtime system. |
136 return 8; | 145 return 8; |
137 #else | 146 #else |
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
782 | 791 |
783 // This sampler is no longer the active sampler. | 792 // This sampler is no longer the active sampler. |
784 active_sampler_ = NULL; | 793 active_sampler_ = NULL; |
785 active_ = false; | 794 active_ = false; |
786 } | 795 } |
787 | 796 |
788 | 797 |
789 #endif // ENABLE_LOGGING_AND_PROFILING | 798 #endif // ENABLE_LOGGING_AND_PROFILING |
790 | 799 |
791 } } // namespace v8::internal | 800 } } // namespace v8::internal |
OLD | NEW |