| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 29 matching lines...) Expand all Loading... |
| 40 // simultaneous reads and writes to adjanced memory locations. | 40 // simultaneous reads and writes to adjanced memory locations. |
| 41 // | 41 // |
| 42 // IMPORTANT: as a producer never checks for chunks cleanness, it is | 42 // IMPORTANT: as a producer never checks for chunks cleanness, it is |
| 43 // possible that it can catch up and overwrite a chunk that a consumer | 43 // possible that it can catch up and overwrite a chunk that a consumer |
| 44 // is currently reading, resulting in a corrupt record being read. | 44 // is currently reading, resulting in a corrupt record being read. |
| 45 class SamplingCircularQueue { | 45 class SamplingCircularQueue { |
| 46 public: | 46 public: |
| 47 // Executed on the application thread. | 47 // Executed on the application thread. |
| 48 SamplingCircularQueue(size_t record_size_in_bytes, | 48 SamplingCircularQueue(size_t record_size_in_bytes, |
| 49 size_t desired_chunk_size_in_bytes, | 49 size_t desired_chunk_size_in_bytes, |
| 50 int buffer_size_in_chunks); | 50 unsigned buffer_size_in_chunks); |
| 51 ~SamplingCircularQueue(); | 51 ~SamplingCircularQueue(); |
| 52 | 52 |
| 53 // Enqueue returns a pointer to a memory location for storing the next | 53 // Enqueue returns a pointer to a memory location for storing the next |
| 54 // record. | 54 // record. |
| 55 INLINE(void* Enqueue()); | 55 INLINE(void* Enqueue()); |
| 56 | 56 |
| 57 // Executed on the consumer (analyzer) thread. | 57 // Executed on the consumer (analyzer) thread. |
| 58 // StartDequeue returns a pointer to a memory location for retrieving | 58 // StartDequeue returns a pointer to a memory location for retrieving |
| 59 // the next record. After the record had been read by a consumer, | 59 // the next record. After the record had been read by a consumer, |
| 60 // FinishDequeue must be called. Until that moment, subsequent calls | 60 // FinishDequeue must be called. Until that moment, subsequent calls |
| (...skipping 20 matching lines...) Expand all Loading... |
| 81 }; | 81 }; |
| 82 struct ConsumerPosition { | 82 struct ConsumerPosition { |
| 83 Cell* dequeue_chunk_pos; | 83 Cell* dequeue_chunk_pos; |
| 84 Cell* dequeue_chunk_poll_pos; | 84 Cell* dequeue_chunk_poll_pos; |
| 85 Cell* dequeue_pos; | 85 Cell* dequeue_pos; |
| 86 Cell* dequeue_end_pos; | 86 Cell* dequeue_end_pos; |
| 87 }; | 87 }; |
| 88 | 88 |
| 89 INLINE(void WrapPositionIfNeeded(Cell** pos)); | 89 INLINE(void WrapPositionIfNeeded(Cell** pos)); |
| 90 | 90 |
| 91 const int record_size_; | 91 const size_t record_size_; |
| 92 const size_t chunk_size_in_bytes_; | 92 const size_t chunk_size_in_bytes_; |
| 93 const int chunk_size_; | 93 const size_t chunk_size_; |
| 94 const int buffer_size_; | 94 const size_t buffer_size_; |
| 95 Cell* buffer_; | 95 Cell* buffer_; |
| 96 byte* positions_; | 96 byte* positions_; |
| 97 ProducerPosition* producer_pos_; | 97 ProducerPosition* producer_pos_; |
| 98 ConsumerPosition* consumer_pos_; | 98 ConsumerPosition* consumer_pos_; |
| 99 | 99 |
| 100 DISALLOW_COPY_AND_ASSIGN(SamplingCircularQueue); | 100 DISALLOW_COPY_AND_ASSIGN(SamplingCircularQueue); |
| 101 }; | 101 }; |
| 102 | 102 |
| 103 | 103 |
| 104 } } // namespace v8::internal | 104 } } // namespace v8::internal |
| 105 | 105 |
| 106 #endif // V8_CIRCULAR_QUEUE_H_ | 106 #endif // V8_CIRCULAR_QUEUE_H_ |
| OLD | NEW |