| OLD | NEW |
| 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 |
| 11 #include <errno.h> | 11 #include <errno.h> |
| 12 #include <stdlib.h> | 12 #include <stdlib.h> |
| 13 #include <string.h> | 13 #include <string.h> |
| 14 #include <sys/stat.h> | 14 #include <sys/stat.h> |
| 15 | 15 |
| 16 #if V8_OS_WIN |
| 17 #include <malloc.h> |
| 18 #endif |
| 19 |
| 16 #ifdef V8_SHARED | 20 #ifdef V8_SHARED |
| 17 #include <assert.h> | 21 #include <assert.h> |
| 18 #endif // V8_SHARED | 22 #endif // V8_SHARED |
| 19 | 23 |
| 20 #ifndef V8_SHARED | 24 #ifndef V8_SHARED |
| 21 #include <algorithm> | 25 #include <algorithm> |
| 22 #endif // !V8_SHARED | 26 #endif // !V8_SHARED |
| 23 | 27 |
| 24 #ifdef V8_SHARED | 28 #ifdef V8_SHARED |
| 25 #include "include/v8-testing.h" | 29 #include "include/v8-testing.h" |
| (...skipping 1499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1525 } | 1529 } |
| 1526 #endif // !V8_SHARED | 1530 #endif // !V8_SHARED |
| 1527 | 1531 |
| 1528 | 1532 |
| 1529 class ShellArrayBufferAllocator : public v8::ArrayBuffer::Allocator { | 1533 class ShellArrayBufferAllocator : public v8::ArrayBuffer::Allocator { |
| 1530 public: | 1534 public: |
| 1531 virtual void* Allocate(size_t length) { | 1535 virtual void* Allocate(size_t length) { |
| 1532 void* data = AllocateUninitialized(length); | 1536 void* data = AllocateUninitialized(length); |
| 1533 return data == NULL ? data : memset(data, 0, length); | 1537 return data == NULL ? data : memset(data, 0, length); |
| 1534 } | 1538 } |
| 1535 virtual void* AllocateUninitialized(size_t length) { return malloc(length); } | 1539 virtual void* AllocateUninitialized(size_t length) { |
| 1536 virtual void Free(void* data, size_t) { free(data); } | 1540 return Allocate(length, 8); |
| 1541 } |
| 1542 virtual void* Allocate(size_t length, size_t alignment) { |
| 1543 #if V8_OS_ANDROID |
| 1544 return memalign(alignment, length); |
| 1545 #elif V8_OS_WIN |
| 1546 return _aligned_malloc(length, alignment); |
| 1547 #else |
| 1548 void* ptr = NULL; |
| 1549 posix_memalign(&ptr, alignment, length); |
| 1550 return ptr; |
| 1551 #endif |
| 1552 } |
| 1553 virtual void Free(void* data, size_t) { Free(data); } |
| 1554 virtual void Free(void* data) { |
| 1555 #if V8_OS_WIN |
| 1556 _aligned_free(data); |
| 1557 #else |
| 1558 free(data); |
| 1559 #endif |
| 1560 } |
| 1537 }; | 1561 }; |
| 1538 | 1562 |
| 1539 | 1563 |
| 1540 class MockArrayBufferAllocator : public v8::ArrayBuffer::Allocator { | 1564 class MockArrayBufferAllocator : public v8::ArrayBuffer::Allocator { |
| 1541 public: | 1565 public: |
| 1542 virtual void* Allocate(size_t) OVERRIDE { | 1566 virtual void* Allocate(size_t) OVERRIDE { |
| 1543 return malloc(0); | 1567 return malloc(0); |
| 1544 } | 1568 } |
| 1545 virtual void* AllocateUninitialized(size_t length) OVERRIDE { | 1569 virtual void* AllocateUninitialized(size_t length) OVERRIDE { |
| 1546 return malloc(0); | 1570 return malloc(0); |
| 1547 } | 1571 } |
| 1572 virtual void* Allocate(size_t length, size_t alignment) OVERRIDE { |
| 1573 #if V8_OS_ANDROID |
| 1574 return memalign(alignment, 0); |
| 1575 #elif V8_OS_WIN |
| 1576 return _aligned_malloc(0, alignment); |
| 1577 #else |
| 1578 void* ptr = NULL; |
| 1579 posix_memalign(&ptr, alignment, 0); |
| 1580 return ptr; |
| 1581 #endif |
| 1582 } |
| 1548 virtual void Free(void* p, size_t) OVERRIDE { | 1583 virtual void Free(void* p, size_t) OVERRIDE { |
| 1549 free(p); | 1584 free(p); |
| 1550 } | 1585 } |
| 1551 }; | 1586 }; |
| 1552 | 1587 |
| 1553 | 1588 |
| 1554 #ifdef V8_USE_EXTERNAL_STARTUP_DATA | 1589 #ifdef V8_USE_EXTERNAL_STARTUP_DATA |
| 1555 class StartupDataHandler { | 1590 class StartupDataHandler { |
| 1556 public: | 1591 public: |
| 1557 StartupDataHandler(const char* natives_blob, | 1592 StartupDataHandler(const char* natives_blob, |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1722 } | 1757 } |
| 1723 | 1758 |
| 1724 } // namespace v8 | 1759 } // namespace v8 |
| 1725 | 1760 |
| 1726 | 1761 |
| 1727 #ifndef GOOGLE3 | 1762 #ifndef GOOGLE3 |
| 1728 int main(int argc, char* argv[]) { | 1763 int main(int argc, char* argv[]) { |
| 1729 return v8::Shell::Main(argc, argv); | 1764 return v8::Shell::Main(argc, argv); |
| 1730 } | 1765 } |
| 1731 #endif | 1766 #endif |
| OLD | NEW |