Reviewers: loislo, Benedikt Meurer,
Description:
Rename some of SamplingCircularQueue methods
Renamed StartDequeue -> Peek, FinishDequeue -> Remove.
BUG=None
Please review this at https://codereview.chromium.org/23686006/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/circular-queue-inl.h
M src/circular-queue.h
M src/cpu-profiler.cc
M test/cctest/test-circular-queue.cc
Index: src/circular-queue-inl.h
diff --git a/src/circular-queue-inl.h b/src/circular-queue-inl.h
index
8b09eeb9fb46c4462fb2472c44d662eeff0bf5a2..dfb70315781a50f0aa370a0347aac6c83eaadd6f
100644
--- a/src/circular-queue-inl.h
+++ b/src/circular-queue-inl.h
@@ -46,7 +46,7 @@ SamplingCircularQueue<T, L>::~SamplingCircularQueue() {
template<typename T, unsigned L>
-T* SamplingCircularQueue<T, L>::StartDequeue() {
+T* SamplingCircularQueue<T, L>::Peek() {
MemoryBarrier();
if (Acquire_Load(&dequeue_pos_->marker) == kFull) {
return &dequeue_pos_->record;
@@ -56,7 +56,7 @@ T* SamplingCircularQueue<T, L>::StartDequeue() {
template<typename T, unsigned L>
-void SamplingCircularQueue<T, L>::FinishDequeue() {
+void SamplingCircularQueue<T, L>::Remove() {
Release_Store(&dequeue_pos_->marker, kEmpty);
dequeue_pos_ = Next(dequeue_pos_);
}
Index: src/circular-queue.h
diff --git a/src/circular-queue.h b/src/circular-queue.h
index
c7797b3801629eef51687e893cdfd77e5baab642..94bc89e7dfb28554f800d7009a7a1f09d8709d1a
100644
--- a/src/circular-queue.h
+++ b/src/circular-queue.h
@@ -55,12 +55,11 @@ class SamplingCircularQueue {
void FinishEnqueue();
// Executed on the consumer (analyzer) thread.
- // StartDequeue returns a pointer to a memory location for retrieving
- // the next record. After the record had been read by a consumer,
- // FinishDequeue must be called. Until that moment, subsequent calls
- // to StartDequeue will return the same pointer.
- T* StartDequeue();
- void FinishDequeue();
+ // Retrieves, but does not remove, the head of this queue, returning NULL
+ // if this queue is empty. After the record had been read by a consumer,
+ // Remove must be called.
+ T* Peek();
+ void Remove();
private:
// Reserved values for the entry marker.
Index: src/cpu-profiler.cc
diff --git a/src/cpu-profiler.cc b/src/cpu-profiler.cc
index
0d0abe9a43e02bafd58ed4858aba6a9f6d18e28c..c9a6d084285771d5dfa082dd3bc37270b3452888
100644
--- a/src/cpu-profiler.cc
+++ b/src/cpu-profiler.cc
@@ -114,11 +114,11 @@ bool ProfilerEventsProcessor::ProcessOneSample() {
return false;
}
- const TickSampleEventRecord* record = ticks_buffer_.StartDequeue();
+ const TickSampleEventRecord* record = ticks_buffer_.Peek();
if (record == NULL) return true;
if (record->order != last_processed_code_event_id_) return true;
generator_->RecordTickSample(record->sample);
- ticks_buffer_.FinishDequeue();
+ ticks_buffer_.Remove();
return false;
}
Index: test/cctest/test-circular-queue.cc
diff --git a/test/cctest/test-circular-queue.cc
b/test/cctest/test-circular-queue.cc
index
1d6775d9e9fba5aa8a16c813b6631593280c4248..c900be1a6463314d95bdc146fd0965c79b2893fe
100644
--- a/test/cctest/test-circular-queue.cc
+++ b/test/cctest/test-circular-queue.cc
@@ -41,7 +41,7 @@ TEST(SamplingCircularQueue) {
// Check that we are using non-reserved values.
// Fill up the first chunk.
- CHECK_EQ(NULL, scq.StartDequeue());
+ CHECK_EQ(NULL, scq.Peek());
for (Record i = 1; i < 1 + kMaxRecordsInQueue; ++i) {
Record* rec = reinterpret_cast<Record*>(scq.StartEnqueue());
CHECK_NE(NULL, rec);
@@ -53,27 +53,27 @@ TEST(SamplingCircularQueue) {
CHECK_EQ(NULL, scq.StartEnqueue());
// Try to enqueue when the the queue is full. Consumption must be
available.
- CHECK_NE(NULL, scq.StartDequeue());
+ CHECK_NE(NULL, scq.Peek());
for (int i = 0; i < 10; ++i) {
Record* rec = reinterpret_cast<Record*>(scq.StartEnqueue());
CHECK_EQ(NULL, rec);
- CHECK_NE(NULL, scq.StartDequeue());
+ CHECK_NE(NULL, scq.Peek());
}
// Consume all records.
for (Record i = 1; i < 1 + kMaxRecordsInQueue; ++i) {
- Record* rec = reinterpret_cast<Record*>(scq.StartDequeue());
+ Record* rec = reinterpret_cast<Record*>(scq.Peek());
CHECK_NE(NULL, rec);
CHECK_EQ(static_cast<int64_t>(i), static_cast<int64_t>(*rec));
- CHECK_EQ(rec, reinterpret_cast<Record*>(scq.StartDequeue()));
- scq.FinishDequeue();
- CHECK_NE(rec, reinterpret_cast<Record*>(scq.StartDequeue()));
+ CHECK_EQ(rec, reinterpret_cast<Record*>(scq.Peek()));
+ scq.Remove();
+ CHECK_NE(rec, reinterpret_cast<Record*>(scq.Peek()));
}
// The queue is empty.
- CHECK_EQ(NULL, scq.StartDequeue());
+ CHECK_EQ(NULL, scq.Peek());
- CHECK_EQ(NULL, scq.StartDequeue());
+ CHECK_EQ(NULL, scq.Peek());
for (Record i = 0; i < kMaxRecordsInQueue / 2; ++i) {
Record* rec = reinterpret_cast<Record*>(scq.StartEnqueue());
CHECK_NE(NULL, rec);
@@ -82,18 +82,18 @@ TEST(SamplingCircularQueue) {
}
// Consume all available kMaxRecordsInQueue / 2 records.
- CHECK_NE(NULL, scq.StartDequeue());
+ CHECK_NE(NULL, scq.Peek());
for (Record i = 0; i < kMaxRecordsInQueue / 2; ++i) {
- Record* rec = reinterpret_cast<Record*>(scq.StartDequeue());
+ Record* rec = reinterpret_cast<Record*>(scq.Peek());
CHECK_NE(NULL, rec);
CHECK_EQ(static_cast<int64_t>(i), static_cast<int64_t>(*rec));
- CHECK_EQ(rec, reinterpret_cast<Record*>(scq.StartDequeue()));
- scq.FinishDequeue();
- CHECK_NE(rec, reinterpret_cast<Record*>(scq.StartDequeue()));
+ CHECK_EQ(rec, reinterpret_cast<Record*>(scq.Peek()));
+ scq.Remove();
+ CHECK_NE(rec, reinterpret_cast<Record*>(scq.Peek()));
}
// The queue is empty.
- CHECK_EQ(NULL, scq.StartDequeue());
+ CHECK_EQ(NULL, scq.Peek());
}
@@ -148,41 +148,41 @@ TEST(SamplingCircularQueueMultithreading) {
ProducerThread producer2(&scq, kRecordsPerChunk, 10, &semaphore);
ProducerThread producer3(&scq, kRecordsPerChunk, 20, &semaphore);
- CHECK_EQ(NULL, scq.StartDequeue());
+ CHECK_EQ(NULL, scq.Peek());
producer1.Start();
semaphore.Wait();
for (Record i = 1; i < 1 + kRecordsPerChunk; ++i) {
- Record* rec = reinterpret_cast<Record*>(scq.StartDequeue());
+ Record* rec = reinterpret_cast<Record*>(scq.Peek());
CHECK_NE(NULL, rec);
CHECK_EQ(static_cast<int64_t>(i), static_cast<int64_t>(*rec));
- CHECK_EQ(rec, reinterpret_cast<Record*>(scq.StartDequeue()));
- scq.FinishDequeue();
- CHECK_NE(rec, reinterpret_cast<Record*>(scq.StartDequeue()));
+ CHECK_EQ(rec, reinterpret_cast<Record*>(scq.Peek()));
+ scq.Remove();
+ CHECK_NE(rec, reinterpret_cast<Record*>(scq.Peek()));
}
- CHECK_EQ(NULL, scq.StartDequeue());
+ CHECK_EQ(NULL, scq.Peek());
producer2.Start();
semaphore.Wait();
for (Record i = 10; i < 10 + kRecordsPerChunk; ++i) {
- Record* rec = reinterpret_cast<Record*>(scq.StartDequeue());
+ Record* rec = reinterpret_cast<Record*>(scq.Peek());
CHECK_NE(NULL, rec);
CHECK_EQ(static_cast<int64_t>(i), static_cast<int64_t>(*rec));
- CHECK_EQ(rec, reinterpret_cast<Record*>(scq.StartDequeue()));
- scq.FinishDequeue();
- CHECK_NE(rec, reinterpret_cast<Record*>(scq.StartDequeue()));
+ CHECK_EQ(rec, reinterpret_cast<Record*>(scq.Peek()));
+ scq.Remove();
+ CHECK_NE(rec, reinterpret_cast<Record*>(scq.Peek()));
}
- CHECK_EQ(NULL, scq.StartDequeue());
+ CHECK_EQ(NULL, scq.Peek());
producer3.Start();
semaphore.Wait();
for (Record i = 20; i < 20 + kRecordsPerChunk; ++i) {
- Record* rec = reinterpret_cast<Record*>(scq.StartDequeue());
+ Record* rec = reinterpret_cast<Record*>(scq.Peek());
CHECK_NE(NULL, rec);
CHECK_EQ(static_cast<int64_t>(i), static_cast<int64_t>(*rec));
- CHECK_EQ(rec, reinterpret_cast<Record*>(scq.StartDequeue()));
- scq.FinishDequeue();
- CHECK_NE(rec, reinterpret_cast<Record*>(scq.StartDequeue()));
+ CHECK_EQ(rec, reinterpret_cast<Record*>(scq.Peek()));
+ scq.Remove();
+ CHECK_NE(rec, reinterpret_cast<Record*>(scq.Peek()));
}
- CHECK_EQ(NULL, scq.StartDequeue());
+ CHECK_EQ(NULL, scq.Peek());
}
--
--
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.