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 2438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2449 } | 2449 } |
2450 | 2450 |
2451 | 2451 |
2452 MaybeHandle<Object> Debug::MakeAsyncTaskEvent(Handle<JSObject> task_event) { | 2452 MaybeHandle<Object> Debug::MakeAsyncTaskEvent(Handle<JSObject> task_event) { |
2453 // Create the async task event object. | 2453 // Create the async task event object. |
2454 Handle<Object> argv[] = { task_event }; | 2454 Handle<Object> argv[] = { task_event }; |
2455 return MakeJSObject("MakeAsyncTaskEvent", arraysize(argv), argv); | 2455 return MakeJSObject("MakeAsyncTaskEvent", arraysize(argv), argv); |
2456 } | 2456 } |
2457 | 2457 |
2458 | 2458 |
2459 void Debug::OnThrow(Handle<Object> exception, bool uncaught) { | 2459 void Debug::OnThrow(Handle<Object> exception) { |
2460 if (in_debug_scope() || ignore_events()) return; | 2460 if (in_debug_scope() || ignore_events()) return; |
2461 // Temporarily clear any scheduled_exception to allow evaluating | 2461 // Temporarily clear any scheduled_exception to allow evaluating |
2462 // JavaScript from the debug event handler. | 2462 // JavaScript from the debug event handler. |
2463 HandleScope scope(isolate_); | 2463 HandleScope scope(isolate_); |
2464 Handle<Object> scheduled_exception; | 2464 Handle<Object> scheduled_exception; |
2465 if (isolate_->has_scheduled_exception()) { | 2465 if (isolate_->has_scheduled_exception()) { |
2466 scheduled_exception = handle(isolate_->scheduled_exception(), isolate_); | 2466 scheduled_exception = handle(isolate_->scheduled_exception(), isolate_); |
2467 isolate_->clear_scheduled_exception(); | 2467 isolate_->clear_scheduled_exception(); |
2468 } | 2468 } |
2469 OnException(exception, uncaught, isolate_->GetPromiseOnStackOnThrow()); | 2469 OnException(exception, isolate_->GetPromiseOnStackOnThrow()); |
2470 if (!scheduled_exception.is_null()) { | 2470 if (!scheduled_exception.is_null()) { |
2471 isolate_->thread_local_top()->scheduled_exception_ = *scheduled_exception; | 2471 isolate_->thread_local_top()->scheduled_exception_ = *scheduled_exception; |
2472 } | 2472 } |
2473 } | 2473 } |
2474 | 2474 |
2475 | 2475 |
2476 void Debug::OnPromiseReject(Handle<JSObject> promise, Handle<Object> value) { | 2476 void Debug::OnPromiseReject(Handle<JSObject> promise, Handle<Object> value) { |
2477 if (in_debug_scope() || ignore_events()) return; | 2477 if (in_debug_scope() || ignore_events()) return; |
2478 HandleScope scope(isolate_); | 2478 HandleScope scope(isolate_); |
2479 // Check whether the promise has been marked as having triggered a message. | 2479 // Check whether the promise has been marked as having triggered a message. |
2480 Handle<Symbol> key = isolate_->factory()->promise_debug_marker_symbol(); | 2480 Handle<Symbol> key = isolate_->factory()->promise_debug_marker_symbol(); |
2481 if (JSObject::GetDataProperty(promise, key)->IsUndefined()) { | 2481 if (JSObject::GetDataProperty(promise, key)->IsUndefined()) { |
2482 OnException(value, false, promise); | 2482 OnException(value, promise); |
2483 } | 2483 } |
2484 } | 2484 } |
2485 | 2485 |
2486 | 2486 |
2487 MaybeHandle<Object> Debug::PromiseHasUserDefinedRejectHandler( | 2487 MaybeHandle<Object> Debug::PromiseHasUserDefinedRejectHandler( |
2488 Handle<JSObject> promise) { | 2488 Handle<JSObject> promise) { |
2489 Handle<JSFunction> fun = Handle<JSFunction>::cast( | 2489 Handle<JSFunction> fun = Handle<JSFunction>::cast( |
2490 JSObject::GetDataProperty(isolate_->js_builtins_object(), | 2490 JSObject::GetDataProperty(isolate_->js_builtins_object(), |
2491 isolate_->factory()->NewStringFromStaticChars( | 2491 isolate_->factory()->NewStringFromStaticChars( |
2492 "PromiseHasUserDefinedRejectHandler"))); | 2492 "PromiseHasUserDefinedRejectHandler"))); |
2493 return Execution::Call(isolate_, fun, promise, 0, NULL); | 2493 return Execution::Call(isolate_, fun, promise, 0, NULL); |
2494 } | 2494 } |
2495 | 2495 |
2496 | 2496 |
2497 void Debug::OnException(Handle<Object> exception, bool uncaught, | 2497 void Debug::OnException(Handle<Object> exception, Handle<Object> promise) { |
2498 Handle<Object> promise) { | 2498 bool uncaught = !isolate_->PredictWhetherExceptionIsCaught(*exception); |
2499 if (!uncaught && promise->IsJSObject()) { | 2499 if (promise->IsJSObject()) { |
2500 Handle<JSObject> jspromise = Handle<JSObject>::cast(promise); | 2500 Handle<JSObject> jspromise = Handle<JSObject>::cast(promise); |
2501 // Mark the promise as already having triggered a message. | 2501 // Mark the promise as already having triggered a message. |
2502 Handle<Symbol> key = isolate_->factory()->promise_debug_marker_symbol(); | 2502 Handle<Symbol> key = isolate_->factory()->promise_debug_marker_symbol(); |
2503 JSObject::SetProperty(jspromise, key, key, STRICT).Assert(); | 2503 JSObject::SetProperty(jspromise, key, key, STRICT).Assert(); |
2504 // Check whether the promise reject is considered an uncaught exception. | 2504 // Check whether the promise reject is considered an uncaught exception. |
2505 Handle<Object> has_reject_handler; | 2505 Handle<Object> has_reject_handler; |
2506 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | 2506 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
2507 isolate_, has_reject_handler, | 2507 isolate_, has_reject_handler, |
2508 PromiseHasUserDefinedRejectHandler(jspromise), /* void */); | 2508 PromiseHasUserDefinedRejectHandler(jspromise), /* void */); |
2509 uncaught = has_reject_handler->IsFalse(); | 2509 uncaught = has_reject_handler->IsFalse(); |
(...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3382 logger_->DebugEvent("Put", message.text()); | 3382 logger_->DebugEvent("Put", message.text()); |
3383 } | 3383 } |
3384 | 3384 |
3385 | 3385 |
3386 void LockingCommandMessageQueue::Clear() { | 3386 void LockingCommandMessageQueue::Clear() { |
3387 base::LockGuard<base::Mutex> lock_guard(&mutex_); | 3387 base::LockGuard<base::Mutex> lock_guard(&mutex_); |
3388 queue_.Clear(); | 3388 queue_.Clear(); |
3389 } | 3389 } |
3390 | 3390 |
3391 } } // namespace v8::internal | 3391 } } // namespace v8::internal |
OLD | NEW |