* target-select.cc (instantiate_target): Don't acquire the lock if
authorIan Lance Taylor <ian@airs.com>
Tue, 24 Mar 2009 17:32:43 +0000 (17:32 +0000)
committerIan Lance Taylor <ian@airs.com>
Tue, 24 Mar 2009 17:32:43 +0000 (17:32 +0000)
the instantiated_target_ field has already been set.

gold/ChangeLog
gold/gold-threads.cc
gold/target-select.cc

index d1ba5e4529de959a2720598cef90fe73728260b0..bb76e937068d6cfeab013e14f3132c715fc0e14b 100644 (file)
@@ -1,3 +1,8 @@
+2009-03-24  Ian Lance Taylor  <iant@google.com>
+
+       * target-select.cc (instantiate_target): Don't acquire the lock if
+       the instantiated_target_ field has already been set.
+
 2009-03-23  Ian Lance Taylor  <iant@google.com>
 
        * gold-threads.h (class Initialize_lock): Define.
index 347170814d587d1ab4412cca9f00bd1580152023..b99cf27584746d906f82a465da1e5bb100c0b30b 100644 (file)
@@ -308,7 +308,7 @@ class Initialize_lock_once
 static pthread_mutex_t initialize_lock_control = PTHREAD_MUTEX_INITIALIZER;
 
 // A pointer to a pointer to the lock which we need to initialize
-// once.  Access to this is controlled by initialize_lock_pointer.
+// once.  Access to this is controlled by initialize_lock_control.
 
 static Lock** initialize_lock_pointer;
 
index 55d63b2dace72c76b9fbc704893621455b2c557f..dcd3017f07c31694d77b9a77589b7120ab858ce8 100644 (file)
@@ -60,10 +60,15 @@ Target_selector::Target_selector(int machine, int size, bool is_big_endian,
 Target*
 Target_selector::instantiate_target()
 {
-  this->initialize_lock_.initialize();
-  Hold_optional_lock hl(this->lock_);
+  // We assume that the pointer will either be written entirely or not
+  // at all.
   if (this->instantiated_target_ == NULL)
-    this->instantiated_target_ = this->do_instantiate_target();
+    {
+      this->initialize_lock_.initialize();
+      Hold_optional_lock hl(this->lock_);
+      if (this->instantiated_target_ == NULL)
+       this->instantiated_target_ = this->do_instantiate_target();
+    }
   return this->instantiated_target_;
 }
 
This page took 0.030363 seconds and 4 git commands to generate.