@@ -1406,6 +1406,14 @@ bool Shell::SetOptions(int argc, char* argv[]) {
1406
1406
#else
1407
1407
options.num_parallel_files ++;
1408
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
1418
#ifdef V8_SHARED
1411
1419
else if (strcmp (argv[i], " --dump-counters" ) == 0 ) {
@@ -1560,6 +1568,63 @@ static void SetStandaloneFlagsViaCommandLine() {
1560
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%05" V8_PTR_PREFIX " x: (%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%05" V8_PTR_PREFIX " x): \" %s\" ,\n " , sname, p, n);
1620
+ }
1621
+ }
1622
+ printf (" }\n " );
1623
+ #undef ROOT_LIST_CASE
1624
+ }
1625
+ #endif // V8_SHARED
1626
+
1627
+
1563
1628
class ShellArrayBufferAllocator : public v8 ::ArrayBuffer::Allocator {
1564
1629
public:
1565
1630
virtual void * Allocate (size_t length) {
@@ -1597,6 +1662,13 @@ int Shell::Main(int argc, char* argv[]) {
1597
1662
PerIsolateData data (isolate);
1598
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
1672
if (options.stress_opt || options.stress_deopt ) {
1601
1673
Testing::SetStressRunType (options.stress_opt
1602
1674
? Testing::kStressTypeOpt
0 commit comments