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

Side by Side Diff: src/circular-queue-inl.h

Issue 22849002: Rewrite SamplingCircularQueue (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Don't create extra copy of event Created 7 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 15 matching lines...) Expand all
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #ifndef V8_CIRCULAR_QUEUE_INL_H_ 28 #ifndef V8_CIRCULAR_QUEUE_INL_H_
29 #define V8_CIRCULAR_QUEUE_INL_H_ 29 #define V8_CIRCULAR_QUEUE_INL_H_
30 30
31 #include "circular-queue.h" 31 #include "circular-queue.h"
32 32
33 namespace v8 { 33 namespace v8 {
34 namespace internal { 34 namespace internal {
35 35
36 36 void* SamplingCircularQueue::StartEnqueue() {
37 void* SamplingCircularQueue::Enqueue() { 37 MemoryBarrier();
38 if (producer_pos_->enqueue_pos == producer_pos_->next_chunk_pos) { 38 if (Acquire_Load(producer_pos_->enqueue_pos) == kEmpty) {
39 if (producer_pos_->enqueue_pos == buffer_ + buffer_size_) {
40 producer_pos_->next_chunk_pos = buffer_;
41 producer_pos_->enqueue_pos = buffer_;
42 }
43 Acquire_Store(producer_pos_->next_chunk_pos, kEnqueueStarted);
44 // Skip marker. 39 // Skip marker.
45 producer_pos_->enqueue_pos += 1; 40 return producer_pos_->enqueue_pos + 1;
46 producer_pos_->next_chunk_pos += chunk_size_;
47 } 41 }
48 void* result = producer_pos_->enqueue_pos; 42 return NULL;
49 producer_pos_->enqueue_pos += record_size_;
50 return result;
51 } 43 }
52 44
53 45
46 void SamplingCircularQueue::FinishEnqueue() {
47 Release_Store(producer_pos_->enqueue_pos, kFull);
48 producer_pos_->enqueue_pos += entry_size_;
49 WrapPositionIfNeeded(&producer_pos_->enqueue_pos);
50 }
Benedikt Meurer 2013/08/13 09:31:32 This assumes that there is always only a single pr
51
52
54 void SamplingCircularQueue::WrapPositionIfNeeded( 53 void SamplingCircularQueue::WrapPositionIfNeeded(
55 SamplingCircularQueue::Cell** pos) { 54 SamplingCircularQueue::Cell** pos) {
56 if (*pos == buffer_ + buffer_size_) *pos = buffer_; 55 if (*pos == buffer_ + buffer_size_) *pos = buffer_;
57 } 56 }
58 57
59 58
60 } } // namespace v8::internal 59 } } // namespace v8::internal
61 60
62 #endif // V8_CIRCULAR_QUEUE_INL_H_ 61 #endif // V8_CIRCULAR_QUEUE_INL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698