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

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: 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 | « src/isolate.h ('k') | no next file » | 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..5bd2b69815b71f2e6d961e98d61e749fde2b1c32 100644
--- a/src/isolate.cc
+++ b/src/isolate.cc
@@ -810,6 +810,15 @@ Object* Isolate::TerminateExecution() {
}
+bool Isolate::IsExecutionTerminating() {
+ if (!IsInitialized()) return false;
+ if (has_scheduled_exception()) {
+ return scheduled_exception() == heap()->termination_exception();
+ }
+ return false;
+}
+
+
void Isolate::CancelTerminateExecution() {
if (try_catch_handler()) {
try_catch_handler()->has_terminated_ = false;
@@ -2281,9 +2290,15 @@ 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();
+ MaybeHandle<Object> result = Execution::Call(
+ this, microtask, factory()->undefined_value(), 0, NULL);
+ if (result.is_null()) {
+ // Microtasks should not throw unless the embedder has asked us to
+ // TerminateExecution.
+ ASSERT(IsExecutionTerminating());
+ handle_scope_implementer()->DecrementCallDepth();
jochen (gone - plz use gerrit) 2014/05/22 07:45:38 why not just break?
adamk 2014/05/22 08:02:16 We're inside a while and a for loop. I would have
+ return;
+ }
}
}
« no previous file with comments | « src/isolate.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698