Commit 4879fd2c authored by jochen's avatar jochen Committed by Commit bot

Move setup of code event handlers to gin

This will make sure that the handlers are set at the correct point
during v8::Isolate construction

BUG=none
R=svenpanne@chromium.org

Review URL: https://codereview.chromium.org/567343002

Cr-Commit-Position: refs/heads/master@{#295066}
parent a45fa214
...@@ -19,6 +19,7 @@ include_rules = [ ...@@ -19,6 +19,7 @@ include_rules = [
"+components/signin/core/common", "+components/signin/core/common",
"+components/translate/core/common", "+components/translate/core/common",
"+extensions/common", "+extensions/common",
"+gin/public", # For profiling.cc
"+google_apis/gaia", # For gaia_switches.h "+google_apis/gaia", # For gaia_switches.h
"+grit", # For generated headers. TODO(thestig): Remove. "+grit", # For generated headers. TODO(thestig): Remove.
"+media", "+media",
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/threading/thread.h" #include "base/threading/thread.h"
#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_switches.h"
#include "gin/public/debug.h"
#include "v8/include/v8.h" #include "v8/include/v8.h"
namespace { namespace {
...@@ -146,14 +147,11 @@ void Profiling::ProcessStarted() { ...@@ -146,14 +147,11 @@ void Profiling::ProcessStarted() {
add_dynamic_symbol_func = base::debug::GetProfilerAddDynamicSymbolFunc(); add_dynamic_symbol_func = base::debug::GetProfilerAddDynamicSymbolFunc();
move_dynamic_symbol_func = base::debug::GetProfilerMoveDynamicSymbolFunc(); move_dynamic_symbol_func = base::debug::GetProfilerMoveDynamicSymbolFunc();
v8::Isolate* isolate = v8::Isolate::GetCurrent(); if (entry_hook_func != NULL &&
if (isolate != NULL &&
entry_hook_func != NULL &&
add_dynamic_symbol_func != NULL && add_dynamic_symbol_func != NULL &&
move_dynamic_symbol_func != NULL) { move_dynamic_symbol_func != NULL) {
v8::V8::SetFunctionEntryHook(isolate, entry_hook_func); gin::Debug::SetFunctionEntryHook(entry_hook_func);
v8::V8::SetJitCodeEventHandler(v8::kJitCodeEventDefault, gin::Debug::SetJitCodeEventHandler(&JitCodeEventHandler);
&JitCodeEventHandler);
} }
} }
......
...@@ -11,6 +11,8 @@ component("gin") { ...@@ -11,6 +11,8 @@ component("gin") {
"context_holder.cc", "context_holder.cc",
"converter.cc", "converter.cc",
"converter.h", "converter.h",
"debug_impl.cc",
"debug_impl.h",
"dictionary.cc", "dictionary.cc",
"dictionary.h", "dictionary.h",
"function_template.cc", "function_template.cc",
...@@ -38,6 +40,7 @@ component("gin") { ...@@ -38,6 +40,7 @@ component("gin") {
"per_isolate_data.cc", "per_isolate_data.cc",
"per_isolate_data.h", "per_isolate_data.h",
"public/context_holder.h", "public/context_holder.h",
"public/debug.h",
"public/gin_embedders.h", "public/gin_embedders.h",
"public/isolate_holder.h", "public/isolate_holder.h",
"public/v8_platform.h", "public/v8_platform.h",
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "gin/debug_impl.h"
namespace gin {
namespace {
v8::FunctionEntryHook g_entry_hook = NULL;
v8::JitCodeEventHandler g_jit_code_event_handler = NULL;
} // namespace
// static
void Debug::SetFunctionEntryHook(v8::FunctionEntryHook entry_hook) {
g_entry_hook = entry_hook;
}
// static
void Debug::SetJitCodeEventHandler(v8::JitCodeEventHandler event_handler) {
g_jit_code_event_handler = event_handler;
}
// static
v8::FunctionEntryHook DebugImpl::GetFunctionEntryHook() {
return g_entry_hook;
}
// static
v8::JitCodeEventHandler DebugImpl::GetJitCodeEventHandler() {
return g_jit_code_event_handler;
}
} // namespace gin
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef GIN_PUBLIC_DEBUG_IMPL_H_
#define GIN_PUBLIC_DEBUG_IMPL_H_
#include "gin/public/debug.h"
#include "v8/include/v8.h"
namespace gin {
class DebugImpl {
public:
static v8::FunctionEntryHook GetFunctionEntryHook();
static v8::JitCodeEventHandler GetJitCodeEventHandler();
};
} // namespace gin
#endif // GIN_PUBLIC_DEBUG_IMPL_H_
...@@ -31,6 +31,8 @@ ...@@ -31,6 +31,8 @@
'context_holder.cc', 'context_holder.cc',
'converter.cc', 'converter.cc',
'converter.h', 'converter.h',
'debug_impl.cc',
'debug_impl.h',
'dictionary.cc', 'dictionary.cc',
'dictionary.h', 'dictionary.h',
'function_template.cc', 'function_template.cc',
...@@ -58,6 +60,7 @@ ...@@ -58,6 +60,7 @@
'per_isolate_data.cc', 'per_isolate_data.cc',
'per_isolate_data.h', 'per_isolate_data.h',
'public/context_holder.h', 'public/context_holder.h',
'public/debug.h',
'public/gin_embedders.h', 'public/gin_embedders.h',
'public/isolate_holder.h', 'public/isolate_holder.h',
'public/v8_platform.h', 'public/v8_platform.h',
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "base/rand_util.h" #include "base/rand_util.h"
#include "base/sys_info.h" #include "base/sys_info.h"
#include "gin/array_buffer.h" #include "gin/array_buffer.h"
#include "gin/debug_impl.h"
#include "gin/function_template.h" #include "gin/function_template.h"
#include "gin/per_isolate_data.h" #include "gin/per_isolate_data.h"
#include "gin/public/v8_platform.h" #include "gin/public/v8_platform.h"
...@@ -31,7 +32,10 @@ bool GenerateEntropy(unsigned char* buffer, size_t amount) { ...@@ -31,7 +32,10 @@ bool GenerateEntropy(unsigned char* buffer, size_t amount) {
IsolateHolder::IsolateHolder() { IsolateHolder::IsolateHolder() {
CHECK(g_array_buffer_allocator) CHECK(g_array_buffer_allocator)
<< "You need to invoke gin::IsolateHolder::Initialize first"; << "You need to invoke gin::IsolateHolder::Initialize first";
isolate_ = v8::Isolate::New(); v8::Isolate::CreateParams params;
params.entry_hook = DebugImpl::GetFunctionEntryHook();
params.code_event_handler = DebugImpl::GetJitCodeEventHandler();
isolate_ = v8::Isolate::New(params);
v8::ResourceConstraints constraints; v8::ResourceConstraints constraints;
constraints.ConfigureDefaults(base::SysInfo::AmountOfPhysicalMemory(), constraints.ConfigureDefaults(base::SysInfo::AmountOfPhysicalMemory(),
base::SysInfo::AmountOfVirtualMemory(), base::SysInfo::AmountOfVirtualMemory(),
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef GIN_PUBLIC_DEBUG_H_
#define GIN_PUBLIC_DEBUG_H_
#include "gin/gin_export.h"
#include "v8/include/v8.h"
namespace gin {
class GIN_EXPORT Debug {
public:
/* Installs a callback that is invoked on entry to every V8-generated
* function.
*
* This only affects IsolateHolder instances created after
* SetFunctionEntryHook was invoked.
*/
static void SetFunctionEntryHook(v8::FunctionEntryHook entry_hook);
/* Installs a callback that is invoked each time jit code is added, moved,
* or removed.
*
* This only affects IsolateHolder instances created after
* SetJitCodeEventHandler was invoked.
*/
static void SetJitCodeEventHandler(v8::JitCodeEventHandler event_handler);
};
} // namespace gin
#endif // GIN_PUBLIC_DEBUG_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment