Index: gobject/gobject.c
===================================================================
--- gobject/gobject.c	(revision 7617)
+++ gobject/gobject.c	(working copy)
@@ -113,7 +113,16 @@
     ((G_DATALIST_GET_FLAGS (&(object)->qdata) & OBJECT_HAS_TOGGLE_REF_FLAG) != 0)
 #define OBJECT_FLOATING_FLAG 0x2
 
+#define CLASS_HAS_PROPS_FLAG 0x1
+#define CLASS_HAS_PROPS(class) \
+	(G_UNLIKELY(class->flags & CLASS_HAS_PROPS_FLAG))
 
+#define OBJECT_IN_CONSTRUCTION_FLAG 1<<31
+#define OBJECT_IN_CONSTRUCTION(o) (G_LIKELY ((o)->ref_count & OBJECT_IN_CONSTRUCTION_FLAG))
+#define OBJECT_CONSTRUCTION_REFCOUNT 0x80000001
+#define OBJECT_IN_CONSTRUCTION_UNFLAG 0x80000000
+
+
 /* --- signals --- */
 enum {
   NOTIFY,
@@ -185,8 +194,6 @@
 static GObjectNotifyContext property_notify_context = { 0, };
 static gulong	            gobject_signals[LAST_SIGNAL] = { 0, };
 static guint (*floating_flag_handler) (GObject*, gint) = object_floating_flag_handler;
-G_LOCK_DEFINE_STATIC (construction_mutex);
-static GSList *construction_objects = NULL;
 
 /* --- functions --- */
 #ifdef	G_ENABLE_DEBUG
@@ -678,17 +685,13 @@
 }
 
 static void
-g_object_init (GObject *object)
+g_object_init (GObject		*object)
 {
-  object->ref_count = 1;
+  object->ref_count = OBJECT_CONSTRUCTION_REFCOUNT;
   g_datalist_init (&object->qdata);
-  
+
   /* freeze object's notification queue, g_object_newv() preserves pairedness */
   g_object_notify_queue_freeze (object, &property_notify_context);
-  /* enter construction list for notify_queue_thaw() and to allow construct-only properties */
-  G_LOCK (construction_mutex);
-  construction_objects = g_slist_prepend (construction_objects, object);
-  G_UNLOCK (construction_mutex);
 
 #ifdef	G_ENABLE_DEBUG
   IF_DEBUG (OBJECTS)
@@ -1059,38 +1062,7 @@
   return object;
 }
 
-static gboolean
-slist_maybe_remove (GSList       **slist,
-                    gconstpointer  data)
-{
-  GSList *last = NULL, *node = *slist;
-  while (node)
-    {
-      if (node->data == data)
-        {
-          if (last)
-            last->next = node->next;
-          else
-            *slist = node->next;
-          g_slist_free_1 (node);
-          return TRUE;
-        }
-      last = node;
-      node = last->next;
-    }
-  return FALSE;
-}
 
-static inline gboolean
-object_in_construction_list (GObject *object)
-{
-  gboolean in_construction;
-  G_LOCK (construction_mutex);
-  in_construction = g_slist_find (construction_objects, object) != NULL;
-  G_UNLOCK (construction_mutex);
-  return in_construction;
-}
-
 /**
  * g_object_newv:
  * @object_type: the type id of the #GObject subtype to instantiate
@@ -1118,7 +1090,7 @@
   GValue *cvalues;
   GList *clist = NULL;
   gboolean newly_constructed;
-  guint i;
+  guint i, new_ref, old_ref;
 
   g_return_val_if_fail (G_TYPE_IS_OBJECT (object_type), NULL);
 
@@ -1216,9 +1188,13 @@
   g_free (cvalues);
 
   /* adjust freeze_count according to g_object_init() and remaining properties */
-  G_LOCK (construction_mutex);
-  newly_constructed = slist_maybe_remove (&construction_objects, object);
-  G_UNLOCK (construction_mutex);
+  newly_constructed = OBJECT_IN_CONSTRUCTION (object);
+
+  old_ref = g_atomic_int_get ((int *)&object->ref_count);
+  new_ref = old_ref & ~OBJECT_IN_CONSTRUCTION_UNFLAG;
+
+  g_atomic_int_compare_and_exchange ((int *)&object->ref_count, old_ref, new_ref);
+  
   if (newly_constructed || n_oparams)
     nqueue = g_object_notify_queue_freeze (object, &property_notify_context);
   if (newly_constructed)
@@ -1406,7 +1382,7 @@
 		     G_OBJECT_TYPE_NAME (object));
 	  break;
 	}
-      if ((pspec->flags & G_PARAM_CONSTRUCT_ONLY) && !object_in_construction_list (object))
+      if ((pspec->flags & G_PARAM_CONSTRUCT_ONLY) && !OBJECT_IN_CONSTRUCTION (object))
         {
           g_warning ("%s: construct property \"%s\" for object `%s' can't be set after construction",
                      G_STRFUNC, pspec->name, G_OBJECT_TYPE_NAME (object));
@@ -1622,7 +1598,7 @@
                G_STRFUNC,
                pspec->name,
                G_OBJECT_TYPE_NAME (object));
-  else if ((pspec->flags & G_PARAM_CONSTRUCT_ONLY) && !object_in_construction_list (object))
+  else if ((pspec->flags & G_PARAM_CONSTRUCT_ONLY) && !OBJECT_IN_CONSTRUCTION (object))
     g_warning ("%s: construct property \"%s\" for object `%s' can't be set after construction",
                G_STRFUNC, pspec->name, G_OBJECT_TYPE_NAME (object));
   else
