tamarin-gcstack-access
author Benjamin Smedberg <benjamin@smedbergs.us>
Sat, 26 Jul 2008 22:49:39 -0400
changeset 167 a4da40849f5436e629c5732f4368c6c48189637f
parent 154 7b66eb66ba95f04cfa2392550b012262466a1275
permissions -rw-r--r--
State as of now

* * *

diff --git a/js/tamarin/MMgc/GC.cpp b/js/tamarin/MMgc/GC.cpp
--- a/js/tamarin/MMgc/GC.cpp
+++ b/js/tamarin/MMgc/GC.cpp
@@ -596,6 +596,8 @@ namespace MMgc
 		SAMPLE_CHECK();
 
 		GCStack<GCWorkItem> work;
+
+		m_currentQueue = &work;
 		{
 #ifdef GCHEAP_LOCK
 			GCAcquireSpinlock lock(m_rootListLock);
@@ -622,6 +624,8 @@ namespace MMgc
 			Mark(work);
 		}
 		
+		m_currentQueue = NULL;
+
 		SAMPLE_CHECK();
 	}
 #endif
@@ -2263,12 +2267,16 @@ bail:
 #ifdef GCHEAP_LOCK
 			GCAcquireSpinlock lock(m_rootListLock);
 #endif
+			m_currentQueue = &m_incrementalWork;
+
 			GCRoot *r = m_roots;
 			while(r) {
 				GCWorkItem item = r->GetWorkItem();
 				MarkItem(item, m_incrementalWork);
 				r = r->next;
 			}
+
+			m_currentQueue = NULL;
 		}
 		markTicks += GetPerformanceCounter() - start;
 		IncrementalMark();
@@ -2633,6 +2641,8 @@ bail:
 			return;
 		} 
 
+		m_currentQueue = &m_incrementalWork;
+
 #ifdef DEBUGGER
 		StartGCActivity();
 #endif
@@ -2667,6 +2677,8 @@ bail:
 		lastMarkTicks = GetPerformanceCounter();
 		markTicks += lastMarkTicks - start;
 
+		m_currentQueue = NULL;
+
 #ifdef DEBUGGER
 		if(GC::gcstats) {
 			double millis = duration(start);
@@ -2695,6 +2707,8 @@ bail:
 		// finished in Sweep
 		sweepStart = GetPerformanceCounter();
 		
+		m_currentQueue = &m_incrementalWork;
+
 		// mark roots again, could have changed (alternative is to put WB's on the roots
 		// which we may need to do if we find FinishIncrementalMark taking too long)
 		
@@ -2718,6 +2732,8 @@ bail:
 			cb->lastmark(m_incrementalWork);
 
 		MarkQueueAndStack(m_incrementalWork);
+
+		m_currentQueue = NULL;
 
 #ifdef _DEBUG
 		// need to traverse all marked objects and make sure they don't contain
diff --git a/js/tamarin/MMgc/GC.h b/js/tamarin/MMgc/GC.h
--- a/js/tamarin/MMgc/GC.h
+++ b/js/tamarin/MMgc/GC.h
@@ -648,6 +648,9 @@ namespace MMgc
 		 */
 		bool incremental;
 
+		// This member is only available during tracing
+		GCStack<GCWorkItem> *m_currentQueue;
+
 		// -- Interface
 		GC(GCHeap *heap);
 		virtual ~GC();
@@ -1141,8 +1144,7 @@ namespace MMgc
 
 		uintptr	GetStackTop() const;
 
-		// for deciding a tree of things should be scanned from presweep
-		void PushWorkItem(const GCWorkItem &item) { PushWorkItem(m_incrementalWork, item); }
+		void PushWorkItem(const GCWorkItem &item) { PushWorkItem(*m_currentQueue, item); }
 
 	private: