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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 for (int i = 0; i < buffer_size_; i += chunk_size_) { | 51 for (int i = 0; i < buffer_size_; i += chunk_size_) { |
52 buffer_[i] = kClear; | 52 buffer_[i] = kClear; |
53 } | 53 } |
54 buffer_[buffer_size_] = kEnd; | 54 buffer_[buffer_size_] = kEnd; |
55 | 55 |
56 // Layout producer and consumer position pointers each on their own | 56 // Layout producer and consumer position pointers each on their own |
57 // cache lines to avoid cache lines thrashing due to simultaneous | 57 // cache lines to avoid cache lines thrashing due to simultaneous |
58 // updates of positions by different processor cores. | 58 // updates of positions by different processor cores. |
59 const int positions_size = | 59 const int positions_size = |
60 RoundUp(1, kProcessorCacheLineSize) + | 60 RoundUp(1, kProcessorCacheLineSize) + |
61 RoundUp(sizeof(ProducerPosition), kProcessorCacheLineSize) + | 61 RoundUp(static_cast<int>(sizeof(ProducerPosition)), |
62 RoundUp(sizeof(ConsumerPosition), kProcessorCacheLineSize); | 62 kProcessorCacheLineSize) + |
| 63 RoundUp(static_cast<int>(sizeof(ConsumerPosition)), |
| 64 kProcessorCacheLineSize); |
63 positions_ = NewArray<byte>(positions_size); | 65 positions_ = NewArray<byte>(positions_size); |
64 | 66 |
65 producer_pos_ = reinterpret_cast<ProducerPosition*>( | 67 producer_pos_ = reinterpret_cast<ProducerPosition*>( |
66 RoundUp(positions_, kProcessorCacheLineSize)); | 68 RoundUp(positions_, kProcessorCacheLineSize)); |
67 producer_pos_->enqueue_pos = buffer_; | 69 producer_pos_->enqueue_pos = buffer_; |
68 | 70 |
69 consumer_pos_ = reinterpret_cast<ConsumerPosition*>( | 71 consumer_pos_ = reinterpret_cast<ConsumerPosition*>( |
70 reinterpret_cast<byte*>(producer_pos_) + kProcessorCacheLineSize); | 72 reinterpret_cast<byte*>(producer_pos_) + kProcessorCacheLineSize); |
71 ASSERT(reinterpret_cast<byte*>(consumer_pos_ + 1) <= | 73 ASSERT(reinterpret_cast<byte*>(consumer_pos_ + 1) <= |
72 positions_ + positions_size); | 74 positions_ + positions_size); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 } | 112 } |
111 | 113 |
112 | 114 |
113 void SamplingCircularQueue::FlushResidualRecords() { | 115 void SamplingCircularQueue::FlushResidualRecords() { |
114 // Eliminate producer / consumer distance. | 116 // Eliminate producer / consumer distance. |
115 consumer_pos_->dequeue_chunk_poll_pos = consumer_pos_->dequeue_chunk_pos; | 117 consumer_pos_->dequeue_chunk_poll_pos = consumer_pos_->dequeue_chunk_pos; |
116 } | 118 } |
117 | 119 |
118 | 120 |
119 } } // namespace v8::internal | 121 } } // namespace v8::internal |
OLD | NEW |