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

Unified Diff: src/d8.cc

Issue 1069883002: WIP SharedArrayBuffer implementation (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 8 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
Index: src/d8.cc
diff --git a/src/d8.cc b/src/d8.cc
index 38a4b8ec1a104cae465c7b75b898699c19589687..82196189959f3ed3fb18104fcd31499a970b1e89 100644
--- a/src/d8.cc
+++ b/src/d8.cc
@@ -1582,6 +1582,18 @@ class ShellArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
};
+class ShellSharedArrayBufferAllocator
+ : public v8::SharedArrayBuffer::Allocator {
+ public:
+ virtual void* Allocate(size_t length) {
+ 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); }
+};
+
+
class MockArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
public:
void* Allocate(size_t) OVERRIDE { return malloc(1); }
@@ -1590,6 +1602,14 @@ class MockArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
};
+class MockSharedArrayBufferAllocator : public v8::SharedArrayBuffer::Allocator {
+ public:
+ void* Allocate(size_t) OVERRIDE { return malloc(1); }
+ void* AllocateUninitialized(size_t length) OVERRIDE { return malloc(1); }
+ void Free(void* p, size_t) OVERRIDE { free(p); }
+};
+
+
int Shell::Main(int argc, char* argv[]) {
#if (defined(_WIN32) || defined(_WIN64))
UINT new_flags =
@@ -1620,10 +1640,14 @@ int Shell::Main(int argc, char* argv[]) {
SetFlagsFromString("--redirect-code-traces-to=code.asm");
ShellArrayBufferAllocator array_buffer_allocator;
MockArrayBufferAllocator mock_arraybuffer_allocator;
+ ShellSharedArrayBufferAllocator shared_array_buffer_allocator;
+ MockSharedArrayBufferAllocator mock_shared_arraybuffer_allocator;
if (options.mock_arraybuffer_allocator) {
v8::V8::SetArrayBufferAllocator(&mock_arraybuffer_allocator);
+ v8::V8::SetSharedArrayBufferAllocator(&mock_shared_arraybuffer_allocator);
} else {
v8::V8::SetArrayBufferAllocator(&array_buffer_allocator);
+ v8::V8::SetSharedArrayBufferAllocator(&shared_array_buffer_allocator);
}
int result = 0;
Isolate::CreateParams create_params;

Powered by Google App Engine
This is Rietveld 408576698