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

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 existing Suppression scope 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..5a5f9801bc498691ca0927364833bce7218d8b6d 100644
--- a/src/isolate.cc
+++ b/src/isolate.cc
@@ -2234,11 +2234,11 @@ void Isolate::FireCallCompletedCallback() {
if (!handle_scope_implementer()->CallDepthIsZero()) return;
if (run_microtasks) RunMicrotasks();
// Fire callbacks. Increase call depth to prevent recursive callbacks.
- handle_scope_implementer()->IncrementCallDepth();
+ v8::Isolate::SuppressMicrotaskExecutionScope suppress(
+ reinterpret_cast<v8::Isolate*>(this));
for (int i = 0; i < call_completed_callbacks_.length(); i++) {
call_completed_callbacks_.at(i)();
}
- handle_scope_implementer()->DecrementCallDepth();
}
@@ -2268,7 +2268,8 @@ void Isolate::RunMicrotasks() {
// ASSERT(handle_scope_implementer()->CallDepthIsZero());
// Increase call depth to prevent recursive callbacks.
- handle_scope_implementer()->IncrementCallDepth();
+ v8::Isolate::SuppressMicrotaskExecutionScope suppress(
+ reinterpret_cast<v8::Isolate*>(this));
while (pending_microtask_count() > 0) {
HandleScope scope(this);
@@ -2281,13 +2282,20 @@ 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);
+ return;
+ }
}
}
-
- 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