OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1357 for (int i = 0; i < argc; i++) { | 1357 for (int i = 0; i < argc; i++) { |
1358 if (strcmp(argv[i], "--stress-opt") == 0) { | 1358 if (strcmp(argv[i], "--stress-opt") == 0) { |
1359 options.stress_opt = true; | 1359 options.stress_opt = true; |
1360 argv[i] = NULL; | 1360 argv[i] = NULL; |
1361 } else if (strcmp(argv[i], "--nostress-opt") == 0) { | 1361 } else if (strcmp(argv[i], "--nostress-opt") == 0) { |
1362 options.stress_opt = false; | 1362 options.stress_opt = false; |
1363 argv[i] = NULL; | 1363 argv[i] = NULL; |
1364 } else if (strcmp(argv[i], "--stress-deopt") == 0) { | 1364 } else if (strcmp(argv[i], "--stress-deopt") == 0) { |
1365 options.stress_deopt = true; | 1365 options.stress_deopt = true; |
1366 argv[i] = NULL; | 1366 argv[i] = NULL; |
| 1367 } else if (strcmp(argv[i], "--mock-arraybuffer-allocator") == 0) { |
| 1368 options.mock_arraybuffer_allocator = true; |
| 1369 argv[i] = NULL; |
1367 } else if (strcmp(argv[i], "--noalways-opt") == 0) { | 1370 } else if (strcmp(argv[i], "--noalways-opt") == 0) { |
1368 // No support for stressing if we can't use --always-opt. | 1371 // No support for stressing if we can't use --always-opt. |
1369 options.stress_opt = false; | 1372 options.stress_opt = false; |
1370 options.stress_deopt = false; | 1373 options.stress_deopt = false; |
1371 } else if (strcmp(argv[i], "--shell") == 0) { | 1374 } else if (strcmp(argv[i], "--shell") == 0) { |
1372 options.interactive_shell = true; | 1375 options.interactive_shell = true; |
1373 argv[i] = NULL; | 1376 argv[i] = NULL; |
1374 } else if (strcmp(argv[i], "--test") == 0) { | 1377 } else if (strcmp(argv[i], "--test") == 0) { |
1375 options.test_shell = true; | 1378 options.test_shell = true; |
1376 argv[i] = NULL; | 1379 argv[i] = NULL; |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1666 virtual void Free(void* data, size_t) { free(data); } | 1669 virtual void Free(void* data, size_t) { free(data); } |
1667 // TODO(dslomov): Remove when v8:2823 is fixed. | 1670 // TODO(dslomov): Remove when v8:2823 is fixed. |
1668 virtual void Free(void* data) { | 1671 virtual void Free(void* data) { |
1669 #ifndef V8_SHARED | 1672 #ifndef V8_SHARED |
1670 UNREACHABLE(); | 1673 UNREACHABLE(); |
1671 #endif | 1674 #endif |
1672 } | 1675 } |
1673 }; | 1676 }; |
1674 | 1677 |
1675 | 1678 |
| 1679 class MockArrayBufferAllocator : public v8::ArrayBuffer::Allocator { |
| 1680 public: |
| 1681 virtual void* Allocate(size_t) V8_OVERRIDE { |
| 1682 return malloc(0); |
| 1683 } |
| 1684 virtual void* AllocateUninitialized(size_t length) V8_OVERRIDE { |
| 1685 return malloc(0); |
| 1686 } |
| 1687 virtual void Free(void*, size_t) V8_OVERRIDE { |
| 1688 } |
| 1689 }; |
| 1690 |
| 1691 |
1676 int Shell::Main(int argc, char* argv[]) { | 1692 int Shell::Main(int argc, char* argv[]) { |
1677 if (!SetOptions(argc, argv)) return 1; | 1693 if (!SetOptions(argc, argv)) return 1; |
1678 v8::V8::InitializeICU(); | 1694 v8::V8::InitializeICU(); |
1679 #ifndef V8_SHARED | 1695 #ifndef V8_SHARED |
1680 i::FLAG_trace_hydrogen_file = "hydrogen.cfg"; | 1696 i::FLAG_trace_hydrogen_file = "hydrogen.cfg"; |
1681 i::FLAG_redirect_code_traces_to = "code.asm"; | 1697 i::FLAG_redirect_code_traces_to = "code.asm"; |
1682 #else | 1698 #else |
1683 SetStandaloneFlagsViaCommandLine(); | 1699 SetStandaloneFlagsViaCommandLine(); |
1684 #endif | 1700 #endif |
1685 ShellArrayBufferAllocator array_buffer_allocator; | 1701 ShellArrayBufferAllocator array_buffer_allocator; |
1686 v8::V8::SetArrayBufferAllocator(&array_buffer_allocator); | 1702 MockArrayBufferAllocator mock_arraybuffer_allocator; |
| 1703 if (options.mock_arraybuffer_allocator) { |
| 1704 v8::V8::SetArrayBufferAllocator(&mock_arraybuffer_allocator); |
| 1705 } else { |
| 1706 v8::V8::SetArrayBufferAllocator(&array_buffer_allocator); |
| 1707 } |
1687 int result = 0; | 1708 int result = 0; |
1688 Isolate* isolate = Isolate::GetCurrent(); | 1709 Isolate* isolate = Isolate::GetCurrent(); |
1689 #ifndef V8_SHARED | 1710 #ifndef V8_SHARED |
1690 v8::ResourceConstraints constraints; | 1711 v8::ResourceConstraints constraints; |
1691 constraints.ConfigureDefaults(i::OS::TotalPhysicalMemory()); | 1712 constraints.ConfigureDefaults(i::OS::TotalPhysicalMemory()); |
1692 v8::SetResourceConstraints(isolate, &constraints); | 1713 v8::SetResourceConstraints(isolate, &constraints); |
1693 #endif | 1714 #endif |
1694 DumbLineEditor dumb_line_editor(isolate); | 1715 DumbLineEditor dumb_line_editor(isolate); |
1695 { | 1716 { |
1696 Initialize(isolate); | 1717 Initialize(isolate); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1764 } | 1785 } |
1765 | 1786 |
1766 } // namespace v8 | 1787 } // namespace v8 |
1767 | 1788 |
1768 | 1789 |
1769 #ifndef GOOGLE3 | 1790 #ifndef GOOGLE3 |
1770 int main(int argc, char* argv[]) { | 1791 int main(int argc, char* argv[]) { |
1771 return v8::Shell::Main(argc, argv); | 1792 return v8::Shell::Main(argc, argv); |
1772 } | 1793 } |
1773 #endif | 1794 #endif |
OLD | NEW |