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

Side by Side Diff: src/debug.cc

Issue 600723005: Introduce PromiseRejectCallback. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: partly revert previous patch set Created 6 years, 2 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 | « src/debug.h ('k') | src/heap/heap.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 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
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 1218 matching lines...) Expand 10 before | Expand all | Expand 10 after
2504 void Debug::OnThrow(Handle<Object> exception, bool uncaught) { 2493 void Debug::OnThrow(Handle<Object> exception, bool uncaught) {
2505 if (in_debug_scope() || ignore_events()) return; 2494 if (in_debug_scope() || ignore_events()) return;
2506 // Temporarily clear any scheduled_exception to allow evaluating 2495 // Temporarily clear any scheduled_exception to allow evaluating
2507 // JavaScript from the debug event handler. 2496 // JavaScript from the debug event handler.
2508 HandleScope scope(isolate_); 2497 HandleScope scope(isolate_);
2509 Handle<Object> scheduled_exception; 2498 Handle<Object> scheduled_exception;
2510 if (isolate_->has_scheduled_exception()) { 2499 if (isolate_->has_scheduled_exception()) {
2511 scheduled_exception = handle(isolate_->scheduled_exception(), isolate_); 2500 scheduled_exception = handle(isolate_->scheduled_exception(), isolate_);
2512 isolate_->clear_scheduled_exception(); 2501 isolate_->clear_scheduled_exception();
2513 } 2502 }
2514 OnException(exception, uncaught, isolate_->GetPromiseOnStackOnThrow()); 2503 Handle<Object> promise = isolate_->GetPromiseOnStackOnThrow();
aandrey 2014/09/30 14:55:15 revert
2504 if (promise->IsJSObject()) {
2505 }
2506 OnException(exception, uncaught, promise);
2515 if (!scheduled_exception.is_null()) { 2507 if (!scheduled_exception.is_null()) {
2516 isolate_->thread_local_top()->scheduled_exception_ = *scheduled_exception; 2508 isolate_->thread_local_top()->scheduled_exception_ = *scheduled_exception;
2517 } 2509 }
2518 } 2510 }
2519 2511
2520 2512
2521 void Debug::OnPromiseReject(Handle<JSObject> promise, Handle<Object> value) { 2513 void Debug::OnPromiseReject(Handle<JSObject> promise, Handle<Object> value) {
2522 if (in_debug_scope() || ignore_events()) return; 2514 if (in_debug_scope() || ignore_events()) return;
2523 HandleScope scope(isolate_); 2515 HandleScope scope(isolate_);
2524 OnException(value, false, promise); 2516 // Check whether the promise has been marked as having triggered a message.
2517 Handle<Symbol> key = isolate_->factory()->promise_debug_marker_symbol();
2518 if (JSObject::GetDataProperty(promise, key)->IsUndefined()) {
2519 OnException(value, false, promise);
2520 }
2521 }
2522
2523
2524 MaybeHandle<Object> Debug::PromiseHasUserDefinedRejectHandler(
2525 Handle<JSObject> promise) {
2526 Handle<JSFunction> fun = Handle<JSFunction>::cast(
2527 JSObject::GetDataProperty(isolate_->js_builtins_object(),
2528 isolate_->factory()->NewStringFromStaticChars(
2529 "PromiseHasUserDefinedRejectHandler")));
2530 return Execution::Call(isolate_, fun, promise, 0, NULL);
2525 } 2531 }
2526 2532
2527 2533
2528 void Debug::OnException(Handle<Object> exception, bool uncaught, 2534 void Debug::OnException(Handle<Object> exception, bool uncaught,
2529 Handle<Object> promise) { 2535 Handle<Object> promise) {
2530 if (promise->IsJSObject()) { 2536 if (!uncaught && promise->IsJSObject()) {
2531 uncaught |= !PromiseHasRejectHandler(Handle<JSObject>::cast(promise)); 2537 Handle<JSObject> jspromise = Handle<JSObject>::cast(promise);
2538 // Mark the promise as already having triggered a message.
2539 Handle<Symbol> key = isolate_->factory()->promise_debug_marker_symbol();
2540 JSObject::SetProperty(jspromise, key, key, STRICT).Assert();
2541 // Check whether the promise reject is considered an uncaught exception.
2542 Handle<Object> has_reject_handler;
2543 ASSIGN_RETURN_ON_EXCEPTION_VALUE(
2544 isolate_, has_reject_handler,
2545 PromiseHasUserDefinedRejectHandler(jspromise), /* void */);
2546 uncaught = has_reject_handler->IsFalse();
2532 } 2547 }
2533 // Bail out if exception breaks are not active 2548 // Bail out if exception breaks are not active
2534 if (uncaught) { 2549 if (uncaught) {
2535 // Uncaught exceptions are reported by either flags. 2550 // Uncaught exceptions are reported by either flags.
2536 if (!(break_on_uncaught_exception_ || break_on_exception_)) return; 2551 if (!(break_on_uncaught_exception_ || break_on_exception_)) return;
2537 } else { 2552 } else {
2538 // Caught exceptions are reported is activated. 2553 // Caught exceptions are reported is activated.
2539 if (!break_on_exception_) return; 2554 if (!break_on_exception_) return;
2540 } 2555 }
2541 2556
(...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after
3370 logger_->DebugEvent("Put", message.text()); 3385 logger_->DebugEvent("Put", message.text());
3371 } 3386 }
3372 3387
3373 3388
3374 void LockingCommandMessageQueue::Clear() { 3389 void LockingCommandMessageQueue::Clear() {
3375 base::LockGuard<base::Mutex> lock_guard(&mutex_); 3390 base::LockGuard<base::Mutex> lock_guard(&mutex_);
3376 queue_.Clear(); 3391 queue_.Clear();
3377 } 3392 }
3378 3393
3379 } } // namespace v8::internal 3394 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/debug.h ('k') | src/heap/heap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698