Bug 757375: Concurrency updates, bug fixes (r=jasowill,p=dtomatck)
authorDan Schaffer <Dan.Schaffer@adobe.com>
Thu, 11 Oct 2012 08:37:39 -0700
changeset 7565 e7e08ab8fc7650e6cb4d83d326bc51bf15e8716a
parent 7564 f5191c18b0e4f3138931857a6c6fb666f8bb2824
child 7566 40afc58cab030f342bd054541720efcb9463a2fa
push id4262
push userdschaffe@adobe.com
push dateWed, 30 Jan 2013 19:01:31 +0000
reviewersjasowill
bugs757375, 1123698, 1124123
Bug 757375: Concurrency updates, bug fixes (r=jasowill,p=dtomatck) Integrate 1123698 CL@1124123
core/AvmCore-inlines.h
core/AvmCore.h
core/ConcurrencyGlue.cpp
core/ConcurrencyGlue.h
core/Isolate.cpp
core/Isolate.h
shell/avmshell.cpp
--- a/core/AvmCore-inlines.h
+++ b/core/AvmCore-inlines.h
@@ -711,22 +711,16 @@ inline void AvmCore::setIsolate(Isolate*
     this->m_isolate = isolate;
 }
 
 REALLY_INLINE Isolate* AvmCore::getIsolate() const
 {
     return m_isolate;
 }
 	
-REALLY_INLINE vmbase::SafepointManager* AvmCore::getSafepointManager ()
-{
-	return getIsolate()->getAggregate()->safepointManager();
-}
-
-
 REALLY_INLINE int AvmCore::getIsolateDesc () const
 {
 	return getIsolate()->getDesc();
 }
 
 template<class CLASSMANIFEST>
 CLASSMANIFEST* AvmCore::prepareBuiltinActionPool(PoolObject* pool,
                                       Toplevel* toplevel,
--- a/core/AvmCore.h
+++ b/core/AvmCore.h
@@ -2161,17 +2161,16 @@ const int kBufferPadding = 16;
     private:
         telemetry::ITelemetry* m_telemetry; // Owned by the AvmCore subclass which calls SetTelemetry
 #endif
 
     public:
         void setIsolate(Isolate* isolate);
         Isolate* getIsolate() const;
         virtual int getIsolateDesc () const;
-		virtual vmbase::SafepointManager* getSafepointManager ();
         virtual int evaluateScriptBuffer(ScriptBuffer& buffer, bool enter_debugger_on_enter);
 
 
         // END methods (private/public intermixed)
         ////////////////////////////////////////////////////////////////////
     };
 
     class Deoptimizer;
--- a/core/ConcurrencyGlue.cpp
+++ b/core/ConcurrencyGlue.cpp
@@ -210,17 +210,17 @@ process_interrupt:
     MutexClass::MutexClass(VTable* cvtable)
         : ClassClosure(cvtable)
     {
         createVanillaPrototype();
     }
 
     bool MutexClass::get_isSupported()
     {
-        return core()->getIsolate() != NULL;
+		return MutexClass::getMutexSupported( toplevel() );
     }
 
     //
     // ConditionObject
     //
 
     ConditionObject::ConditionObject(VTable* cvtable, ScriptObject* delegate) 
         : ScriptObject(cvtable, delegate)
@@ -460,17 +460,17 @@ process_interrupt:
     ConditionClass::ConditionClass(VTable* cvtable)
         : ClassClosure(cvtable)
     {
         createVanillaPrototype();
     }
 
     bool ConditionClass::get_isSupported()
     {
-        return core()->getIsolate() != NULL;
+		return MutexClass::getMutexSupported( toplevel() );
     }
 
     //
     // ConcurrenyMemory
     //
 
     int32_t ConcurrentMemory::casi32(ScriptObject *obj, int32_t addr, int32_t expectedVal, int32_t newVal)
     {
--- a/core/ConcurrencyGlue.h
+++ b/core/ConcurrencyGlue.h
@@ -205,16 +205,20 @@ namespace avmplus {
         Isolate::InterruptibleState m_interruptibleState;
     };
     
     class GC_AS3_EXACT(MutexClass, ClassClosure)
     {
     public:
         MutexClass(VTable* cvtable);
         bool get_isSupported();
+		
+		// implemented per FP/AIR/Shell to determine mutex/condition support
+		static bool getMutexSupported( GCRef<avmplus::Toplevel> toplevel );
+		
     private:
         GC_NO_DATA(MutexClass)
         DECLARE_SLOTS_MutexClass;
     };
 
     
     class GC_AS3_EXACT(ConditionClass, ClassClosure)
     {
--- a/core/Isolate.cpp
+++ b/core/Isolate.cpp
@@ -58,25 +58,29 @@ namespace avmplus
         : m_primordialGiid(Isolate::INVALID_DESC) // eventually there will be many of those
         , m_activeIsolateCount(0)
         , m_inShutdown(false)
         , m_activeIsolateThreadMap(15)
     {}
 
     Aggregate::~Aggregate()
     {
-		if(MMgc::GCHeap::GetGCHeap()->GetStatus() == MMgc::kMemAbort)
-			vmbase::SafepointRecord::cleanupAfterOOM();
     }
 
     void Aggregate::destroy()
     {
         mmfx_delete(this);
     }
     
+    void Aggregate::outOfMemoryShutdown()
+    {
+        requestAggregateExit();
+		vmbase::SafepointRecord::cleanupAfterOOM();
+    }
+
     bool Aggregate::requestIsolateExit(Isolate::descriptor_t desc, Toplevel* currentToplevel)
     {
         bool result = false;
         SCOPE_LOCK_NAMED(locker, m_globals.m_lock) {
             Isolate* isolate = m_globals.getIsolateForID(desc);
             // if the isolate isn't found in the global table terminate 
             // has been called previously, skip the rest.
             if (isolate == NULL) { 
@@ -1067,21 +1071,21 @@ throw_terminated_error:
     EnterSafepointManager::EnterSafepointManager(AvmCore* core)
 	: m_safepointMgr(0)
     {
         Isolate* isolate = core->getIsolate();
         if (isolate) {
 			// hang onto the aggregate during the safepont to ensure it doesn't go away.
 		    m_aggregate = isolate->getAggregate();
 			
-			m_safepointMgr = core->getSafepointManager();
+			m_safepointMgr = m_aggregate->safepointManager();
 			m_spRecord.setLocationAndDesc( (int32_t*)&core->interrupted, core->getIsolateDesc() ); 
-			
-			if (m_safepointMgr)
-				m_safepointMgr->enter(&m_spRecord);
+
+            AvmAssert(m_safepointMgr != NULL);
+			m_safepointMgr->enter(&m_spRecord);
 		}
     }
     
     EnterSafepointManager::~EnterSafepointManager()
     {
         leaveSafepoint();
     }
 
--- a/core/Isolate.h
+++ b/core/Isolate.h
@@ -401,16 +401,17 @@ namespace avmplus
 			void cleanup();
 		};
 		
     public:
         Aggregate();
         virtual ~Aggregate();
         virtual void destroy();
 
+        void outOfMemoryShutdown();
         bool isPrimordial(Isolate::descriptor_t giid) const;
 
         // If parent == NULL, the primordial isolate will be created.
         Isolate* newIsolate(Isolate* parent);
 
         bool spawnIsolateThread(Isolate* isolate);
 
         void initialize(AvmCore* targetCore, Isolate* isolate);
--- a/shell/avmshell.cpp
+++ b/shell/avmshell.cpp
@@ -1381,10 +1381,18 @@ namespace avmplus
     Isolate* Isolate::newIsolate(int32_t desc, int32_t parentDesc, Aggregate* aggregate)
     {
         if (parentDesc == Isolate::INVALID_DESC) {
             return mmfx_new(avmshell::PrimordialShellIsolate(desc, parentDesc, aggregate));
         } else {
             return mmfx_new(avmshell::ShellIsolate(desc, parentDesc, aggregate));
         }
     }
+
+	/*static*/
+	bool MutexClass::getMutexSupported (GCRef<avmplus::Toplevel> toplevel)
+	{
+		AvmAssert(toplevel != NULL);
+		
+		return toplevel->core()->getIsolate() != NULL;;
+	}
 }