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 1244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1255 | 1255 |
1256 bool Debug::IsBreakOnException(ExceptionBreakType type) { | 1256 bool Debug::IsBreakOnException(ExceptionBreakType type) { |
1257 if (type == BreakUncaughtException) { | 1257 if (type == BreakUncaughtException) { |
1258 return break_on_uncaught_exception_; | 1258 return break_on_uncaught_exception_; |
1259 } else { | 1259 } else { |
1260 return break_on_exception_; | 1260 return break_on_exception_; |
1261 } | 1261 } |
1262 } | 1262 } |
1263 | 1263 |
1264 | 1264 |
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, | 1265 void Debug::PrepareStep(StepAction step_action, |
1277 int step_count, | 1266 int step_count, |
1278 StackFrame::Id frame_id) { | 1267 StackFrame::Id frame_id) { |
1279 HandleScope scope(isolate_); | 1268 HandleScope scope(isolate_); |
1280 | 1269 |
1281 PrepareForBreakPoints(); | 1270 PrepareForBreakPoints(); |
1282 | 1271 |
1283 DCHECK(in_debug_scope()); | 1272 DCHECK(in_debug_scope()); |
1284 | 1273 |
1285 // Remember this step action and count. | 1274 // Remember this step action and count. |
(...skipping 1228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2514 OnException(exception, uncaught, isolate_->GetPromiseOnStackOnThrow()); | 2503 OnException(exception, uncaught, isolate_->GetPromiseOnStackOnThrow()); |
2515 if (!scheduled_exception.is_null()) { | 2504 if (!scheduled_exception.is_null()) { |
2516 isolate_->thread_local_top()->scheduled_exception_ = *scheduled_exception; | 2505 isolate_->thread_local_top()->scheduled_exception_ = *scheduled_exception; |
2517 } | 2506 } |
2518 } | 2507 } |
2519 | 2508 |
2520 | 2509 |
2521 void Debug::OnPromiseReject(Handle<JSObject> promise, Handle<Object> value) { | 2510 void Debug::OnPromiseReject(Handle<JSObject> promise, Handle<Object> value) { |
2522 if (in_debug_scope() || ignore_events()) return; | 2511 if (in_debug_scope() || ignore_events()) return; |
2523 HandleScope scope(isolate_); | 2512 HandleScope scope(isolate_); |
2524 OnException(value, false, promise); | 2513 // Check whether the promise has been marked as having triggered a message. |
2514 Handle<Symbol> key = isolate_->factory()->promise_debug_marker_symbol(); | |
2515 if (JSObject::GetDataProperty(promise, key)->IsUndefined()) { | |
2516 OnException(value, false, promise); | |
aandrey
2014/09/30 14:08:24
I think we should move to here:
JSObject::SetPro
Yang
2014/09/30 14:29:47
That would not work. When a promise is rejected vi
| |
2517 } | |
2518 } | |
2519 | |
2520 | |
2521 MaybeHandle<Object> Debug::PromiseHasUserDefinedRejectHandler( | |
2522 Handle<JSObject> promise) { | |
2523 Handle<JSFunction> fun = Handle<JSFunction>::cast( | |
2524 JSObject::GetDataProperty(isolate_->js_builtins_object(), | |
2525 isolate_->factory()->NewStringFromStaticChars( | |
2526 "PromiseHasUserDefinedRejectHandler"))); | |
2527 return Execution::Call(isolate_, fun, promise, 0, NULL); | |
2525 } | 2528 } |
2526 | 2529 |
2527 | 2530 |
2528 void Debug::OnException(Handle<Object> exception, bool uncaught, | 2531 void Debug::OnException(Handle<Object> exception, bool uncaught, |
2529 Handle<Object> promise) { | 2532 Handle<Object> promise) { |
2530 if (promise->IsJSObject()) { | 2533 if (!uncaught && promise->IsJSObject()) { |
2531 uncaught |= !PromiseHasRejectHandler(Handle<JSObject>::cast(promise)); | 2534 Handle<JSObject> jspromise = Handle<JSObject>::cast(promise); |
2535 // Mark the promise as already having triggered a message. | |
2536 Handle<Symbol> key = isolate_->factory()->promise_debug_marker_symbol(); | |
2537 JSObject::SetProperty(jspromise, key, key, STRICT); | |
2538 // Check whether the promise reject is considered an uncaught exception. | |
2539 Handle<Object> has_reject_handler; | |
2540 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | |
2541 isolate_, has_reject_handler, | |
2542 PromiseHasUserDefinedRejectHandler(jspromise), /* void */); | |
2543 uncaught = has_reject_handler->IsFalse(); | |
2532 } | 2544 } |
2533 // Bail out if exception breaks are not active | 2545 // Bail out if exception breaks are not active |
2534 if (uncaught) { | 2546 if (uncaught) { |
2535 // Uncaught exceptions are reported by either flags. | 2547 // Uncaught exceptions are reported by either flags. |
2536 if (!(break_on_uncaught_exception_ || break_on_exception_)) return; | 2548 if (!(break_on_uncaught_exception_ || break_on_exception_)) return; |
2537 } else { | 2549 } else { |
2538 // Caught exceptions are reported is activated. | 2550 // Caught exceptions are reported is activated. |
2539 if (!break_on_exception_) return; | 2551 if (!break_on_exception_) return; |
2540 } | 2552 } |
2541 | 2553 |
(...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3370 logger_->DebugEvent("Put", message.text()); | 3382 logger_->DebugEvent("Put", message.text()); |
3371 } | 3383 } |
3372 | 3384 |
3373 | 3385 |
3374 void LockingCommandMessageQueue::Clear() { | 3386 void LockingCommandMessageQueue::Clear() { |
3375 base::LockGuard<base::Mutex> lock_guard(&mutex_); | 3387 base::LockGuard<base::Mutex> lock_guard(&mutex_); |
3376 queue_.Clear(); | 3388 queue_.Clear(); |
3377 } | 3389 } |
3378 | 3390 |
3379 } } // namespace v8::internal | 3391 } } // namespace v8::internal |
OLD | NEW |