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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 5
6 // Defined when linking against shared lib on Windows. 6 // Defined when linking against shared lib on Windows.
7 #if defined(USING_V8_SHARED) && !defined(V8_SHARED) 7 #if defined(USING_V8_SHARED) && !defined(V8_SHARED)
8 #define V8_SHARED 8 #define V8_SHARED
9 #endif 9 #endif
10 10
(...skipping 1564 matching lines...) Expand 10 before | Expand all | Expand 10 after
1575 public: 1575 public:
1576 virtual void* Allocate(size_t length) { 1576 virtual void* Allocate(size_t length) {
1577 void* data = AllocateUninitialized(length); 1577 void* data = AllocateUninitialized(length);
1578 return data == NULL ? data : memset(data, 0, length); 1578 return data == NULL ? data : memset(data, 0, length);
1579 } 1579 }
1580 virtual void* AllocateUninitialized(size_t length) { return malloc(length); } 1580 virtual void* AllocateUninitialized(size_t length) { return malloc(length); }
1581 virtual void Free(void* data, size_t) { free(data); } 1581 virtual void Free(void* data, size_t) { free(data); }
1582 }; 1582 };
1583 1583
1584 1584
1585 class ShellSharedArrayBufferAllocator
1586 : public v8::SharedArrayBuffer::Allocator {
1587 public:
1588 virtual void* Allocate(size_t length) {
1589 void* data = AllocateUninitialized(length);
1590 return data == NULL ? data : memset(data, 0, length);
1591 }
1592 virtual void* AllocateUninitialized(size_t length) { return malloc(length); }
1593 virtual void Free(void* data, size_t) { free(data); }
1594 };
1595
1596
1585 class MockArrayBufferAllocator : public v8::ArrayBuffer::Allocator { 1597 class MockArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
1586 public: 1598 public:
1587 void* Allocate(size_t) OVERRIDE { return malloc(1); } 1599 void* Allocate(size_t) OVERRIDE { return malloc(1); }
1588 void* AllocateUninitialized(size_t length) OVERRIDE { return malloc(1); } 1600 void* AllocateUninitialized(size_t length) OVERRIDE { return malloc(1); }
1589 void Free(void* p, size_t) OVERRIDE { free(p); } 1601 void Free(void* p, size_t) OVERRIDE { free(p); }
1590 }; 1602 };
1591 1603
1592 1604
1605 class MockSharedArrayBufferAllocator : public v8::SharedArrayBuffer::Allocator {
1606 public:
1607 void* Allocate(size_t) OVERRIDE { return malloc(1); }
1608 void* AllocateUninitialized(size_t length) OVERRIDE { return malloc(1); }
1609 void Free(void* p, size_t) OVERRIDE { free(p); }
1610 };
1611
1612
1593 int Shell::Main(int argc, char* argv[]) { 1613 int Shell::Main(int argc, char* argv[]) {
1594 #if (defined(_WIN32) || defined(_WIN64)) 1614 #if (defined(_WIN32) || defined(_WIN64))
1595 UINT new_flags = 1615 UINT new_flags =
1596 SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX; 1616 SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX;
1597 UINT existing_flags = SetErrorMode(new_flags); 1617 UINT existing_flags = SetErrorMode(new_flags);
1598 SetErrorMode(existing_flags | new_flags); 1618 SetErrorMode(existing_flags | new_flags);
1599 #if defined(_MSC_VER) 1619 #if defined(_MSC_VER)
1600 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE); 1620 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE);
1601 _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); 1621 _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
1602 _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE); 1622 _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE);
(...skipping 10 matching lines...) Expand all
1613 v8::V8::Initialize(); 1633 v8::V8::Initialize();
1614 #ifdef V8_USE_EXTERNAL_STARTUP_DATA 1634 #ifdef V8_USE_EXTERNAL_STARTUP_DATA
1615 v8::StartupDataHandler startup_data(argv[0], options.natives_blob, 1635 v8::StartupDataHandler startup_data(argv[0], options.natives_blob,
1616 options.snapshot_blob); 1636 options.snapshot_blob);
1617 #endif 1637 #endif
1618 SetFlagsFromString("--trace-hydrogen-file=hydrogen.cfg"); 1638 SetFlagsFromString("--trace-hydrogen-file=hydrogen.cfg");
1619 SetFlagsFromString("--trace-turbo-cfg-file=turbo.cfg"); 1639 SetFlagsFromString("--trace-turbo-cfg-file=turbo.cfg");
1620 SetFlagsFromString("--redirect-code-traces-to=code.asm"); 1640 SetFlagsFromString("--redirect-code-traces-to=code.asm");
1621 ShellArrayBufferAllocator array_buffer_allocator; 1641 ShellArrayBufferAllocator array_buffer_allocator;
1622 MockArrayBufferAllocator mock_arraybuffer_allocator; 1642 MockArrayBufferAllocator mock_arraybuffer_allocator;
1643 ShellSharedArrayBufferAllocator shared_array_buffer_allocator;
1644 MockSharedArrayBufferAllocator mock_shared_arraybuffer_allocator;
1623 if (options.mock_arraybuffer_allocator) { 1645 if (options.mock_arraybuffer_allocator) {
1624 v8::V8::SetArrayBufferAllocator(&mock_arraybuffer_allocator); 1646 v8::V8::SetArrayBufferAllocator(&mock_arraybuffer_allocator);
1647 v8::V8::SetSharedArrayBufferAllocator(&mock_shared_arraybuffer_allocator);
1625 } else { 1648 } else {
1626 v8::V8::SetArrayBufferAllocator(&array_buffer_allocator); 1649 v8::V8::SetArrayBufferAllocator(&array_buffer_allocator);
1650 v8::V8::SetSharedArrayBufferAllocator(&shared_array_buffer_allocator);
1627 } 1651 }
1628 int result = 0; 1652 int result = 0;
1629 Isolate::CreateParams create_params; 1653 Isolate::CreateParams create_params;
1630 #if !defined(V8_SHARED) && defined(ENABLE_GDB_JIT_INTERFACE) 1654 #if !defined(V8_SHARED) && defined(ENABLE_GDB_JIT_INTERFACE)
1631 if (i::FLAG_gdbjit) { 1655 if (i::FLAG_gdbjit) {
1632 create_params.code_event_handler = i::GDBJITInterface::EventHandler; 1656 create_params.code_event_handler = i::GDBJITInterface::EventHandler;
1633 } 1657 }
1634 #endif 1658 #endif
1635 #ifdef ENABLE_VTUNE_JIT_INTERFACE 1659 #ifdef ENABLE_VTUNE_JIT_INTERFACE
1636 create_params.code_event_handler = vTune::GetVtuneCodeEventHandler(); 1660 create_params.code_event_handler = vTune::GetVtuneCodeEventHandler();
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1718 } 1742 }
1719 1743
1720 } // namespace v8 1744 } // namespace v8
1721 1745
1722 1746
1723 #ifndef GOOGLE3 1747 #ifndef GOOGLE3
1724 int main(int argc, char* argv[]) { 1748 int main(int argc, char* argv[]) {
1725 return v8::Shell::Main(argc, argv); 1749 return v8::Shell::Main(argc, argv);
1726 } 1750 }
1727 #endif 1751 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698