Two fixes in GCTests.cpp: extend the stack a bit more so the tests pass in debug mode on MacIntel; fix RunGCTests to compile in non-MMGC_THREADSAFE builds.
authorjorendorff@mozilla.com
Mon, 10 Dec 2007 14:06:33 -0600
changeset 21 ed155007d2cd37876539f30bb6e2d35b34f80b94
parent 18 964b0d139a110b363e3eba3d08426300b59ed477
child 22 0ca31a2285356f7802d7a2ecda77ba7591f833cc
child 23 debe472d7df5aa7e8322d101564a9d1ca6387913
push id1
push userbsmedberg@mozilla.com
push dateMon, 21 Apr 2008 01:54:18 +0000
Two fixes in GCTests.cpp: extend the stack a bit more so the tests pass in debug mode on MacIntel; fix RunGCTests to compile in non-MMGC_THREADSAFE builds.
mmgc-threadsafe-gctests
--- a/mmgc-threadsafe-gctests
+++ b/mmgc-threadsafe-gctests
@@ -12,16 +12,30 @@ diff --git a/MMgc/GCTests.cpp b/MMgc/GCT
 +#else
 +		gc->Collect();
 +#endif
 +	}
 +
  	GCWeakRef* createWeakRef(int extra = 0)
  	{
  		// Bogusly use up some extra stack.
+@@ -65,11 +74,11 @@ namespace MMgc
+ 		// pointer there causes the temporary to be marked, and not collected,
+ 		// which causes tests to fail with assertions.
+ 		///
+-		// The extra 32 bytes here causes the temporary to end up higher on
++		// The extra 64 bytes here causes the temporary to end up higher on
+ 		// the stack (numerically lesser address, on Intel at least) where
+ 		// CleanStack will clobber it.
+ 		//
+-		char buf[32];
++		char buf[64];
+ 		sprintf(buf, "%d", extra);  // don't optimize away buf
+ 
+ 		return (new (gc, extra) GCObject())->GetWeakRef();
 @@ -78,9 +87,9 @@ namespace MMgc
  	void weakRefSweepSmall()
  	{
  		GCWeakRef *ref = createWeakRef();
 -		gc->Collect();
 +		collect();
  		gc->CleanStack(true);
 -		gc->Collect();
@@ -36,22 +50,26 @@ diff --git a/MMgc/GCTests.cpp b/MMgc/GCT
 -		gc->Collect();
 +		collect();
  		gc->CleanStack(true);
 -		gc->Collect();
 +		collect();
  		(void)ref;
  		GCAssert(ref->get() == NULL);
  	}
-@@ -166,11 +175,13 @@ namespace MMgc
+@@ -166,11 +175,17 @@ namespace MMgc
  	void RunGCTests(GC *g)
  	{
  		gc = g;
-+		gc->OnEnterRequest();
++#ifdef MMGC_THREADSAFE
++		g->OnEnterRequest();
++#endif
  		weakRefSweepSmall();
  		weakRefSweepLarge();
  		weakRefFreeSmall();
  		weakRefFreeLarge();
  		drcApolloTest();
-+		gc->OnLeaveRequest();
++#ifdef MMGC_THREADSAFE
++		g->OnLeaveRequest();
++#endif
  	}
  }