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 17 matching lines...) Expand all Loading... |
28 #include "v8.h" | 28 #include "v8.h" |
29 | 29 |
30 #include "circular-queue-inl.h" | 30 #include "circular-queue-inl.h" |
31 | 31 |
32 namespace v8 { | 32 namespace v8 { |
33 namespace internal { | 33 namespace internal { |
34 | 34 |
35 | 35 |
36 SamplingCircularQueue::SamplingCircularQueue(size_t record_size_in_bytes, | 36 SamplingCircularQueue::SamplingCircularQueue(size_t record_size_in_bytes, |
37 size_t desired_chunk_size_in_bytes, | 37 size_t desired_chunk_size_in_bytes, |
38 int buffer_size_in_chunks) | 38 unsigned buffer_size_in_chunks) |
39 : record_size_(record_size_in_bytes / sizeof(Cell)), | 39 : record_size_(record_size_in_bytes / sizeof(Cell)), |
40 chunk_size_in_bytes_(desired_chunk_size_in_bytes / record_size_in_bytes * | 40 chunk_size_in_bytes_(desired_chunk_size_in_bytes / record_size_in_bytes * |
41 record_size_in_bytes + sizeof(Cell)), | 41 record_size_in_bytes + sizeof(Cell)), |
42 chunk_size_(chunk_size_in_bytes_ / sizeof(Cell)), | 42 chunk_size_(chunk_size_in_bytes_ / sizeof(Cell)), |
43 buffer_size_(chunk_size_ * buffer_size_in_chunks), | 43 buffer_size_(chunk_size_ * buffer_size_in_chunks), |
44 buffer_(NewArray<Cell>(buffer_size_)) { | 44 buffer_(NewArray<Cell>(buffer_size_)) { |
45 ASSERT(record_size_ * sizeof(Cell) == record_size_in_bytes); | 45 ASSERT(record_size_ * sizeof(Cell) == record_size_in_bytes); |
46 ASSERT(chunk_size_ * sizeof(Cell) == chunk_size_in_bytes_); | 46 ASSERT(chunk_size_ * sizeof(Cell) == chunk_size_in_bytes_); |
47 ASSERT(buffer_size_in_chunks > 2); | 47 ASSERT(buffer_size_in_chunks > 2); |
48 // Mark all chunks as clear. | 48 // Mark all chunks as clear. |
49 for (int i = 0; i < buffer_size_; i += chunk_size_) { | 49 for (size_t i = 0; i < buffer_size_; i += chunk_size_) { |
50 buffer_[i] = kClear; | 50 buffer_[i] = kClear; |
51 } | 51 } |
52 | 52 |
53 // Layout producer and consumer position pointers each on their own | 53 // Layout producer and consumer position pointers each on their own |
54 // cache lines to avoid cache lines thrashing due to simultaneous | 54 // cache lines to avoid cache lines thrashing due to simultaneous |
55 // updates of positions by different processor cores. | 55 // updates of positions by different processor cores. |
56 const int positions_size = | 56 const int positions_size = |
57 RoundUp(1, kProcessorCacheLineSize) + | 57 RoundUp(1, kProcessorCacheLineSize) + |
58 RoundUp(static_cast<int>(sizeof(ProducerPosition)), | 58 RoundUp(static_cast<int>(sizeof(ProducerPosition)), |
59 kProcessorCacheLineSize) + | 59 kProcessorCacheLineSize) + |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 } | 116 } |
117 | 117 |
118 | 118 |
119 void SamplingCircularQueue::FlushResidualRecords() { | 119 void SamplingCircularQueue::FlushResidualRecords() { |
120 // Eliminate producer / consumer distance. | 120 // Eliminate producer / consumer distance. |
121 consumer_pos_->dequeue_chunk_poll_pos = consumer_pos_->dequeue_chunk_pos; | 121 consumer_pos_->dequeue_chunk_poll_pos = consumer_pos_->dequeue_chunk_pos; |
122 } | 122 } |
123 | 123 |
124 | 124 |
125 } } // namespace v8::internal | 125 } } // namespace v8::internal |
OLD | NEW |