OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 #ifndef VM_OS_H_ | 5 #ifndef VM_OS_H_ |
6 #define VM_OS_H_ | 6 #define VM_OS_H_ |
7 | 7 |
8 #include "vm/globals.h" | 8 #include "vm/globals.h" |
9 | 9 |
10 // Forward declarations. | 10 // Forward declarations. |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 // Returns the frequency of the monotonic clock. | 57 // Returns the frequency of the monotonic clock. |
58 static int64_t GetCurrentMonotonicFrequency(); | 58 static int64_t GetCurrentMonotonicFrequency(); |
59 | 59 |
60 // Returns the value of current thread's CPU usage clock in microseconds. | 60 // Returns the value of current thread's CPU usage clock in microseconds. |
61 // NOTE: This clock will return different values depending on the calling | 61 // NOTE: This clock will return different values depending on the calling |
62 // thread. It is only expected to increase in value as the thread uses | 62 // thread. It is only expected to increase in value as the thread uses |
63 // CPU time. | 63 // CPU time. |
64 // NOTE: This function will return -1 on OSs that are not supported. | 64 // NOTE: This function will return -1 on OSs that are not supported. |
65 static int64_t GetCurrentThreadCPUMicros(); | 65 static int64_t GetCurrentThreadCPUMicros(); |
66 | 66 |
67 // Returns a cleared aligned array of type T with n entries. | |
68 // Alignment must be >= 16 and a power of two. | |
69 template<typename T> | |
70 static T* AllocateAlignedArray(intptr_t n, intptr_t alignment) { | |
71 T* result = reinterpret_cast<T*>(OS::AlignedAllocate(n * sizeof(*result), | |
72 alignment)); | |
73 memset(result, 0, n * sizeof(*result)); | |
74 return result; | |
75 } | |
76 | |
77 // Returns an aligned pointer in the C heap with room for size bytes. | |
78 // Alignment must be >= 16 and a power of two. | |
79 static void* AlignedAllocate(intptr_t size, intptr_t alignment); | |
80 | |
81 // Frees a pointer returned from AlignedAllocate. | |
82 static void AlignedFree(void* ptr); | |
83 | |
84 // Returns the activation frame alignment constraint or one if | 67 // Returns the activation frame alignment constraint or one if |
85 // the platform doesn't care. Guaranteed to be a power of two. | 68 // the platform doesn't care. Guaranteed to be a power of two. |
86 static intptr_t ActivationFrameAlignment(); | 69 static intptr_t ActivationFrameAlignment(); |
87 | 70 |
88 // This constant is guaranteed to be greater or equal to the | 71 // This constant is guaranteed to be greater or equal to the |
89 // preferred code alignment on all platforms. | 72 // preferred code alignment on all platforms. |
90 static const int kMaxPreferredCodeAlignment = 32; | 73 static const int kMaxPreferredCodeAlignment = 32; |
91 | 74 |
92 // Returns the preferred code alignment or zero if | 75 // Returns the preferred code alignment or zero if |
93 // the platform doesn't care. Guaranteed to be a power of two. | 76 // the platform doesn't care. Guaranteed to be a power of two. |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 static void Shutdown(); | 150 static void Shutdown(); |
168 | 151 |
169 static void Abort(); | 152 static void Abort(); |
170 | 153 |
171 static void Exit(int code); | 154 static void Exit(int code); |
172 }; | 155 }; |
173 | 156 |
174 } // namespace dart | 157 } // namespace dart |
175 | 158 |
176 #endif // VM_OS_H_ | 159 #endif // VM_OS_H_ |
OLD | NEW |