+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.
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;
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_;
}