Removed GetDefaultIsolate{Debugger,ForLocking,StackGuard}.

Some first steps towards removing the default Isolate. Fixed argument
order on the way, incl. temporary helpers.

BUG=359977
LOG=y
R=bmeurer@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20747 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
svenpanne@chromium.org 2014-04-15 07:47:33 +00:00
parent 6b4d4b7287
commit cd89f90bd1
7 changed files with 33 additions and 109 deletions

View File

@ -190,32 +190,28 @@ class V8_EXPORT Debug {
Handle<Value> data = Handle<Value>());
// Schedule a debugger break to happen when JavaScript code is run
// in the given isolate. If no isolate is provided the default
// isolate is used.
static void DebugBreak(Isolate* isolate = NULL);
// in the given isolate.
static void DebugBreak(Isolate* isolate);
// Remove scheduled debugger break in given isolate if it has not
// happened yet. If no isolate is provided the default isolate is
// used.
static void CancelDebugBreak(Isolate* isolate = NULL);
// happened yet.
static void CancelDebugBreak(Isolate* isolate);
// Break execution of JavaScript in the given isolate (this method
// can be invoked from a non-VM thread) for further client command
// execution on a VM thread. Client data is then passed in
// EventDetails to EventCallback2 at the moment when the VM actually
// stops. If no isolate is provided the default isolate is used.
static void DebugBreakForCommand(ClientData* data = NULL,
Isolate* isolate = NULL);
// stops.
static void DebugBreakForCommand(Isolate* isolate, ClientData* data);
// TODO(svenpanne) Remove this when Chrome is updated.
static void DebugBreakForCommand(ClientData* data, Isolate* isolate) {
DebugBreakForCommand(isolate, data);
}
// Message based interface. The message protocol is JSON.
static void SetMessageHandler2(MessageHandler2 handler);
// If no isolate is provided the default isolate is
// used.
// TODO(dcarney): remove
static void SendCommand(const uint16_t* command, int length,
ClientData* client_data = NULL,
Isolate* isolate = NULL);
static void SendCommand(Isolate* isolate,
const uint16_t* command, int length,
ClientData* client_data = NULL);
@ -331,7 +327,12 @@ class V8_EXPORT Debug {
* (default Isolate if not provided). V8 will abort if LiveEdit is
* unexpectedly used. LiveEdit is enabled by default.
*/
static void SetLiveEditEnabled(bool enable, Isolate* isolate = NULL);
static void SetLiveEditEnabled(Isolate* isolate, bool enable);
// TODO(svenpanne) Remove this when Chrome is updated.
static void SetLiveEditEnabled(bool enable, Isolate* isolate) {
SetLiveEditEnabled(isolate, enable);
}
};

View File

@ -4840,15 +4840,14 @@ class V8_EXPORT V8 {
/**
* Forcefully terminate the current thread of JavaScript execution
* in the given isolate. If no isolate is provided, the default
* isolate is used.
* in the given isolate.
*
* This method can be used by any thread even if that thread has not
* acquired the V8 lock with a Locker object.
*
* \param isolate The isolate in which to terminate the current JS execution.
*/
static void TerminateExecution(Isolate* isolate = NULL);
static void TerminateExecution(Isolate* isolate);
/**
* Is V8 terminating JavaScript execution.

View File

@ -6522,12 +6522,7 @@ void V8::RemoveCallCompletedCallback(CallCompletedCallback callback) {
void V8::TerminateExecution(Isolate* isolate) {
// If no isolate is supplied, use the default isolate.
if (isolate != NULL) {
reinterpret_cast<i::Isolate*>(isolate)->stack_guard()->TerminateExecution();
} else {
i::Isolate::GetDefaultIsolateStackGuard()->TerminateExecution();
}
reinterpret_cast<i::Isolate*>(isolate)->stack_guard()->TerminateExecution();
}
@ -6844,34 +6839,19 @@ bool Debug::SetDebugEventListener(v8::Handle<v8::Object> that,
void Debug::DebugBreak(Isolate* isolate) {
// If no isolate is supplied, use the default isolate.
if (isolate != NULL) {
reinterpret_cast<i::Isolate*>(isolate)->stack_guard()->DebugBreak();
} else {
i::Isolate::GetDefaultIsolateStackGuard()->DebugBreak();
}
reinterpret_cast<i::Isolate*>(isolate)->stack_guard()->DebugBreak();
}
void Debug::CancelDebugBreak(Isolate* isolate) {
// If no isolate is supplied, use the default isolate.
if (isolate != NULL) {
i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
internal_isolate->stack_guard()->Continue(i::DEBUGBREAK);
} else {
i::Isolate::GetDefaultIsolateStackGuard()->Continue(i::DEBUGBREAK);
}
i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
internal_isolate->stack_guard()->Continue(i::DEBUGBREAK);
}
void Debug::DebugBreakForCommand(ClientData* data, Isolate* isolate) {
// If no isolate is supplied, use the default isolate.
if (isolate != NULL) {
i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
internal_isolate->debugger()->EnqueueDebugCommand(data);
} else {
i::Isolate::GetDefaultIsolateDebugger()->EnqueueDebugCommand(data);
}
void Debug::DebugBreakForCommand(Isolate* isolate, ClientData* data) {
i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
internal_isolate->debugger()->EnqueueDebugCommand(data);
}
@ -6893,21 +6873,6 @@ void Debug::SendCommand(Isolate* isolate,
}
void Debug::SendCommand(const uint16_t* command, int length,
ClientData* client_data,
Isolate* isolate) {
// If no isolate is supplied, use the default isolate.
if (isolate != NULL) {
i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
internal_isolate->debugger()->ProcessCommand(
i::Vector<const uint16_t>(command, length), client_data);
} else {
i::Isolate::GetDefaultIsolateDebugger()->ProcessCommand(
i::Vector<const uint16_t>(command, length), client_data);
}
}
void Debug::SetHostDispatchHandler(HostDispatchHandler handler,
int period) {
i::Isolate* isolate = i::Isolate::Current();
@ -7004,16 +6969,9 @@ Local<Context> Debug::GetDebugContext() {
}
void Debug::SetLiveEditEnabled(bool enable, Isolate* isolate) {
// If no isolate is supplied, use the default isolate.
i::Debugger* debugger;
if (isolate != NULL) {
i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
debugger = internal_isolate->debugger();
} else {
debugger = i::Isolate::GetDefaultIsolateDebugger();
}
debugger->set_live_edit_enabled(enable);
void Debug::SetLiveEditEnabled(Isolate* isolate, bool enable) {
i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
internal_isolate->debugger()->set_live_edit_enabled(enable);
}

View File

@ -229,10 +229,10 @@ void DebuggerAgentSession::Run() {
decoder.WriteUtf16(temp.start(), utf16_length);
// Send the request received to the debugger.
v8::Debug::SendCommand(temp.start(),
v8::Debug::SendCommand(reinterpret_cast<v8::Isolate*>(agent_->isolate()),
temp.start(),
utf16_length,
NULL,
reinterpret_cast<v8::Isolate*>(agent_->isolate()));
NULL);
if (is_closing_session) {
// Session is closed.

View File

@ -3333,7 +3333,7 @@ bool Debugger::StartAgent(const char* name, int port,
// Once become suspended, V8 will stay so indefinitely long, until remote
// debugger connects and issues "continue" command.
Debugger::message_handler_ = StubMessageHandler2;
v8::Debug::DebugBreak();
v8::Debug::DebugBreak(reinterpret_cast<v8::Isolate*>(isolate_));
}
if (agent_ == NULL) {

View File

@ -212,19 +212,6 @@ struct StaticInitializer {
}
} static_initializer;
#ifdef ENABLE_DEBUGGER_SUPPORT
Debugger* Isolate::GetDefaultIsolateDebugger() {
EnsureDefaultIsolate();
return default_isolate_->debugger();
}
#endif
StackGuard* Isolate::GetDefaultIsolateStackGuard() {
EnsureDefaultIsolate();
return default_isolate_->stack_guard();
}
void Isolate::EnterDefaultIsolate() {
EnsureDefaultIsolate();
@ -238,12 +225,6 @@ void Isolate::EnterDefaultIsolate() {
}
v8::Isolate* Isolate::GetDefaultIsolateForLocking() {
EnsureDefaultIsolate();
return reinterpret_cast<v8::Isolate*>(default_isolate_);
}
Address Isolate::get_address_from_id(Isolate::AddressId id) {
return isolate_addresses_[id];
}

View File

@ -556,16 +556,6 @@ class Isolate {
// If one does not yet exist, return null.
PerIsolateThreadData* FindPerThreadDataForThread(ThreadId thread_id);
#ifdef ENABLE_DEBUGGER_SUPPORT
// Get the debugger from the default isolate. Preinitializes the
// default isolate if needed.
static Debugger* GetDefaultIsolateDebugger();
#endif
// Get the stack guard from the default isolate. Preinitializes the
// default isolate if needed.
static StackGuard* GetDefaultIsolateStackGuard();
// Returns the key used to store the pointer to the current isolate.
// Used internally for V8 threads that do not execute JavaScript but still
// are part of the domain of an isolate (like the context switcher).
@ -1124,11 +1114,6 @@ class Isolate {
return sweeper_thread_;
}
// PreInits and returns a default isolate. Needed when a new thread tries
// to create a Locker for the first time (the lock itself is in the isolate).
// TODO(svenpanne) This method is on death row...
static v8::Isolate* GetDefaultIsolateForLocking();
int id() const { return static_cast<int>(id_); }
HStatistics* GetHStatistics();