| 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 #include "vm/globals.h" | 5 #include "vm/globals.h" |
| 6 #if defined(TARGET_OS_MACOS) | 6 #if defined(TARGET_OS_MACOS) |
| 7 | 7 |
| 8 #include "vm/os.h" | 8 #include "vm/os.h" |
| 9 | 9 |
| 10 #include <errno.h> // NOLINT | 10 #include <errno.h> // NOLINT |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 ASSERT(r == KERN_SUCCESS); | 159 ASSERT(r == KERN_SUCCESS); |
| 160 int64_t thread_cpu_micros = | 160 int64_t thread_cpu_micros = |
| 161 (info->system_time.seconds + info->user_time.seconds); | 161 (info->system_time.seconds + info->user_time.seconds); |
| 162 thread_cpu_micros *= kMicrosecondsPerSecond; | 162 thread_cpu_micros *= kMicrosecondsPerSecond; |
| 163 thread_cpu_micros += info->user_time.microseconds; | 163 thread_cpu_micros += info->user_time.microseconds; |
| 164 thread_cpu_micros += info->system_time.microseconds; | 164 thread_cpu_micros += info->system_time.microseconds; |
| 165 return thread_cpu_micros; | 165 return thread_cpu_micros; |
| 166 } | 166 } |
| 167 | 167 |
| 168 | 168 |
| 169 void* OS::AlignedAllocate(intptr_t size, intptr_t alignment) { | |
| 170 const int kMinimumAlignment = 16; | |
| 171 ASSERT(Utils::IsPowerOfTwo(alignment)); | |
| 172 ASSERT(alignment >= kMinimumAlignment); | |
| 173 // Temporary workaround until xcode is upgraded. | |
| 174 // Mac guarantees malloc returns a 16 byte aligned memory chunk. | |
| 175 // Currently we only allocate with 16-bye alignment. | |
| 176 ASSERT(alignment == 16); | |
| 177 // TODO(johnmccutchan): Remove hack and switch to posix_memalign. | |
| 178 return malloc(size); | |
| 179 } | |
| 180 | |
| 181 | |
| 182 void OS::AlignedFree(void* ptr) { | |
| 183 free(ptr); | |
| 184 } | |
| 185 | |
| 186 | |
| 187 intptr_t OS::ActivationFrameAlignment() { | 169 intptr_t OS::ActivationFrameAlignment() { |
| 188 #if TARGET_OS_IOS | 170 #if TARGET_OS_IOS |
| 189 #if TARGET_ARCH_ARM | 171 #if TARGET_ARCH_ARM |
| 190 // Even if we generate code that maintains a stronger alignment, we cannot | 172 // Even if we generate code that maintains a stronger alignment, we cannot |
| 191 // assert the stronger stack alignment because C++ code will not maintain it. | 173 // assert the stronger stack alignment because C++ code will not maintain it. |
| 192 return 8; | 174 return 8; |
| 193 #elif TARGET_ARCH_ARM64 | 175 #elif TARGET_ARCH_ARM64 |
| 194 return 16; | 176 return 16; |
| 195 #elif TARGET_ARCH_IA32 | 177 #elif TARGET_ARCH_IA32 |
| 196 return 16; // iOS simulator | 178 return 16; // iOS simulator |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 } | 438 } |
| 457 | 439 |
| 458 | 440 |
| 459 void OS::Exit(int code) { | 441 void OS::Exit(int code) { |
| 460 exit(code); | 442 exit(code); |
| 461 } | 443 } |
| 462 | 444 |
| 463 } // namespace dart | 445 } // namespace dart |
| 464 | 446 |
| 465 #endif // defined(TARGET_OS_MACOS) | 447 #endif // defined(TARGET_OS_MACOS) |
| OLD | NEW |