Add memory scribbling back in.
authorErik Verbruggen <erik.verbruggen@me.com>
Tue, 5 Feb 2013 21:47:10 +0000 (22:47 +0100)
committerLars Knoll <lars.knoll@digia.com>
Wed, 6 Feb 2013 07:50:11 +0000 (08:50 +0100)
Disabled by default, turn on by setting the env. var. MM_SCRIBBLE.

Change-Id: I616f48976d7f0541390dd1920efc69e294c5056e
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
src/v4/qv4mm.cpp
src/v4/qv4mm.h

index d12388a..8e85001 100644 (file)
@@ -79,7 +79,7 @@ struct MemoryManager::Data
     {
         memset(smallItems, 0, sizeof(smallItems));
         memset(nChunks, 0, sizeof(nChunks));
-        scribble = qgetenv("MM_NO_SCRIBBLE").isEmpty();
+        scribble = !qgetenv("MM_SCRIBBLE").isEmpty();
         aggressiveGC = !qgetenv("MM_AGGRESSIVE_GC").isEmpty();
     }
 
@@ -167,11 +167,9 @@ Managed *MemoryManager::alloc(std::size_t size)
     return m;
 }
 
-void MemoryManager::scribble(Managed *obj, int c, int size) const
-{
-    if (m_d->scribble)
+#define SCRIBBLE(obj, c, size) \
+    if (m_d->scribble) \
         ::memset((void *)(obj + 1), c, size - sizeof(Managed));
-}
 
 void MemoryManager::mark()
 {
@@ -222,7 +220,7 @@ std::size_t MemoryManager::sweep(char *chunkStart, std::size_t chunkSize, size_t
 
                 m->nextFree = *f;
                 f = &m->nextFree;
-                //scribble(m, 0x99, size);
+                SCRIBBLE(m, 0x99, size);
                 ++freedCount;
             }
         }
index 2abc1b4..3ee914e 100644 (file)
@@ -105,8 +105,6 @@ protected:
     // TODO: try to inline
     Managed *alloc(std::size_t size);
 
-    void scribble(Managed *obj, int c, int size) const;
-
     ExecutionEngine *engine() const;
 
 #ifdef DETAILED_MM_STATS