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

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: update MakeTypeError calls Created 5 years, 7 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 1575 matching lines...) Expand 10 before | Expand all | Expand 10 after
1586 public: 1586 public:
1587 virtual void* Allocate(size_t length) { 1587 virtual void* Allocate(size_t length) {
1588 void* data = AllocateUninitialized(length); 1588 void* data = AllocateUninitialized(length);
1589 return data == NULL ? data : memset(data, 0, length); 1589 return data == NULL ? data : memset(data, 0, length);
1590 } 1590 }
1591 virtual void* AllocateUninitialized(size_t length) { return malloc(length); } 1591 virtual void* AllocateUninitialized(size_t length) { return malloc(length); }
1592 virtual void Free(void* data, size_t) { free(data); } 1592 virtual void Free(void* data, size_t) { free(data); }
1593 }; 1593 };
1594 1594
1595 1595
1596 class ShellSharedArrayBufferAllocator
1597 : public v8::SharedArrayBuffer::Allocator {
1598 public:
1599 virtual void* Allocate(size_t length) {
1600 void* data = AllocateUninitialized(length);
1601 return data == NULL ? data : memset(data, 0, length);
1602 }
1603 virtual void* AllocateUninitialized(size_t length) { return malloc(length); }
1604 virtual void Free(void* data, size_t) { free(data); }
1605 };
1606
1607
1596 class MockArrayBufferAllocator : public v8::ArrayBuffer::Allocator { 1608 class MockArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
1597 public: 1609 public:
1598 void* Allocate(size_t) override { return malloc(1); } 1610 void* Allocate(size_t) override { return malloc(1); }
1599 void* AllocateUninitialized(size_t length) override { return malloc(1); } 1611 void* AllocateUninitialized(size_t length) override { return malloc(1); }
1600 void Free(void* p, size_t) override { free(p); } 1612 void Free(void* p, size_t) override { free(p); }
1601 }; 1613 };
1602 1614
1603 1615
1616 class MockSharedArrayBufferAllocator : public v8::SharedArrayBuffer::Allocator {
1617 public:
1618 void* Allocate(size_t) override { return malloc(1); }
1619 void* AllocateUninitialized(size_t length) override { return malloc(1); }
1620 void Free(void* p, size_t) override { free(p); }
1621 };
1622
1623
1604 int Shell::Main(int argc, char* argv[]) { 1624 int Shell::Main(int argc, char* argv[]) {
1605 #if (defined(_WIN32) || defined(_WIN64)) 1625 #if (defined(_WIN32) || defined(_WIN64))
1606 UINT new_flags = 1626 UINT new_flags =
1607 SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX; 1627 SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX;
1608 UINT existing_flags = SetErrorMode(new_flags); 1628 UINT existing_flags = SetErrorMode(new_flags);
1609 SetErrorMode(existing_flags | new_flags); 1629 SetErrorMode(existing_flags | new_flags);
1610 #if defined(_MSC_VER) 1630 #if defined(_MSC_VER)
1611 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE); 1631 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE);
1612 _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); 1632 _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
1613 _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE); 1633 _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE);
(...skipping 10 matching lines...) Expand all
1624 v8::V8::Initialize(); 1644 v8::V8::Initialize();
1625 #ifdef V8_USE_EXTERNAL_STARTUP_DATA 1645 #ifdef V8_USE_EXTERNAL_STARTUP_DATA
1626 v8::StartupDataHandler startup_data(argv[0], options.natives_blob, 1646 v8::StartupDataHandler startup_data(argv[0], options.natives_blob,
1627 options.snapshot_blob); 1647 options.snapshot_blob);
1628 #endif 1648 #endif
1629 SetFlagsFromString("--trace-hydrogen-file=hydrogen.cfg"); 1649 SetFlagsFromString("--trace-hydrogen-file=hydrogen.cfg");
1630 SetFlagsFromString("--trace-turbo-cfg-file=turbo.cfg"); 1650 SetFlagsFromString("--trace-turbo-cfg-file=turbo.cfg");
1631 SetFlagsFromString("--redirect-code-traces-to=code.asm"); 1651 SetFlagsFromString("--redirect-code-traces-to=code.asm");
1632 ShellArrayBufferAllocator array_buffer_allocator; 1652 ShellArrayBufferAllocator array_buffer_allocator;
1633 MockArrayBufferAllocator mock_arraybuffer_allocator; 1653 MockArrayBufferAllocator mock_arraybuffer_allocator;
1654 ShellSharedArrayBufferAllocator shared_array_buffer_allocator;
1655 MockSharedArrayBufferAllocator mock_shared_arraybuffer_allocator;
1634 if (options.mock_arraybuffer_allocator) { 1656 if (options.mock_arraybuffer_allocator) {
1635 v8::V8::SetArrayBufferAllocator(&mock_arraybuffer_allocator); 1657 v8::V8::SetArrayBufferAllocator(&mock_arraybuffer_allocator);
1658 v8::V8::SetSharedArrayBufferAllocator(&mock_shared_arraybuffer_allocator);
1636 } else { 1659 } else {
1637 v8::V8::SetArrayBufferAllocator(&array_buffer_allocator); 1660 v8::V8::SetArrayBufferAllocator(&array_buffer_allocator);
1661 v8::V8::SetSharedArrayBufferAllocator(&shared_array_buffer_allocator);
1638 } 1662 }
1639 int result = 0; 1663 int result = 0;
1640 Isolate::CreateParams create_params; 1664 Isolate::CreateParams create_params;
1641 #if !defined(V8_SHARED) && defined(ENABLE_GDB_JIT_INTERFACE) 1665 #if !defined(V8_SHARED) && defined(ENABLE_GDB_JIT_INTERFACE)
1642 if (i::FLAG_gdbjit) { 1666 if (i::FLAG_gdbjit) {
1643 create_params.code_event_handler = i::GDBJITInterface::EventHandler; 1667 create_params.code_event_handler = i::GDBJITInterface::EventHandler;
1644 } 1668 }
1645 #endif 1669 #endif
1646 #ifdef ENABLE_VTUNE_JIT_INTERFACE 1670 #ifdef ENABLE_VTUNE_JIT_INTERFACE
1647 create_params.code_event_handler = vTune::GetVtuneCodeEventHandler(); 1671 create_params.code_event_handler = vTune::GetVtuneCodeEventHandler();
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1728 } 1752 }
1729 1753
1730 } // namespace v8 1754 } // namespace v8
1731 1755
1732 1756
1733 #ifndef GOOGLE3 1757 #ifndef GOOGLE3
1734 int main(int argc, char* argv[]) { 1758 int main(int argc, char* argv[]) {
1735 return v8::Shell::Main(argc, argv); 1759 return v8::Shell::Main(argc, argv);
1736 } 1760 }
1737 #endif 1761 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698