| 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 20 matching lines...) Expand all Loading... |
| 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 template<typename Record> | 37 template<typename Record> |
| 38 CircularQueue<Record>::CircularQueue(int desired_buffer_size_in_bytes) | 38 CircularQueue<Record>::CircularQueue(int desired_buffer_size_in_bytes) |
| 39 : buffer_(NewArray<Record>(desired_buffer_size_in_bytes / sizeof(Record))), | 39 : buffer_(NewArray<Record>(desired_buffer_size_in_bytes / sizeof(Record))), |
| 40 buffer_end_(buffer_ + desired_buffer_size_in_bytes / sizeof(Record)), | 40 buffer_end_(buffer_ + desired_buffer_size_in_bytes / sizeof(Record)), |
| 41 enqueue_semaphore_(OS::CreateSemaphore((buffer_end_ - buffer_) - 1)), | 41 enqueue_semaphore_( |
| 42 OS::CreateSemaphore(static_cast<int>(buffer_end_ - buffer_) - 1)), |
| 42 enqueue_pos_(buffer_), | 43 enqueue_pos_(buffer_), |
| 43 dequeue_pos_(buffer_) { | 44 dequeue_pos_(buffer_) { |
| 44 // To be able to distinguish between a full and an empty queue | 45 // To be able to distinguish between a full and an empty queue |
| 45 // state, the queue must be capable of containing at least 2 | 46 // state, the queue must be capable of containing at least 2 |
| 46 // records. | 47 // records. |
| 47 ASSERT((buffer_end_ - buffer_) >= 2); | 48 ASSERT((buffer_end_ - buffer_) >= 2); |
| 48 } | 49 } |
| 49 | 50 |
| 50 | 51 |
| 51 template<typename Record> | 52 template<typename Record> |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 | 92 |
| 92 void SamplingCircularQueue::WrapPositionIfNeeded( | 93 void SamplingCircularQueue::WrapPositionIfNeeded( |
| 93 SamplingCircularQueue::Cell** pos) { | 94 SamplingCircularQueue::Cell** pos) { |
| 94 if (**pos == kEnd) *pos = buffer_; | 95 if (**pos == kEnd) *pos = buffer_; |
| 95 } | 96 } |
| 96 | 97 |
| 97 | 98 |
| 98 } } // namespace v8::internal | 99 } } // namespace v8::internal |
| 99 | 100 |
| 100 #endif // V8_CIRCULAR_BUFFER_INL_H_ | 101 #endif // V8_CIRCULAR_BUFFER_INL_H_ |
| OLD | NEW |