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

Side by Side Diff: test/cctest/test-trace-event.cc

Issue 1704253002: Reland: Add Scoped Context Info (Isolate) to V8 Traces (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase 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
« no previous file with comments | « test/cctest/heap/test-incremental-marking.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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 #include <stdlib.h> 4 #include <stdlib.h>
5 #include <string.h> 5 #include <string.h>
6 6
7 #include "src/v8.h" 7 #include "src/v8.h"
8 8
9 #include "src/list.h" 9 #include "src/list.h"
10 #include "src/list-inl.h" 10 #include "src/list-inl.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 65
66 bool PendingIdleTask() { return false; } 66 bool PendingIdleTask() { return false; }
67 67
68 void PerformIdleTask(double idle_time_in_seconds) {} 68 void PerformIdleTask(double idle_time_in_seconds) {}
69 69
70 bool PendingDelayedTask() { return false; } 70 bool PendingDelayedTask() { return false; }
71 71
72 void PerformDelayedTask() {} 72 void PerformDelayedTask() {}
73 73
74 uint64_t AddTraceEvent(char phase, const uint8_t* category_enabled_flag, 74 uint64_t AddTraceEvent(char phase, const uint8_t* category_enabled_flag,
75 const char* name, uint64_t id, uint64_t bind_id, 75 const char* name, const char* scope, uint64_t id,
76 int num_args, const char** arg_names, 76 uint64_t bind_id, int num_args, const char** arg_names,
77 const uint8_t* arg_types, const uint64_t* arg_values, 77 const uint8_t* arg_types, const uint64_t* arg_values,
78 unsigned int flags) override { 78 unsigned int flags) override {
79 MockTraceObject* to = new MockTraceObject(phase, std::string(name), id, 79 MockTraceObject* to = new MockTraceObject(phase, std::string(name), id,
80 bind_id, num_args, flags); 80 bind_id, num_args, flags);
81 trace_object_list_.Add(to); 81 trace_object_list_.Add(to);
82 return 0; 82 return 0;
83 } 83 }
84 84
85 // TODO(fmeawad): Remove once all embedders implement the scope version.
86 uint64_t AddTraceEvent(char phase, const uint8_t* category_enabled_flag,
87 const char* name, uint64_t id, uint64_t bind_id,
88 int num_args, const char** arg_names,
89 const uint8_t* arg_types, const uint64_t* arg_values,
90 unsigned int flags) override {
91 return 0;
92 }
93
85 void UpdateTraceEventDuration(const uint8_t* category_enabled_flag, 94 void UpdateTraceEventDuration(const uint8_t* category_enabled_flag,
86 const char* name, uint64_t handle) override {} 95 const char* name, uint64_t handle) override {}
87 96
88 const uint8_t* GetCategoryGroupEnabled(const char* name) override { 97 const uint8_t* GetCategoryGroupEnabled(const char* name) override {
89 if (strcmp(name, "v8-cat")) { 98 if (strcmp(name, "v8-cat")) {
90 static uint8_t no = 0; 99 static uint8_t no = 0;
91 return &no; 100 return &no;
92 } else { 101 } else {
93 static uint8_t yes = 0x7; 102 static uint8_t yes = 0x7;
94 return &yes; 103 return &yes;
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 TRACE_EVENT_ASYNC_END0("v8-cat", "a1", event_id); 258 TRACE_EVENT_ASYNC_END0("v8-cat", "a1", event_id);
250 259
251 CHECK_EQ(2, GET_TRACE_OBJECTS_LIST->length()); 260 CHECK_EQ(2, GET_TRACE_OBJECTS_LIST->length());
252 CHECK_EQ(TRACE_EVENT_PHASE_ASYNC_BEGIN, GET_TRACE_OBJECT(0)->phase); 261 CHECK_EQ(TRACE_EVENT_PHASE_ASYNC_BEGIN, GET_TRACE_OBJECT(0)->phase);
253 CHECK_EQ(event_id, GET_TRACE_OBJECT(0)->id); 262 CHECK_EQ(event_id, GET_TRACE_OBJECT(0)->id);
254 CHECK_EQ(TRACE_EVENT_PHASE_ASYNC_END, GET_TRACE_OBJECT(1)->phase); 263 CHECK_EQ(TRACE_EVENT_PHASE_ASYNC_END, GET_TRACE_OBJECT(1)->phase);
255 CHECK_EQ(event_id, GET_TRACE_OBJECT(1)->id); 264 CHECK_EQ(event_id, GET_TRACE_OBJECT(1)->id);
256 265
257 i::V8::SetPlatformForTesting(old_platform); 266 i::V8::SetPlatformForTesting(old_platform);
258 } 267 }
268
269 TEST(TestEventInContext) {
270 v8::Platform* old_platform = i::V8::GetCurrentPlatform();
271 MockTracingPlatform platform(old_platform);
272 i::V8::SetPlatformForTesting(&platform);
273
274 static uint64_t isolate_id = 0x20151021;
275 {
276 TRACE_EVENT_SCOPED_CONTEXT("v8-cat", "Isolate", isolate_id);
277 TRACE_EVENT0("v8-cat", "e");
278 }
279
280 CHECK_EQ(3, GET_TRACE_OBJECTS_LIST->length());
281 CHECK_EQ(TRACE_EVENT_PHASE_ENTER_CONTEXT, GET_TRACE_OBJECT(0)->phase);
282 CHECK_EQ("Isolate", GET_TRACE_OBJECT(0)->name);
283 CHECK_EQ(isolate_id, GET_TRACE_OBJECT(0)->id);
284 CHECK_EQ(TRACE_EVENT_PHASE_COMPLETE, GET_TRACE_OBJECT(1)->phase);
285 CHECK_EQ("e", GET_TRACE_OBJECT(1)->name);
286 CHECK_EQ(TRACE_EVENT_PHASE_LEAVE_CONTEXT, GET_TRACE_OBJECT(2)->phase);
287 CHECK_EQ("Isolate", GET_TRACE_OBJECT(2)->name);
288 CHECK_EQ(isolate_id, GET_TRACE_OBJECT(2)->id);
289
290 i::V8::SetPlatformForTesting(old_platform);
291 }
OLDNEW
« no previous file with comments | « test/cctest/heap/test-incremental-marking.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698