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

Side by Side Diff: runtime/vm/trace_buffer.h

Issue 1711163002: Remove more things (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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
OLDNEW
(Empty)
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 #ifndef VM_TRACE_BUFFER_H_
6 #define VM_TRACE_BUFFER_H_
7
8 #include "platform/assert.h"
9 #include "platform/globals.h"
10 #include "vm/json_stream.h"
11
12 namespace dart {
13
14 class JSONStream;
15 class Script;
16
17 struct TraceBufferEntry {
18 int64_t micros;
19 char* message;
20 bool message_is_escaped;
21 bool empty() const {
22 return message == NULL;
23 }
24 };
25
26 class TraceBuffer {
27 public:
28 static const intptr_t kDefaultCapacity = 1024;
29
30 static void Init(Isolate* isolate, intptr_t capacity = kDefaultCapacity);
31
32 ~TraceBuffer();
33
34 void Clear();
35
36 // Internally message is copied.
37 void Trace(int64_t micros, const char* msg, bool msg_is_escaped = false);
38 // Internally message is copied.
39 void Trace(const char* msg, bool msg_is_escaped = false);
40 void TraceF(const char* format, ...) PRINTF_ATTRIBUTE(2, 3);
41
42 void PrintToJSONStream(JSONStream* stream) const;
43
44 // Accessors for testing.
45 TraceBufferEntry* At(intptr_t i) const { return &ring_[RingIndex(i)]; }
46 intptr_t Length() const { return ring_cursor_; }
47
48 private:
49 TraceBuffer(Isolate* isolate, intptr_t capacity);
50 void Cleanup();
51 void Fill(TraceBufferEntry* entry, int64_t micros,
52 char* msg, bool msg_is_escaped = false);
53 void AppendTrace(int64_t micros, char* msg, bool msg_is_escaped = false);
54
55 Isolate* isolate_;
56 TraceBufferEntry* ring_;
57 const intptr_t ring_capacity_;
58 intptr_t ring_cursor_;
59
60 intptr_t RingIndex(intptr_t i) const {
61 return i % ring_capacity_;
62 }
63
64 DISALLOW_COPY_AND_ASSIGN(TraceBuffer);
65 };
66
67
68 } // namespace dart
69
70 #endif // VM_TRACE_BUFFER_H_
OLDNEW
« runtime/vm/os_linux.cc ('K') | « runtime/vm/timer.h ('k') | runtime/vm/trace_buffer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698