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

Unified Diff: src/d8.cc

Issue 768543002: [WIP] TrapHandler 2014/11/27. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 years, 1 month 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/compiler/verifier.cc ('k') | src/isolate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/d8.cc
diff --git a/src/d8.cc b/src/d8.cc
index e18f2da91d1a03ccdba7e5de40a00c3d86127f71..db189a5c42040d67b8f478a94c1f57c36cc9e0e1 100644
--- a/src/d8.cc
+++ b/src/d8.cc
@@ -13,6 +13,10 @@
#include <string.h>
#include <sys/stat.h>
+#if V8_OS_WIN
+#include <malloc.h>
+#endif
+
#ifdef V8_SHARED
#include <assert.h>
#endif // V8_SHARED
@@ -1532,8 +1536,28 @@ class ShellArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
void* data = AllocateUninitialized(length);
return data == NULL ? data : memset(data, 0, length);
}
- virtual void* AllocateUninitialized(size_t length) { return malloc(length); }
- virtual void Free(void* data, size_t) { free(data); }
+ virtual void* AllocateUninitialized(size_t length) {
+ return Allocate(length, 8);
+ }
+ virtual void* Allocate(size_t length, size_t alignment) {
+#if V8_OS_ANDROID
+ return memalign(alignment, length);
+#elif V8_OS_WIN
+ return _aligned_malloc(length, alignment);
+#else
+ void* ptr = NULL;
+ posix_memalign(&ptr, alignment, length);
+ return ptr;
+#endif
+ }
+ virtual void Free(void* data, size_t) { Free(data); }
+ virtual void Free(void* data) {
+#if V8_OS_WIN
+ _aligned_free(data);
+#else
+ free(data);
+#endif
+ }
};
@@ -1545,6 +1569,17 @@ class MockArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
virtual void* AllocateUninitialized(size_t length) OVERRIDE {
return malloc(0);
}
+ virtual void* Allocate(size_t length, size_t alignment) OVERRIDE {
+#if V8_OS_ANDROID
+ return memalign(alignment, 0);
+#elif V8_OS_WIN
+ return _aligned_malloc(0, alignment);
+#else
+ void* ptr = NULL;
+ posix_memalign(&ptr, alignment, 0);
+ return ptr;
+#endif
+ }
virtual void Free(void* p, size_t) OVERRIDE {
free(p);
}
« no previous file with comments | « src/compiler/verifier.cc ('k') | src/isolate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698