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

Unified Diff: src/isolate.cc

Issue 294943009: Allow microtasks to throw exceptions and handle them gracefully (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Use TryCall to swallow exceptions Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/v8.h ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/isolate.cc
diff --git a/src/isolate.cc b/src/isolate.cc
index f7605d8d21b346e85a78c557aca0b74d78cb624c..427f76940caf571c946481c2dfd92f98f1a4586f 100644
--- a/src/isolate.cc
+++ b/src/isolate.cc
@@ -2281,12 +2281,22 @@ void Isolate::RunMicrotasks() {
for (int i = 0; i < num_tasks; i++) {
HandleScope scope(this);
Handle<JSFunction> microtask(JSFunction::cast(queue->get(i)), this);
- // TODO(adamk): This should ignore/clear exceptions instead of Checking.
- Execution::Call(this, microtask, factory()->undefined_value(),
- 0, NULL).Check();
+ Handle<Object> exception;
+ MaybeHandle<Object> result = Execution::TryCall(
+ microtask, factory()->undefined_value(), 0, NULL, &exception);
+ // If execution is terminating, just bail out.
+ if (result.is_null() &&
+ !exception.is_null() &&
+ *exception == heap()->termination_exception()) {
+ // Clear out any remaining callbacks in the queue.
+ heap()->set_microtask_queue(heap()->empty_fixed_array());
+ set_pending_microtask_count(0);
+ goto done;
Michael Starzinger 2014/05/22 11:27:59 Pretty please with a cherry on top, no gotos ... s
Yang 2014/05/22 11:33:26 Even nicer could be just a return here. Instead of
adamk 2014/05/22 11:49:25 Hmm, that seems a bit fragile to me, if someone ch
danno-g 2014/05/22 13:35:07 DBC: Please, no goto. Either the explicit return o
adamk 2014/05/22 13:48:50 No need to worry, the goto is long gone. I added i
+ }
}
}
+done:
handle_scope_implementer()->DecrementCallDepth();
}
« no previous file with comments | « include/v8.h ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698