OLD | NEW |
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 1454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1465 fprintf(stderr, "%ld", *it); | 1465 fprintf(stderr, "%ld", *it); |
1466 if (--count) | 1466 if (--count) |
1467 fprintf(stderr, ", "); | 1467 fprintf(stderr, ", "); |
1468 } | 1468 } |
1469 ASSERT(!count); | 1469 ASSERT(!count); |
1470 fprintf(stderr, "}"); | 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 ObjectGraph::const_iterator it = graph.find(target); |
| 1476 if (it == graph.end()) |
| 1477 return; |
1475 fprintf(stderr, "Path to %lx of %s\n", target, classOf(reinterpret_cast<
const void*>(target)).ascii().data()); | 1478 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); | |
1477 while (it != graph.end()) { | 1479 while (it != graph.end()) { |
1478 fprintf(stderr, "<- %lx of %s\n", it->value.first, it->value.second.
ascii().data()); | 1480 fprintf(stderr, "<- %lx of %s\n", it->value.first, it->value.second.
utf8().data()); |
1479 it = graph.find(it->value.first); | 1481 it = graph.find(it->value.first); |
1480 } | 1482 } |
1481 fprintf(stderr, "\n"); | 1483 fprintf(stderr, "\n"); |
1482 } | 1484 } |
1483 | 1485 |
1484 static void dumpPathToObjectOnNextGC(void* p) | 1486 static void dumpPathToObjectOnNextGC(void* p) |
1485 { | 1487 { |
1486 objectsToFindPath().add(reinterpret_cast<uintptr_t>(p)); | 1488 objectsToFindPath().add(reinterpret_cast<uintptr_t>(p)); |
1487 } | 1489 } |
1488 | 1490 |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1600 #if ENABLE(GC_TRACING) | 1602 #if ENABLE(GC_TRACING) |
1601 const GCInfo* Heap::findGCInfo(Address address) | 1603 const GCInfo* Heap::findGCInfo(Address address) |
1602 { | 1604 { |
1603 return ThreadState::findGCInfoFromAllThreads(address); | 1605 return ThreadState::findGCInfoFromAllThreads(address); |
1604 } | 1606 } |
1605 | 1607 |
1606 void Heap::dumpPathToObjectOnNextGC(void* p) | 1608 void Heap::dumpPathToObjectOnNextGC(void* p) |
1607 { | 1609 { |
1608 static_cast<MarkingVisitor*>(s_markingVisitor)->dumpPathToObjectOnNextGC(p); | 1610 static_cast<MarkingVisitor*>(s_markingVisitor)->dumpPathToObjectOnNextGC(p); |
1609 } | 1611 } |
| 1612 |
| 1613 String Heap::createBacktraceString() |
| 1614 { |
| 1615 int framesToShow = 3; |
| 1616 int stackFrameSize = 16; |
| 1617 ASSERT(stackFrameSize >= framesToShow); |
| 1618 typedef void* FramePointer; |
| 1619 FramePointer* stackFrame = static_cast<FramePointer*>(alloca(sizeof(FramePoi
nter) * stackFrameSize)); |
| 1620 WTFGetBacktrace(stackFrame, &stackFrameSize); |
| 1621 |
| 1622 StringBuilder builder; |
| 1623 builder.append("Persistent"); |
| 1624 bool didAppendFirstName = false; |
| 1625 // Skip frames before/including "WebCore::Persistent". |
| 1626 bool didSeePersistent = false; |
| 1627 for (int i = 0; i < stackFrameSize && framesToShow > 0; ++i) { |
| 1628 FrameToNameScope frameToName(stackFrame[i]); |
| 1629 if (!frameToName.nullableName()) |
| 1630 continue; |
| 1631 if (strstr(frameToName.nullableName(), "WebCore::Persistent")) { |
| 1632 didSeePersistent = true; |
| 1633 continue; |
| 1634 } |
| 1635 if (!didSeePersistent) |
| 1636 continue; |
| 1637 if (!didAppendFirstName) { |
| 1638 didAppendFirstName = true; |
| 1639 builder.append(" ... Backtrace:"); |
| 1640 } |
| 1641 builder.append("\n\t"); |
| 1642 builder.append(frameToName.nullableName()); |
| 1643 --framesToShow; |
| 1644 } |
| 1645 return builder.toString().replace("WebCore::", ""); |
| 1646 } |
1610 #endif | 1647 #endif |
1611 | 1648 |
1612 void Heap::pushTraceCallback(void* object, TraceCallback callback) | 1649 void Heap::pushTraceCallback(void* object, TraceCallback callback) |
1613 { | 1650 { |
1614 ASSERT(Heap::contains(object)); | 1651 ASSERT(Heap::contains(object)); |
1615 CallbackStack::Item* slot = s_markingStack->allocateEntry(&s_markingStack); | 1652 CallbackStack::Item* slot = s_markingStack->allocateEntry(&s_markingStack); |
1616 *slot = CallbackStack::Item(object, callback); | 1653 *slot = CallbackStack::Item(object, callback); |
1617 } | 1654 } |
1618 | 1655 |
1619 bool Heap::popAndInvokeTraceCallback(Visitor* visitor) | 1656 bool Heap::popAndInvokeTraceCallback(Visitor* visitor) |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1771 template class ThreadHeap<FinalizedHeapObjectHeader>; | 1808 template class ThreadHeap<FinalizedHeapObjectHeader>; |
1772 template class ThreadHeap<HeapObjectHeader>; | 1809 template class ThreadHeap<HeapObjectHeader>; |
1773 | 1810 |
1774 Visitor* Heap::s_markingVisitor; | 1811 Visitor* Heap::s_markingVisitor; |
1775 CallbackStack* Heap::s_markingStack; | 1812 CallbackStack* Heap::s_markingStack; |
1776 CallbackStack* Heap::s_weakCallbackStack; | 1813 CallbackStack* Heap::s_weakCallbackStack; |
1777 HeapDoesNotContainCache* Heap::s_heapDoesNotContainCache; | 1814 HeapDoesNotContainCache* Heap::s_heapDoesNotContainCache; |
1778 bool Heap::s_shutdownCalled = false; | 1815 bool Heap::s_shutdownCalled = false; |
1779 bool Heap::s_lastGCWasConservative = false; | 1816 bool Heap::s_lastGCWasConservative = false; |
1780 } | 1817 } |
OLD | NEW |