gdb: add target_ops::supports_displaced_step
[deliverable/binutils-gdb.git] / gold / workqueue.cc
index 565c7fd2c4e989df3821d7d84807d368380d5ca5..157582eefbaee8968f04cbb1235deb74c24b4714 100644 (file)
@@ -1,6 +1,6 @@
 // workqueue.cc -- the workqueue for gold
 
-// Copyright 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+// Copyright (C) 2006-2020 Free Software Foundation, Inc.
 // Written by Ian Lance Taylor <iant@google.com>.
 
 // This file is part of gold.
@@ -24,6 +24,7 @@
 
 #include "debug.h"
 #include "options.h"
+#include "timer.h"
 #include "workqueue.h"
 #include "workqueue-internal.h"
 
@@ -109,7 +110,7 @@ class Workqueue_threader_single : public Workqueue_threader
   { gold_assert(thread_count > 0); }
 
   bool
-  should_cancel_thread()
+  should_cancel_thread(int)
   { return false; }
 };
 
@@ -148,7 +149,7 @@ Workqueue::~Workqueue()
 // waiting for a Token.
 
 void
-Workqueue::add_to_queue(Task_list* que, Task* t, bool front)
+Workqueue::add_to_queue(Task_list* queue, Task* t, bool front)
 {
   Hold_lock hl(this->lock_);
 
@@ -164,9 +165,9 @@ Workqueue::add_to_queue(Task_list* que, Task* t, bool front)
   else
     {
       if (front)
-       que->push_front(t);
+       queue->push_front(t);
       else
-       que->push_back(t);
+       queue->push_back(t);
       // Tell any waiting thread that there is work to do.
       this->condvar_.signal();
     }
@@ -201,9 +202,9 @@ Workqueue::queue_next(Task* t)
 // Return whether to cancel the current thread.
 
 inline bool
-Workqueue::should_cancel_thread()
+Workqueue::should_cancel_thread(int thread_number)
 {
-  return this->threader_->should_cancel_thread();
+  return this->threader_->should_cancel_thread(thread_number);
 }
 
 // Find a runnable task in TASKS.  Return NULL if none could be found.
@@ -263,7 +264,7 @@ Workqueue::find_runnable_or_wait(int thread_number)
          return NULL;
        }
 
-      if (this->should_cancel_thread())
+      if (this->should_cancel_thread(thread_number))
        return NULL;
 
       gold_debug(DEBUG_TASK, "%3d sleeping", thread_number);
@@ -311,10 +312,24 @@ Workqueue::find_and_run_task(int thread_number)
       gold_debug(DEBUG_TASK, "%3d running   task %s", thread_number,
                 t->name().c_str());
 
+      Timer timer;
+      if (is_debugging_enabled(DEBUG_TASK))
+        timer.start();
+
       t->run(this);
 
-      gold_debug(DEBUG_TASK, "%3d completed task %s", thread_number,
-                t->name().c_str());
+      if (is_debugging_enabled(DEBUG_TASK))
+        {
+          Timer::TimeStats elapsed = timer.get_elapsed_time();
+
+          gold_debug(DEBUG_TASK,
+                     "%3d completed task %s "
+                     "(user: %ld.%06ld sys: %ld.%06ld wall: %ld.%06ld)",
+                     thread_number,  t->name().c_str(),
+                     elapsed.user / 1000, (elapsed.user % 1000) * 1000,
+                     elapsed.sys / 1000, (elapsed.sys % 1000) * 1000,
+                     elapsed.wall / 1000, (elapsed.wall % 1000) * 1000);
+        }
 
       Task* next;
       {
@@ -441,11 +456,11 @@ Workqueue::release_locks(Task* t, Task_locker* tl)
            {
              // The token has been unblocked.  Every waiting Task may
              // now be runnable.
-             Task* tok;
-             while ((tok = token->remove_first_waiting()) != NULL)
+             Task* t;
+             while ((t = token->remove_first_waiting()) != NULL)
                {
                  --this->waiting_;
-                 this->return_or_queue(tok, true, &ret);
+                 this->return_or_queue(t, true, &ret);
                }
            }
        }
@@ -458,11 +473,11 @@ Workqueue::release_locks(Task* t, Task_locker* tl)
          // move all the Tasks to the runnable queue, to avoid a
          // potential deadlock if the locking status changes before
          // we run the next thread.
-         Task* tok;
-         while ((tok = token->remove_first_waiting()) != NULL)
+         Task* t;
+         while ((t = token->remove_first_waiting()) != NULL)
            {
              --this->waiting_;
-             if (this->return_or_queue(tok, false, &ret))
+             if (this->return_or_queue(t, false, &ret))
                break;
            }
        }
This page took 0.034033 seconds and 4 git commands to generate.