Showing the changes to libraries/script-engine/src/v8/ScriptEngineV8.cpp (1 of 6 files). Show all
Unified · Split
| @@ -42,6 +42,8 @@ · 41 unmodified lines | |||
| 42 | 42 | ||
| 43 | #include <Profile.h> | 43 | #include <Profile.h> |
| 44 | 44 | ||
| 45 | #include <v8-profiler.h> | ||
| 46 | |||
| 45 | #include "../ScriptEngineLogging.h" | 47 | #include "../ScriptEngineLogging.h" |
| 46 | #include "../ScriptProgram.h" | 48 | #include "../ScriptProgram.h" |
| 47 | #include "../ScriptValue.h" | 49 | #include "../ScriptValue.h" |
| @@ -282,7 +284,11 @@ ScriptEngineV8::ScriptEngineV8(ScriptManager *manager) : ScriptEngine(manager), · 234 unmodified lines | |||
| 282 | // --assert-types | 284 | // --assert-types |
| 283 | 285 | ||
| 284 | v8::V8::InitializeICU(); | 286 | v8::V8::InitializeICU(); |
| 285 | v8::V8::SetFlagsFromString("--stack-size=256 --verify-heap --assert-types"); | 287 | #ifdef OVERTE_V8_MEMORY_DEBUG |
| 288 | v8::V8::SetFlagsFromString("--stack-size=256 --track_gc_object_stats --assert-types"); | ||
| 289 | #else | ||
| 290 | v8::V8::SetFlagsFromString("--stack-size=256"); | ||
| 291 | #endif | ||
| 286 | //v8::V8::SetFlagsFromString("--stack-size=256 --single-threaded"); | 292 | //v8::V8::SetFlagsFromString("--stack-size=256 --single-threaded"); |
| 287 | v8::Platform* platform = getV8Platform(); | 293 | v8::Platform* platform = getV8Platform(); |
| 288 | v8::V8::InitializePlatform(platform); | 294 | v8::V8::InitializePlatform(platform); |
| @@ -1720,10 +1726,31 @@ ScriptEngineMemoryStatistics ScriptEngineV8::getMemoryUsageStatistics() { · 1431 unmodified lines | |||
| 1720 | statistics.totalAvailableSize = heapStatistics.total_available_size(); | 1726 | statistics.totalAvailableSize = heapStatistics.total_available_size(); |
| 1721 | statistics.totalGlobalHandlesSize = heapStatistics.total_global_handles_size(); | 1727 | statistics.totalGlobalHandlesSize = heapStatistics.total_global_handles_size(); |
| 1722 | statistics.usedGlobalHandlesSize = heapStatistics.used_global_handles_size(); | 1728 | statistics.usedGlobalHandlesSize = heapStatistics.used_global_handles_size(); |
| 1723 | #ifdef OVERTE_V8_HANDLE_COUNTERS | 1729 | #ifdef OVERTE_V8_MEMORY_DEBUG |
| 1724 | statistics.scriptValueCount = scriptValueCount; | 1730 | statistics.scriptValueCount = scriptValueCount; |
| 1725 | statistics.scriptValueProxyCount = scriptValueProxyCount; | 1731 | statistics.scriptValueProxyCount = scriptValueProxyCount; |
| 1726 | #endif | 1732 | #endif |
| 1727 | |||
| 1728 | return statistics; | 1733 | return statistics; |
| 1729 | } | 1734 | } |
| 1735 | |||
| 1736 | void ScriptEngineV8::startCollectingObjectStatistics() { | ||
| 1737 | auto heapProfiler = _v8Isolate->GetHeapProfiler(); | ||
| 1738 | heapProfiler->StartTrackingHeapObjects(); | ||
| 1739 | } | ||
| 1740 | |||
| 1741 | void ScriptEngineV8::dumpHeapObjectStatistics() { | ||
| 1742 | // V8TODO: this is not very elegant, but very convenient | ||
| 1743 | QFile dumpFile("/tmp/heap_objectStatistics_dump.csv"); | ||
| 1744 | if (!dumpFile.open(QFile::WriteOnly | QFile::Truncate)) { | ||
| 1745 | return; | ||
| 1746 | } | ||
| 1747 | QTextStream dump(&dumpFile); | ||
| 1748 | size_t objectTypeCount = _v8Isolate->NumberOfTrackedHeapObjectTypes(); | ||
| 1749 | for (size_t i = 0; i < objectTypeCount; i++) { | ||
| 1750 | v8::HeapObjectStatistics statistics; | ||
| 1751 | if (_v8Isolate->GetHeapObjectStatisticsAtLastGC(&statistics, i)) { | ||
| 1752 | dump << statistics.object_type() << " " << statistics.object_sub_type() << " " << statistics.object_count() << " " | ||
| 1753 | << statistics.object_size() << "\n"; | ||
| 1754 | } | ||
| 1755 | } | ||
| 1756 | } | ||