OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "v8.h" | 5 #include "v8.h" |
6 | 6 |
7 #include "api.h" | 7 #include "api.h" |
8 #include "arguments.h" | 8 #include "arguments.h" |
9 #include "bootstrapper.h" | 9 #include "bootstrapper.h" |
10 #include "code-stubs.h" | 10 #include "code-stubs.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 namespace v8 { | 30 namespace v8 { |
31 namespace internal { | 31 namespace internal { |
32 | 32 |
33 Debug::Debug(Isolate* isolate) | 33 Debug::Debug(Isolate* isolate) |
34 : has_break_points_(false), | 34 : has_break_points_(false), |
35 script_cache_(NULL), | 35 script_cache_(NULL), |
36 debug_info_list_(NULL), | 36 debug_info_list_(NULL), |
37 disable_break_(false), | 37 disable_break_(false), |
38 break_on_exception_(false), | 38 break_on_exception_(false), |
39 break_on_uncaught_exception_(false), | 39 break_on_uncaught_exception_(false), |
40 promise_catch_handlers_(0), | |
41 promise_getters_(0), | |
42 isolate_(isolate) { | 40 isolate_(isolate) { |
43 ThreadInit(); | 41 ThreadInit(); |
44 } | 42 } |
45 | 43 |
46 | 44 |
47 static v8::Handle<v8::Context> GetDebugEventContext(Isolate* isolate) { | 45 static v8::Handle<v8::Context> GetDebugEventContext(Isolate* isolate) { |
48 Handle<Context> context = isolate->debug()->debugger_entry()->GetContext(); | 46 Handle<Context> context = isolate->debug()->debugger_entry()->GetContext(); |
49 // Isolate::context() may have been NULL when "script collected" event | 47 // Isolate::context() may have been NULL when "script collected" event |
50 // occured. | 48 // occured. |
51 if (context.is_null()) return v8::Local<v8::Context>(); | 49 if (context.is_null()) return v8::Local<v8::Context>(); |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 thread_local_.step_count_ = 0; | 502 thread_local_.step_count_ = 0; |
505 thread_local_.last_fp_ = 0; | 503 thread_local_.last_fp_ = 0; |
506 thread_local_.queued_step_count_ = 0; | 504 thread_local_.queued_step_count_ = 0; |
507 thread_local_.step_into_fp_ = 0; | 505 thread_local_.step_into_fp_ = 0; |
508 thread_local_.step_out_fp_ = 0; | 506 thread_local_.step_out_fp_ = 0; |
509 thread_local_.after_break_target_ = 0; | 507 thread_local_.after_break_target_ = 0; |
510 // TODO(isolates): frames_are_dropped_? | 508 // TODO(isolates): frames_are_dropped_? |
511 thread_local_.debugger_entry_ = NULL; | 509 thread_local_.debugger_entry_ = NULL; |
512 thread_local_.has_pending_interrupt_ = false; | 510 thread_local_.has_pending_interrupt_ = false; |
513 thread_local_.restarter_frame_function_pointer_ = NULL; | 511 thread_local_.restarter_frame_function_pointer_ = NULL; |
| 512 thread_local_.promise_on_stack_ = NULL; |
514 } | 513 } |
515 | 514 |
516 | 515 |
517 char* Debug::ArchiveDebug(char* storage) { | 516 char* Debug::ArchiveDebug(char* storage) { |
518 char* to = storage; | 517 char* to = storage; |
519 OS::MemCopy(to, reinterpret_cast<char*>(&thread_local_), sizeof(ThreadLocal)); | 518 OS::MemCopy(to, reinterpret_cast<char*>(&thread_local_), sizeof(ThreadLocal)); |
520 ThreadInit(); | 519 ThreadInit(); |
521 return storage + ArchiveSpacePerThread(); | 520 return storage + ArchiveSpacePerThread(); |
522 } | 521 } |
523 | 522 |
(...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1242 | 1241 |
1243 bool Debug::IsBreakOnException(ExceptionBreakType type) { | 1242 bool Debug::IsBreakOnException(ExceptionBreakType type) { |
1244 if (type == BreakUncaughtException) { | 1243 if (type == BreakUncaughtException) { |
1245 return break_on_uncaught_exception_; | 1244 return break_on_uncaught_exception_; |
1246 } else { | 1245 } else { |
1247 return break_on_exception_; | 1246 return break_on_exception_; |
1248 } | 1247 } |
1249 } | 1248 } |
1250 | 1249 |
1251 | 1250 |
| 1251 Debug::PromiseOnStack::PromiseOnStack(Isolate* isolate, |
| 1252 PromiseOnStack* prev, |
| 1253 Handle<JSFunction> getter) |
| 1254 : isolate_(isolate), prev_(prev) { |
| 1255 handler_ = StackHandler::FromAddress( |
| 1256 Isolate::handler(isolate->thread_local_top())); |
| 1257 getter_ = Handle<JSFunction>::cast( |
| 1258 isolate->global_handles()->Create(*getter)); |
| 1259 } |
| 1260 |
| 1261 |
| 1262 Debug::PromiseOnStack::~PromiseOnStack() { |
| 1263 isolate_->global_handles()->Destroy(Handle<Object>::cast(getter_).location()); |
| 1264 } |
| 1265 |
| 1266 |
1252 void Debug::PromiseHandlePrologue(Handle<JSFunction> promise_getter) { | 1267 void Debug::PromiseHandlePrologue(Handle<JSFunction> promise_getter) { |
1253 Handle<JSFunction> promise_getter_global = Handle<JSFunction>::cast( | 1268 PromiseOnStack* prev = thread_local_.promise_on_stack_; |
1254 isolate_->global_handles()->Create(*promise_getter)); | 1269 thread_local_.promise_on_stack_ = |
1255 StackHandler* handler = | 1270 new PromiseOnStack(isolate_, prev, promise_getter); |
1256 StackHandler::FromAddress(Isolate::handler(isolate_->thread_local_top())); | |
1257 promise_getters_.Add(promise_getter_global); | |
1258 promise_catch_handlers_.Add(handler); | |
1259 } | 1271 } |
1260 | 1272 |
1261 | 1273 |
1262 void Debug::PromiseHandleEpilogue() { | 1274 void Debug::PromiseHandleEpilogue() { |
1263 if (promise_catch_handlers_.length() == 0) return; | 1275 if (thread_local_.promise_on_stack_ == NULL) return; |
1264 promise_catch_handlers_.RemoveLast(); | 1276 PromiseOnStack* prev = thread_local_.promise_on_stack_->prev(); |
1265 Handle<Object> promise_getter = promise_getters_.RemoveLast(); | 1277 delete thread_local_.promise_on_stack_; |
1266 isolate_->global_handles()->Destroy(promise_getter.location()); | 1278 thread_local_.promise_on_stack_ = prev; |
1267 } | 1279 } |
1268 | 1280 |
1269 | 1281 |
1270 Handle<Object> Debug::GetPromiseForUncaughtException() { | 1282 Handle<Object> Debug::GetPromiseForUncaughtException() { |
1271 Handle<Object> undefined = isolate_->factory()->undefined_value(); | 1283 Handle<Object> undefined = isolate_->factory()->undefined_value(); |
1272 if (promise_getters_.length() == 0) return undefined; | 1284 if (thread_local_.promise_on_stack_ == NULL) return undefined; |
1273 Handle<JSFunction> promise_getter = promise_getters_.last(); | 1285 Handle<JSFunction> promise_getter = thread_local_.promise_on_stack_->getter(); |
1274 StackHandler* promise_catch = promise_catch_handlers_.last(); | 1286 StackHandler* promise_catch = thread_local_.promise_on_stack_->handler(); |
1275 // Find the top-most try-catch handler. | 1287 // Find the top-most try-catch handler. |
1276 StackHandler* handler = StackHandler::FromAddress( | 1288 StackHandler* handler = StackHandler::FromAddress( |
1277 Isolate::handler(isolate_->thread_local_top())); | 1289 Isolate::handler(isolate_->thread_local_top())); |
1278 while (handler != NULL && !handler->is_catch()) { | 1290 while (handler != NULL && !handler->is_catch()) { |
1279 handler = handler->next(); | 1291 handler = handler->next(); |
1280 } | 1292 } |
1281 #ifdef DEBUG | 1293 #ifdef DEBUG |
1282 // Make sure that our promise catch handler is in the list of handlers, | 1294 // Make sure that our promise catch handler is in the list of handlers, |
1283 // even if it's not the top-most try-catch handler. | 1295 // even if it's not the top-most try-catch handler. |
1284 StackHandler* temp = handler; | 1296 StackHandler* temp = handler; |
(...skipping 2254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3539 logger_->DebugEvent("Put", message.text()); | 3551 logger_->DebugEvent("Put", message.text()); |
3540 } | 3552 } |
3541 | 3553 |
3542 | 3554 |
3543 void LockingCommandMessageQueue::Clear() { | 3555 void LockingCommandMessageQueue::Clear() { |
3544 LockGuard<Mutex> lock_guard(&mutex_); | 3556 LockGuard<Mutex> lock_guard(&mutex_); |
3545 queue_.Clear(); | 3557 queue_.Clear(); |
3546 } | 3558 } |
3547 | 3559 |
3548 } } // namespace v8::internal | 3560 } } // namespace v8::internal |
OLD | NEW |