Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(146)

Side by Side Diff: src/circular-queue.cc

Issue 3251004: Fix a error in SamplingCircularQueue found using Valgrind memcheck. (Closed)
Patch Set: Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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), 41 record_size_in_bytes),
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 // The distance ensures that producer and consumer never step on 44 // The distance ensures that producer and consumer never step on
45 // each other's chunks and helps eviction of produced data from 45 // each other's chunks and helps eviction of produced data from
46 // the CPU cache (having that chunk size is bigger than the cache.) 46 // the CPU cache (having that chunk size is bigger than the cache.)
47 producer_consumer_distance_(2 * chunk_size_), 47 producer_consumer_distance_(2 * chunk_size_),
48 buffer_(NewArray<Cell>(buffer_size_ + 1)) { 48 buffer_(NewArray<Cell>(buffer_size_ + 1)) {
49 ASSERT(buffer_size_in_chunks > 2); 49 ASSERT(buffer_size_in_chunks > 2);
50 // Only need to keep the first cell of a chunk clean. 50 // Clean up the whole buffer to avoid encountering a random kEnd
51 for (int i = 0; i < buffer_size_; i += chunk_size_) { 51 // while enqueuing.
52 for (int i = 0; i < buffer_size_; ++i) {
52 buffer_[i] = kClear; 53 buffer_[i] = kClear;
53 } 54 }
54 buffer_[buffer_size_] = kEnd; 55 buffer_[buffer_size_] = kEnd;
55 56
56 // Layout producer and consumer position pointers each on their own 57 // Layout producer and consumer position pointers each on their own
57 // cache lines to avoid cache lines thrashing due to simultaneous 58 // cache lines to avoid cache lines thrashing due to simultaneous
58 // updates of positions by different processor cores. 59 // updates of positions by different processor cores.
59 const int positions_size = 60 const int positions_size =
60 RoundUp(1, kProcessorCacheLineSize) + 61 RoundUp(1, kProcessorCacheLineSize) +
61 RoundUp(static_cast<int>(sizeof(ProducerPosition)), 62 RoundUp(static_cast<int>(sizeof(ProducerPosition)),
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 } 113 }
113 114
114 115
115 void SamplingCircularQueue::FlushResidualRecords() { 116 void SamplingCircularQueue::FlushResidualRecords() {
116 // Eliminate producer / consumer distance. 117 // Eliminate producer / consumer distance.
117 consumer_pos_->dequeue_chunk_poll_pos = consumer_pos_->dequeue_chunk_pos; 118 consumer_pos_->dequeue_chunk_poll_pos = consumer_pos_->dequeue_chunk_pos;
118 } 119 }
119 120
120 121
121 } } // namespace v8::internal 122 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698