Revision: 15219
Author: [email protected]
Date: Wed Jun 19 23:23:34 2013
Log: Fix data race in v8::internal::UnboundQueue
This change modifies memory accesses to ensure proper load/store ordering.
BUG=249750
[email protected], [email protected]
Review URL: https://codereview.chromium.org/17294004
http://code.google.com/p/v8/source/detail?r=15219
Modified:
/branches/bleeding_edge/src/cpu-profiler.cc
/branches/bleeding_edge/src/optimizing-compiler-thread.cc
/branches/bleeding_edge/src/unbound-queue-inl.h
/branches/bleeding_edge/src/unbound-queue.h
=======================================
--- /branches/bleeding_edge/src/cpu-profiler.cc Mon Jun 3 02:46:32 2013
+++ /branches/bleeding_edge/src/cpu-profiler.cc Wed Jun 19 23:23:34 2013
@@ -191,9 +191,8 @@
bool ProfilerEventsProcessor::ProcessCodeEvent(unsigned* dequeue_order) {
- if (!events_buffer_.IsEmpty()) {
- CodeEventsContainer record;
- events_buffer_.Dequeue(&record);
+ CodeEventsContainer record;
+ if (events_buffer_.Dequeue(&record)) {
switch (record.generic.type) {
#define PROFILER_TYPE_CASE(type, clss) \
case CodeEventRecord::type: \
=======================================
--- /branches/bleeding_edge/src/optimizing-compiler-thread.cc Mon Jun 3
08:32:22 2013
+++ /branches/bleeding_edge/src/optimizing-compiler-thread.cc Wed Jun 19
23:23:34 2013
@@ -128,9 +128,8 @@
ASSERT(!IsOptimizerThread());
HandleScope handle_scope(isolate_);
int functions_installed = 0;
- while (!output_queue_.IsEmpty()) {
- OptimizingCompiler* compiler;
- output_queue_.Dequeue(&compiler);
+ OptimizingCompiler* compiler;
+ while (output_queue_.Dequeue(&compiler)) {
Compiler::InstallOptimizedCode(compiler);
functions_installed++;
}
=======================================
--- /branches/bleeding_edge/src/unbound-queue-inl.h Wed Jun 19 23:16:24 2013
+++ /branches/bleeding_edge/src/unbound-queue-inl.h Wed Jun 19 23:23:34 2013
@@ -68,11 +68,12 @@
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;
Release_Store(÷r_, reinterpret_cast<AtomicWord>(next));
+ return true;
}
@@ -81,13 +82,22 @@
Node*& next = reinterpret_cast<Node*>(last_)->next;
next = new Node(rec);
Release_Store(&last_, reinterpret_cast<AtomicWord>(next));
- while (first_ != reinterpret_cast<Node*>(divider_)) DeleteFirst();
+
+ while (first_ != reinterpret_cast<Node*>(Acquire_Load(÷r_))) {
+ DeleteFirst();
+ }
}
template<typename Record>
-Record* UnboundQueue<Record>::Peek() {
- ASSERT(divider_ != last_);
+bool UnboundQueue<Record>::IsEmpty() const {
+ return NoBarrier_Load(÷r_) == NoBarrier_Load(&last_);
+}
+
+
+template<typename Record>
+Record* UnboundQueue<Record>::Peek() const {
+ if (divider_ == Acquire_Load(&last_)) return NULL;
Node* next = reinterpret_cast<Node*>(divider_)->next;
return &next->value;
}
=======================================
--- /branches/bleeding_edge/src/unbound-queue.h Thu May 5 23:50:20 2011
+++ /branches/bleeding_edge/src/unbound-queue.h Wed Jun 19 23:23:34 2013
@@ -46,10 +46,10 @@
inline UnboundQueue();
inline ~UnboundQueue();
- INLINE(void Dequeue(Record* rec));
+ INLINE(bool Dequeue(Record* rec));
INLINE(void Enqueue(const Record& rec));
- INLINE(bool IsEmpty()) { return divider_ == last_; }
- INLINE(Record* Peek());
+ INLINE(bool IsEmpty() const);
+ INLINE(Record* Peek() const);
private:
INLINE(void DeleteFirst());
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.