aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gold/ChangeLog5
-rw-r--r--gold/gold-threads.cc2
-rw-r--r--gold/target-select.cc11
3 files changed, 14 insertions, 4 deletions
diff --git a/gold/ChangeLog b/gold/ChangeLog
index d1ba5e4..bb76e93 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -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.
diff --git a/gold/gold-threads.cc b/gold/gold-threads.cc
index 3471708..b99cf27 100644
--- a/gold/gold-threads.cc
+++ b/gold/gold-threads.cc
@@ -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;
diff --git a/gold/target-select.cc b/gold/target-select.cc
index 55d63b2..dcd3017 100644
--- a/gold/target-select.cc
+++ b/gold/target-select.cc
@@ -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_;
}