Commit 65a18578 authored by jochen@chromium.org's avatar jochen@chromium.org

Currently, a new isolate is created in an uninitialized state, and

several API methods will automatically initialize it. During this
uninitialized state, code event handlers and function entry handlers can
be attached to the isolate.

This CL deprecates SetFunctionEntryHook and moves the configuration of
those handlers to the Isolate factory method.

This will allow for initializing the Isolate at creation time in the
future.

Users of V8::SetFunctionEntryHook should pass the entry hook to
Isolate::New instead. V8::SetJitCodeEventHandler should either be passed
to Isolate::New as well, or (if startup events are not required) invoked
via the Isolate.

BUG=none
LOG=y
R=svenpanne@chromium.org

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

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23940 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 734fd707
This diff is collapsed.
......@@ -6662,8 +6662,16 @@ Isolate* Isolate::GetCurrent() {
}
Isolate* Isolate::New() {
Isolate* Isolate::New(const Isolate::CreateParams& params) {
i::Isolate* isolate = new i::Isolate();
if (params.entry_hook) {
isolate->set_function_entry_hook(params.entry_hook);
}
if (params.code_event_handler) {
isolate->InitializeLoggingAndCounters();
isolate->logger()->SetCodeEventHandler(kJitCodeEventDefault,
params.code_event_handler);
}
return reinterpret_cast<Isolate*>(isolate);
}
......@@ -6872,6 +6880,15 @@ int v8::Isolate::ContextDisposedNotification() {
}
void v8::Isolate::SetJitCodeEventHandler(JitCodeEventOptions options,
JitCodeEventHandler event_handler) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
// Ensure that logging is initialized for our isolate.
isolate->InitializeLoggingAndCounters();
isolate->logger()->SetCodeEventHandler(options, event_handler);
}
String::Utf8Value::Utf8Value(v8::Handle<v8::Value> obj)
: str_(NULL), length_(0) {
i::Isolate* isolate = i::Isolate::Current();
......
......@@ -1612,7 +1612,16 @@ int Shell::Main(int argc, char* argv[]) {
v8::V8::SetArrayBufferAllocator(&array_buffer_allocator);
}
int result = 0;
Isolate* isolate = Isolate::New();
Isolate::CreateParams create_params;
#if !defined(V8_SHARED) && defined(ENABLE_GDB_JIT_INTERFACE)
if (i::FLAG_gdbjit) {
create_params.code_event_handler = i::GDBJITInterface::EventHandler;
}
#endif
#ifdef ENABLE_VTUNE_JIT_INTERFACE
vTune::InitializeVtuneForV8(create_params);
#endif
Isolate* isolate = Isolate::New(create_params);
#ifndef V8_SHARED
v8::ResourceConstraints constraints;
constraints.ConfigureDefaults(base::SysInfo::AmountOfPhysicalMemory(),
......@@ -1624,15 +1633,6 @@ int Shell::Main(int argc, char* argv[]) {
{
Isolate::Scope scope(isolate);
Initialize(isolate);
#if !defined(V8_SHARED) && defined(ENABLE_GDB_JIT_INTERFACE)
if (i::FLAG_gdbjit) {
v8::V8::SetJitCodeEventHandler(v8::kJitCodeEventDefault,
i::GDBJITInterface::EventHandler);
}
#endif
#ifdef ENABLE_VTUNE_JIT_INTERFACE
vTune::InitializeVtuneForV8();
#endif
PerIsolateData data(isolate);
InitializeDebugger(isolate);
......
include_rules = [
"+../../../include",
]
......@@ -58,9 +58,11 @@
#ifndef V8_VTUNE_H_
#define V8_VTUNE_H_
#include "../../../include/v8.h"
namespace vTune {
void InitializeVtuneForV8();
void InitializeVtuneForV8(v8::Isolate::CreateParams& params);
} // namespace vTune
......
......@@ -271,13 +271,10 @@ void VTUNEJITInterface::event_handler(const v8::JitCodeEvent* event) {
} // namespace internal
void InitializeVtuneForV8() {
if (v8::V8::Initialize()) {
void InitializeVtuneForV8(v8::Isolate::CreateParams& params) {
v8::V8::SetFlagsFromString("--nocompact_code_space",
(int)strlen("--nocompact_code_space"));
v8::V8::SetJitCodeEventHandler(v8::kJitCodeEventDefault,
vTune::internal::VTUNEJITInterface::event_handler);
}
params.code_event_handler = vTune::internal::VTUNEJITInterface::event_handler;
}
} // namespace vTune
......@@ -14171,19 +14171,14 @@ void SetFunctionEntryHookTest::RunLoopInNewEnv(v8::Isolate* isolate) {
void SetFunctionEntryHookTest::RunTest() {
// Work in a new isolate throughout.
v8::Isolate* isolate = v8::Isolate::New();
// Test setting the entry hook on the new isolate.
CHECK(v8::V8::SetFunctionEntryHook(isolate, EntryHook));
// Replacing the hook, once set should fail.
CHECK_EQ(false, v8::V8::SetFunctionEntryHook(isolate, EntryHook));
v8::Isolate::CreateParams create_params;
create_params.entry_hook = EntryHook;
create_params.code_event_handler = JitEvent;
v8::Isolate* isolate = v8::Isolate::New(create_params);
{
v8::Isolate::Scope scope(isolate);
v8::V8::SetJitCodeEventHandler(v8::kJitCodeEventDefault, JitEvent);
RunLoopInNewEnv(isolate);
// Check the exepected invocation counts.
......@@ -14211,9 +14206,6 @@ void SetFunctionEntryHookTest::RunTest() {
// We should record no invocations in this isolate.
CHECK_EQ(0, static_cast<int>(invocations_.size()));
}
// Since the isolate has been used, we shouldn't be able to set an entry
// hook anymore.
CHECK_EQ(false, v8::V8::SetFunctionEntryHook(isolate, EntryHook));
isolate->Dispose();
}
......@@ -14407,7 +14399,7 @@ UNINITIALIZED_TEST(SetJitCodeEventHandler) {
saw_bar = 0;
move_events = 0;
V8::SetJitCodeEventHandler(v8::kJitCodeEventDefault, event_handler);
isolate->SetJitCodeEventHandler(v8::kJitCodeEventDefault, event_handler);
// Generate new code objects sparsely distributed across several
// different fragmented code-space pages.
......@@ -14431,7 +14423,7 @@ UNINITIALIZED_TEST(SetJitCodeEventHandler) {
// Force code movement.
heap->CollectAllAvailableGarbage("TestSetJitCodeEventHandler");
V8::SetJitCodeEventHandler(v8::kJitCodeEventDefault, NULL);
isolate->SetJitCodeEventHandler(v8::kJitCodeEventDefault, NULL);
CHECK_LE(kIterations, saw_bar);
CHECK_LT(0, move_events);
......@@ -14461,8 +14453,9 @@ UNINITIALIZED_TEST(SetJitCodeEventHandler) {
i::HashMap lineinfo(MatchPointers);
jitcode_line_info = &lineinfo;
V8::SetJitCodeEventHandler(v8::kJitCodeEventEnumExisting, event_handler);
V8::SetJitCodeEventHandler(v8::kJitCodeEventDefault, NULL);
isolate->SetJitCodeEventHandler(v8::kJitCodeEventEnumExisting,
event_handler);
isolate->SetJitCodeEventHandler(v8::kJitCodeEventDefault, NULL);
jitcode_line_info = NULL;
// We expect that we got some events. Note that if we could get code removal
......
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