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

Unified Diff: src/debug.cc

Issue 7003108: "Deiceolate" Thread classes. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 6 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
Index: src/debug.cc
diff --git a/src/debug.cc b/src/debug.cc
index 85c4b5ef34d25758e97e3bcdd47ae002ba5e5e6c..f341fc6f1f1657f9eec848d011958f4224c8559a 100644
--- a/src/debug.cc
+++ b/src/debug.cc
@@ -796,7 +796,6 @@ bool Debug::Load() {
// Return if debugger is already loaded.
if (IsLoaded()) return true;
- ASSERT(Isolate::Current() == isolate_);
Vitaly Repeshko 2011/06/10 08:18:50 Some of these asserts are useful as the isolate is
mnaganov (inactive) 2011/06/10 09:31:32 http://code.google.com/p/v8/issues/detail?id=1449
Debugger* debugger = isolate_->debugger();
// Bail out if we're already in the process of compiling the native
@@ -1048,7 +1047,6 @@ Handle<Object> Debug::CheckBreakPoints(Handle<Object> break_point_objects) {
// Check whether a single break point object is triggered.
bool Debug::CheckBreakPoint(Handle<Object> break_point_object) {
- ASSERT(Isolate::Current() == isolate_);
Factory* factory = isolate_->factory();
HandleScope scope(isolate_);
@@ -1234,7 +1232,6 @@ bool Debug::IsBreakOnException(ExceptionBreakType type) {
void Debug::PrepareStep(StepAction step_action, int step_count) {
- ASSERT(Isolate::Current() == isolate_);
HandleScope scope(isolate_);
ASSERT(Debug::InDebugger());
@@ -1739,7 +1736,6 @@ void Debug::RemoveDebugInfo(Handle<DebugInfo> debug_info) {
void Debug::SetAfterBreakTarget(JavaScriptFrame* frame) {
- ASSERT(Isolate::Current() == isolate_);
HandleScope scope(isolate_);
// Get the executing function in which the debug break occurred.
@@ -1872,7 +1868,6 @@ bool Debug::IsDebugGlobal(GlobalObject* global) {
void Debug::ClearMirrorCache() {
- ASSERT(Isolate::Current() == isolate_);
PostponeInterruptsScope postpone(isolate_);
HandleScope scope(isolate_);
ASSERT(isolate_->context() == *Debug::debug_context());
@@ -1892,7 +1887,6 @@ void Debug::ClearMirrorCache() {
void Debug::CreateScriptCache() {
- ASSERT(Isolate::Current() == isolate_);
Heap* heap = isolate_->heap();
HandleScope scope(isolate_);
@@ -1934,7 +1928,6 @@ void Debug::AddScriptToScriptCache(Handle<Script> script) {
Handle<FixedArray> Debug::GetLoadedScripts() {
- ASSERT(Isolate::Current() == isolate_);
// Create and fill the script cache when the loaded scripts is requested for
// the first time.
if (script_cache_ == NULL) {
@@ -1964,7 +1957,7 @@ void Debug::AfterGarbageCollection() {
}
-Debugger::Debugger()
+Debugger::Debugger(Isolate* isolate)
: debugger_access_(OS::CreateMutex()),
event_listener_(Handle<Object>()),
event_listener_data_(Handle<Object>()),
@@ -1979,9 +1972,10 @@ Debugger::Debugger()
message_dispatch_helper_thread_(NULL),
host_dispatch_micros_(100 * 1000),
agent_(NULL),
- command_queue_(kQueueInitialSize),
+ command_queue_(isolate->logger(), kQueueInitialSize),
command_received_(OS::CreateSemaphore(0)),
- event_command_queue_(kQueueInitialSize) {
+ event_command_queue_(isolate->logger(), kQueueInitialSize),
+ isolate_(isolate) {
}
@@ -1998,7 +1992,6 @@ Debugger::~Debugger() {
Handle<Object> Debugger::MakeJSObject(Vector<const char> constructor_name,
int argc, Object*** argv,
bool* caught_exception) {
- ASSERT(Isolate::Current() == isolate_);
ASSERT(isolate_->context() == *isolate_->debug()->debug_context());
// Create the execution state object.
@@ -2020,7 +2013,6 @@ Handle<Object> Debugger::MakeJSObject(Vector<const char> constructor_name,
Handle<Object> Debugger::MakeExecutionState(bool* caught_exception) {
- ASSERT(Isolate::Current() == isolate_);
// Create the execution state object.
Handle<Object> break_id = isolate_->factory()->NewNumberFromInt(
isolate_->debug()->break_id());
@@ -2034,7 +2026,6 @@ Handle<Object> Debugger::MakeExecutionState(bool* caught_exception) {
Handle<Object> Debugger::MakeBreakEvent(Handle<Object> exec_state,
Handle<Object> break_points_hit,
bool* caught_exception) {
- ASSERT(Isolate::Current() == isolate_);
// Create the new break event object.
const int argc = 2;
Object** argv[argc] = { exec_state.location(),
@@ -2050,7 +2041,6 @@ Handle<Object> Debugger::MakeExceptionEvent(Handle<Object> exec_state,
Handle<Object> exception,
bool uncaught,
bool* caught_exception) {
- ASSERT(Isolate::Current() == isolate_);
Factory* factory = isolate_->factory();
// Create the new exception event object.
const int argc = 3;
@@ -2065,7 +2055,6 @@ Handle<Object> Debugger::MakeExceptionEvent(Handle<Object> exec_state,
Handle<Object> Debugger::MakeNewFunctionEvent(Handle<Object> function,
bool* caught_exception) {
- ASSERT(Isolate::Current() == isolate_);
// Create the new function event object.
const int argc = 1;
Object** argv[argc] = { function.location() };
@@ -2077,7 +2066,6 @@ Handle<Object> Debugger::MakeNewFunctionEvent(Handle<Object> function,
Handle<Object> Debugger::MakeCompileEvent(Handle<Script> script,
bool before,
bool* caught_exception) {
- ASSERT(Isolate::Current() == isolate_);
Factory* factory = isolate_->factory();
// Create the compile event object.
Handle<Object> exec_state = MakeExecutionState(caught_exception);
@@ -2097,7 +2085,6 @@ Handle<Object> Debugger::MakeCompileEvent(Handle<Script> script,
Handle<Object> Debugger::MakeScriptCollectedEvent(int id,
bool* caught_exception) {
- ASSERT(Isolate::Current() == isolate_);
// Create the script collected event object.
Handle<Object> exec_state = MakeExecutionState(caught_exception);
Handle<Object> id_object = Handle<Smi>(Smi::FromInt(id));
@@ -2112,7 +2099,6 @@ Handle<Object> Debugger::MakeScriptCollectedEvent(int id,
void Debugger::OnException(Handle<Object> exception, bool uncaught) {
- ASSERT(Isolate::Current() == isolate_);
HandleScope scope(isolate_);
Debug* debug = isolate_->debug();
@@ -2157,7 +2143,6 @@ void Debugger::OnException(Handle<Object> exception, bool uncaught) {
void Debugger::OnDebugBreak(Handle<Object> break_points_hit,
bool auto_continue) {
- ASSERT(Isolate::Current() == isolate_);
HandleScope scope(isolate_);
// Debugger has already been entered by caller.
@@ -2167,7 +2152,7 @@ void Debugger::OnDebugBreak(Handle<Object> break_points_hit,
if (!Debugger::EventActive(v8::Break)) return;
// Debugger must be entered in advance.
- ASSERT(Isolate::Current()->context() == *isolate_->debug()->debug_context());
+ ASSERT(isolate_->context() == *isolate_->debug()->debug_context());
// Create the event data object.
bool caught_exception = false;
@@ -2190,7 +2175,6 @@ void Debugger::OnDebugBreak(Handle<Object> break_points_hit,
void Debugger::OnBeforeCompile(Handle<Script> script) {
- ASSERT(Isolate::Current() == isolate_);
HandleScope scope(isolate_);
// Bail out based on state or if there is no listener for this event
@@ -2220,7 +2204,6 @@ void Debugger::OnBeforeCompile(Handle<Script> script) {
// Handle debugger actions when a new script is compiled.
void Debugger::OnAfterCompile(Handle<Script> script,
AfterCompileFlags after_compile_flags) {
- ASSERT(Isolate::Current() == isolate_);
HandleScope scope(isolate_);
Debug* debug = isolate_->debug();
@@ -2289,7 +2272,6 @@ void Debugger::OnAfterCompile(Handle<Script> script,
void Debugger::OnScriptCollected(int id) {
- ASSERT(Isolate::Current() == isolate_);
HandleScope scope(isolate_);
// No more to do if not debugging.
@@ -2319,7 +2301,6 @@ void Debugger::OnScriptCollected(int id) {
void Debugger::ProcessDebugEvent(v8::DebugEvent event,
Handle<JSObject> event_data,
bool auto_continue) {
- ASSERT(Isolate::Current() == isolate_);
HandleScope scope(isolate_);
// Clear any pending debug break if this is a real break.
@@ -2395,7 +2376,6 @@ void Debugger::CallJSEventCallback(v8::DebugEvent event,
Handle<Object> exec_state,
Handle<Object> event_data) {
ASSERT(event_listener_->IsJSFunction());
- ASSERT(Isolate::Current() == isolate_);
Handle<JSFunction> fun(Handle<JSFunction>::cast(event_listener_));
// Invoke the JavaScript debug event listener.
@@ -2411,7 +2391,6 @@ void Debugger::CallJSEventCallback(v8::DebugEvent event,
Handle<Context> Debugger::GetDebugContext() {
- ASSERT(Isolate::Current() == isolate_);
never_unload_debugger_ = true;
EnterDebugger debugger;
return isolate_->debug()->debug_context();
@@ -2419,7 +2398,6 @@ Handle<Context> Debugger::GetDebugContext() {
void Debugger::UnloadDebugger() {
- ASSERT(Isolate::Current() == isolate_);
Debug* debug = isolate_->debug();
// Make sure that there are no breakpoints left.
@@ -2439,7 +2417,6 @@ void Debugger::NotifyMessageHandler(v8::DebugEvent event,
Handle<JSObject> exec_state,
Handle<JSObject> event_data,
bool auto_continue) {
- ASSERT(Isolate::Current() == isolate_);
HandleScope scope(isolate_);
if (!isolate_->debug()->Load()) return;
@@ -2535,7 +2512,8 @@ void Debugger::NotifyMessageHandler(v8::DebugEvent event,
// Get the command from the queue.
CommandMessage command = command_queue_.Get();
- LOGGER->DebugTag("Got request from command queue, in interactive loop.");
+ isolate_->logger()->DebugTag(
+ "Got request from command queue, in interactive loop.");
if (!Debugger::IsDebuggerActive()) {
// Delete command text and user data.
command.Dispose();
@@ -2609,7 +2587,6 @@ void Debugger::NotifyMessageHandler(v8::DebugEvent event,
void Debugger::SetEventListener(Handle<Object> callback,
Handle<Object> data) {
- ASSERT(Isolate::Current() == isolate_);
HandleScope scope(isolate_);
GlobalHandles* global_handles = isolate_->global_handles();
@@ -2643,7 +2620,6 @@ void Debugger::SetEventListener(Handle<Object> callback,
void Debugger::SetMessageHandler(v8::Debug::MessageHandler2 handler) {
- ASSERT(Isolate::Current() == isolate_);
ScopedLock with(debugger_access_);
message_handler_ = handler;
@@ -2659,7 +2635,6 @@ void Debugger::SetMessageHandler(v8::Debug::MessageHandler2 handler) {
void Debugger::ListenersChanged() {
- ASSERT(Isolate::Current() == isolate_);
if (IsDebuggerActive()) {
// Disable the compilation cache when the debugger is active.
isolate_->compilation_cache()->Disable();
Vitaly Repeshko 2011/06/10 08:18:50 As we discussed this is actually unsafe. Listeners
mnaganov (inactive) 2011/06/10 09:31:32 http://code.google.com/p/v8/issues/detail?id=1448
@@ -2675,7 +2650,6 @@ void Debugger::ListenersChanged() {
void Debugger::SetHostDispatchHandler(v8::Debug::HostDispatchHandler handler,
int period) {
- ASSERT(Isolate::Current() == isolate_);
host_dispatch_handler_ = handler;
host_dispatch_micros_ = period * 1000;
}
@@ -2683,7 +2657,6 @@ void Debugger::SetHostDispatchHandler(v8::Debug::HostDispatchHandler handler,
void Debugger::SetDebugMessageDispatchHandler(
v8::Debug::DebugMessageDispatchHandler handler, bool provide_locker) {
- ASSERT(Isolate::Current() == isolate_);
ScopedLock with(dispatch_handler_access_);
debug_message_dispatch_handler_ = handler;
@@ -2697,7 +2670,6 @@ void Debugger::SetDebugMessageDispatchHandler(
// Calls the registered debug message handler. This callback is part of the
// public API.
void Debugger::InvokeMessageHandler(MessageImpl message) {
- ASSERT(Isolate::Current() == isolate_);
ScopedLock with(debugger_access_);
if (message_handler_ != NULL) {
@@ -2712,13 +2684,12 @@ void Debugger::InvokeMessageHandler(MessageImpl message) {
// by the API client thread.
void Debugger::ProcessCommand(Vector<const uint16_t> command,
v8::Debug::ClientData* client_data) {
- ASSERT(Isolate::Current() == isolate_);
// Need to cast away const.
CommandMessage message = CommandMessage::New(
Vector<uint16_t>(const_cast<uint16_t*>(command.start()),
command.length()),
client_data);
- LOGGER->DebugTag("Put command on command_queue.");
+ isolate_->logger()->DebugTag("Put command on command_queue.");
command_queue_.Put(message);
command_received_->Signal();
@@ -2742,13 +2713,11 @@ void Debugger::ProcessCommand(Vector<const uint16_t> command,
bool Debugger::HasCommands() {
- ASSERT(Isolate::Current() == isolate_);
return !command_queue_.IsEmpty();
}
void Debugger::EnqueueDebugCommand(v8::Debug::ClientData* client_data) {
- ASSERT(Isolate::Current() == isolate_);
CommandMessage message = CommandMessage::New(Vector<uint16_t>(), client_data);
event_command_queue_.Put(message);
@@ -2760,7 +2729,6 @@ void Debugger::EnqueueDebugCommand(v8::Debug::ClientData* client_data) {
bool Debugger::IsDebuggerActive() {
- ASSERT(Isolate::Current() == isolate_);
ScopedLock with(debugger_access_);
return message_handler_ != NULL || !event_listener_.is_null();
@@ -2770,7 +2738,6 @@ bool Debugger::IsDebuggerActive() {
Handle<Object> Debugger::Call(Handle<JSFunction> fun,
Handle<Object> data,
bool* pending_exception) {
- ASSERT(Isolate::Current() == isolate_);
// When calling functions in the debugger prevent it from beeing unloaded.
Debugger::never_unload_debugger_ = true;
@@ -2820,7 +2787,7 @@ bool Debugger::StartAgent(const char* name, int port,
if (Socket::Setup()) {
if (agent_ == NULL) {
- agent_ = new DebuggerAgent(isolate_, name, port);
+ agent_ = new DebuggerAgent(name, port);
agent_->Start();
}
return true;
@@ -2849,7 +2816,6 @@ void Debugger::WaitForAgent() {
void Debugger::CallMessageDispatchHandler() {
- ASSERT(Isolate::Current() == isolate_);
v8::Debug::DebugMessageDispatchHandler handler;
{
ScopedLock with(dispatch_handler_access_);
@@ -3083,8 +3049,8 @@ void CommandMessageQueue::Expand() {
}
-LockingCommandMessageQueue::LockingCommandMessageQueue(int size)
- : queue_(size) {
+LockingCommandMessageQueue::LockingCommandMessageQueue(Logger* logger, int size)
+ : logger_(logger), queue_(size) {
lock_ = OS::CreateMutex();
}
@@ -3103,7 +3069,7 @@ bool LockingCommandMessageQueue::IsEmpty() const {
CommandMessage LockingCommandMessageQueue::Get() {
ScopedLock sl(lock_);
CommandMessage result = queue_.Get();
- LOGGER->DebugEvent("Get", result.text());
+ logger_->DebugEvent("Get", result.text());
return result;
}
@@ -3111,7 +3077,7 @@ CommandMessage LockingCommandMessageQueue::Get() {
void LockingCommandMessageQueue::Put(const CommandMessage& message) {
ScopedLock sl(lock_);
queue_.Put(message);
- LOGGER->DebugEvent("Put", message.text());
+ logger_->DebugEvent("Put", message.text());
}
@@ -3122,7 +3088,7 @@ void LockingCommandMessageQueue::Clear() {
MessageDispatchHelperThread::MessageDispatchHelperThread(Isolate* isolate)
- : Thread(isolate, "v8:MsgDispHelpr"),
+ : Thread("v8:MsgDispHelpr"),
sem_(OS::CreateSemaphore(0)), mutex_(OS::CreateMutex()),
already_signalled_(false) {
}

Powered by Google App Engine
This is Rietveld 408576698