| OLD | NEW |
| 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 17 matching lines...) Expand all Loading... |
| 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 |
| 37 void* SamplingCircularQueue::Enqueue() { | 37 void* SamplingCircularQueue::Enqueue() { |
| 38 WrapPositionIfNeeded(&producer_pos_->enqueue_pos); | 38 if (producer_pos_->enqueue_pos == producer_pos_->next_chunk_pos) { |
| 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. |
| 45 producer_pos_->enqueue_pos += 1; |
| 46 producer_pos_->next_chunk_pos += chunk_size_; |
| 47 } |
| 39 void* result = producer_pos_->enqueue_pos; | 48 void* result = producer_pos_->enqueue_pos; |
| 40 producer_pos_->enqueue_pos += record_size_; | 49 producer_pos_->enqueue_pos += record_size_; |
| 41 return result; | 50 return result; |
| 42 } | 51 } |
| 43 | 52 |
| 44 | 53 |
| 45 void SamplingCircularQueue::WrapPositionIfNeeded( | 54 void SamplingCircularQueue::WrapPositionIfNeeded( |
| 46 SamplingCircularQueue::Cell** pos) { | 55 SamplingCircularQueue::Cell** pos) { |
| 47 if (**pos == kEnd) *pos = buffer_; | 56 if (*pos == buffer_ + buffer_size_) *pos = buffer_; |
| 48 } | 57 } |
| 49 | 58 |
| 50 | 59 |
| 51 } } // namespace v8::internal | 60 } } // namespace v8::internal |
| 52 | 61 |
| 53 #endif // V8_CIRCULAR_QUEUE_INL_H_ | 62 #endif // V8_CIRCULAR_QUEUE_INL_H_ |
| OLD | NEW |