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

Unified Diff: test/cctest/test-debug.cc

Issue 583153002: Reland 24052 - Require V8 to be explicitly initialized before an Isolate is created (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/cctest/test-dataflow.cc ('k') | test/cctest/test-deoptimization.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-debug.cc
diff --git a/test/cctest/test-debug.cc b/test/cctest/test-debug.cc
index 0adcc0a2bc53b8a68cfac9d5441c28bd33d56efc..69c10c29d0fd141dfbe02152d13c5978c721f2bf 100644
--- a/test/cctest/test-debug.cc
+++ b/test/cctest/test-debug.cc
@@ -73,16 +73,23 @@ using ::v8::internal::StrLength;
class DebugLocalContext {
public:
inline DebugLocalContext(
+ v8::Isolate* isolate, v8::ExtensionConfiguration* extensions = 0,
+ v8::Handle<v8::ObjectTemplate> global_template =
+ v8::Handle<v8::ObjectTemplate>(),
+ v8::Handle<v8::Value> global_object = v8::Handle<v8::Value>())
+ : scope_(isolate),
+ context_(v8::Context::New(isolate, extensions, global_template,
+ global_object)) {
+ context_->Enter();
+ }
+ inline DebugLocalContext(
v8::ExtensionConfiguration* extensions = 0,
v8::Handle<v8::ObjectTemplate> global_template =
v8::Handle<v8::ObjectTemplate>(),
v8::Handle<v8::Value> global_object = v8::Handle<v8::Value>())
: scope_(CcTest::isolate()),
- context_(
- v8::Context::New(CcTest::isolate(),
- extensions,
- global_template,
- global_object)) {
+ context_(v8::Context::New(CcTest::isolate(), extensions,
+ global_template, global_object)) {
context_->Enter();
}
inline ~DebugLocalContext() {
@@ -137,8 +144,7 @@ static v8::Local<v8::Function> CompileFunction(v8::Isolate* isolate,
const char* source,
const char* function_name) {
v8::Script::Compile(v8::String::NewFromUtf8(isolate, source))->Run();
- v8::Local<v8::Object> global =
- CcTest::isolate()->GetCurrentContext()->Global();
+ v8::Local<v8::Object> global = isolate->GetCurrentContext()->Global();
return v8::Local<v8::Function>::Cast(
global->Get(v8::String::NewFromUtf8(isolate, function_name)));
}
@@ -5155,12 +5161,20 @@ class V8Thread : public v8::base::Thread {
public:
V8Thread() : Thread(Options("V8Thread")) {}
void Run();
+ v8::Isolate* isolate() { return isolate_; }
+
+ private:
+ v8::Isolate* isolate_;
};
class DebuggerThread : public v8::base::Thread {
public:
- DebuggerThread() : Thread(Options("DebuggerThread")) {}
+ explicit DebuggerThread(v8::Isolate* isolate)
+ : Thread(Options("DebuggerThread")), isolate_(isolate) {}
void Run();
+
+ private:
+ v8::Isolate* isolate_;
};
@@ -5203,22 +5217,25 @@ void V8Thread::Run() {
"\n"
"foo();\n";
- v8::Isolate* isolate = CcTest::isolate();
- v8::Isolate::Scope isolate_scope(isolate);
- DebugLocalContext env;
- v8::HandleScope scope(env->GetIsolate());
- v8::Debug::SetMessageHandler(&ThreadedMessageHandler);
- v8::Handle<v8::ObjectTemplate> global_template =
- v8::ObjectTemplate::New(env->GetIsolate());
- global_template->Set(
- v8::String::NewFromUtf8(env->GetIsolate(), "ThreadedAtBarrier1"),
- v8::FunctionTemplate::New(isolate, ThreadedAtBarrier1));
- v8::Handle<v8::Context> context = v8::Context::New(isolate,
- NULL,
- global_template);
- v8::Context::Scope context_scope(context);
-
- CompileRun(source);
+ isolate_ = v8::Isolate::New();
+ threaded_debugging_barriers.barrier_3.Wait();
+ {
+ v8::Isolate::Scope isolate_scope(isolate_);
+ DebugLocalContext env(isolate_);
+ v8::HandleScope scope(isolate_);
+ v8::Debug::SetMessageHandler(&ThreadedMessageHandler);
+ v8::Handle<v8::ObjectTemplate> global_template =
+ v8::ObjectTemplate::New(env->GetIsolate());
+ global_template->Set(
+ v8::String::NewFromUtf8(env->GetIsolate(), "ThreadedAtBarrier1"),
+ v8::FunctionTemplate::New(isolate_, ThreadedAtBarrier1));
+ v8::Handle<v8::Context> context =
+ v8::Context::New(isolate_, NULL, global_template);
+ v8::Context::Scope context_scope(context);
+
+ CompileRun(source);
+ }
+ isolate_->Dispose();
}
@@ -5234,21 +5251,21 @@ void DebuggerThread::Run() {
"\"type\":\"request\","
"\"command\":\"continue\"}";
- v8::Isolate* isolate = CcTest::isolate();
threaded_debugging_barriers.barrier_1.Wait();
- v8::Debug::DebugBreak(isolate);
+ v8::Debug::DebugBreak(isolate_);
threaded_debugging_barriers.barrier_2.Wait();
- v8::Debug::SendCommand(isolate, buffer, AsciiToUtf16(command_1, buffer));
- v8::Debug::SendCommand(isolate, buffer, AsciiToUtf16(command_2, buffer));
+ v8::Debug::SendCommand(isolate_, buffer, AsciiToUtf16(command_1, buffer));
+ v8::Debug::SendCommand(isolate_, buffer, AsciiToUtf16(command_2, buffer));
}
TEST(ThreadedDebugging) {
- DebuggerThread debugger_thread;
V8Thread v8_thread;
// Create a V8 environment
v8_thread.Start();
+ threaded_debugging_barriers.barrier_3.Wait();
+ DebuggerThread debugger_thread(v8_thread.isolate());
debugger_thread.Start();
v8_thread.Join();
@@ -5267,17 +5284,24 @@ class BreakpointsV8Thread : public v8::base::Thread {
public:
BreakpointsV8Thread() : Thread(Options("BreakpointsV8Thread")) {}
void Run();
+
+ v8::Isolate* isolate() { return isolate_; }
+
+ private:
+ v8::Isolate* isolate_;
};
class BreakpointsDebuggerThread : public v8::base::Thread {
public:
- explicit BreakpointsDebuggerThread(bool global_evaluate)
+ BreakpointsDebuggerThread(bool global_evaluate, v8::Isolate* isolate)
: Thread(Options("BreakpointsDebuggerThread")),
- global_evaluate_(global_evaluate) {}
+ global_evaluate_(global_evaluate),
+ isolate_(isolate) {}
void Run();
private:
bool global_evaluate_;
+ v8::Isolate* isolate_;
};
@@ -5322,16 +5346,20 @@ void BreakpointsV8Thread::Run() {
const char* source_2 = "cat(17);\n"
"cat(19);\n";
- v8::Isolate* isolate = CcTest::isolate();
- v8::Isolate::Scope isolate_scope(isolate);
- DebugLocalContext env;
- v8::HandleScope scope(isolate);
- v8::Debug::SetMessageHandler(&BreakpointsMessageHandler);
-
- CompileRun(source_1);
- breakpoints_barriers->barrier_1.Wait();
- breakpoints_barriers->barrier_2.Wait();
- CompileRun(source_2);
+ isolate_ = v8::Isolate::New();
+ breakpoints_barriers->barrier_3.Wait();
+ {
+ v8::Isolate::Scope isolate_scope(isolate_);
+ DebugLocalContext env(isolate_);
+ v8::HandleScope scope(isolate_);
+ v8::Debug::SetMessageHandler(&BreakpointsMessageHandler);
+
+ CompileRun(source_1);
+ breakpoints_barriers->barrier_1.Wait();
+ breakpoints_barriers->barrier_2.Wait();
+ CompileRun(source_2);
+ }
+ isolate_->Dispose();
}
@@ -5397,14 +5425,12 @@ void BreakpointsDebuggerThread::Run() {
"\"command\":\"continue\"}";
- v8::Isolate* isolate = CcTest::isolate();
- v8::Isolate::Scope isolate_scope(isolate);
// v8 thread initializes, runs source_1
breakpoints_barriers->barrier_1.Wait();
// 1:Set breakpoint in cat() (will get id 1).
- v8::Debug::SendCommand(isolate, buffer, AsciiToUtf16(command_1, buffer));
+ v8::Debug::SendCommand(isolate_, buffer, AsciiToUtf16(command_1, buffer));
// 2:Set breakpoint in dog() (will get id 2).
- v8::Debug::SendCommand(isolate, buffer, AsciiToUtf16(command_2, buffer));
+ v8::Debug::SendCommand(isolate_, buffer, AsciiToUtf16(command_2, buffer));
breakpoints_barriers->barrier_2.Wait();
// V8 thread starts compiling source_2.
// Automatic break happens, to run queued commands
@@ -5416,43 +5442,42 @@ void BreakpointsDebuggerThread::Run() {
// Must have hit breakpoint #1.
CHECK_EQ(1, break_event_breakpoint_id);
// 4:Evaluate dog() (which has a breakpoint).
- v8::Debug::SendCommand(isolate, buffer, AsciiToUtf16(command_3, buffer));
+ v8::Debug::SendCommand(isolate_, buffer, AsciiToUtf16(command_3, buffer));
// V8 thread hits breakpoint in dog().
breakpoints_barriers->semaphore_1.Wait(); // wait for break event
// Must have hit breakpoint #2.
CHECK_EQ(2, break_event_breakpoint_id);
// 5:Evaluate (x + 1).
- v8::Debug::SendCommand(isolate, buffer, AsciiToUtf16(command_4, buffer));
+ v8::Debug::SendCommand(isolate_, buffer, AsciiToUtf16(command_4, buffer));
// Evaluate (x + 1) finishes.
breakpoints_barriers->semaphore_1.Wait();
// Must have result 108.
CHECK_EQ(108, evaluate_int_result);
// 6:Continue evaluation of dog().
- v8::Debug::SendCommand(isolate, buffer, AsciiToUtf16(command_5, buffer));
+ v8::Debug::SendCommand(isolate_, buffer, AsciiToUtf16(command_5, buffer));
// Evaluate dog() finishes.
breakpoints_barriers->semaphore_1.Wait();
// Must have result 107.
CHECK_EQ(107, evaluate_int_result);
// 7:Continue evaluation of source_2, finish cat(17), hit breakpoint
// in cat(19).
- v8::Debug::SendCommand(isolate, buffer, AsciiToUtf16(command_6, buffer));
+ v8::Debug::SendCommand(isolate_, buffer, AsciiToUtf16(command_6, buffer));
// Message callback gets break event.
breakpoints_barriers->semaphore_1.Wait(); // wait for break event
// Must have hit breakpoint #1.
CHECK_EQ(1, break_event_breakpoint_id);
// 8: Evaluate dog() with breaks disabled.
- v8::Debug::SendCommand(isolate, buffer, AsciiToUtf16(command_7, buffer));
+ v8::Debug::SendCommand(isolate_, buffer, AsciiToUtf16(command_7, buffer));
// Evaluate dog() finishes.
breakpoints_barriers->semaphore_1.Wait();
// Must have result 116.
CHECK_EQ(116, evaluate_int_result);
// 9: Continue evaluation of source2, reach end.
- v8::Debug::SendCommand(isolate, buffer, AsciiToUtf16(command_8, buffer));
+ v8::Debug::SendCommand(isolate_, buffer, AsciiToUtf16(command_8, buffer));
}
void TestRecursiveBreakpointsGeneric(bool global_evaluate) {
- BreakpointsDebuggerThread breakpoints_debugger_thread(global_evaluate);
BreakpointsV8Thread breakpoints_v8_thread;
// Create a V8 environment
@@ -5460,6 +5485,9 @@ void TestRecursiveBreakpointsGeneric(bool global_evaluate) {
breakpoints_barriers = &stack_allocated_breakpoints_barriers;
breakpoints_v8_thread.Start();
+ breakpoints_barriers->barrier_3.Wait();
+ BreakpointsDebuggerThread breakpoints_debugger_thread(
+ global_evaluate, breakpoints_v8_thread.isolate());
breakpoints_debugger_thread.Start();
breakpoints_v8_thread.Join();
« no previous file with comments | « test/cctest/test-dataflow.cc ('k') | test/cctest/test-deoptimization.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698