From: Ian Lance Taylor <iant@google.com>
To: binutils@sourceware.org
Subject: gold patch committed: Only lock target selector if necessary
Date: Tue, 24 Mar 2009 17:34:00 -0000 [thread overview]
Message-ID: <m37i2eddvh.fsf@google.com> (raw)
[-- 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_;
}
reply other threads:[~2009-03-24 17:34 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m37i2eddvh.fsf@google.com \
--to=iant@google.com \
--cc=binutils@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).