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

Side by Side Diff: src/libplatform/tracing/trace-buffer.h

Issue 2137013006: [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 unified diff | Download patch
« no previous file with comments | « src/libplatform/default-tracing-controller.cc ('k') | src/libplatform/tracing/trace-buffer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef SRC_LIBPLATFORM_TRACING_TRACE_BUFFER_H_
6 #define SRC_LIBPLATFORM_TRACING_TRACE_BUFFER_H_
7
8 #include <memory>
9 #include <vector>
10
11 #include "include/libplatform/v8-tracing.h"
12
13 namespace v8 {
14 namespace platform {
15 namespace tracing {
16
17 class TraceBufferChunk {
18 public:
19 explicit TraceBufferChunk(uint32_t seq);
20
21 void Reset(uint32_t new_seq);
22 bool IsFull() const { return next_free_ == kChunkSize; }
23 TraceObject* AddTraceEvent(size_t* event_index);
24 TraceObject* GetEventAt(size_t index) { return &chunk_[index]; }
25
26 uint32_t seq() const { return seq_; }
27 size_t size() const { return next_free_; }
28
29 static const size_t kChunkSize = 64;
30
31 private:
32 size_t next_free_;
33 TraceObject chunk_[kChunkSize];
34 uint32_t seq_;
35 };
rskang 2016/07/12 00:58:52 Can TraceBufferChunk go into v8-tracing.h as well?
fmeawad 2016/07/12 21:03:19 Done.
36
37 class TraceBufferRingBuffer : public TraceBuffer {
38 public:
39 TraceBufferRingBuffer(size_t max_chunks, TraceWriter* trace_writer);
40 ~TraceBufferRingBuffer();
41
42 TraceObject* AddTraceEvent(uint64_t* handle) override;
43 TraceObject* GetEventByHandle(uint64_t handle) override;
44 bool Flush() override;
45
46 private:
47 uint64_t MakeHandle(size_t chunk_index, uint32_t chunk_seq,
48 size_t event_index) const;
49 void ExtractHandle(uint64_t handle, size_t* chunk_index, uint32_t* chunk_seq,
50 size_t* event_index) const;
51 size_t Capacity() const { return max_chunks_ * TraceBufferChunk::kChunkSize; }
52 size_t NextChunkIndex(size_t index) const;
53
54 size_t max_chunks_;
55 std::unique_ptr<TraceWriter> trace_writer_;
56 std::vector<std::unique_ptr<TraceBufferChunk>> chunks_;
57 size_t chunk_index_;
58 bool is_empty_;
59 uint32_t current_chunk_seq_;
60 };
61
62 } // namespace tracing
63 } // namespace platform
64 } // namespace v8
65
66 #endif // SRC_LIBPLATFORM_TRACING_TRACE_BUFFER_H_
OLDNEW
« no previous file with comments | « src/libplatform/default-tracing-controller.cc ('k') | src/libplatform/tracing/trace-buffer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698