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

Side by Side Diff: src/isolate.cc

Issue 399473006: Reland "Make v8::TryCatch able to consume natively thrown exceptions." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 5 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 "src/v8.h" 7 #include "src/v8.h"
8 8
9 #include "src/ast.h" 9 #include "src/ast.h"
10 #include "src/base/platform/platform.h" 10 #include "src/base/platform/platform.h"
(...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 Object* script = reinterpret_cast<Object*>(handler->message_script_); 881 Object* script = reinterpret_cast<Object*>(handler->message_script_);
882 ASSERT(message->IsJSMessageObject() || message->IsTheHole()); 882 ASSERT(message->IsJSMessageObject() || message->IsTheHole());
883 ASSERT(script->IsScript() || script->IsTheHole()); 883 ASSERT(script->IsScript() || script->IsTheHole());
884 thread_local_top()->pending_message_obj_ = message; 884 thread_local_top()->pending_message_obj_ = message;
885 thread_local_top()->pending_message_script_ = script; 885 thread_local_top()->pending_message_script_ = script;
886 thread_local_top()->pending_message_start_pos_ = handler->message_start_pos_; 886 thread_local_top()->pending_message_start_pos_ = handler->message_start_pos_;
887 thread_local_top()->pending_message_end_pos_ = handler->message_end_pos_; 887 thread_local_top()->pending_message_end_pos_ = handler->message_end_pos_;
888 } 888 }
889 889
890 890
891 void Isolate::CancelScheduledExceptionFromTryCatch(v8::TryCatch* handler) {
892 ASSERT(has_scheduled_exception());
893 if (scheduled_exception() == handler->exception_) {
894 ASSERT(scheduled_exception() != heap()->termination_exception());
895 clear_scheduled_exception();
896 }
897 }
898
899
891 Object* Isolate::PromoteScheduledException() { 900 Object* Isolate::PromoteScheduledException() {
892 Object* thrown = scheduled_exception(); 901 Object* thrown = scheduled_exception();
893 clear_scheduled_exception(); 902 clear_scheduled_exception();
894 // Re-throw the exception to avoid getting repeated error reporting. 903 // Re-throw the exception to avoid getting repeated error reporting.
895 return ReThrow(thrown); 904 return ReThrow(thrown);
896 } 905 }
897 906
898 907
899 void Isolate::PrintCurrentStackTrace(FILE* out) { 908 void Isolate::PrintCurrentStackTrace(FILE* out) {
900 StackTraceFrameIterator it(this); 909 StackTraceFrameIterator it(this);
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
1184 1193
1185 return false; 1194 return false;
1186 } 1195 }
1187 1196
1188 1197
1189 void Isolate::ReportPendingMessages() { 1198 void Isolate::ReportPendingMessages() {
1190 ASSERT(has_pending_exception()); 1199 ASSERT(has_pending_exception());
1191 bool can_clear_message = PropagatePendingExceptionToExternalTryCatch(); 1200 bool can_clear_message = PropagatePendingExceptionToExternalTryCatch();
1192 1201
1193 HandleScope scope(this); 1202 HandleScope scope(this);
1194 if (thread_local_top_.pending_exception_ == 1203 if (thread_local_top_.pending_exception_ == heap()->termination_exception()) {
1195 heap()->termination_exception()) {
1196 // Do nothing: if needed, the exception has been already propagated to 1204 // Do nothing: if needed, the exception has been already propagated to
1197 // v8::TryCatch. 1205 // v8::TryCatch.
1198 } else { 1206 } else {
1199 if (thread_local_top_.has_pending_message_) { 1207 if (thread_local_top_.has_pending_message_) {
1200 thread_local_top_.has_pending_message_ = false; 1208 thread_local_top_.has_pending_message_ = false;
1201 if (!thread_local_top_.pending_message_obj_->IsTheHole()) { 1209 if (!thread_local_top_.pending_message_obj_->IsTheHole()) {
1202 HandleScope scope(this); 1210 HandleScope scope(this);
1203 Handle<Object> message_obj(thread_local_top_.pending_message_obj_, 1211 Handle<Object> message_obj(thread_local_top_.pending_message_obj_,
1204 this); 1212 this);
1205 if (!thread_local_top_.pending_message_script_->IsTheHole()) { 1213 if (!thread_local_top_.pending_message_script_->IsTheHole()) {
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
1732 return true; 1740 return true;
1733 } 1741 }
1734 1742
1735 bool catchable_by_js = is_catchable_by_javascript(pending_exception()); 1743 bool catchable_by_js = is_catchable_by_javascript(pending_exception());
1736 if (catchable_by_js && IsFinallyOnTop()) { 1744 if (catchable_by_js && IsFinallyOnTop()) {
1737 thread_local_top_.external_caught_exception_ = false; 1745 thread_local_top_.external_caught_exception_ = false;
1738 return false; 1746 return false;
1739 } 1747 }
1740 1748
1741 thread_local_top_.external_caught_exception_ = true; 1749 thread_local_top_.external_caught_exception_ = true;
1742 if (thread_local_top_.pending_exception_ == 1750 if (thread_local_top_.pending_exception_ == heap()->termination_exception()) {
1743 heap()->termination_exception()) {
1744 try_catch_handler()->can_continue_ = false; 1751 try_catch_handler()->can_continue_ = false;
1745 try_catch_handler()->has_terminated_ = true; 1752 try_catch_handler()->has_terminated_ = true;
1746 try_catch_handler()->exception_ = heap()->null_value(); 1753 try_catch_handler()->exception_ = heap()->null_value();
1747 } else { 1754 } else {
1748 v8::TryCatch* handler = try_catch_handler(); 1755 v8::TryCatch* handler = try_catch_handler();
1749 ASSERT(thread_local_top_.pending_message_obj_->IsJSMessageObject() || 1756 ASSERT(thread_local_top_.pending_message_obj_->IsJSMessageObject() ||
1750 thread_local_top_.pending_message_obj_->IsTheHole()); 1757 thread_local_top_.pending_message_obj_->IsTheHole());
1751 ASSERT(thread_local_top_.pending_message_script_->IsScript() || 1758 ASSERT(thread_local_top_.pending_message_script_->IsScript() ||
1752 thread_local_top_.pending_message_script_->IsTheHole()); 1759 thread_local_top_.pending_message_script_->IsTheHole());
1753 handler->can_continue_ = true; 1760 handler->can_continue_ = true;
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after
2351 if (prev_ && prev_->Intercept(flag)) return true; 2358 if (prev_ && prev_->Intercept(flag)) return true;
2352 // Then check whether this scope intercepts. 2359 // Then check whether this scope intercepts.
2353 if ((flag & intercept_mask_)) { 2360 if ((flag & intercept_mask_)) {
2354 intercepted_flags_ |= flag; 2361 intercepted_flags_ |= flag;
2355 return true; 2362 return true;
2356 } 2363 }
2357 return false; 2364 return false;
2358 } 2365 }
2359 2366
2360 } } // namespace v8::internal 2367 } } // 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