Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Unified Diff: src/allocation.cc

Issue 131393002: Fixed alignment issues of ProfilerEventsProcessor. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Simplified. Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/allocation.h ('k') | src/cpu-profiler.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/allocation.cc
diff --git a/src/allocation.cc b/src/allocation.cc
index 69edf6906cf2d03601af6bf90a98ae798c836316..ff16dab3cc0f94af62baa5faa5906f772d2730e7 100644
--- a/src/allocation.cc
+++ b/src/allocation.cc
@@ -32,6 +32,10 @@
#include "platform.h"
#include "utils.h"
+#if V8_LIBC_BIONIC
+#include <malloc.h> // NOLINT
+#endif
+
namespace v8 {
namespace internal {
@@ -100,4 +104,33 @@ char* StrNDup(const char* str, int n) {
return result;
}
+
+void* AlignedAlloc(size_t size, size_t alignment) {
+ ASSERT(IsPowerOf2(alignment) && alignment >= V8_ALIGNOF(void*)); // NOLINT
+ void* ptr;
+#if V8_OS_WIN
+ ptr = _aligned_malloc(size, alignment);
+#elif V8_LIBC_BIONIC
+ // posix_memalign is not exposed in some Android versions, so we fall back to
+ // memalign. See http://code.google.com/p/android/issues/detail?id=35391.
+ ptr = memalign(alignment, size);
+#else
+ if (posix_memalign(&ptr, alignment, size)) ptr = NULL;
+#endif
+ if (ptr == NULL) FatalProcessOutOfMemory("AlignedAlloc");
+ return ptr;
+}
+
+
+void AlignedFree(void *ptr) {
+#if V8_OS_WIN
+ _aligned_free(ptr);
+#elif V8_LIBC_BIONIC
+ // Using free is not correct in general, but for V8_LIBC_BIONIC it is.
+ free(ptr);
+#else
+ free(ptr);
+#endif
+}
+
} } // namespace v8::internal
« no previous file with comments | « src/allocation.h ('k') | src/cpu-profiler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698