New patches for GC stack sanity and access.
authorbenjamin@smedbergs.us
Tue, 20 Nov 2007 17:08:51 -0500
changeset 4 2696e7fd59fb342037a49d4823cb86606b2d3fc7
parent 3 942335ad5ee9e1c0c52d9a0472ac3f4180d16ed7
child 5 399ff94b3d77e32c0b43ba646ea5ebc54f86589d
push id1
push userbsmedberg@mozilla.com
push dateMon, 21 Apr 2008 01:54:18 +0000
New patches for GC stack sanity and access.
alloc-backtrace
const-workitem.patch
gcstack-access
series
new file mode 100644
--- /dev/null
+++ b/alloc-backtrace
@@ -0,0 +1,28 @@
+--- a/MMgc/GC.cpp
++++ b/MMgc/GC.cpp
+@@ -95,6 +96,8 @@
+ #include <sys/stack.h>
+ extern "C" greg_t _getsp(void);
+ #endif
++
++#include <execinfo.h>
+ 
+ #if defined(_MSC_VER) && defined(_DEBUG)
+ // we turn on exceptions in DEBUG builds
+--- a/MMgc/GC.cpp
++++ b/MMgc/GC.cpp
+@@ -568,6 +575,14 @@ namespace MMgc
+ 			memset(item, 0, Size(item));
+ 		}
+ #endif
++		static FILE* logf = fdopen(3, "a");
++
++		fprintf(logf, "GC::Alloc(%i, %x, %i) = %p\n",
++			(int) size, flags, skip, item);
++		fflush(logf);
++		void *btbuf[10];
++		int btsize = backtrace(btbuf, 10);
++		backtrace_symbols_fd(btbuf, btsize, 3);
+ 
+ 		return item;
+ 	}
new file mode 100644
--- /dev/null
+++ b/const-workitem.patch
@@ -0,0 +1,45 @@
+diff --git a/MMgc/GC.cpp b/MMgc/GC.cpp
+--- a/MMgc/GC.cpp
++++ b/MMgc/GC.cpp
+@@ -2730,7 +2730,7 @@ bail:
+ 		}
+ 	}
+ 
+-	void GC::PushWorkItem(GCStack<GCWorkItem> &stack, GCWorkItem item)
++	void GC::PushWorkItem(GCStack<GCWorkItem> &stack, const GCWorkItem item)
+ 	{
+ 		if(item.ptr) {
+ 			stack.Push(item);
+diff --git a/MMgc/GC.h b/MMgc/GC.h
+--- a/MMgc/GC.h
++++ b/MMgc/GC.h
+@@ -289,7 +289,7 @@ namespace MMgc
+ 		 * only from lastmark().
+ 		 */
+ 		void PushWorkItem(GCStack<GCWorkItem>& work,
+-		                  GCWorkItem item);
++		                  const GCWorkItem item);
+ 
+ 		/**
+ 		 * Mark all gray nodes, recursively, until none are
+@@ -1093,7 +1093,7 @@ private:
+ 
+ 		void CheckThread();
+ 
+-		void PushWorkItem(GCStack<GCWorkItem> &stack, GCWorkItem item);
++		void PushWorkItem(GCStack<GCWorkItem> &stack, const GCWorkItem item);
+ 
+ #ifdef DEBUGGER
+ 		// sent for Collect (fullgc)
+diff --git a/MMgc/GCStack.h b/MMgc/GCStack.h
+--- a/MMgc/GCStack.h
++++ b/MMgc/GCStack.h
+@@ -64,7 +64,7 @@ namespace MMgc
+ 			m_iCount = m_iAllocSize = 0;
+ 		}
+ 
+-		void Push(T item)
++		void Push(const T item)
+ 		{
+ 			if ( ( m_iCount + 1 ) > m_iAllocSize ) 
+ 			{
new file mode 100644
--- /dev/null
+++ b/gcstack-access
@@ -0,0 +1,57 @@
+diff --git a/MMgc/GC.cpp b/MMgc/GC.cpp
+--- a/MMgc/GC.cpp
++++ b/MMgc/GC.cpp
+@@ -1,3 +1,4 @@
++/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+ /* ***** BEGIN LICENSE BLOCK *****
+  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+  *
+@@ -458,6 +459,8 @@ namespace MMgc
+ 		SAMPLE_CHECK();
+ 
+ 		GCStack<GCWorkItem> work;
++
++		m_currentQueue = &work;
+ 		{
+ #ifdef GCHEAP_LOCK
+ 			GCAcquireSpinlock lock(m_rootListLock);
+@@ -484,6 +487,8 @@ namespace MMgc
+ 			Mark(work);
+ 		}
+ 		
++		m_currentQueue = NULL;
++
+ 		SAMPLE_CHECK();
+ 	}
+ 
+@@ -2376,6 +2381,8 @@ bail:
+ 			return;
+ 		} 
+ 
++		m_currentQueue = &m_incrementalWork;
++
+ #ifdef DEBUGGER
+ 		StartGCActivity();
+ #endif
+@@ -2409,6 +2416,8 @@ bail:
+ 
+ 		lastMarkTicks = GetPerformanceCounter();
+ 		markTicks += lastMarkTicks - start;
++
++		m_currentQueue = NULL;
+ 
+ #ifdef DEBUGGER
+ 		if(GC::gcstats) {
+diff --git a/MMgc/GC.h b/MMgc/GC.h
+--- a/MMgc/GC.h
++++ b/MMgc/GC.h
+@@ -549,6 +549,9 @@ namespace MMgc
+ 
+ 		bool incremental;
+ 
++		// This member is only available during tracing
++		GCStack<GCWorkItem> *m_currentQueue;
++
+ 		// -- Interface
+ 		GC(GCHeap *heap);
+ 		virtual ~GC();
--- a/series
+++ b/series
@@ -1,4 +1,7 @@
 mmgc-threasafe-build.patch
 finalized-base.patch
 explicit-namespaces.patch
 x86-64
+const-workitem.patch
+gcstack-access
+alloc-backtrace