Add logging when executable code gets deallocated
authorfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 28 Jul 2015 16:58:08 +0000 (16:58 +0000)
committerfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 28 Jul 2015 16:58:08 +0000 (16:58 +0000)
https://bugs.webkit.org/show_bug.cgi?id=147355

Reviewed by Mark Lam.

Source/JavaScriptCore:

* ftl/FTLJITCode.cpp:
(JSC::FTL::JITCode::~JITCode): Print something when this is freed.
* jit/JITCode.cpp:
(JSC::JITCodeWithCodeRef::~JITCodeWithCodeRef): Print something when this is freed.

Source/WTF:

* wtf/MetaAllocator.cpp:
(WTF::MetaAllocatorHandle::dump): It's useful to be able to dump these.
* wtf/MetaAllocatorHandle.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@187488 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/ftl/FTLJITCode.cpp
Source/JavaScriptCore/jit/JITCode.cpp
Source/WTF/ChangeLog
Source/WTF/wtf/MetaAllocator.cpp
Source/WTF/wtf/MetaAllocatorHandle.h

index 91d9acc..474a3a0 100644 (file)
@@ -1,5 +1,17 @@
 2015-07-27  Filip Pizlo  <fpizlo@apple.com>
 
+        Add logging when executable code gets deallocated
+        https://bugs.webkit.org/show_bug.cgi?id=147355
+
+        Reviewed by Mark Lam.
+
+        * ftl/FTLJITCode.cpp:
+        (JSC::FTL::JITCode::~JITCode): Print something when this is freed.
+        * jit/JITCode.cpp:
+        (JSC::JITCodeWithCodeRef::~JITCodeWithCodeRef): Print something when this is freed.
+
+2015-07-27  Filip Pizlo  <fpizlo@apple.com>
+
         DFG::safeToExecute() cases for GetByOffset/PutByOffset don't handle clobbered structure abstract values correctly
         https://bugs.webkit.org/show_bug.cgi?id=147354
 
index 6120f05..66d38de 100644 (file)
@@ -28,6 +28,8 @@
 
 #if ENABLE(FTL_JIT)
 
+#include "FTLState.h"
+
 namespace JSC { namespace FTL {
 
 JITCode::JITCode()
@@ -37,6 +39,15 @@ JITCode::JITCode()
 
 JITCode::~JITCode()
 {
+    if (FTL::shouldShowDisassembly()) {
+        dataLog("Destroying FTL JIT code at ");
+        CommaPrinter comma;
+        for (auto& handle : m_handles)
+            dataLog(comma, pointerDump(handle.get()));
+        dataLog(comma, pointerDump(m_arityCheckEntrypoint.executableMemory()));
+        dataLog(comma, pointerDump(m_exitThunks.executableMemory()));
+        dataLog("\n");
+    }
 }
 
 void JITCode::initializeExitThunks(CodeRef exitThunks)
index e86b5c3..5310b5d 100644 (file)
@@ -119,6 +119,9 @@ JITCodeWithCodeRef::JITCodeWithCodeRef(CodeRef ref, JITType jitType)
 
 JITCodeWithCodeRef::~JITCodeWithCodeRef()
 {
+    if ((Options::showDisassembly() || (isOptimizingJIT(jitType()) && Options::showDFGDisassembly()))
+        && m_ref.executableMemory())
+        dataLog("Destroying JIT code at ", pointerDump(m_ref.executableMemory()), "\n");
 }
 
 void* JITCodeWithCodeRef::executableAddressAtOffset(size_t offset)
index b1c30bd..0f0e775 100644 (file)
@@ -1,3 +1,14 @@
+2015-07-27  Filip Pizlo  <fpizlo@apple.com>
+
+        Add logging when executable code gets deallocated
+        https://bugs.webkit.org/show_bug.cgi?id=147355
+
+        Reviewed by Mark Lam.
+
+        * wtf/MetaAllocator.cpp:
+        (WTF::MetaAllocatorHandle::dump): It's useful to be able to dump these.
+        * wtf/MetaAllocatorHandle.h:
+
 2015-07-28  Benjamin Poulain  <bpoulain@apple.com>
 
         Speed up StringBuilder::appendQuotedJSONString()
index 1e740ee..4408572 100644 (file)
@@ -113,6 +113,11 @@ void MetaAllocatorHandle::shrink(size_t newSizeInBytes)
     m_sizeInBytes = newSizeInBytes;
 }
 
+void MetaAllocatorHandle::dump(PrintStream& out) const
+{
+    out.print(RawPointer(start()), "...", RawPointer(end()));
+}
+
 MetaAllocator::MetaAllocator(size_t allocationGranule, size_t pageSize)
     : m_allocationGranule(allocationGranule)
     , m_pageSize(pageSize)
index 6713251..7f4888b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2011, 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2011, 2013, 2015 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -37,6 +37,7 @@
 namespace WTF {
 
 class MetaAllocator;
+class PrintStream;
 
 class MetaAllocatorHandle : public ThreadSafeRefCounted<MetaAllocatorHandle>, public RedBlackTree<MetaAllocatorHandle, void*>::Node {
 private:
@@ -102,6 +103,8 @@ public:
     {
         return m_start;
     }
+
+    void dump(PrintStream& out) const;
     
 private:
     friend class MetaAllocator;