Index: src/libplatform/task-queue.cc |
diff --git a/src/hydrogen-infer-types.h b/src/libplatform/task-queue.cc |
similarity index 63% |
copy from src/hydrogen-infer-types.h |
copy to src/libplatform/task-queue.cc |
index cfcbf3549ba51603ea9f8aabd55f4d6070ad0488..1ea31eb26e0aa700944fa9927e460ef73b5ae9fa 100644 |
--- a/src/hydrogen-infer-types.h |
+++ b/src/libplatform/task-queue.cc |
@@ -25,35 +25,56 @@ |
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
-#ifndef V8_HYDROGEN_INFER_TYPES_H_ |
-#define V8_HYDROGEN_INFER_TYPES_H_ |
+#include "task-queue.h" |
-#include "hydrogen.h" |
+// TODO(jochen): We should have our own version of checks.h. |
+#include "../checks.h" |
namespace v8 { |
namespace internal { |
+TaskQueue::TaskQueue() : process_queue_semaphore_(0), terminated_(false) {} |
-class HInferTypesPhase : public HPhase { |
- public: |
- explicit HInferTypesPhase(HGraph* graph) |
- : HPhase("H_Inferring types", graph), worklist_(8, zone()), |
- in_worklist_(graph->GetMaximumValueID(), zone()) { } |
- void Run() { |
- InferTypes(0, graph()->blocks()->length() - 1); |
- } |
+TaskQueue::~TaskQueue() { |
+ LockGuard<Mutex> guard(&lock_); |
+ ASSERT(terminated_); |
+ ASSERT(task_queue_.empty()); |
+} |
- private: |
- void InferTypes(int from_inclusive, int to_inclusive); |
- ZoneList<HValue*> worklist_; |
- BitVector in_worklist_; |
+void TaskQueue::Append(Task* task) { |
+ LockGuard<Mutex> guard(&lock_); |
+ ASSERT(!terminated_); |
+ task_queue_.push(task); |
+ process_queue_semaphore_.Signal(); |
+} |
- DISALLOW_COPY_AND_ASSIGN(HInferTypesPhase); |
-}; |
+Task* TaskQueue::GetNext() { |
+ for (;;) { |
+ { |
+ LockGuard<Mutex> guard(&lock_); |
+ if (!task_queue_.empty()) { |
+ Task* result = task_queue_.front(); |
+ task_queue_.pop(); |
+ return result; |
+ } |
+ if (terminated_) { |
+ process_queue_semaphore_.Signal(); |
+ return NULL; |
+ } |
+ } |
+ process_queue_semaphore_.Wait(); |
+ } |
+} |
-} } // namespace v8::internal |
-#endif // V8_HYDROGEN_INFER_TYPES_H_ |
+void TaskQueue::Terminate() { |
+ LockGuard<Mutex> guard(&lock_); |
+ ASSERT(!terminated_); |
+ terminated_ = true; |
+ process_queue_semaphore_.Signal(); |
+} |
+ |
+} } // namespace v8::internal |