| 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 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 Failure* Isolate::StackOverflow() { | 527 Failure* Isolate::StackOverflow() { |
| 528 HandleScope scope; | 528 HandleScope scope; |
| 529 Handle<String> key = factory()->stack_overflow_symbol(); | 529 Handle<String> key = factory()->stack_overflow_symbol(); |
| 530 Handle<JSObject> boilerplate = | 530 Handle<JSObject> boilerplate = |
| 531 Handle<JSObject>::cast(GetProperty(js_builtins_object(), key)); | 531 Handle<JSObject>::cast(GetProperty(js_builtins_object(), key)); |
| 532 Handle<Object> exception = Copy(boilerplate); | 532 Handle<Object> exception = Copy(boilerplate); |
| 533 // TODO(1240995): To avoid having to call JavaScript code to compute | 533 // TODO(1240995): To avoid having to call JavaScript code to compute |
| 534 // the message for stack overflow exceptions which is very likely to | 534 // the message for stack overflow exceptions which is very likely to |
| 535 // double fault with another stack overflow exception, we use a | 535 // double fault with another stack overflow exception, we use a |
| 536 // precomputed message. | 536 // precomputed message. |
| 537 DoThrow(*exception, NULL, kStackOverflowMessage); | 537 DoThrow(*exception, NULL); |
| 538 return Failure::Exception(); | 538 return Failure::Exception(); |
| 539 } | 539 } |
| 540 | 540 |
| 541 | 541 |
| 542 Failure* Isolate::TerminateExecution() { | 542 Failure* Isolate::TerminateExecution() { |
| 543 DoThrow(heap_.termination_exception(), NULL, NULL); | 543 DoThrow(heap_.termination_exception(), NULL); |
| 544 return Failure::Exception(); | 544 return Failure::Exception(); |
| 545 } | 545 } |
| 546 | 546 |
| 547 | 547 |
| 548 Failure* Isolate::Throw(Object* exception, MessageLocation* location) { | 548 Failure* Isolate::Throw(Object* exception, MessageLocation* location) { |
| 549 DoThrow(exception, location, NULL); | 549 DoThrow(exception, location); |
| 550 return Failure::Exception(); | 550 return Failure::Exception(); |
| 551 } | 551 } |
| 552 | 552 |
| 553 | 553 |
| 554 Failure* Isolate::ReThrow(MaybeObject* exception, MessageLocation* location) { | 554 Failure* Isolate::ReThrow(MaybeObject* exception, MessageLocation* location) { |
| 555 bool can_be_caught_externally = false; | 555 bool can_be_caught_externally = false; |
| 556 ShouldReportException(&can_be_caught_externally, | 556 ShouldReportException(&can_be_caught_externally, |
| 557 is_catchable_by_javascript(exception)); | 557 is_catchable_by_javascript(exception)); |
| 558 thread_local_top()->catcher_ = can_be_caught_externally ? | 558 thread_local_top()->catcher_ = can_be_caught_externally ? |
| 559 try_catch_handler() : NULL; | 559 try_catch_handler() : NULL; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 657 if (*can_be_caught_externally) { | 657 if (*can_be_caught_externally) { |
| 658 // Only report the exception if the external handler is verbose. | 658 // Only report the exception if the external handler is verbose. |
| 659 return try_catch_handler()->is_verbose_; | 659 return try_catch_handler()->is_verbose_; |
| 660 } else { | 660 } else { |
| 661 // Report the exception if it isn't caught by JavaScript code. | 661 // Report the exception if it isn't caught by JavaScript code. |
| 662 return handler == NULL; | 662 return handler == NULL; |
| 663 } | 663 } |
| 664 } | 664 } |
| 665 | 665 |
| 666 | 666 |
| 667 void Isolate::DoThrow(MaybeObject* exception, | 667 void Isolate::DoThrow(MaybeObject* exception, MessageLocation* location) { |
| 668 MessageLocation* location, | |
| 669 const char* message) { | |
| 670 ASSERT(!has_pending_exception()); | 668 ASSERT(!has_pending_exception()); |
| 671 | 669 |
| 672 HandleScope scope; | 670 HandleScope scope; |
| 673 Object* exception_object = Smi::FromInt(0); | 671 Object* exception_object = Smi::FromInt(0); |
| 674 bool is_object = exception->ToObject(&exception_object); | 672 bool is_object = exception->ToObject(&exception_object); |
| 675 Handle<Object> exception_handle(exception_object); | 673 Handle<Object> exception_handle(exception_object); |
| 676 | 674 |
| 677 // Determine reporting and whether the exception is caught externally. | 675 // Determine reporting and whether the exception is caught externally. |
| 678 bool catchable_by_javascript = is_catchable_by_javascript(exception); | 676 bool catchable_by_javascript = is_catchable_by_javascript(exception); |
| 679 // Only real objects can be caught by JS. | 677 // Only real objects can be caught by JS. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 716 } | 714 } |
| 717 ASSERT(is_object); // Can't use the handle unless there's a real object. | 715 ASSERT(is_object); // Can't use the handle unless there's a real object. |
| 718 message_obj = MessageHandler::MakeMessageObject("uncaught_exception", | 716 message_obj = MessageHandler::MakeMessageObject("uncaught_exception", |
| 719 location, HandleVector<Object>(&exception_handle, 1), stack_trace, | 717 location, HandleVector<Object>(&exception_handle, 1), stack_trace, |
| 720 stack_trace_object); | 718 stack_trace_object); |
| 721 } | 719 } |
| 722 } | 720 } |
| 723 | 721 |
| 724 // Save the message for reporting if the the exception remains uncaught. | 722 // Save the message for reporting if the the exception remains uncaught. |
| 725 thread_local_top()->has_pending_message_ = report_exception; | 723 thread_local_top()->has_pending_message_ = report_exception; |
| 726 thread_local_top()->pending_message_ = message; | |
| 727 if (!message_obj.is_null()) { | 724 if (!message_obj.is_null()) { |
| 728 thread_local_top()->pending_message_obj_ = *message_obj; | 725 thread_local_top()->pending_message_obj_ = *message_obj; |
| 729 if (location != NULL) { | 726 if (location != NULL) { |
| 730 thread_local_top()->pending_message_script_ = *location->script(); | 727 thread_local_top()->pending_message_script_ = *location->script(); |
| 731 thread_local_top()->pending_message_start_pos_ = location->start_pos(); | 728 thread_local_top()->pending_message_start_pos_ = location->start_pos(); |
| 732 thread_local_top()->pending_message_end_pos_ = location->end_pos(); | 729 thread_local_top()->pending_message_end_pos_ = location->end_pos(); |
| 733 } | 730 } |
| 734 } | 731 } |
| 735 | 732 |
| 736 // Do not forget to clean catcher_ if currently thrown exception cannot | 733 // Do not forget to clean catcher_ if currently thrown exception cannot |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 804 HandleScope scope; | 801 HandleScope scope; |
| 805 if (thread_local_top_.pending_exception_ == Failure::OutOfMemoryException()) { | 802 if (thread_local_top_.pending_exception_ == Failure::OutOfMemoryException()) { |
| 806 context()->mark_out_of_memory(); | 803 context()->mark_out_of_memory(); |
| 807 } else if (thread_local_top_.pending_exception_ == | 804 } else if (thread_local_top_.pending_exception_ == |
| 808 heap()->termination_exception()) { | 805 heap()->termination_exception()) { |
| 809 // Do nothing: if needed, the exception has been already propagated to | 806 // Do nothing: if needed, the exception has been already propagated to |
| 810 // v8::TryCatch. | 807 // v8::TryCatch. |
| 811 } else { | 808 } else { |
| 812 if (thread_local_top_.has_pending_message_) { | 809 if (thread_local_top_.has_pending_message_) { |
| 813 thread_local_top_.has_pending_message_ = false; | 810 thread_local_top_.has_pending_message_ = false; |
| 814 if (thread_local_top_.pending_message_ != NULL) { | 811 if (!thread_local_top_.pending_message_obj_->IsTheHole()) { |
| 815 MessageHandler::ReportMessage(thread_local_top_.pending_message_); | |
| 816 } else if (!thread_local_top_.pending_message_obj_->IsTheHole()) { | |
| 817 HandleScope scope; | 812 HandleScope scope; |
| 818 Handle<Object> message_obj(thread_local_top_.pending_message_obj_); | 813 Handle<Object> message_obj(thread_local_top_.pending_message_obj_); |
| 819 if (thread_local_top_.pending_message_script_ != NULL) { | 814 if (thread_local_top_.pending_message_script_ != NULL) { |
| 820 Handle<Script> script(thread_local_top_.pending_message_script_); | 815 Handle<Script> script(thread_local_top_.pending_message_script_); |
| 821 int start_pos = thread_local_top_.pending_message_start_pos_; | 816 int start_pos = thread_local_top_.pending_message_start_pos_; |
| 822 int end_pos = thread_local_top_.pending_message_end_pos_; | 817 int end_pos = thread_local_top_.pending_message_end_pos_; |
| 823 MessageLocation location(script, start_pos, end_pos); | 818 MessageLocation location(script, start_pos, end_pos); |
| 824 MessageHandler::ReportMessage(this, &location, message_obj); | 819 MessageHandler::ReportMessage(this, &location, message_obj); |
| 825 } else { | 820 } else { |
| 826 MessageHandler::ReportMessage(this, NULL, message_obj); | 821 MessageHandler::ReportMessage(this, NULL, message_obj); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 961 thread_local_top()->simulator_ = Simulator::current(this); | 956 thread_local_top()->simulator_ = Simulator::current(this); |
| 962 #endif | 957 #endif |
| 963 #endif | 958 #endif |
| 964 if (RuntimeProfiler::IsEnabled() && current_vm_state() == JS) { | 959 if (RuntimeProfiler::IsEnabled() && current_vm_state() == JS) { |
| 965 RuntimeProfiler::IsolateEnteredJS(this); | 960 RuntimeProfiler::IsolateEnteredJS(this); |
| 966 } | 961 } |
| 967 return from + sizeof(ThreadLocalTop); | 962 return from + sizeof(ThreadLocalTop); |
| 968 } | 963 } |
| 969 | 964 |
| 970 } } // namespace v8::internal | 965 } } // namespace v8::internal |
| OLD | NEW |