Chromium Code Reviews| 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 "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/api.h" | 7 #include "src/api.h" |
| 8 #include "src/arguments.h" | 8 #include "src/arguments.h" |
| 9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
| 10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
| (...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 761 MaybeHandle<Object> result = Execution::TryCall( | 761 MaybeHandle<Object> result = Execution::TryCall( |
| 762 function, handle(context->global_proxy()), 0, NULL, &maybe_exception); | 762 function, handle(context->global_proxy()), 0, NULL, &maybe_exception); |
| 763 | 763 |
| 764 // Check for caught exceptions. | 764 // Check for caught exceptions. |
| 765 if (result.is_null()) { | 765 if (result.is_null()) { |
| 766 DCHECK(!isolate->has_pending_exception()); | 766 DCHECK(!isolate->has_pending_exception()); |
| 767 MessageLocation computed_location; | 767 MessageLocation computed_location; |
| 768 isolate->ComputeLocation(&computed_location); | 768 isolate->ComputeLocation(&computed_location); |
| 769 Handle<Object> message = MessageHandler::MakeMessageObject( | 769 Handle<Object> message = MessageHandler::MakeMessageObject( |
| 770 isolate, "error_loading_debugger", &computed_location, | 770 isolate, "error_loading_debugger", &computed_location, |
| 771 Vector<Handle<Object> >::empty(), Handle<JSArray>()); | 771 Vector<Handle<Object> >::empty(), Handle<JSObject>(), |
| 772 Handle<JSArray>()); | |
| 772 DCHECK(!isolate->has_pending_exception()); | 773 DCHECK(!isolate->has_pending_exception()); |
| 773 Handle<Object> exception; | 774 Handle<Object> exception; |
| 774 if (maybe_exception.ToHandle(&exception)) { | 775 if (maybe_exception.ToHandle(&exception)) { |
| 775 isolate->set_pending_exception(*exception); | 776 isolate->set_pending_exception(*exception); |
| 776 MessageHandler::ReportMessage(isolate, NULL, message); | 777 MessageHandler::ReportMessage(isolate, NULL, message); |
| 777 isolate->clear_pending_exception(); | 778 isolate->clear_pending_exception(); |
| 778 } | 779 } |
| 779 return false; | 780 return false; |
| 780 } | 781 } |
| 781 | 782 |
| (...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1255 | 1256 |
| 1256 bool Debug::IsBreakOnException(ExceptionBreakType type) { | 1257 bool Debug::IsBreakOnException(ExceptionBreakType type) { |
| 1257 if (type == BreakUncaughtException) { | 1258 if (type == BreakUncaughtException) { |
| 1258 return break_on_uncaught_exception_; | 1259 return break_on_uncaught_exception_; |
| 1259 } else { | 1260 } else { |
| 1260 return break_on_exception_; | 1261 return break_on_exception_; |
| 1261 } | 1262 } |
| 1262 } | 1263 } |
| 1263 | 1264 |
| 1264 | 1265 |
| 1265 bool Debug::PromiseHasRejectHandler(Handle<JSObject> promise) { | |
| 1266 Handle<JSFunction> fun = Handle<JSFunction>::cast( | |
| 1267 JSObject::GetDataProperty(isolate_->js_builtins_object(), | |
| 1268 isolate_->factory()->NewStringFromStaticChars( | |
| 1269 "PromiseHasRejectHandler"))); | |
| 1270 Handle<Object> result = | |
| 1271 Execution::Call(isolate_, fun, promise, 0, NULL).ToHandleChecked(); | |
| 1272 return result->IsTrue(); | |
| 1273 } | |
| 1274 | |
| 1275 | |
| 1276 void Debug::PrepareStep(StepAction step_action, | 1266 void Debug::PrepareStep(StepAction step_action, |
| 1277 int step_count, | 1267 int step_count, |
| 1278 StackFrame::Id frame_id) { | 1268 StackFrame::Id frame_id) { |
| 1279 HandleScope scope(isolate_); | 1269 HandleScope scope(isolate_); |
| 1280 | 1270 |
| 1281 PrepareForBreakPoints(); | 1271 PrepareForBreakPoints(); |
| 1282 | 1272 |
| 1283 DCHECK(in_debug_scope()); | 1273 DCHECK(in_debug_scope()); |
| 1284 | 1274 |
| 1285 // Remember this step action and count. | 1275 // Remember this step action and count. |
| (...skipping 1208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2494 } | 2484 } |
| 2495 | 2485 |
| 2496 | 2486 |
| 2497 MaybeHandle<Object> Debug::MakeAsyncTaskEvent(Handle<JSObject> task_event) { | 2487 MaybeHandle<Object> Debug::MakeAsyncTaskEvent(Handle<JSObject> task_event) { |
| 2498 // Create the async task event object. | 2488 // Create the async task event object. |
| 2499 Handle<Object> argv[] = { task_event }; | 2489 Handle<Object> argv[] = { task_event }; |
| 2500 return MakeJSObject("MakeAsyncTaskEvent", arraysize(argv), argv); | 2490 return MakeJSObject("MakeAsyncTaskEvent", arraysize(argv), argv); |
| 2501 } | 2491 } |
| 2502 | 2492 |
| 2503 | 2493 |
| 2504 void Debug::OnThrow(Handle<Object> exception, bool uncaught) { | 2494 void Debug::OnThrow(Handle<Object> exception, Handle<Object> promise, |
| 2495 bool uncaught) { | |
| 2505 if (in_debug_scope() || ignore_events()) return; | 2496 if (in_debug_scope() || ignore_events()) return; |
| 2506 // Temporarily clear any scheduled_exception to allow evaluating | 2497 // Temporarily clear any scheduled_exception to allow evaluating |
| 2507 // JavaScript from the debug event handler. | 2498 // JavaScript from the debug event handler. |
| 2508 HandleScope scope(isolate_); | 2499 HandleScope scope(isolate_); |
| 2509 Handle<Object> scheduled_exception; | 2500 Handle<Object> scheduled_exception; |
| 2510 if (isolate_->has_scheduled_exception()) { | 2501 if (isolate_->has_scheduled_exception()) { |
| 2511 scheduled_exception = handle(isolate_->scheduled_exception(), isolate_); | 2502 scheduled_exception = handle(isolate_->scheduled_exception(), isolate_); |
| 2512 isolate_->clear_scheduled_exception(); | 2503 isolate_->clear_scheduled_exception(); |
| 2513 } | 2504 } |
| 2514 OnException(exception, uncaught, isolate_->GetPromiseOnStackOnThrow()); | 2505 OnException(exception, uncaught, promise); |
| 2515 if (!scheduled_exception.is_null()) { | 2506 if (!scheduled_exception.is_null()) { |
| 2516 isolate_->thread_local_top()->scheduled_exception_ = *scheduled_exception; | 2507 isolate_->thread_local_top()->scheduled_exception_ = *scheduled_exception; |
| 2517 } | 2508 } |
| 2518 } | 2509 } |
| 2519 | 2510 |
| 2520 | 2511 |
| 2521 void Debug::OnPromiseReject(Handle<JSObject> promise, Handle<Object> value) { | 2512 void Debug::OnPromiseReject(Handle<JSObject> promise, Handle<Object> value) { |
| 2522 if (in_debug_scope() || ignore_events()) return; | 2513 if (in_debug_scope() || ignore_events()) return; |
| 2523 HandleScope scope(isolate_); | 2514 HandleScope scope(isolate_); |
| 2524 OnException(value, false, promise); | 2515 OnException(value, false, promise); |
| 2525 } | 2516 } |
| 2526 | 2517 |
| 2527 | 2518 |
| 2528 void Debug::OnException(Handle<Object> exception, bool uncaught, | 2519 void Debug::OnException(Handle<Object> exception, bool uncaught, |
| 2529 Handle<Object> promise) { | 2520 Handle<Object> promise) { |
| 2530 if (promise->IsJSObject()) { | 2521 if (promise->IsJSObject()) { |
|
aandrey
2014/09/26 14:58:46
can it be "if (!uncaught && promise->IsJSObject())
Yang
2014/09/26 15:04:42
Done.
I agree. The side effect is now gone. We ma
| |
| 2531 uncaught |= !PromiseHasRejectHandler(Handle<JSObject>::cast(promise)); | 2522 Handle<Object> has_reject_handler; |
| 2523 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | |
| 2524 isolate_, has_reject_handler, | |
| 2525 Execution::PromiseHasRejectHandler(isolate_, promise), /* void */); | |
| 2526 uncaught |= has_reject_handler->IsFalse(); | |
| 2532 } | 2527 } |
| 2533 // Bail out if exception breaks are not active | 2528 // Bail out if exception breaks are not active |
| 2534 if (uncaught) { | 2529 if (uncaught) { |
| 2535 // Uncaught exceptions are reported by either flags. | 2530 // Uncaught exceptions are reported by either flags. |
| 2536 if (!(break_on_uncaught_exception_ || break_on_exception_)) return; | 2531 if (!(break_on_uncaught_exception_ || break_on_exception_)) return; |
| 2537 } else { | 2532 } else { |
| 2538 // Caught exceptions are reported is activated. | 2533 // Caught exceptions are reported is activated. |
| 2539 if (!break_on_exception_) return; | 2534 if (!break_on_exception_) return; |
| 2540 } | 2535 } |
| 2541 | 2536 |
| (...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3370 logger_->DebugEvent("Put", message.text()); | 3365 logger_->DebugEvent("Put", message.text()); |
| 3371 } | 3366 } |
| 3372 | 3367 |
| 3373 | 3368 |
| 3374 void LockingCommandMessageQueue::Clear() { | 3369 void LockingCommandMessageQueue::Clear() { |
| 3375 base::LockGuard<base::Mutex> lock_guard(&mutex_); | 3370 base::LockGuard<base::Mutex> lock_guard(&mutex_); |
| 3376 queue_.Clear(); | 3371 queue_.Clear(); |
| 3377 } | 3372 } |
| 3378 | 3373 |
| 3379 } } // namespace v8::internal | 3374 } } // namespace v8::internal |
| OLD | NEW |