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 1388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1399 return false; | 1399 return false; |
1400 #endif // V8_SHARED | 1400 #endif // V8_SHARED |
1401 options.num_isolates++; | 1401 options.num_isolates++; |
1402 } else if (strcmp(argv[i], "-p") == 0) { | 1402 } else if (strcmp(argv[i], "-p") == 0) { |
1403 #ifdef V8_SHARED | 1403 #ifdef V8_SHARED |
1404 printf("D8 with shared library does not support multi-threading\n"); | 1404 printf("D8 with shared library does not support multi-threading\n"); |
1405 return false; | 1405 return false; |
1406 #else | 1406 #else |
1407 options.num_parallel_files++; | 1407 options.num_parallel_files++; |
1408 #endif // V8_SHARED | 1408 #endif // V8_SHARED |
| 1409 } else if (strcmp(argv[i], "--dump-heap-constants") == 0) { |
| 1410 #ifdef V8_SHARED |
| 1411 printf("D8 with shared library does not support constant dumping\n"); |
| 1412 return false; |
| 1413 #else |
| 1414 options.dump_heap_constants = true; |
| 1415 argv[i] = NULL; |
| 1416 #endif |
1409 } | 1417 } |
1410 #ifdef V8_SHARED | 1418 #ifdef V8_SHARED |
1411 else if (strcmp(argv[i], "--dump-counters") == 0) { | 1419 else if (strcmp(argv[i], "--dump-counters") == 0) { |
1412 printf("D8 with shared library does not include counters\n"); | 1420 printf("D8 with shared library does not include counters\n"); |
1413 return false; | 1421 return false; |
1414 } else if (strcmp(argv[i], "--debugger") == 0) { | 1422 } else if (strcmp(argv[i], "--debugger") == 0) { |
1415 printf("Javascript debugger not included\n"); | 1423 printf("Javascript debugger not included\n"); |
1416 return false; | 1424 return false; |
1417 } | 1425 } |
1418 #endif // V8_SHARED | 1426 #endif // V8_SHARED |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1553 fake_argv[0] = NULL; | 1561 fake_argv[0] = NULL; |
1554 fake_argv[1] = strdup("--harmony-typed-arrays"); | 1562 fake_argv[1] = strdup("--harmony-typed-arrays"); |
1555 fake_argv[2] = strdup("--trace-hydrogen-file=hydrogen.cfg"); | 1563 fake_argv[2] = strdup("--trace-hydrogen-file=hydrogen.cfg"); |
1556 v8::V8::SetFlagsFromCommandLine(&fake_argc, fake_argv, false); | 1564 v8::V8::SetFlagsFromCommandLine(&fake_argc, fake_argv, false); |
1557 free(fake_argv[1]); | 1565 free(fake_argv[1]); |
1558 delete[] fake_argv; | 1566 delete[] fake_argv; |
1559 } | 1567 } |
1560 #endif | 1568 #endif |
1561 | 1569 |
1562 | 1570 |
| 1571 #ifndef V8_SHARED |
| 1572 static void DumpHeapConstants(i::Isolate* isolate) { |
| 1573 i::Heap* heap = isolate->heap(); |
| 1574 |
| 1575 // Dump the INSTANCE_TYPES table to the console. |
| 1576 printf("# List of known V8 instance types.\n"); |
| 1577 #define DUMP_TYPE(T) printf(" %d: \"%s\",\n", i::T, #T); |
| 1578 printf("INSTANCE_TYPES = {\n"); |
| 1579 INSTANCE_TYPE_LIST(DUMP_TYPE) |
| 1580 printf("}\n"); |
| 1581 #undef DUMP_TYPE |
| 1582 |
| 1583 // Dump the KNOWN_MAP table to the console. |
| 1584 printf("\n# List of known V8 maps.\n"); |
| 1585 #define ROOT_LIST_CASE(type, name, camel_name) \ |
| 1586 if (o == heap->name()) n = #camel_name; |
| 1587 #define STRUCT_LIST_CASE(upper_name, camel_name, name) \ |
| 1588 if (o == heap->name##_map()) n = #camel_name "Map"; |
| 1589 i::HeapObjectIterator it(heap->map_space()); |
| 1590 printf("KNOWN_MAPS = {\n"); |
| 1591 for (i::Object* o = it.Next(); o != NULL; o = it.Next()) { |
| 1592 i::Map* m = i::Map::cast(o); |
| 1593 const char* n = NULL; |
| 1594 intptr_t p = reinterpret_cast<intptr_t>(m) & 0xfffff; |
| 1595 int t = m->instance_type(); |
| 1596 ROOT_LIST(ROOT_LIST_CASE) |
| 1597 STRUCT_LIST(STRUCT_LIST_CASE) |
| 1598 if (n == NULL) continue; |
| 1599 printf(" 0x%05x: (%d, \"%s\"),\n", p, t, n); |
| 1600 } |
| 1601 printf("}\n"); |
| 1602 #undef STRUCT_LIST_CASE |
| 1603 #undef ROOT_LIST_CASE |
| 1604 |
| 1605 // Dump the KNOWN_OBJECTS table to the console. |
| 1606 printf("\n# List of known V8 objects.\n"); |
| 1607 #define ROOT_LIST_CASE(type, name, camel_name) \ |
| 1608 if (o == heap->name()) n = #camel_name; |
| 1609 i::OldSpaces spit(heap); |
| 1610 printf("KNOWN_OBJECTS = {\n"); |
| 1611 for (i::PagedSpace* s = spit.next(); s != NULL; s = spit.next()) { |
| 1612 i::HeapObjectIterator it(s); |
| 1613 const char* sname = AllocationSpaceName(s->identity()); |
| 1614 for (i::Object* o = it.Next(); o != NULL; o = it.Next()) { |
| 1615 const char* n = NULL; |
| 1616 intptr_t p = reinterpret_cast<intptr_t>(o) & 0xfffff; |
| 1617 ROOT_LIST(ROOT_LIST_CASE) |
| 1618 if (n == NULL) continue; |
| 1619 printf(" (\"%s\", 0x%05x): \"%s\",\n", sname, p, n); |
| 1620 } |
| 1621 } |
| 1622 printf("}\n"); |
| 1623 #undef ROOT_LIST_CASE |
| 1624 } |
| 1625 #endif // V8_SHARED |
| 1626 |
| 1627 |
1563 class ShellArrayBufferAllocator : public v8::ArrayBuffer::Allocator { | 1628 class ShellArrayBufferAllocator : public v8::ArrayBuffer::Allocator { |
1564 public: | 1629 public: |
1565 virtual void* Allocate(size_t length) { | 1630 virtual void* Allocate(size_t length) { |
1566 void* result = malloc(length); | 1631 void* result = malloc(length); |
1567 memset(result, 0, length); | 1632 memset(result, 0, length); |
1568 return result; | 1633 return result; |
1569 } | 1634 } |
1570 virtual void* AllocateUninitialized(size_t length) { | 1635 virtual void* AllocateUninitialized(size_t length) { |
1571 return malloc(length); | 1636 return malloc(length); |
1572 } | 1637 } |
(...skipping 17 matching lines...) Expand all Loading... |
1590 Isolate* isolate = Isolate::GetCurrent(); | 1655 Isolate* isolate = Isolate::GetCurrent(); |
1591 DumbLineEditor dumb_line_editor(isolate); | 1656 DumbLineEditor dumb_line_editor(isolate); |
1592 { | 1657 { |
1593 Initialize(isolate); | 1658 Initialize(isolate); |
1594 #ifdef ENABLE_VTUNE_JIT_INTERFACE | 1659 #ifdef ENABLE_VTUNE_JIT_INTERFACE |
1595 vTune::InitializeVtuneForV8(); | 1660 vTune::InitializeVtuneForV8(); |
1596 #endif | 1661 #endif |
1597 PerIsolateData data(isolate); | 1662 PerIsolateData data(isolate); |
1598 InitializeDebugger(isolate); | 1663 InitializeDebugger(isolate); |
1599 | 1664 |
| 1665 #ifndef V8_SHARED |
| 1666 if (options.dump_heap_constants) { |
| 1667 DumpHeapConstants(reinterpret_cast<i::Isolate*>(isolate)); |
| 1668 return 0; |
| 1669 } |
| 1670 #endif |
| 1671 |
1600 if (options.stress_opt || options.stress_deopt) { | 1672 if (options.stress_opt || options.stress_deopt) { |
1601 Testing::SetStressRunType(options.stress_opt | 1673 Testing::SetStressRunType(options.stress_opt |
1602 ? Testing::kStressTypeOpt | 1674 ? Testing::kStressTypeOpt |
1603 : Testing::kStressTypeDeopt); | 1675 : Testing::kStressTypeDeopt); |
1604 int stress_runs = Testing::GetStressRuns(); | 1676 int stress_runs = Testing::GetStressRuns(); |
1605 for (int i = 0; i < stress_runs && result == 0; i++) { | 1677 for (int i = 0; i < stress_runs && result == 0; i++) { |
1606 printf("============ Stress %d/%d ============\n", i + 1, stress_runs); | 1678 printf("============ Stress %d/%d ============\n", i + 1, stress_runs); |
1607 Testing::PrepareStressRun(i); | 1679 Testing::PrepareStressRun(i); |
1608 options.last_run = (i == stress_runs - 1); | 1680 options.last_run = (i == stress_runs - 1); |
1609 result = RunMain(isolate, argc, argv); | 1681 result = RunMain(isolate, argc, argv); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1654 } | 1726 } |
1655 | 1727 |
1656 } // namespace v8 | 1728 } // namespace v8 |
1657 | 1729 |
1658 | 1730 |
1659 #ifndef GOOGLE3 | 1731 #ifndef GOOGLE3 |
1660 int main(int argc, char* argv[]) { | 1732 int main(int argc, char* argv[]) { |
1661 return v8::Shell::Main(argc, argv); | 1733 return v8::Shell::Main(argc, argv); |
1662 } | 1734 } |
1663 #endif | 1735 #endif |
OLD | NEW |