Chromium Code Reviews| Index: runtime/vm/os.h |
| diff --git a/runtime/vm/os.h b/runtime/vm/os.h |
| index e33b274f7122fd2ec583676464fc8dcba59b8368..d7d293acafc92b66b95574712fdd53dd3e5bda75 100644 |
| --- a/runtime/vm/os.h |
| +++ b/runtime/vm/os.h |
| @@ -40,6 +40,22 @@ class OS { |
| // from midnight January 1, 1970 UTC. |
| static int64_t GetCurrentTimeMicros(); |
| + // Returns an aligned array of type T with n entries. |
| + // Alignment must be >= 16 and a power of two. |
| + template<typename T> |
| + static T* AllocateAlignedArray(intptr_t n, intptr_t alignment) { |
| + T* result = reinterpret_cast<T*>(OS::AlignedAllocate(n * sizeof(*result), |
| + alignment)); |
| + return result; |
| + } |
|
siva
2012/11/30 22:15:53
This function here looks pretty ugly and is not st
cshapiro
2012/11/30 22:18:11
It was my idea to stuff this in here. I would hav
siva
2012/11/30 22:33:21
The only use of this currently seems to be in byte
Cutch
2012/11/30 22:34:27
This is how the code was originally structured. Th
cshapiro
2012/11/30 22:35:53
We also have code that uses new and delete which h
|
| + |
| + // Returns an aligned pointer in the C heap with room for size bytes. |
| + // Alignment must be >= 16 and a power of two. |
| + static void* AlignedAllocate(intptr_t size, intptr_t alignment); |
| + |
| + // Frees a pointer returned from AlignedAllocate. |
| + static void AlignedFree(void* ptr); |
| + |
| // Returns the activation frame alignment constraint or zero if |
| // the platform doesn't care. Guaranteed to be a power of two. |
| static word ActivationFrameAlignment(); |