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

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: 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 | « src/isolate.h ('k') | no next file » | 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 792 matching lines...) Expand 10 before | Expand all | Expand 10 after
803 return heap()->exception(); 803 return heap()->exception();
804 } 804 }
805 805
806 806
807 Object* Isolate::TerminateExecution() { 807 Object* Isolate::TerminateExecution() {
808 DoThrow(heap_.termination_exception(), NULL); 808 DoThrow(heap_.termination_exception(), NULL);
809 return heap()->exception(); 809 return heap()->exception();
810 } 810 }
811 811
812 812
813 bool Isolate::IsExecutionTerminating() {
814 if (!IsInitialized()) return false;
815 if (has_scheduled_exception()) {
816 return scheduled_exception() == heap()->termination_exception();
817 }
818 return false;
819 }
820
821
813 void Isolate::CancelTerminateExecution() { 822 void Isolate::CancelTerminateExecution() {
814 if (try_catch_handler()) { 823 if (try_catch_handler()) {
815 try_catch_handler()->has_terminated_ = false; 824 try_catch_handler()->has_terminated_ = false;
816 } 825 }
817 if (has_pending_exception() && 826 if (has_pending_exception() &&
818 pending_exception() == heap_.termination_exception()) { 827 pending_exception() == heap_.termination_exception()) {
819 thread_local_top()->external_caught_exception_ = false; 828 thread_local_top()->external_caught_exception_ = false;
820 clear_pending_exception(); 829 clear_pending_exception();
821 } 830 }
822 if (has_scheduled_exception() && 831 if (has_scheduled_exception() &&
(...skipping 1451 matching lines...) Expand 10 before | Expand all | Expand 10 after
2274 HandleScope scope(this); 2283 HandleScope scope(this);
2275 int num_tasks = pending_microtask_count(); 2284 int num_tasks = pending_microtask_count();
2276 Handle<FixedArray> queue(heap()->microtask_queue(), this); 2285 Handle<FixedArray> queue(heap()->microtask_queue(), this);
2277 ASSERT(num_tasks <= queue->length()); 2286 ASSERT(num_tasks <= queue->length());
2278 set_pending_microtask_count(0); 2287 set_pending_microtask_count(0);
2279 heap()->set_microtask_queue(heap()->empty_fixed_array()); 2288 heap()->set_microtask_queue(heap()->empty_fixed_array());
2280 2289
2281 for (int i = 0; i < num_tasks; i++) { 2290 for (int i = 0; i < num_tasks; i++) {
2282 HandleScope scope(this); 2291 HandleScope scope(this);
2283 Handle<JSFunction> microtask(JSFunction::cast(queue->get(i)), this); 2292 Handle<JSFunction> microtask(JSFunction::cast(queue->get(i)), this);
2284 // TODO(adamk): This should ignore/clear exceptions instead of Checking. 2293 MaybeHandle<Object> result = Execution::Call(
2285 Execution::Call(this, microtask, factory()->undefined_value(), 2294 this, microtask, factory()->undefined_value(), 0, NULL);
2286 0, NULL).Check(); 2295 if (result.is_null()) {
2296 // Microtasks should not throw unless the embedder has asked us to
2297 // TerminateExecution.
2298 ASSERT(IsExecutionTerminating());
2299 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
2300 return;
2301 }
2287 } 2302 }
2288 } 2303 }
2289 2304
2290 handle_scope_implementer()->DecrementCallDepth(); 2305 handle_scope_implementer()->DecrementCallDepth();
2291 } 2306 }
2292 2307
2293 2308
2294 } } // namespace v8::internal 2309 } } // namespace v8::internal
OLDNEW
« 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