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

Unified Diff: src/libplatform/tracing/trace-buffer.cc

Issue 2183943002: Revert of [Tracing] V8 Tracing Controller (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/libplatform/tracing/trace-buffer.h ('k') | src/libplatform/tracing/trace-config.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/libplatform/tracing/trace-buffer.cc
diff --git a/src/libplatform/tracing/trace-buffer.cc b/src/libplatform/tracing/trace-buffer.cc
deleted file mode 100644
index 354f0459f68531503bd6eaf6ee09d5928945015f..0000000000000000000000000000000000000000
--- a/src/libplatform/tracing/trace-buffer.cc
+++ /dev/null
@@ -1,109 +0,0 @@
-// Copyright 2016 the V8 project authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "src/libplatform/tracing/trace-buffer.h"
-
-namespace v8 {
-namespace platform {
-namespace tracing {
-
-TraceBufferRingBuffer::TraceBufferRingBuffer(size_t max_chunks,
- TraceWriter* trace_writer)
- : max_chunks_(max_chunks) {
- trace_writer_.reset(trace_writer);
- chunks_.resize(max_chunks);
-}
-
-TraceBufferRingBuffer::~TraceBufferRingBuffer() {}
-
-TraceObject* TraceBufferRingBuffer::AddTraceEvent(uint64_t* handle) {
- base::LockGuard<base::Mutex> guard(&mutex_);
- if (is_empty_ || chunks_[chunk_index_]->IsFull()) {
- chunk_index_ = is_empty_ ? 0 : NextChunkIndex(chunk_index_);
- is_empty_ = false;
- auto& chunk = chunks_[chunk_index_];
- if (chunk) {
- chunk->Reset(current_chunk_seq_++);
- } else {
- chunk.reset(new TraceBufferChunk(current_chunk_seq_++));
- }
- }
- auto& chunk = chunks_[chunk_index_];
- size_t event_index;
- TraceObject* trace_object = chunk->AddTraceEvent(&event_index);
- *handle = MakeHandle(chunk_index_, chunk->seq(), event_index);
- return trace_object;
-}
-
-TraceObject* TraceBufferRingBuffer::GetEventByHandle(uint64_t handle) {
- base::LockGuard<base::Mutex> guard(&mutex_);
- size_t chunk_index, event_index;
- uint32_t chunk_seq;
- ExtractHandle(handle, &chunk_index, &chunk_seq, &event_index);
- if (chunk_index >= chunks_.size()) return NULL;
- auto& chunk = chunks_[chunk_index];
- if (!chunk || chunk->seq() != chunk_seq) return NULL;
- return chunk->GetEventAt(event_index);
-}
-
-bool TraceBufferRingBuffer::Flush() {
- base::LockGuard<base::Mutex> guard(&mutex_);
- // This flushes all the traces stored in the buffer.
- if (!is_empty_) {
- for (size_t i = NextChunkIndex(chunk_index_);; i = NextChunkIndex(i)) {
- if (auto& chunk = chunks_[i]) {
- for (size_t j = 0; j < chunk->size(); ++j) {
- trace_writer_->AppendTraceEvent(chunk->GetEventAt(j));
- }
- }
- if (i == chunk_index_) break;
- }
- }
- trace_writer_->Flush();
- // This resets the trace buffer.
- is_empty_ = true;
- return true;
-}
-
-uint64_t TraceBufferRingBuffer::MakeHandle(size_t chunk_index,
- uint32_t chunk_seq,
- size_t event_index) const {
- return static_cast<uint64_t>(chunk_seq) * Capacity() +
- chunk_index * TraceBufferChunk::kChunkSize + event_index;
-}
-
-void TraceBufferRingBuffer::ExtractHandle(uint64_t handle, size_t* chunk_index,
- uint32_t* chunk_seq,
- size_t* event_index) const {
- *chunk_seq = static_cast<uint32_t>(handle / Capacity());
- size_t indices = handle % Capacity();
- *chunk_index = indices / TraceBufferChunk::kChunkSize;
- *event_index = indices % TraceBufferChunk::kChunkSize;
-}
-
-size_t TraceBufferRingBuffer::NextChunkIndex(size_t index) const {
- if (++index >= max_chunks_) index = 0;
- return index;
-}
-
-TraceBufferChunk::TraceBufferChunk(uint32_t seq) : seq_(seq) {}
-
-void TraceBufferChunk::Reset(uint32_t new_seq) {
- next_free_ = 0;
- seq_ = new_seq;
-}
-
-TraceObject* TraceBufferChunk::AddTraceEvent(size_t* event_index) {
- *event_index = next_free_++;
- return &chunk_[*event_index];
-}
-
-TraceBuffer* TraceBuffer::CreateTraceBufferRingBuffer(
- size_t max_chunks, TraceWriter* trace_writer) {
- return new TraceBufferRingBuffer(max_chunks, trace_writer);
-}
-
-} // namespace tracing
-} // namespace platform
-} // namespace v8
« no previous file with comments | « src/libplatform/tracing/trace-buffer.h ('k') | src/libplatform/tracing/trace-config.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698