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

Unified Diff: samples/shell.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 | « include/v8.h ('k') | src/api.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samples/shell.cc
diff --git a/samples/shell.cc b/samples/shell.cc
index 1a08afffdc8ad211ec10adb898ab943427ed1b5b..a37593678edbe8b61aae9710ca74d79af45b495d 100644
--- a/samples/shell.cc
+++ b/samples/shell.cc
@@ -35,6 +35,14 @@
#include <stdlib.h>
#include <string.h>
+#if V8_OS_WIN
+#include <malloc.h>
+#endif
+
+#ifdef COMPRESS_STARTUP_DATA_BZ2
+#error Using compressed startup data is not supported for this sample
+#endif
+
/**
* This sample program shows how to implement a simple javascript shell
* based on V8. This includes initializing V8 with command line options,
@@ -70,8 +78,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
+ }
};
« no previous file with comments | « include/v8.h ('k') | src/api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698