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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 } | 75 } |
76 | 76 |
77 | 77 |
78 template<typename Record> | 78 template<typename Record> |
79 Record* CircularQueue<Record>::Next(Record* curr) { | 79 Record* CircularQueue<Record>::Next(Record* curr) { |
80 return ++curr != buffer_end_ ? curr : buffer_; | 80 return ++curr != buffer_end_ ? curr : buffer_; |
81 } | 81 } |
82 | 82 |
83 | 83 |
84 void* SamplingCircularQueue::Enqueue() { | 84 void* SamplingCircularQueue::Enqueue() { |
85 Cell* enqueue_pos = reinterpret_cast<Cell*>( | 85 WrapPositionIfNeeded(&producer_pos_->enqueue_pos); |
86 Thread::GetThreadLocal(producer_key_)); | 86 void* result = producer_pos_->enqueue_pos; |
87 WrapPositionIfNeeded(&enqueue_pos); | 87 producer_pos_->enqueue_pos += record_size_; |
88 Thread::SetThreadLocal(producer_key_, enqueue_pos + record_size_); | 88 return result; |
89 return enqueue_pos; | |
90 } | 89 } |
91 | 90 |
92 | 91 |
93 void SamplingCircularQueue::WrapPositionIfNeeded( | 92 void SamplingCircularQueue::WrapPositionIfNeeded( |
94 SamplingCircularQueue::Cell** pos) { | 93 SamplingCircularQueue::Cell** pos) { |
95 if (**pos == kEnd) *pos = buffer_; | 94 if (**pos == kEnd) *pos = buffer_; |
96 } | 95 } |
97 | 96 |
98 | 97 |
99 } } // namespace v8::internal | 98 } } // namespace v8::internal |
100 | 99 |
101 #endif // V8_CIRCULAR_BUFFER_INL_H_ | 100 #endif // V8_CIRCULAR_BUFFER_INL_H_ |
OLD | NEW |