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

Side by Side Diff: src/isolate.cc

Issue 291393002: Make v8::TryCatch able to consume natively thrown exceptions (again). (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') | 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 890 matching lines...) Expand 10 before | Expand all | Expand 10 after
901 Object* script = reinterpret_cast<Object*>(handler->message_script_); 901 Object* script = reinterpret_cast<Object*>(handler->message_script_);
902 ASSERT(message->IsJSMessageObject() || message->IsTheHole()); 902 ASSERT(message->IsJSMessageObject() || message->IsTheHole());
903 ASSERT(script->IsScript() || script->IsTheHole()); 903 ASSERT(script->IsScript() || script->IsTheHole());
904 thread_local_top()->pending_message_obj_ = message; 904 thread_local_top()->pending_message_obj_ = message;
905 thread_local_top()->pending_message_script_ = script; 905 thread_local_top()->pending_message_script_ = script;
906 thread_local_top()->pending_message_start_pos_ = handler->message_start_pos_; 906 thread_local_top()->pending_message_start_pos_ = handler->message_start_pos_;
907 thread_local_top()->pending_message_end_pos_ = handler->message_end_pos_; 907 thread_local_top()->pending_message_end_pos_ = handler->message_end_pos_;
908 } 908 }
909 909
910 910
911 void Isolate::CancelScheduledExceptionFromTryCatch(v8::TryCatch* handler) {
912 ASSERT(has_scheduled_exception());
913 if (scheduled_exception() == handler->exception_) {
914 ASSERT(scheduled_exception() != heap()->termination_exception());
915 clear_scheduled_exception();
916 }
917 }
918
919
911 Object* Isolate::PromoteScheduledException() { 920 Object* Isolate::PromoteScheduledException() {
912 Object* thrown = scheduled_exception(); 921 Object* thrown = scheduled_exception();
913 clear_scheduled_exception(); 922 clear_scheduled_exception();
914 // Re-throw the exception to avoid getting repeated error reporting. 923 // Re-throw the exception to avoid getting repeated error reporting.
915 return ReThrow(thrown); 924 return ReThrow(thrown);
916 } 925 }
917 926
918 927
919 void Isolate::PrintCurrentStackTrace(FILE* out) { 928 void Isolate::PrintCurrentStackTrace(FILE* out) {
920 StackTraceFrameIterator it(this); 929 StackTraceFrameIterator it(this);
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
1188 1197
1189 return true; 1198 return true;
1190 } 1199 }
1191 1200
1192 1201
1193 void Isolate::ReportPendingMessages() { 1202 void Isolate::ReportPendingMessages() {
1194 ASSERT(has_pending_exception()); 1203 ASSERT(has_pending_exception());
1195 PropagatePendingExceptionToExternalTryCatch(); 1204 PropagatePendingExceptionToExternalTryCatch();
1196 1205
1197 HandleScope scope(this); 1206 HandleScope scope(this);
1198 if (thread_local_top_.pending_exception_ == 1207 if (thread_local_top_.pending_exception_ == heap()->termination_exception()) {
1199 heap()->termination_exception()) {
1200 // Do nothing: if needed, the exception has been already propagated to 1208 // Do nothing: if needed, the exception has been already propagated to
1201 // v8::TryCatch. 1209 // v8::TryCatch.
1202 } else { 1210 } else {
1203 if (thread_local_top_.has_pending_message_) { 1211 if (thread_local_top_.has_pending_message_) {
1204 thread_local_top_.has_pending_message_ = false; 1212 thread_local_top_.has_pending_message_ = false;
1205 if (!thread_local_top_.pending_message_obj_->IsTheHole()) { 1213 if (!thread_local_top_.pending_message_obj_->IsTheHole()) {
1206 HandleScope scope(this); 1214 HandleScope scope(this);
1207 Handle<Object> message_obj(thread_local_top_.pending_message_obj_, 1215 Handle<Object> message_obj(thread_local_top_.pending_message_obj_,
1208 this); 1216 this);
1209 if (!thread_local_top_.pending_message_script_->IsTheHole()) { 1217 if (!thread_local_top_.pending_message_script_->IsTheHole()) {
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
1726 1734
1727 1735
1728 void Isolate::PropagatePendingExceptionToExternalTryCatch() { 1736 void Isolate::PropagatePendingExceptionToExternalTryCatch() {
1729 ASSERT(has_pending_exception()); 1737 ASSERT(has_pending_exception());
1730 1738
1731 bool external_caught = IsExternallyCaught(); 1739 bool external_caught = IsExternallyCaught();
1732 thread_local_top_.external_caught_exception_ = external_caught; 1740 thread_local_top_.external_caught_exception_ = external_caught;
1733 1741
1734 if (!external_caught) return; 1742 if (!external_caught) return;
1735 1743
1736 if (thread_local_top_.pending_exception_ == 1744 if (thread_local_top_.pending_exception_ == heap()->termination_exception()) {
1737 heap()->termination_exception()) {
1738 try_catch_handler()->can_continue_ = false; 1745 try_catch_handler()->can_continue_ = false;
1739 try_catch_handler()->has_terminated_ = true; 1746 try_catch_handler()->has_terminated_ = true;
1740 try_catch_handler()->exception_ = heap()->null_value(); 1747 try_catch_handler()->exception_ = heap()->null_value();
1741 } else { 1748 } else {
1742 v8::TryCatch* handler = try_catch_handler(); 1749 v8::TryCatch* handler = try_catch_handler();
1743 ASSERT(thread_local_top_.pending_message_obj_->IsJSMessageObject() || 1750 ASSERT(thread_local_top_.pending_message_obj_->IsJSMessageObject() ||
1744 thread_local_top_.pending_message_obj_->IsTheHole()); 1751 thread_local_top_.pending_message_obj_->IsTheHole());
1745 ASSERT(thread_local_top_.pending_message_script_->IsScript() || 1752 ASSERT(thread_local_top_.pending_message_script_->IsScript() ||
1746 thread_local_top_.pending_message_script_->IsTheHole()); 1753 thread_local_top_.pending_message_script_->IsTheHole());
1747 handler->can_continue_ = true; 1754 handler->can_continue_ = true;
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
2288 Execution::Call(this, microtask, factory()->undefined_value(), 2295 Execution::Call(this, microtask, factory()->undefined_value(),
2289 0, NULL).Check(); 2296 0, NULL).Check();
2290 } 2297 }
2291 } 2298 }
2292 2299
2293 handle_scope_implementer()->DecrementCallDepth(); 2300 handle_scope_implementer()->DecrementCallDepth();
2294 } 2301 }
2295 2302
2296 2303
2297 } } // namespace v8::internal 2304 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/isolate.h ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698