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

Side by Side Diff: include/v8-platform.h

Issue 2367603002: [tracing] Support ConvertableToTraceFormat argument type. (Closed)
Patch Set: Fix layout tests failures & reland. Created 4 years, 2 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 | « include/libplatform/v8-tracing.h ('k') | src/libplatform/default-platform.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_V8_PLATFORM_H_ 5 #ifndef V8_V8_PLATFORM_H_
6 #define V8_V8_PLATFORM_H_ 6 #define V8_V8_PLATFORM_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 #include <memory>
11 #include <string>
10 12
11 namespace v8 { 13 namespace v8 {
12 14
13 class Isolate; 15 class Isolate;
14 16
15 /** 17 /**
16 * A Task represents a unit of work. 18 * A Task represents a unit of work.
17 */ 19 */
18 class Task { 20 class Task {
19 public: 21 public:
20 virtual ~Task() {} 22 virtual ~Task() = default;
21 23
22 virtual void Run() = 0; 24 virtual void Run() = 0;
23 }; 25 };
24 26
25
26 /** 27 /**
27 * An IdleTask represents a unit of work to be performed in idle time. 28 * An IdleTask represents a unit of work to be performed in idle time.
28 * The Run method is invoked with an argument that specifies the deadline in 29 * The Run method is invoked with an argument that specifies the deadline in
29 * seconds returned by MonotonicallyIncreasingTime(). 30 * seconds returned by MonotonicallyIncreasingTime().
30 * The idle task is expected to complete by this deadline. 31 * The idle task is expected to complete by this deadline.
31 */ 32 */
32 class IdleTask { 33 class IdleTask {
33 public: 34 public:
34 virtual ~IdleTask() {} 35 virtual ~IdleTask() = default;
35 virtual void Run(double deadline_in_seconds) = 0; 36 virtual void Run(double deadline_in_seconds) = 0;
36 }; 37 };
37 38
39 /**
40 * The interface represents complex arguments to trace events.
41 */
42 class ConvertableToTraceFormat {
43 public:
44 virtual ~ConvertableToTraceFormat() = default;
45
46 /**
47 * Append the class info to the provided |out| string. The appended
48 * data must be a valid JSON object. Strings must be properly quoted, and
49 * escaped. There is no processing applied to the content after it is
50 * appended.
51 */
52 virtual void AppendAsTraceFormat(std::string* out) const = 0;
53 };
38 54
39 /** 55 /**
40 * V8 Platform abstraction layer. 56 * V8 Platform abstraction layer.
41 * 57 *
42 * The embedder has to provide an implementation of this interface before 58 * The embedder has to provide an implementation of this interface before
43 * initializing the rest of V8. 59 * initializing the rest of V8.
44 */ 60 */
45 class Platform { 61 class Platform {
46 public: 62 public:
47 /** 63 /**
48 * This enum is used to indicate whether a task is potentially long running, 64 * This enum is used to indicate whether a task is potentially long running,
49 * or causes a long wait. The embedder might want to use this hint to decide 65 * or causes a long wait. The embedder might want to use this hint to decide
50 * whether to execute the task on a dedicated thread. 66 * whether to execute the task on a dedicated thread.
51 */ 67 */
52 enum ExpectedRuntime { 68 enum ExpectedRuntime {
53 kShortRunningTask, 69 kShortRunningTask,
54 kLongRunningTask 70 kLongRunningTask
55 }; 71 };
56 72
57 virtual ~Platform() {} 73 virtual ~Platform() = default;
58 74
59 /** 75 /**
60 * Gets the number of threads that are used to execute background tasks. Is 76 * Gets the number of threads that are used to execute background tasks. Is
61 * used to estimate the number of tasks a work package should be split into. 77 * used to estimate the number of tasks a work package should be split into.
62 * A return value of 0 means that there are no background threads available. 78 * A return value of 0 means that there are no background threads available.
63 * Note that a value of 0 won't prohibit V8 from posting tasks using 79 * Note that a value of 0 won't prohibit V8 from posting tasks using
64 * |CallOnBackgroundThread|. 80 * |CallOnBackgroundThread|.
65 */ 81 */
66 virtual size_t NumberOfAvailableBackgroundThreads() { return 0; } 82 virtual size_t NumberOfAvailableBackgroundThreads() { return 0; }
67 83
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 */ 168 */
153 virtual uint64_t AddTraceEvent( 169 virtual uint64_t AddTraceEvent(
154 char phase, const uint8_t* category_enabled_flag, const char* name, 170 char phase, const uint8_t* category_enabled_flag, const char* name,
155 const char* scope, uint64_t id, uint64_t bind_id, int32_t num_args, 171 const char* scope, uint64_t id, uint64_t bind_id, int32_t num_args,
156 const char** arg_names, const uint8_t* arg_types, 172 const char** arg_names, const uint8_t* arg_types,
157 const uint64_t* arg_values, unsigned int flags) { 173 const uint64_t* arg_values, unsigned int flags) {
158 return 0; 174 return 0;
159 } 175 }
160 176
161 /** 177 /**
178 * Adds a trace event to the platform tracing system. This function call is
179 * usually the result of a TRACE_* macro from trace_event_common.h when
180 * tracing and the category of the particular trace are enabled. It is not
181 * advisable to call this function on its own; it is really only meant to be
182 * used by the trace macros. The returned handle can be used by
183 * UpdateTraceEventDuration to update the duration of COMPLETE events.
184 */
185 virtual uint64_t AddTraceEvent(
186 char phase, const uint8_t* category_enabled_flag, const char* name,
187 const char* scope, uint64_t id, uint64_t bind_id, int32_t num_args,
188 const char** arg_names, const uint8_t* arg_types,
189 const uint64_t* arg_values,
190 std::unique_ptr<ConvertableToTraceFormat>* arg_convertables,
191 unsigned int flags) {
192 return AddTraceEvent(phase, category_enabled_flag, name, scope, id, bind_id,
193 num_args, arg_names, arg_types, arg_values, flags);
194 }
195
196 /**
162 * Sets the duration field of a COMPLETE trace event. It must be called with 197 * Sets the duration field of a COMPLETE trace event. It must be called with
163 * the handle returned from AddTraceEvent(). 198 * the handle returned from AddTraceEvent().
164 **/ 199 **/
165 virtual void UpdateTraceEventDuration(const uint8_t* category_enabled_flag, 200 virtual void UpdateTraceEventDuration(const uint8_t* category_enabled_flag,
166 const char* name, uint64_t handle) {} 201 const char* name, uint64_t handle) {}
167 202
168 class TraceStateObserver { 203 class TraceStateObserver {
169 public: 204 public:
170 virtual ~TraceStateObserver() = default; 205 virtual ~TraceStateObserver() = default;
171 virtual void OnTraceEnabled() = 0; 206 virtual void OnTraceEnabled() = 0;
172 virtual void OnTraceDisabled() = 0; 207 virtual void OnTraceDisabled() = 0;
173 }; 208 };
174 209
175 /** Adds tracing state change observer. */ 210 /** Adds tracing state change observer. */
176 virtual void AddTraceStateObserver(TraceStateObserver*) {} 211 virtual void AddTraceStateObserver(TraceStateObserver*) {}
177 212
178 /** Removes tracing state change observer. */ 213 /** Removes tracing state change observer. */
179 virtual void RemoveTraceStateObserver(TraceStateObserver*) {} 214 virtual void RemoveTraceStateObserver(TraceStateObserver*) {}
180 }; 215 };
181 216
182 } // namespace v8 217 } // namespace v8
183 218
184 #endif // V8_V8_PLATFORM_H_ 219 #endif // V8_V8_PLATFORM_H_
OLDNEW
« no previous file with comments | « include/libplatform/v8-tracing.h ('k') | src/libplatform/default-platform.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698