public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* gold patch committed: Only lock target selector if necessary
@ 2009-03-24 17:34 Ian Lance Taylor
  0 siblings, 0 replies; only message in thread
From: Ian Lance Taylor @ 2009-03-24 17:34 UTC (permalink / raw)
  To: binutils

[-- Attachment #1: Type: text/plain, Size: 398 bytes --]

I committed this patch to gold.  This tweaks yesterday's patch to only
lock the target selector if necessary, avoiding a bunch of lock calls in
a large link.

I also committed a comment fix, without a ChangeLog entry.

Ian


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.



[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Only lock target selector if necessary --]
[-- Type: text/x-patch, Size: 1600 bytes --]

Index: gold-threads.cc
===================================================================
RCS file: /cvs/src/src/gold/gold-threads.cc,v
retrieving revision 1.8
diff -u -p -r1.8 gold-threads.cc
--- gold-threads.cc	24 Mar 2009 04:50:32 -0000	1.8
+++ gold-threads.cc	24 Mar 2009 17:32:24 -0000
@@ -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: target-select.cc
===================================================================
RCS file: /cvs/src/src/gold/target-select.cc,v
retrieving revision 1.9
diff -u -p -r1.9 target-select.cc
--- target-select.cc	24 Mar 2009 04:50:32 -0000	1.9
+++ target-select.cc	24 Mar 2009 17:32:24 -0000
@@ -60,10 +60,15 @@ Target_selector::Target_selector(int mac
 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_;
 }
 

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-03-24 17:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-24 17:34 gold patch committed: Only lock target selector if necessary Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).