OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 delete preallocated_message_space; | 246 delete preallocated_message_space; |
247 preallocated_message_space = NULL; | 247 preallocated_message_space = NULL; |
248 } | 248 } |
249 | 249 |
250 PreallocatedMemoryThread::StopThread(); | 250 PreallocatedMemoryThread::StopThread(); |
251 initialized = false; | 251 initialized = false; |
252 } | 252 } |
253 } | 253 } |
254 | 254 |
255 | 255 |
| 256 // There are cases where the C stack is separated from JS stack (ARM simulator). |
| 257 // To figure out the order of top-most JS try-catch handler and the top-most C |
| 258 // try-catch handler, the C try-catch handler keeps a reference to the top-most |
| 259 // JS try_catch handler when it was created. |
| 260 // |
| 261 // Here is a picture to explain the idea: |
| 262 // Top::thread_local_.handler_ Top::thread_local_.try_catch_handler_ |
| 263 // |
| 264 // | | |
| 265 // v v |
| 266 // |
| 267 // | JS handler | | C try_catch handler | |
| 268 // | next |--+ +-------- | js_handler_ | |
| 269 // | | | next_ |--+ |
| 270 // | | | |
| 271 // | JS handler |--+ <---------+ | |
| 272 // | next | |
| 273 // |
| 274 // If the top-most JS try-catch handler is not equal to |
| 275 // Top::thread_local_.try_catch_handler_.js_handler_, it means the JS handler |
| 276 // is on the top. Otherwise, it means the C try-catch handler is on the top. |
| 277 // |
256 void Top::RegisterTryCatchHandler(v8::TryCatch* that) { | 278 void Top::RegisterTryCatchHandler(v8::TryCatch* that) { |
| 279 that->js_handler_ = thread_local_.handler_; // casted to void* |
257 thread_local_.try_catch_handler_ = that; | 280 thread_local_.try_catch_handler_ = that; |
258 } | 281 } |
259 | 282 |
260 | 283 |
261 void Top::UnregisterTryCatchHandler(v8::TryCatch* that) { | 284 void Top::UnregisterTryCatchHandler(v8::TryCatch* that) { |
262 ASSERT(thread_local_.try_catch_handler_ == that); | 285 ASSERT(thread_local_.try_catch_handler_ == that); |
263 thread_local_.try_catch_handler_ = that->next_; | 286 thread_local_.try_catch_handler_ = that->next_; |
264 } | 287 } |
265 | 288 |
266 | 289 |
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
712 | 735 |
713 | 736 |
714 bool Top::ShouldReportException(bool* is_caught_externally) { | 737 bool Top::ShouldReportException(bool* is_caught_externally) { |
715 StackHandler* handler = | 738 StackHandler* handler = |
716 StackHandler::FromAddress(Top::handler(Top::GetCurrentThread())); | 739 StackHandler::FromAddress(Top::handler(Top::GetCurrentThread())); |
717 | 740 |
718 // Determine if we have an external exception handler and get the | 741 // Determine if we have an external exception handler and get the |
719 // address of the external handler so we can compare the address to | 742 // address of the external handler so we can compare the address to |
720 // determine which one is closer to the top of the stack. | 743 // determine which one is closer to the top of the stack. |
721 bool has_external_handler = (thread_local_.try_catch_handler_ != NULL); | 744 bool has_external_handler = (thread_local_.try_catch_handler_ != NULL); |
722 Address external_handler_address = | 745 v8::TryCatch* try_catch = thread_local_.try_catch_handler_; |
723 reinterpret_cast<Address>(thread_local_.try_catch_handler_); | |
724 | 746 |
725 // NOTE: The stack is assumed to grown towards lower addresses. If | 747 // NOTE: The stack is assumed to grown towards lower addresses. If |
726 // the handler is at a higher address than the external address it | 748 // the handler is at a higher address than the external address it |
727 // means that it is below it on the stack. | 749 // means that it is below it on the stack. |
728 | 750 |
729 // Find the top-most try-catch handler. | 751 // Find the top-most try-catch handler. |
730 while (handler != NULL && !handler->is_try_catch()) { | 752 while (handler != NULL && !handler->is_try_catch()) { |
731 handler = handler->next(); | 753 handler = handler->next(); |
732 } | 754 } |
733 | 755 |
734 // The exception has been externally caught if and only if there is | 756 // The exception has been externally caught if and only if there is |
735 // an external handler which is above any JavaScript try-catch but NOT | 757 // an external handler which is on top of the top-most try-catch |
736 // try-finally handlers. | 758 // handler. |
| 759 // |
| 760 // See comments in RegisterTryCatchHandler for details. |
737 *is_caught_externally = has_external_handler && | 761 *is_caught_externally = has_external_handler && |
738 (handler == NULL || handler->address() > external_handler_address); | 762 (handler == NULL || handler == try_catch->js_handler_); |
739 | 763 |
740 // If we have a try-catch handler then the exception is caught in | 764 // If we have a try-catch handler then the exception is caught in |
741 // JavaScript code. | 765 // JavaScript code. |
742 bool is_uncaught_by_js = (handler == NULL); | 766 bool is_uncaught_by_js = (handler == NULL); |
743 | 767 |
744 // If there is no external try-catch handler, we report the | 768 // If there is no external try-catch handler, we report the |
745 // exception if it isn't caught by JavaScript code. | 769 // exception if it isn't caught by JavaScript code. |
746 if (!has_external_handler) return is_uncaught_by_js; | 770 if (!has_external_handler) return is_uncaught_by_js; |
747 | 771 |
748 if (is_uncaught_by_js || handler->address() > external_handler_address) { | 772 if (is_uncaught_by_js || handler == try_catch->js_handler_) { |
749 // Only report the exception if the external handler is verbose. | 773 // Only report the exception if the external handler is verbose. |
750 return thread_local_.try_catch_handler_->is_verbose_; | 774 return thread_local_.try_catch_handler_->is_verbose_; |
751 } else { | 775 } else { |
752 // Report the exception if it isn't caught by JavaScript code. | 776 // Report the exception if it isn't caught by JavaScript code. |
753 return is_uncaught_by_js; | 777 return is_uncaught_by_js; |
754 } | 778 } |
755 } | 779 } |
756 | 780 |
757 | 781 |
758 void Top::DoThrow(Object* exception, | 782 void Top::DoThrow(Object* exception, |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
893 Top::break_access_->Lock(); | 917 Top::break_access_->Lock(); |
894 } | 918 } |
895 | 919 |
896 | 920 |
897 ExecutionAccess::~ExecutionAccess() { | 921 ExecutionAccess::~ExecutionAccess() { |
898 Top::break_access_->Unlock(); | 922 Top::break_access_->Unlock(); |
899 } | 923 } |
900 | 924 |
901 | 925 |
902 } } // namespace v8::internal | 926 } } // namespace v8::internal |
OLD | NEW |