Browse Source

scan roots ignore persistent objects. simplify table key equality check.

Greg 14 years ago
parent
commit
f19598516b
3 changed files with 22 additions and 25 deletions
  1. 3 0
      gmsrc/doc/ChangeLog.txt
  2. 7 0
      gmsrc/src/gm/gmIncGC.cpp
  3. 12 25
      gmsrc/src/gm/gmTableObject.cpp

+ 3 - 0
gmsrc/doc/ChangeLog.txt

@@ -385,3 +385,6 @@ o Fixed GC root scan.
 o Increased GMTHREAD_MAXBYTESIZE to allow samples to run in 64bit
 o Fixed gmTable 64bit gmVariable equality test.
 o Fixed byte code generator. 64bit was mixing 32 and 64 bit patched addresses.
+
+3/10/11
+o Fixed GC root scan to ignore persistent objects.

+ 7 - 0
gmsrc/src/gm/gmIncGC.cpp

@@ -240,6 +240,13 @@ void gmGCColorSet::GrayThisRootObject(gmGCObjBase* a_obj)
   // it is convenient to force roots to gray from whatever logical state they are in.
   // This is due to GC design choices including: atomic root snapshot, write barrier and allocate black.
 
+#if  GM_GC_KEEP_PERSISTANT_SEPARATE
+  if(a_obj->GetPersist()) // Don't do anything with persistant objects
+  {
+    return;
+  }
+#endif //GM_GC_KEEP_PERSISTANT_SEPARATE
+
   gmGCObjBase* objPrev = a_obj->GetPrev();
   gmGCObjBase* objNext = a_obj->GetNext();
 

+ 12 - 25
gmsrc/src/gm/gmTableObject.cpp

@@ -102,12 +102,13 @@ void gmTableObject::Destruct(gmMachine * a_machine)
 }
 
 
-// Helper to minimally compare if two variables are equal, for finding in table
+// Helper to minimally compare if two variables are equal, for finding matching keys in table
 // This function is a candidate for platform specific optimization
-inline int VariablesEqual(const gmVariable& a_varA, const gmVariable& a_varB)
+inline int VarKeysEqual(const gmVariable& a_varA, const gmVariable& a_varB)
 {
   // We can't assume unused bits in m_ref are zero.
   // Some GM variants can't assume sizeof(m_ref) is the largest union component.
+  // We currently CAN assume table keys are either Strings (refs) or Integers (indices).
 
 #if GMMACHINE_NULL_VAR_CTOR
   if( (a_varA.m_ref == a_varB.m_ref) &&
@@ -118,31 +119,17 @@ inline int VariablesEqual(const gmVariable& a_varA, const gmVariable& a_varB)
 #else //GMMACHINE_NULL_VAR_CTOR
   if( a_varA.m_type == a_varB.m_type )
   {
-    switch( a_varA.m_type )
+    if( a_varA.m_type == GM_INT)
     {
-      case GM_INT: 
+      if( a_varA.m_value.m_int == a_varB.m_value.m_int )
       {
-        if( a_varA.m_value.m_int == a_varB.m_value.m_int )
-        {
-          return true;
-        }
-        break;
-      }
-      case GM_FLOAT:
-      {
-        //if( a_varA.m_value.m_float == a_varB.m_value.m_float ) return true;
-        return ( memcmp(&a_varA.m_value.m_ref, &a_varB.m_value.m_ref, sizeof(gmfloat)) == 0 ); // Don't use FPU for comparison
-        break;
-      }
-      default: // All other types are reference, NULLs are not stored.
-      {
-        if( a_varA.m_value.m_ref == a_varB.m_value.m_ref )
-        {
-          return true;
-        }
-        break;
+        return true;
       }
     }
+    else if( a_varA.m_value.m_ref == a_varB.m_value.m_ref )
+    {
+      return true;
+    }
   }
 #endif  
   return false;
@@ -159,7 +146,7 @@ gmVariable gmTableObject::Get(const gmVariable &a_key) const
 
     do
     {
-      if( VariablesEqual(a_key, foundNode->m_key) )
+      if( VarKeysEqual(a_key, foundNode->m_key) )
       {
         return foundNode->m_value;
       }
@@ -204,7 +191,7 @@ void gmTableObject::Set(gmMachine * a_machine, const gmVariable &a_key, const gm
   // find key, if it exists
   do
   {
-    if( VariablesEqual(a_key, foundNode->m_key) )
+    if( VarKeysEqual(a_key, foundNode->m_key) )
     {
       //If found and value is null, remove it
       if(GM_NULL == a_value.m_type)