OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 #include "vm/globals.h" | 5 #include "vm/globals.h" |
6 #if defined(TARGET_OS_FUCHSIA) | 6 #if defined(TARGET_OS_FUCHSIA) |
7 | 7 |
8 #include "vm/os.h" | 8 #include "vm/os.h" |
9 | 9 |
10 #include <errno.h> | 10 #include <errno.h> |
11 #include <magenta/syscalls.h> | 11 #include <magenta/syscalls.h> |
12 #include <magenta/types.h> | 12 #include <magenta/types.h> |
13 | 13 |
14 #include "platform/assert.h" | 14 #include "platform/assert.h" |
15 #include "vm/zone.h" | 15 #include "vm/zone.h" |
16 | 16 |
17 namespace dart { | 17 namespace dart { |
18 | 18 |
19 #ifndef PRODUCT | 19 #ifndef PRODUCT |
20 | 20 |
21 DEFINE_FLAG(bool, generate_perf_events_symbols, false, | 21 DEFINE_FLAG(bool, |
22 "Generate events symbols for profiling with perf"); | 22 generate_perf_events_symbols, |
| 23 false, |
| 24 "Generate events symbols for profiling with perf"); |
23 | 25 |
24 #endif // !PRODUCT | 26 #endif // !PRODUCT |
25 | 27 |
26 const char* OS::Name() { | 28 const char* OS::Name() { |
27 return "fuchsia"; | 29 return "fuchsia"; |
28 } | 30 } |
29 | 31 |
30 | 32 |
31 intptr_t OS::ProcessId() { | 33 intptr_t OS::ProcessId() { |
32 return static_cast<intptr_t>(getpid()); | 34 return static_cast<intptr_t>(getpid()); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 | 100 |
99 int64_t OS::GetCurrentThreadCPUMicros() { | 101 int64_t OS::GetCurrentThreadCPUMicros() { |
100 UNIMPLEMENTED(); | 102 UNIMPLEMENTED(); |
101 return 0; | 103 return 0; |
102 } | 104 } |
103 | 105 |
104 | 106 |
105 // TODO(5411554): May need to hoist these architecture dependent code | 107 // TODO(5411554): May need to hoist these architecture dependent code |
106 // into a architecture specific file e.g: os_ia32_fuchsia.cc | 108 // into a architecture specific file e.g: os_ia32_fuchsia.cc |
107 intptr_t OS::ActivationFrameAlignment() { | 109 intptr_t OS::ActivationFrameAlignment() { |
108 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) || \ | 110 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) || \ |
109 defined(TARGET_ARCH_ARM64) | 111 defined(TARGET_ARCH_ARM64) |
110 const int kMinimumAlignment = 16; | 112 const int kMinimumAlignment = 16; |
111 #elif defined(TARGET_ARCH_ARM) || defined(TARGET_ARCH_DBC) | 113 #elif defined(TARGET_ARCH_ARM) || defined(TARGET_ARCH_DBC) |
112 const int kMinimumAlignment = 8; | 114 const int kMinimumAlignment = 8; |
113 #else | 115 #else |
114 #error Unsupported architecture. | 116 #error Unsupported architecture. |
115 #endif | 117 #endif |
116 intptr_t alignment = kMinimumAlignment; | 118 intptr_t alignment = kMinimumAlignment; |
117 // TODO(5411554): Allow overriding default stack alignment for | 119 // TODO(5411554): Allow overriding default stack alignment for |
118 // testing purposes. | 120 // testing purposes. |
119 // Flags::DebugIsInt("stackalign", &alignment); | 121 // Flags::DebugIsInt("stackalign", &alignment); |
120 ASSERT(Utils::IsPowerOfTwo(alignment)); | 122 ASSERT(Utils::IsPowerOfTwo(alignment)); |
121 ASSERT(alignment >= kMinimumAlignment); | 123 ASSERT(alignment >= kMinimumAlignment); |
122 return alignment; | 124 return alignment; |
123 } | 125 } |
124 | 126 |
125 | 127 |
126 intptr_t OS::PreferredCodeAlignment() { | 128 intptr_t OS::PreferredCodeAlignment() { |
127 #if defined(TARGET_ARCH_IA32) || \ | 129 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) || \ |
128 defined(TARGET_ARCH_X64) || \ | 130 defined(TARGET_ARCH_ARM64) || defined(TARGET_ARCH_DBC) |
129 defined(TARGET_ARCH_ARM64) || \ | |
130 defined(TARGET_ARCH_DBC) | |
131 const int kMinimumAlignment = 32; | 131 const int kMinimumAlignment = 32; |
132 #elif defined(TARGET_ARCH_ARM) || defined(TARGET_ARCH_MIPS) | 132 #elif defined(TARGET_ARCH_ARM) || defined(TARGET_ARCH_MIPS) |
133 const int kMinimumAlignment = 16; | 133 const int kMinimumAlignment = 16; |
134 #else | 134 #else |
135 #error Unsupported architecture. | 135 #error Unsupported architecture. |
136 #endif | 136 #endif |
137 intptr_t alignment = kMinimumAlignment; | 137 intptr_t alignment = kMinimumAlignment; |
138 // TODO(5411554): Allow overriding default code alignment for | 138 // TODO(5411554): Allow overriding default code alignment for |
139 // testing purposes. | 139 // testing purposes. |
140 // Flags::DebugIsInt("codealign", &alignment); | 140 // Flags::DebugIsInt("codealign", &alignment); |
(...skipping 15 matching lines...) Expand all Loading... |
156 } | 156 } |
157 | 157 |
158 | 158 |
159 uintptr_t OS::MaxRSS() { | 159 uintptr_t OS::MaxRSS() { |
160 UNIMPLEMENTED(); | 160 UNIMPLEMENTED(); |
161 return 0; | 161 return 0; |
162 } | 162 } |
163 | 163 |
164 | 164 |
165 void OS::Sleep(int64_t millis) { | 165 void OS::Sleep(int64_t millis) { |
166 mx_nanosleep( | 166 mx_nanosleep(millis * kMicrosecondsPerMillisecond * |
167 millis * kMicrosecondsPerMillisecond * kNanosecondsPerMicrosecond); | 167 kNanosecondsPerMicrosecond); |
168 } | 168 } |
169 | 169 |
170 | 170 |
171 void OS::SleepMicros(int64_t micros) { | 171 void OS::SleepMicros(int64_t micros) { |
172 mx_nanosleep( | 172 mx_nanosleep(micros * kNanosecondsPerMicrosecond); |
173 micros * kNanosecondsPerMicrosecond); | |
174 } | 173 } |
175 | 174 |
176 | 175 |
177 void OS::DebugBreak() { | 176 void OS::DebugBreak() { |
178 UNIMPLEMENTED(); | 177 UNIMPLEMENTED(); |
179 } | 178 } |
180 | 179 |
181 | 180 |
182 char* OS::StrNDup(const char* s, intptr_t n) { | 181 char* OS::StrNDup(const char* s, intptr_t n) { |
183 return strndup(s, n); | 182 return strndup(s, n); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 | 254 |
256 | 255 |
257 bool OS::StringToInt64(const char* str, int64_t* value) { | 256 bool OS::StringToInt64(const char* str, int64_t* value) { |
258 ASSERT(str != NULL && strlen(str) > 0 && value != NULL); | 257 ASSERT(str != NULL && strlen(str) > 0 && value != NULL); |
259 int32_t base = 10; | 258 int32_t base = 10; |
260 char* endptr; | 259 char* endptr; |
261 int i = 0; | 260 int i = 0; |
262 if (str[0] == '-') { | 261 if (str[0] == '-') { |
263 i = 1; | 262 i = 1; |
264 } | 263 } |
265 if ((str[i] == '0') && | 264 if ((str[i] == '0') && (str[i + 1] == 'x' || str[i + 1] == 'X') && |
266 (str[i + 1] == 'x' || str[i + 1] == 'X') && | |
267 (str[i + 2] != '\0')) { | 265 (str[i + 2] != '\0')) { |
268 base = 16; | 266 base = 16; |
269 } | 267 } |
270 errno = 0; | 268 errno = 0; |
271 *value = strtoll(str, &endptr, base); | 269 *value = strtoll(str, &endptr, base); |
272 return ((errno == 0) && (endptr != str) && (*endptr == 0)); | 270 return ((errno == 0) && (endptr != str) && (*endptr == 0)); |
273 } | 271 } |
274 | 272 |
275 | 273 |
276 void OS::RegisterCodeObservers() { | 274 void OS::RegisterCodeObservers() { |
(...skipping 16 matching lines...) Expand all Loading... |
293 void OS::InitOnce() { | 291 void OS::InitOnce() { |
294 // TODO(5411554): For now we check that initonce is called only once, | 292 // TODO(5411554): For now we check that initonce is called only once, |
295 // Once there is more formal mechanism to call InitOnce we can move | 293 // Once there is more formal mechanism to call InitOnce we can move |
296 // this check there. | 294 // this check there. |
297 static bool init_once_called = false; | 295 static bool init_once_called = false; |
298 ASSERT(init_once_called == false); | 296 ASSERT(init_once_called == false); |
299 init_once_called = true; | 297 init_once_called = true; |
300 } | 298 } |
301 | 299 |
302 | 300 |
303 void OS::Shutdown() { | 301 void OS::Shutdown() {} |
304 } | |
305 | 302 |
306 | 303 |
307 void OS::Abort() { | 304 void OS::Abort() { |
308 abort(); | 305 abort(); |
309 } | 306 } |
310 | 307 |
311 | 308 |
312 void OS::Exit(int code) { | 309 void OS::Exit(int code) { |
313 UNIMPLEMENTED(); | 310 UNIMPLEMENTED(); |
314 } | 311 } |
315 | 312 |
316 } // namespace dart | 313 } // namespace dart |
317 | 314 |
318 #endif // defined(TARGET_OS_FUCHSIA) | 315 #endif // defined(TARGET_OS_FUCHSIA) |
OLD | NEW |