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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « include/v8.h ('k') | test/cctest/test-api.cc » ('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 <stdlib.h> 5 #include <stdlib.h>
6 6
7 #include "v8.h" 7 #include "v8.h"
8 8
9 #include "ast.h" 9 #include "ast.h"
10 #include "bootstrapper.h" 10 #include "bootstrapper.h"
(...skipping 2263 matching lines...) Expand 10 before | Expand all | Expand 10 after
2274 HandleScope scope(this); 2274 HandleScope scope(this);
2275 int num_tasks = pending_microtask_count(); 2275 int num_tasks = pending_microtask_count();
2276 Handle<FixedArray> queue(heap()->microtask_queue(), this); 2276 Handle<FixedArray> queue(heap()->microtask_queue(), this);
2277 ASSERT(num_tasks <= queue->length()); 2277 ASSERT(num_tasks <= queue->length());
2278 set_pending_microtask_count(0); 2278 set_pending_microtask_count(0);
2279 heap()->set_microtask_queue(heap()->empty_fixed_array()); 2279 heap()->set_microtask_queue(heap()->empty_fixed_array());
2280 2280
2281 for (int i = 0; i < num_tasks; i++) { 2281 for (int i = 0; i < num_tasks; i++) {
2282 HandleScope scope(this); 2282 HandleScope scope(this);
2283 Handle<JSFunction> microtask(JSFunction::cast(queue->get(i)), this); 2283 Handle<JSFunction> microtask(JSFunction::cast(queue->get(i)), this);
2284 // TODO(adamk): This should ignore/clear exceptions instead of Checking. 2284 Handle<Object> exception;
2285 Execution::Call(this, microtask, factory()->undefined_value(), 2285 MaybeHandle<Object> result = Execution::TryCall(
2286 0, NULL).Check(); 2286 microtask, factory()->undefined_value(), 0, NULL, &exception);
2287 // If execution is terminating, just bail out.
2288 if (result.is_null() &&
2289 !exception.is_null() &&
2290 *exception == heap()->termination_exception()) {
2291 // Clear out any remaining callbacks in the queue.
2292 heap()->set_microtask_queue(heap()->empty_fixed_array());
2293 set_pending_microtask_count(0);
2294 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
2295 }
2287 } 2296 }
2288 } 2297 }
2289 2298
2299 done:
2290 handle_scope_implementer()->DecrementCallDepth(); 2300 handle_scope_implementer()->DecrementCallDepth();
2291 } 2301 }
2292 2302
2293 2303
2294 } } // namespace v8::internal 2304 } } // namespace v8::internal
OLDNEW
« 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