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

Side by Side Diff: Source/platform/heap/Heap.cpp

Issue 314943004: GC_TRACING dumps its result to stderr (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 1320 matching lines...) Expand 10 before | Expand all | Expand 10 after
1331 header->mark(); 1331 header->mark();
1332 #if ENABLE(GC_TRACING) 1332 #if ENABLE(GC_TRACING)
1333 MutexLocker locker(objectGraphMutex()); 1333 MutexLocker locker(objectGraphMutex());
1334 String className(classOf(objectPointer)); 1334 String className(classOf(objectPointer));
1335 { 1335 {
1336 LiveObjectMap::AddResult result = currentlyLive().add(className, Liv eObjectSet()); 1336 LiveObjectMap::AddResult result = currentlyLive().add(className, Liv eObjectSet());
1337 result.storedValue->value.add(reinterpret_cast<uintptr_t>(objectPoin ter)); 1337 result.storedValue->value.add(reinterpret_cast<uintptr_t>(objectPoin ter));
1338 } 1338 }
1339 ObjectGraph::AddResult result = objectGraph().add(reinterpret_cast<uintp tr_t>(objectPointer), std::make_pair(reinterpret_cast<uintptr_t>(m_hostObject), m_hostName)); 1339 ObjectGraph::AddResult result = objectGraph().add(reinterpret_cast<uintp tr_t>(objectPointer), std::make_pair(reinterpret_cast<uintptr_t>(m_hostObject), m_hostName));
1340 ASSERT(result.isNewEntry); 1340 ASSERT(result.isNewEntry);
1341 // printf("%s[%p] -> %s[%p]\n", m_hostName.ascii().data(), m_hostObject, className.ascii().data(), objectPointer); 1341 // fprintf(stderr, "%s[%p] -> %s[%p]\n", m_hostName.ascii().data(), m_ho stObject, className.ascii().data(), objectPointer);
1342 #endif 1342 #endif
1343 if (callback) 1343 if (callback)
1344 Heap::pushTraceCallback(const_cast<void*>(objectPointer), callback); 1344 Heap::pushTraceCallback(const_cast<void*>(objectPointer), callback);
1345 } 1345 }
1346 1346
1347 virtual void mark(HeapObjectHeader* header, TraceCallback callback) OVERRIDE 1347 virtual void mark(HeapObjectHeader* header, TraceCallback callback) OVERRIDE
1348 { 1348 {
1349 // We need both the HeapObjectHeader and FinalizedHeapObjectHeader 1349 // We need both the HeapObjectHeader and FinalizedHeapObjectHeader
1350 // version to correctly find the payload. 1350 // version to correctly find the payload.
1351 visitHeader(header, header->payload(), callback); 1351 visitHeader(header, header->payload(), callback);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1419 { \ 1419 { \
1420 return HeapObjectHeader::fromPayload(objectPointer)->isMarked(); \ 1420 return HeapObjectHeader::fromPayload(objectPointer)->isMarked(); \
1421 } 1421 }
1422 1422
1423 FOR_EACH_TYPED_HEAP(DEFINE_VISITOR_METHODS) 1423 FOR_EACH_TYPED_HEAP(DEFINE_VISITOR_METHODS)
1424 #undef DEFINE_VISITOR_METHODS 1424 #undef DEFINE_VISITOR_METHODS
1425 1425
1426 #if ENABLE(GC_TRACING) 1426 #if ENABLE(GC_TRACING)
1427 void reportStats() 1427 void reportStats()
1428 { 1428 {
1429 printf("\n---------- AFTER MARKING -------------------\n"); 1429 fprintf(stderr, "\n---------- AFTER MARKING -------------------\n");
1430 for (LiveObjectMap::iterator it = currentlyLive().begin(), end = current lyLive().end(); it != end; ++it) { 1430 for (LiveObjectMap::iterator it = currentlyLive().begin(), end = current lyLive().end(); it != end; ++it) {
1431 printf("%s %u", it->key.ascii().data(), it->value.size()); 1431 fprintf(stderr, "%s %u", it->key.ascii().data(), it->value.size());
1432 1432
1433 if (it->key == "WebCore::Document") 1433 if (it->key == "WebCore::Document")
1434 reportStillAlive(it->value, previouslyLive().get(it->key)); 1434 reportStillAlive(it->value, previouslyLive().get(it->key));
1435 1435
1436 printf("\n"); 1436 fprintf(stderr, "\n");
1437 } 1437 }
1438 1438
1439 previouslyLive().swap(currentlyLive()); 1439 previouslyLive().swap(currentlyLive());
1440 currentlyLive().clear(); 1440 currentlyLive().clear();
1441 1441
1442 for (HashSet<uintptr_t>::iterator it = objectsToFindPath().begin(), end = objectsToFindPath().end(); it != end; ++it) { 1442 for (HashSet<uintptr_t>::iterator it = objectsToFindPath().begin(), end = objectsToFindPath().end(); it != end; ++it) {
1443 dumpPathToObjectFromObjectGraph(objectGraph(), *it); 1443 dumpPathToObjectFromObjectGraph(objectGraph(), *it);
1444 } 1444 }
1445 } 1445 }
1446 1446
1447 static void reportStillAlive(LiveObjectSet current, LiveObjectSet previous) 1447 static void reportStillAlive(LiveObjectSet current, LiveObjectSet previous)
1448 { 1448 {
1449 int count = 0; 1449 int count = 0;
1450 1450
1451 printf(" [previously %u]", previous.size()); 1451 fprintf(stderr, " [previously %u]", previous.size());
1452 for (LiveObjectSet::iterator it = current.begin(), end = current.end(); it != end; ++it) { 1452 for (LiveObjectSet::iterator it = current.begin(), end = current.end(); it != end; ++it) {
1453 if (previous.find(*it) == previous.end()) 1453 if (previous.find(*it) == previous.end())
1454 continue; 1454 continue;
1455 count++; 1455 count++;
1456 } 1456 }
1457 1457
1458 if (!count) 1458 if (!count)
1459 return; 1459 return;
1460 1460
1461 printf(" {survived 2GCs %d: ", count); 1461 fprintf(stderr, " {survived 2GCs %d: ", count);
1462 for (LiveObjectSet::iterator it = current.begin(), end = current.end(); it != end; ++it) { 1462 for (LiveObjectSet::iterator it = current.begin(), end = current.end(); it != end; ++it) {
1463 if (previous.find(*it) == previous.end()) 1463 if (previous.find(*it) == previous.end())
1464 continue; 1464 continue;
1465 printf("%ld", *it); 1465 fprintf(stderr, "%ld", *it);
1466 if (--count) 1466 if (--count)
1467 printf(", "); 1467 fprintf(stderr, ", ");
1468 } 1468 }
1469 ASSERT(!count); 1469 ASSERT(!count);
1470 printf("}"); 1470 fprintf(stderr, "}");
1471 } 1471 }
1472 1472
1473 static void dumpPathToObjectFromObjectGraph(const ObjectGraph& graph, uintpt r_t target) 1473 static void dumpPathToObjectFromObjectGraph(const ObjectGraph& graph, uintpt r_t target)
1474 { 1474 {
1475 printf("Path to %lx of %s\n", target, classOf(reinterpret_cast<const voi d*>(target)).ascii().data()); 1475 fprintf(stderr, "Path to %lx of %s\n", target, classOf(reinterpret_cast< const void*>(target)).ascii().data());
1476 ObjectGraph::const_iterator it = graph.find(target); 1476 ObjectGraph::const_iterator it = graph.find(target);
1477 while (it != graph.end()) { 1477 while (it != graph.end()) {
1478 printf("<- %lx of %s\n", it->value.first, it->value.second.ascii().d ata()); 1478 fprintf(stderr, "<- %lx of %s\n", it->value.first, it->value.second. ascii().data());
1479 it = graph.find(it->value.first); 1479 it = graph.find(it->value.first);
1480 } 1480 }
1481 printf("\n"); 1481 fprintf(stderr, "\n");
1482 } 1482 }
1483 1483
1484 static void dumpPathToObjectOnNextGC(void* p) 1484 static void dumpPathToObjectOnNextGC(void* p)
1485 { 1485 {
1486 objectsToFindPath().add(reinterpret_cast<uintptr_t>(p)); 1486 objectsToFindPath().add(reinterpret_cast<uintptr_t>(p));
1487 } 1487 }
1488 1488
1489 static Mutex& objectGraphMutex() 1489 static Mutex& objectGraphMutex()
1490 { 1490 {
1491 AtomicallyInitializedStatic(Mutex&, mutex = *new Mutex); 1491 AtomicallyInitializedStatic(Mutex&, mutex = *new Mutex);
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
1777 template class ThreadHeap<FinalizedHeapObjectHeader>; 1777 template class ThreadHeap<FinalizedHeapObjectHeader>;
1778 template class ThreadHeap<HeapObjectHeader>; 1778 template class ThreadHeap<HeapObjectHeader>;
1779 1779
1780 Visitor* Heap::s_markingVisitor; 1780 Visitor* Heap::s_markingVisitor;
1781 CallbackStack* Heap::s_markingStack; 1781 CallbackStack* Heap::s_markingStack;
1782 CallbackStack* Heap::s_weakCallbackStack; 1782 CallbackStack* Heap::s_weakCallbackStack;
1783 HeapDoesNotContainCache* Heap::s_heapDoesNotContainCache; 1783 HeapDoesNotContainCache* Heap::s_heapDoesNotContainCache;
1784 bool Heap::s_shutdownCalled = false; 1784 bool Heap::s_shutdownCalled = false;
1785 bool Heap::s_lastGCWasConservative = false; 1785 bool Heap::s_lastGCWasConservative = false;
1786 } 1786 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698