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

Side by Side Diff: src/api.cc

Issue 6672044: [Isolates] Fix debugger and termination APIs callable from other threads. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/isolates
Patch Set: Address comments. Created 9 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « include/v8-debug.h ('k') | src/isolate.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 4273 matching lines...) Expand 10 before | Expand all | Expand 10 after
4284 // execution right away. Otherwise, ask the thread manager to 4284 // execution right away. Otherwise, ask the thread manager to
4285 // terminate the thread with the given id if any. 4285 // terminate the thread with the given id if any.
4286 if (thread_id == isolate->thread_id()) { 4286 if (thread_id == isolate->thread_id()) {
4287 isolate->stack_guard()->TerminateExecution(); 4287 isolate->stack_guard()->TerminateExecution();
4288 } else { 4288 } else {
4289 isolate->thread_manager()->TerminateExecution(thread_id); 4289 isolate->thread_manager()->TerminateExecution(thread_id);
4290 } 4290 }
4291 } 4291 }
4292 4292
4293 4293
4294 void V8::TerminateExecution() { 4294 void V8::TerminateExecution(Isolate* isolate) {
4295 if (!i::Isolate::Current()->IsInitialized()) return; 4295 // If no isolate is supplied, use the default isolate.
4296 i::Isolate::Current()->stack_guard()->TerminateExecution(); 4296 if (isolate != NULL) {
4297 reinterpret_cast<i::Isolate*>(isolate)->stack_guard()->TerminateExecution();
4298 } else {
4299 i::Isolate::GetDefaultIsolateStackGuard()->TerminateExecution();
4300 }
4297 } 4301 }
4298 4302
4299 4303
4300 bool V8::IsExecutionTerminating() { 4304 bool V8::IsExecutionTerminating() {
4301 if (!i::Isolate::Current()->IsInitialized()) return false; 4305 if (!i::Isolate::Current()->IsInitialized()) return false;
4302 if (i::Isolate::Current()->has_scheduled_exception()) { 4306 if (i::Isolate::Current()->has_scheduled_exception()) {
4303 return i::Isolate::Current()->scheduled_exception() == 4307 return i::Isolate::Current()->scheduled_exception() ==
4304 HEAP->termination_exception(); 4308 HEAP->termination_exception();
4305 } 4309 }
4306 return false; 4310 return false;
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
4551 bool Debug::SetDebugEventListener(v8::Handle<v8::Object> that, 4555 bool Debug::SetDebugEventListener(v8::Handle<v8::Object> that,
4552 Handle<Value> data) { 4556 Handle<Value> data) {
4553 ON_BAILOUT("v8::Debug::SetDebugEventListener()", return false); 4557 ON_BAILOUT("v8::Debug::SetDebugEventListener()", return false);
4554 ENTER_V8; 4558 ENTER_V8;
4555 i::Isolate::Current()->debugger()->SetEventListener(Utils::OpenHandle(*that), 4559 i::Isolate::Current()->debugger()->SetEventListener(Utils::OpenHandle(*that),
4556 Utils::OpenHandle(*data)); 4560 Utils::OpenHandle(*data));
4557 return true; 4561 return true;
4558 } 4562 }
4559 4563
4560 4564
4561 void Debug::DebugBreak() { 4565 void Debug::DebugBreak(Isolate* isolate) {
4562 if (!i::Isolate::Current()->IsInitialized()) return; 4566 // If no isolate is supplied, use the default isolate.
4563 i::Isolate::Current()->stack_guard()->DebugBreak(); 4567 if (isolate != NULL) {
4568 reinterpret_cast<i::Isolate*>(isolate)->stack_guard()->DebugBreak();
4569 } else {
4570 i::Isolate::GetDefaultIsolateStackGuard()->DebugBreak();
4571 }
4564 } 4572 }
4565 4573
4566 4574
4567 void Debug::CancelDebugBreak() { 4575 void Debug::CancelDebugBreak(Isolate* isolate) {
4568 i::Isolate::Current()->stack_guard()->Continue(i::DEBUGBREAK); 4576 // If no isolate is supplied, use the default isolate.
4577 if (isolate != NULL) {
4578 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
4579 internal_isolate->stack_guard()->Continue(i::DEBUGBREAK);
4580 } else {
4581 i::Isolate::GetDefaultIsolateStackGuard()->Continue(i::DEBUGBREAK);
4582 }
4569 } 4583 }
4570 4584
4571 4585
4572 void Debug::DebugBreakForCommand(ClientData* data) { 4586 void Debug::DebugBreakForCommand(ClientData* data, Isolate* isolate) {
4573 if (!i::Isolate::Current()->IsInitialized()) return; 4587 // If no isolate is supplied, use the default isolate.
4574 i::Isolate::Current()->debugger()->EnqueueDebugCommand(data); 4588 if (isolate != NULL) {
4589 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
4590 internal_isolate->debugger()->EnqueueDebugCommand(data);
4591 } else {
4592 i::Isolate::GetDefaultIsolateDebugger()->EnqueueDebugCommand(data);
4593 }
4575 } 4594 }
4576 4595
4577 4596
4578 static void MessageHandlerWrapper(const v8::Debug::Message& message) { 4597 static void MessageHandlerWrapper(const v8::Debug::Message& message) {
4579 i::Isolate* isolate = i::Isolate::Current(); 4598 i::Isolate* isolate = i::Isolate::Current();
4580 if (isolate->message_handler()) { 4599 if (isolate->message_handler()) {
4581 v8::String::Value json(message.GetJSON()); 4600 v8::String::Value json(message.GetJSON());
4582 (isolate->message_handler())(*json, json.length(), message.GetClientData()); 4601 (isolate->message_handler())(*json, json.length(), message.GetClientData());
4583 } 4602 }
4584 } 4603 }
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after
5266 5285
5267 5286
5268 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { 5287 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) {
5269 HandleScopeImplementer* thread_local = 5288 HandleScopeImplementer* thread_local =
5270 reinterpret_cast<HandleScopeImplementer*>(storage); 5289 reinterpret_cast<HandleScopeImplementer*>(storage);
5271 thread_local->IterateThis(v); 5290 thread_local->IterateThis(v);
5272 return storage + ArchiveSpacePerThread(); 5291 return storage + ArchiveSpacePerThread();
5273 } 5292 }
5274 5293
5275 } } // namespace v8::internal 5294 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « include/v8-debug.h ('k') | src/isolate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698