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

Unified Diff: src/d8.cc

Issue 61623009: Use mock ArrayBuffer allocator to avoid really allocating 1Gb. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 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/d8.h ('k') | test/mjsunit/mjsunit.status » ('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 d227ac3a3dcea03755ced48391ac2616592f2bc0..eaec7d3c3f4d7021ac82a03bea5f57fb5b5ca9db 100644
--- a/src/d8.cc
+++ b/src/d8.cc
@@ -1364,6 +1364,9 @@ bool Shell::SetOptions(int argc, char* argv[]) {
} else if (strcmp(argv[i], "--stress-deopt") == 0) {
options.stress_deopt = true;
argv[i] = NULL;
+ } else if (strcmp(argv[i], "--mock-arraybuffer-allocator") == 0) {
+ options.mock_arraybuffer_allocator = true;
+ argv[i] = NULL;
} else if (strcmp(argv[i], "--noalways-opt") == 0) {
// No support for stressing if we can't use --always-opt.
options.stress_opt = false;
@@ -1673,6 +1676,19 @@ class ShellArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
};
+class MockArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
+ public:
+ virtual void* Allocate(size_t) V8_OVERRIDE {
+ return malloc(0);
+ }
+ virtual void* AllocateUninitialized(size_t length) V8_OVERRIDE {
+ return malloc(0);
+ }
+ virtual void Free(void*, size_t) V8_OVERRIDE {
+ }
+};
+
+
int Shell::Main(int argc, char* argv[]) {
if (!SetOptions(argc, argv)) return 1;
v8::V8::InitializeICU();
@@ -1683,7 +1699,12 @@ int Shell::Main(int argc, char* argv[]) {
SetStandaloneFlagsViaCommandLine();
#endif
ShellArrayBufferAllocator array_buffer_allocator;
- v8::V8::SetArrayBufferAllocator(&array_buffer_allocator);
+ MockArrayBufferAllocator mock_arraybuffer_allocator;
+ if (options.mock_arraybuffer_allocator) {
+ v8::V8::SetArrayBufferAllocator(&mock_arraybuffer_allocator);
+ } else {
+ v8::V8::SetArrayBufferAllocator(&array_buffer_allocator);
+ }
int result = 0;
Isolate* isolate = Isolate::GetCurrent();
#ifndef V8_SHARED
« no previous file with comments | « src/d8.h ('k') | test/mjsunit/mjsunit.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698