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

Unified Diff: src/d8.cc

Issue 1069883002: WIP SharedArrayBuffer implementation (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: update MakeTypeError calls 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 cf448172f7a9f8afd500a240abbe0d9312647034..9f14109091aeb9c1310a06624093877adbdf6f88 100644
--- a/src/d8.cc
+++ b/src/d8.cc
@@ -1593,6 +1593,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); }
@@ -1601,6 +1613,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 =
@@ -1631,10 +1651,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