v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
trace-buffer.h
Go to the documentation of this file.
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 V8_LIBPLATFORM_TRACING_TRACE_BUFFER_H_
6#define V8_LIBPLATFORM_TRACING_TRACE_BUFFER_H_
7
8#include <memory>
9#include <vector>
10
13
14namespace v8 {
15namespace platform {
16namespace tracing {
17
19 public:
20 // Takes ownership of |trace_writer|.
21 TraceBufferRingBuffer(size_t max_chunks, TraceWriter* trace_writer);
22 ~TraceBufferRingBuffer() override = default;
23
24 TraceObject* AddTraceEvent(uint64_t* handle) override;
25 TraceObject* GetEventByHandle(uint64_t handle) override;
26 bool Flush() override;
27
28 private:
29 uint64_t MakeHandle(size_t chunk_index, uint32_t chunk_seq,
30 size_t event_index) const;
31 void ExtractHandle(uint64_t handle, size_t* chunk_index, uint32_t* chunk_seq,
32 size_t* event_index) const;
34 size_t NextChunkIndex(size_t index) const;
35
38 std::unique_ptr<TraceWriter> trace_writer_;
39 std::vector<std::unique_ptr<TraceBufferChunk>> chunks_;
41 bool is_empty_ = true;
42 uint32_t current_chunk_seq_ = 1;
43};
44
45} // namespace tracing
46} // namespace platform
47} // namespace v8
48
49#endif // V8_LIBPLATFORM_TRACING_TRACE_BUFFER_H_
TraceBufferRingBuffer(size_t max_chunks, TraceWriter *trace_writer)
TraceObject * GetEventByHandle(uint64_t handle) override
TraceObject * AddTraceEvent(uint64_t *handle) override
std::unique_ptr< TraceWriter > trace_writer_
std::vector< std::unique_ptr< TraceBufferChunk > > chunks_
uint64_t MakeHandle(size_t chunk_index, uint32_t chunk_seq, size_t event_index) const
size_t NextChunkIndex(size_t index) const
void ExtractHandle(uint64_t handle, size_t *chunk_index, uint32_t *chunk_seq, size_t *event_index) const