Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Unified Diff: src/unbound-queue-inl.h

Issue 142813003: A64: Synchronize with r15358. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/unbound-queue.h ('k') | src/v8-counters.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/unbound-queue-inl.h
diff --git a/src/unbound-queue-inl.h b/src/unbound-queue-inl.h
index fffb1dbcfb13d966c2164d19dc781404c976af52..796ba401d58664faccf1f8432dc5b7fdd073480d 100644
--- a/src/unbound-queue-inl.h
+++ b/src/unbound-queue-inl.h
@@ -30,6 +30,8 @@
#include "unbound-queue.h"
+#include "atomicops.h"
+
namespace v8 {
namespace internal {
@@ -66,11 +68,12 @@ void UnboundQueue<Record>::DeleteFirst() {
template<typename Record>
-void UnboundQueue<Record>::Dequeue(Record* rec) {
- ASSERT(divider_ != last_);
+bool UnboundQueue<Record>::Dequeue(Record* rec) {
+ if (divider_ == Acquire_Load(&last_)) return false;
Node* next = reinterpret_cast<Node*>(divider_)->next;
*rec = next->value;
- OS::ReleaseStore(&divider_, reinterpret_cast<AtomicWord>(next));
+ Release_Store(&divider_, reinterpret_cast<AtomicWord>(next));
+ return true;
}
@@ -78,14 +81,23 @@ template<typename Record>
void UnboundQueue<Record>::Enqueue(const Record& rec) {
Node*& next = reinterpret_cast<Node*>(last_)->next;
next = new Node(rec);
- OS::ReleaseStore(&last_, reinterpret_cast<AtomicWord>(next));
- while (first_ != reinterpret_cast<Node*>(divider_)) DeleteFirst();
+ Release_Store(&last_, reinterpret_cast<AtomicWord>(next));
+
+ while (first_ != reinterpret_cast<Node*>(Acquire_Load(&divider_))) {
+ DeleteFirst();
+ }
+}
+
+
+template<typename Record>
+bool UnboundQueue<Record>::IsEmpty() const {
+ return NoBarrier_Load(&divider_) == NoBarrier_Load(&last_);
}
template<typename Record>
-Record* UnboundQueue<Record>::Peek() {
- ASSERT(divider_ != last_);
+Record* UnboundQueue<Record>::Peek() const {
+ if (divider_ == Acquire_Load(&last_)) return NULL;
Node* next = reinterpret_cast<Node*>(divider_)->next;
return &next->value;
}
« no previous file with comments | « src/unbound-queue.h ('k') | src/v8-counters.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698