Initial changes against actionmonkey from my mac tree
authorbenjamin@smedbergs.us
Mon, 22 Oct 2007 11:02:55 -0400
changeset 1 c592a6ff3526ed20d1d151d3d7ffa77966d295cf
child 2 8b0ebf10667ee784780547bc06319abb3b2682c2
push id1
push userbsmedberg@mozilla.com
push dateMon, 21 Apr 2008 01:54:18 +0000
Initial changes against actionmonkey from my mac tree
finalized-base.patch
mmgc-threasafe-build.patch
series
new file mode 100644
--- /dev/null
+++ b/finalized-base.patch
@@ -0,0 +1,136 @@
+diff --git a/MMgc/GC.cpp b/MMgc/GC.cpp
+--- a/MMgc/GC.cpp
++++ b/MMgc/GC.cpp
+@@ -1201,7 +1201,7 @@ bail:
+ 				cb = cb->nextCB;
+ 			}
+ 			if(gc->IsFinalized(obj))
+-				((GCFinalizedObject*)obj)->~GCFinalizedObject();
++				((GCFinalizedBase*)obj)->~GCFinalizedBase();
+ 			gc->Free(obj);
+ 			return;
+ 		}
+@@ -1441,7 +1441,7 @@ bail:
+ 
+ 				GCAssert(*(int*)rcobj != 0);
+ 				GCAssert(gc->IsFinalized(rcobj));
+-				((GCFinalizedObject*)rcobj)->~GCFinalizedObject();
++				((GCFinalizedBase*)rcobj)->~GCFinalizedBase();
+ #ifdef DEBUGGER
+ 				numObjects++;
+ 				objSize += GC::Size(rcobj);
+diff --git a/MMgc/GC.h b/MMgc/GC.h
+--- a/MMgc/GC.h
++++ b/MMgc/GC.h
+@@ -896,6 +896,7 @@ namespace MMgc
+ 
+ 		bool Destroying() { return destroying; }
+ 
++		static GCWeakRef *GetWeakRef(const void *obj);
+ 		void ClearWeakRef(const void *obj);
+ 
+ 		uintptr	GetStackTop() const;		
+@@ -924,9 +925,6 @@ namespace MMgc
+ 		uint32 *m_bitsNext;
+ 
+ 		GCHashtable weakRefs;
+-		friend class GCObject;
+-		friend class GCFinalizedObject;
+-		static GCWeakRef *GetWeakRef(const void *obj);
+ 
+ 		bool destroying;
+ 
+diff --git a/MMgc/GCAlloc.cpp b/MMgc/GCAlloc.cpp
+--- a/MMgc/GCAlloc.cpp
++++ b/MMgc/GCAlloc.cpp
+@@ -428,9 +428,9 @@ start:
+ 
+ 					if (marks & kFinalize)
+ 					{     
+-						GCFinalizedObject *obj = (GCFinalizedObject*)GetUserPointer(item);
++						GCFinalizedBase *obj = (GCFinalizedObject*)GetUserPointer(item);
+ 						GCAssert(*(int*)obj != 0);
+-						obj->~GCFinalizedObject();
++						obj->~GCFinalizedBase();
+ 
+ 						bits[i] &= ~(kFinalize<<(j*4));
+ 
+diff --git a/MMgc/GCLargeAlloc.cpp b/MMgc/GCLargeAlloc.cpp
+--- a/MMgc/GCLargeAlloc.cpp
++++ b/MMgc/GCLargeAlloc.cpp
+@@ -127,9 +127,9 @@ namespace MMgc
+ 			if ((b->flags & kMarkFlag) == 0) {
+ 				void *item = b+1;
+ 				if (NeedsFinalize(b)) {
+-					GCFinalizedObject *obj = (GCFinalizedObject *) item;
+-					obj = (GCFinalizedObject *) GetUserPointer(obj);
+-					obj->~GCFinalizedObject();
++					GCFinalizedBase *obj = (GCFinalizedBase *) item;
++					obj = (GCFinalizedBase *) GetUserPointer(obj);
++					obj->~GCFinalizedBase();
+ #if defined(_DEBUG) && defined(MMGC_DRC)
+ 					if((b->flags & kRCObject) != 0) {
+ 						b->gc->RCObjectZeroCheck((RCObject*)obj);
+diff --git a/MMgc/GCObject.h b/MMgc/GCObject.h
+--- a/MMgc/GCObject.h
++++ b/MMgc/GCObject.h
+@@ -65,16 +65,6 @@ namespace MMgc
+ namespace MMgc
+ {
+ 	/**
+-	 *
+-	 */
+-	class GCCustomSizer
+-	{
+-	public:
+-		virtual ~GCCustomSizer() {} // here since gcc complains otherwise
+-		virtual size_t Size() = 0;
+-	};
+-
+-	/**
+ 	 * Baseclass for GC managed objects that aren't finalized
+ 	 */
+ 	class MMGC_API GCObject
+@@ -108,16 +98,15 @@ namespace MMgc
+ 	};
+ 
+ 	/**
+-	 *	Baseclass for GC managed objects that are finalized 
++	 * Base class for GC-managed objects that are finalized
++	 * @note This class does not provider operator new/delete: derive from GCFinalizedObject
++	 *       or GCFinalizedObjectOptIn to provide correct handling of "new Class"
+ 	 */
+-	class MMGC_API GCFinalizedObject
+-	//: public GCObject can't do this, get weird compile errors in AVM plus, I think it has to do with
+-	// the most base class (GCObject) not having any virtual methods)
+-	{
+-	public:
+-		virtual ~GCFinalizedObject() {}
+-		GCWeakRef *GetWeakRef() const;
+-
++	class MMGC_API GCFinalizedBase
++	{
++	public:
++		virtual ~GCFinalizedBase() { }
++	
+ 		/**
+ 		 * A hook allowing objects to participate in the Mark phase
+ 		 * of garbage collection.  It is called only if the object
+@@ -135,6 +124,17 @@ namespace MMgc
+ 		 * nothing and returns false.
+ 		 */
+ 		virtual bool CustomMark() { return false; }
++	};
++
++	/**
++	 *	Baseclass for GC managed objects that are finalized 
++	 */
++	class MMGC_API GCFinalizedObject : public GCFinalizedBase
++	//: public GCObject can't do this, get weird compile errors in AVM plus, I think it has to do with
++	// the most base class (GCObject) not having any virtual methods)
++	{
++	public:
++		GCWeakRef *GetWeakRef() const;
+ 
+ 		static void *operator new(size_t size, GC *gc, size_t extra = 0);
+ 		static void operator delete (void *gcObject);
new file mode 100644
--- /dev/null
+++ b/mmgc-threasafe-build.patch
@@ -0,0 +1,69 @@
+diff --git a/configure.py b/configure.py
+--- a/configure.py
++++ b/configure.py
+@@ -71,15 +71,28 @@ DEBUG_CXXFLAGS = ""
+ DEBUG_CXXFLAGS = ""
+ DEBUG_LDFLAGS = ""
+ OS_LIBS = []
++OS_LDFLAGS = ""
+ MMGC_CPPFLAGS = ""
+ AVMSHELL_CPPFLAGS = ""
+ AVMSHELL_LDFLAGS = ""
+ MMGC_DEFINES = {'SOFT_ASSERTS': None}
++NSPR_INCLUDES=""
++NSPR_LDOPTS=""
+ 
+ MMGC_DYNAMIC = o.getBoolArg('mmgc-shared', False)
+ if MMGC_DYNAMIC:
+     MMGC_DEFINES['MMGC_DLL'] = None
+     MMGC_CPPFLAGS += "-DMMGC_IMPL "
++
++MMGC_THREADSAFE = o.getBoolArg('threadsafe-mmgc', False)
++if MMGC_THREADSAFE:
++    MMGC_DEFINES['MMGC_THREADSAFE'] = None
++    NSPR_INCLUDES = o.getStringArg('nspr-includes')
++    MMGC_CPPFLAGS += NSPR_INCLUDES + " "
++    APP_CPPFLAGS += NSPR_INCLUDES + " "
++
++    NSPR_LDOPTS = o.getStringArg('nspr-ldopts')
++    OS_LDFLAGS += " " + NSPR_LDOPTS
+ 
+ if config.COMPILER_IS_GCC:
+     APP_CXXFLAGS = "-fno-exceptions -Werror -Wall -Wno-reorder -Wno-switch -Wno-invalid-offsetof -Wno-uninitialized -Wno-strict-aliasing -fmessage-length=0 -finline-functions -finline-limit=65536 "
+@@ -178,6 +191,7 @@ config.subst("DEBUG_CXXFLAGS", DEBUG_CXX
+ config.subst("DEBUG_CXXFLAGS", DEBUG_CXXFLAGS)
+ config.subst("DEBUG_LDFLAGS", DEBUG_LDFLAGS)
+ config.subst("OS_LIBS", " ".join(OS_LIBS))
++config.subst("OS_LDFLAGS", OS_LDFLAGS)
+ config.subst("MMGC_CPPFLAGS", MMGC_CPPFLAGS)
+ config.subst("AVMSHELL_CPPFLAGS", AVMSHELL_CPPFLAGS)
+ config.subst("AVMSHELL_LDFLAGS", AVMSHELL_LDFLAGS)
+diff --git a/pcre/config.h b/pcre/config.h
+--- a/pcre/config.h
++++ b/pcre/config.h
+@@ -40,7 +40,9 @@ them both to 0; an emulation function wi
+ #define HAVE_LIMITS_H 1
+ 
+ /* Define to 1 if the system has the type `long long'. */
++#ifndef HAVE_LONG_LONG
+ #define HAVE_LONG_LONG 1
++#endif
+ 
+ /* Define to 1 if you have the `memmove' function. */
+ #define HAVE_MEMMOVE 1
+diff --git a/shell/avmshell.h b/shell/avmshell.h
+--- a/shell/avmshell.h
++++ b/shell/avmshell.h
+@@ -48,6 +48,12 @@
+ // #define AVMPLUS_INTERACTIVE
+ 
+ using namespace avmplus;
++
++// avmplus and NSPR both typedef some basic types: we must disambiguate
++using avmplus::uint64;
++using avmplus::uint32;
++using avmplus::uint16;
++using avmplus::uint8;
+ 
+ namespace avmshell
+ {
new file mode 100644
--- /dev/null
+++ b/series
@@ -0,0 +1,2 @@
+mmgc-threasafe-build.patch
+finalized-base.patch