OLD | NEW |
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 <fstream> // NOLINT(readability/streams) | 7 #include <fstream> // NOLINT(readability/streams) |
8 #include <sstream> | 8 #include <sstream> |
9 | 9 |
10 #include "src/v8.h" | 10 #include "src/v8.h" |
(...skipping 892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
903 | 903 |
904 thread_local_top()->catcher_ = can_be_caught_externally ? | 904 thread_local_top()->catcher_ = can_be_caught_externally ? |
905 try_catch_handler() : NULL; | 905 try_catch_handler() : NULL; |
906 | 906 |
907 // Set the exception being re-thrown. | 907 // Set the exception being re-thrown. |
908 set_pending_exception(exception); | 908 set_pending_exception(exception); |
909 return heap()->exception(); | 909 return heap()->exception(); |
910 } | 910 } |
911 | 911 |
912 | 912 |
| 913 Object* Isolate::FindHandler() { |
| 914 Object* exception = pending_exception(); |
| 915 |
| 916 // Determine target stack handler. Special handling of termination exceptions |
| 917 // which are uncatchable by JavaScript code, we unwind the handlers until the |
| 918 // top ENTRY handler is found. |
| 919 StackHandler* handler = |
| 920 StackHandler::FromAddress(Isolate::handler(thread_local_top())); |
| 921 if (!is_catchable_by_javascript(exception)) { |
| 922 while (!handler->is_js_entry()) handler = handler->next(); |
| 923 } |
| 924 |
| 925 // Restore the next handler. |
| 926 thread_local_top_.handler_ = handler->next()->address(); |
| 927 |
| 928 // Compute handler and stack unwinding information. |
| 929 // TODO(mstarzinger): Extend this to perform actual stack-walk and take into |
| 930 // account that TurboFan code can contain handlers as well. |
| 931 Code* code = handler->code(); |
| 932 Context* context = handler->is_js_entry() ? nullptr : handler->context(); |
| 933 int offset = Smi::cast(code->handler_table()->get(handler->index()))->value(); |
| 934 Address handler_sp = handler->address() + StackHandlerConstants::kSize; |
| 935 Address handler_fp = handler->frame_pointer(); |
| 936 |
| 937 |
| 938 // Store information to be consumed by the CEntryStub. |
| 939 thread_local_top_.pending_handler_context_ = context; |
| 940 thread_local_top_.pending_handler_code_ = code; |
| 941 thread_local_top_.pending_handler_offset_ = offset; |
| 942 thread_local_top_.pending_handler_fp_ = handler_fp; |
| 943 thread_local_top_.pending_handler_sp_ = handler_sp; |
| 944 |
| 945 // Return and clear pending exception. |
| 946 clear_pending_exception(); |
| 947 return exception; |
| 948 } |
| 949 |
| 950 |
913 Object* Isolate::ThrowIllegalOperation() { | 951 Object* Isolate::ThrowIllegalOperation() { |
914 if (FLAG_stack_trace_on_illegal) PrintStack(stdout); | 952 if (FLAG_stack_trace_on_illegal) PrintStack(stdout); |
915 return Throw(heap_.illegal_access_string()); | 953 return Throw(heap_.illegal_access_string()); |
916 } | 954 } |
917 | 955 |
918 | 956 |
919 void Isolate::ScheduleThrow(Object* exception) { | 957 void Isolate::ScheduleThrow(Object* exception) { |
920 // When scheduling a throw we first throw the exception to get the | 958 // When scheduling a throw we first throw the exception to get the |
921 // error reporting if it is uncaught before rescheduling it. | 959 // error reporting if it is uncaught before rescheduling it. |
922 Throw(exception); | 960 Throw(exception); |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1279 } | 1317 } |
1280 | 1318 |
1281 // Save the message for reporting if the the exception remains uncaught. | 1319 // Save the message for reporting if the the exception remains uncaught. |
1282 thread_local_top()->has_pending_message_ = report_exception; | 1320 thread_local_top()->has_pending_message_ = report_exception; |
1283 | 1321 |
1284 // Do not forget to clean catcher_ if currently thrown exception cannot | 1322 // Do not forget to clean catcher_ if currently thrown exception cannot |
1285 // be caught. If necessary, ReThrow will update the catcher. | 1323 // be caught. If necessary, ReThrow will update the catcher. |
1286 thread_local_top()->catcher_ = can_be_caught_externally ? | 1324 thread_local_top()->catcher_ = can_be_caught_externally ? |
1287 try_catch_handler() : NULL; | 1325 try_catch_handler() : NULL; |
1288 | 1326 |
| 1327 // Set the exception being thrown. |
1289 set_pending_exception(*exception_handle); | 1328 set_pending_exception(*exception_handle); |
1290 } | 1329 } |
1291 | 1330 |
1292 | 1331 |
1293 bool Isolate::HasExternalTryCatch() { | 1332 bool Isolate::HasExternalTryCatch() { |
1294 DCHECK(has_pending_exception()); | 1333 DCHECK(has_pending_exception()); |
1295 | 1334 |
1296 return (thread_local_top()->catcher_ != NULL) && | 1335 return (thread_local_top()->catcher_ != NULL) && |
1297 (try_catch_handler() == thread_local_top()->catcher_); | 1336 (try_catch_handler() == thread_local_top()->catcher_); |
1298 } | 1337 } |
(...skipping 1252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2551 if (prev_ && prev_->Intercept(flag)) return true; | 2590 if (prev_ && prev_->Intercept(flag)) return true; |
2552 // Then check whether this scope intercepts. | 2591 // Then check whether this scope intercepts. |
2553 if ((flag & intercept_mask_)) { | 2592 if ((flag & intercept_mask_)) { |
2554 intercepted_flags_ |= flag; | 2593 intercepted_flags_ |= flag; |
2555 return true; | 2594 return true; |
2556 } | 2595 } |
2557 return false; | 2596 return false; |
2558 } | 2597 } |
2559 | 2598 |
2560 } } // namespace v8::internal | 2599 } } // namespace v8::internal |
OLD | NEW |