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

Side by Side Diff: chrome/child/child_profiling.cc

Issue 2627753004: Move gin and v8 portion of profiling to child from common (Closed)
Patch Set: revert gin removal for now Created 3 years, 11 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 2017 The Chromium 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 #include "chrome/child/child_profiling.h"
6
7 #include "base/debug/profiler.h"
8 #include "base/logging.h"
9 #include "gin/public/debug.h"
10 #include "v8/include/v8.h"
11
12 namespace {
13
14 base::debug::AddDynamicSymbol add_dynamic_symbol_func = NULL;
15 base::debug::MoveDynamicSymbol move_dynamic_symbol_func = NULL;
16
17 void JitCodeEventHandler(const v8::JitCodeEvent* event) {
18 DCHECK_NE(static_cast<base::debug::AddDynamicSymbol>(NULL),
19 add_dynamic_symbol_func);
20 DCHECK_NE(static_cast<base::debug::MoveDynamicSymbol>(NULL),
21 move_dynamic_symbol_func);
22
23 switch (event->type) {
24 case v8::JitCodeEvent::CODE_ADDED:
25 add_dynamic_symbol_func(event->code_start, event->code_len,
26 event->name.str, event->name.len);
27 break;
28
29 case v8::JitCodeEvent::CODE_MOVED:
30 move_dynamic_symbol_func(event->code_start, event->new_code_start);
31 break;
32
33 default:
34 break;
35 }
36 }
37
38 } // namespace
39
40 // static
41 void ChildProfiling::ProcessStarted() {
42 // Establish the V8 profiling hooks if we're an instrumented binary.
43 if (base::debug::IsBinaryInstrumented()) {
44 base::debug::ReturnAddressLocationResolver resolve_func =
45 base::debug::GetProfilerReturnAddrResolutionFunc();
46
47 if (resolve_func != NULL) {
48 v8::V8::SetReturnAddressLocationResolver(resolve_func);
49 }
50
51 // Set up the JIT code entry handler and the symbol callbacks if the
52 // profiler supplies them.
53 // TODO(siggi): Maybe add a switch or an environment variable to turn off
54 // V8 profiling?
55 base::debug::DynamicFunctionEntryHook entry_hook_func =
56 base::debug::GetProfilerDynamicFunctionEntryHookFunc();
57 add_dynamic_symbol_func = base::debug::GetProfilerAddDynamicSymbolFunc();
58 move_dynamic_symbol_func = base::debug::GetProfilerMoveDynamicSymbolFunc();
59
60 if (entry_hook_func != NULL &&
61 add_dynamic_symbol_func != NULL &&
62 move_dynamic_symbol_func != NULL) {
63 gin::Debug::SetFunctionEntryHook(entry_hook_func);
64 gin::Debug::SetJitCodeEventHandler(&JitCodeEventHandler);
65 }
66 }
67 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698