| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 ASSERT(!has_pending_message_); | 285 ASSERT(!has_pending_message_); |
| 286 ASSERT(!external_caught_exception_); | 286 ASSERT(!external_caught_exception_); |
| 287 ASSERT(try_catch_handler_address_ == NULL); | 287 ASSERT(try_catch_handler_address_ == NULL); |
| 288 } | 288 } |
| 289 | 289 |
| 290 Isolate* isolate_; | 290 Isolate* isolate_; |
| 291 // The context where the current execution method is created and for variable | 291 // The context where the current execution method is created and for variable |
| 292 // lookups. | 292 // lookups. |
| 293 Context* context_; | 293 Context* context_; |
| 294 ThreadId thread_id_; | 294 ThreadId thread_id_; |
| 295 MaybeObject* pending_exception_; | 295 Object* pending_exception_; |
| 296 bool has_pending_message_; | 296 bool has_pending_message_; |
| 297 bool rethrowing_message_; | 297 bool rethrowing_message_; |
| 298 Object* pending_message_obj_; | 298 Object* pending_message_obj_; |
| 299 Object* pending_message_script_; | 299 Object* pending_message_script_; |
| 300 int pending_message_start_pos_; | 300 int pending_message_start_pos_; |
| 301 int pending_message_end_pos_; | 301 int pending_message_end_pos_; |
| 302 // Use a separate value for scheduled exceptions to preserve the | 302 // Use a separate value for scheduled exceptions to preserve the |
| 303 // invariants that hold about pending_exception. We may want to | 303 // invariants that hold about pending_exception. We may want to |
| 304 // unify them later. | 304 // unify them later. |
| 305 MaybeObject* scheduled_exception_; | 305 Object* scheduled_exception_; |
| 306 bool external_caught_exception_; | 306 bool external_caught_exception_; |
| 307 SaveContext* save_context_; | 307 SaveContext* save_context_; |
| 308 v8::TryCatch* catcher_; | 308 v8::TryCatch* catcher_; |
| 309 | 309 |
| 310 // Stack. | 310 // Stack. |
| 311 Address c_entry_fp_; // the frame pointer of the top c entry frame | 311 Address c_entry_fp_; // the frame pointer of the top c entry frame |
| 312 Address handler_; // try-blocks are chained through the stack | 312 Address handler_; // try-blocks are chained through the stack |
| 313 | 313 |
| 314 #ifdef USE_SIMULATOR | 314 #ifdef USE_SIMULATOR |
| 315 Simulator* simulator_; | 315 Simulator* simulator_; |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 601 thread_local_top_.context_ = context; | 601 thread_local_top_.context_ = context; |
| 602 } | 602 } |
| 603 Context** context_address() { return &thread_local_top_.context_; } | 603 Context** context_address() { return &thread_local_top_.context_; } |
| 604 | 604 |
| 605 THREAD_LOCAL_TOP_ACCESSOR(SaveContext*, save_context) | 605 THREAD_LOCAL_TOP_ACCESSOR(SaveContext*, save_context) |
| 606 | 606 |
| 607 // Access to current thread id. | 607 // Access to current thread id. |
| 608 THREAD_LOCAL_TOP_ACCESSOR(ThreadId, thread_id) | 608 THREAD_LOCAL_TOP_ACCESSOR(ThreadId, thread_id) |
| 609 | 609 |
| 610 // Interface to pending exception. | 610 // Interface to pending exception. |
| 611 MaybeObject* pending_exception() { | 611 Object* pending_exception() { |
| 612 ASSERT(has_pending_exception()); | 612 ASSERT(has_pending_exception()); |
| 613 ASSERT(!thread_local_top_.pending_exception_->IsFailure()); |
| 613 return thread_local_top_.pending_exception_; | 614 return thread_local_top_.pending_exception_; |
| 614 } | 615 } |
| 615 | 616 |
| 616 void set_pending_exception(MaybeObject* exception) { | 617 void set_pending_exception(Object* exception) { |
| 618 ASSERT(!exception->IsFailure()); |
| 617 thread_local_top_.pending_exception_ = exception; | 619 thread_local_top_.pending_exception_ = exception; |
| 618 } | 620 } |
| 619 | 621 |
| 620 void clear_pending_exception() { | 622 void clear_pending_exception() { |
| 623 ASSERT(!thread_local_top_.pending_exception_->IsFailure()); |
| 621 thread_local_top_.pending_exception_ = heap_.the_hole_value(); | 624 thread_local_top_.pending_exception_ = heap_.the_hole_value(); |
| 622 } | 625 } |
| 623 | 626 |
| 624 MaybeObject** pending_exception_address() { | 627 Object** pending_exception_address() { |
| 625 return &thread_local_top_.pending_exception_; | 628 return &thread_local_top_.pending_exception_; |
| 626 } | 629 } |
| 627 | 630 |
| 628 bool has_pending_exception() { | 631 bool has_pending_exception() { |
| 632 ASSERT(!thread_local_top_.pending_exception_->IsFailure()); |
| 629 return !thread_local_top_.pending_exception_->IsTheHole(); | 633 return !thread_local_top_.pending_exception_->IsTheHole(); |
| 630 } | 634 } |
| 631 | 635 |
| 632 THREAD_LOCAL_TOP_ACCESSOR(bool, external_caught_exception) | 636 THREAD_LOCAL_TOP_ACCESSOR(bool, external_caught_exception) |
| 633 | 637 |
| 634 void clear_pending_message() { | 638 void clear_pending_message() { |
| 635 thread_local_top_.has_pending_message_ = false; | 639 thread_local_top_.has_pending_message_ = false; |
| 636 thread_local_top_.pending_message_obj_ = heap_.the_hole_value(); | 640 thread_local_top_.pending_message_obj_ = heap_.the_hole_value(); |
| 637 thread_local_top_.pending_message_script_ = heap_.the_hole_value(); | 641 thread_local_top_.pending_message_script_ = heap_.the_hole_value(); |
| 638 } | 642 } |
| 639 v8::TryCatch* try_catch_handler() { | 643 v8::TryCatch* try_catch_handler() { |
| 640 return thread_local_top_.TryCatchHandler(); | 644 return thread_local_top_.TryCatchHandler(); |
| 641 } | 645 } |
| 642 Address try_catch_handler_address() { | 646 Address try_catch_handler_address() { |
| 643 return thread_local_top_.try_catch_handler_address(); | 647 return thread_local_top_.try_catch_handler_address(); |
| 644 } | 648 } |
| 645 bool* external_caught_exception_address() { | 649 bool* external_caught_exception_address() { |
| 646 return &thread_local_top_.external_caught_exception_; | 650 return &thread_local_top_.external_caught_exception_; |
| 647 } | 651 } |
| 648 | 652 |
| 649 THREAD_LOCAL_TOP_ACCESSOR(v8::TryCatch*, catcher) | 653 THREAD_LOCAL_TOP_ACCESSOR(v8::TryCatch*, catcher) |
| 650 | 654 |
| 651 MaybeObject** scheduled_exception_address() { | 655 Object** scheduled_exception_address() { |
| 652 return &thread_local_top_.scheduled_exception_; | 656 return &thread_local_top_.scheduled_exception_; |
| 653 } | 657 } |
| 654 | 658 |
| 655 Address pending_message_obj_address() { | 659 Address pending_message_obj_address() { |
| 656 return reinterpret_cast<Address>(&thread_local_top_.pending_message_obj_); | 660 return reinterpret_cast<Address>(&thread_local_top_.pending_message_obj_); |
| 657 } | 661 } |
| 658 | 662 |
| 659 Address has_pending_message_address() { | 663 Address has_pending_message_address() { |
| 660 return reinterpret_cast<Address>(&thread_local_top_.has_pending_message_); | 664 return reinterpret_cast<Address>(&thread_local_top_.has_pending_message_); |
| 661 } | 665 } |
| 662 | 666 |
| 663 Address pending_message_script_address() { | 667 Address pending_message_script_address() { |
| 664 return reinterpret_cast<Address>( | 668 return reinterpret_cast<Address>( |
| 665 &thread_local_top_.pending_message_script_); | 669 &thread_local_top_.pending_message_script_); |
| 666 } | 670 } |
| 667 | 671 |
| 668 MaybeObject* scheduled_exception() { | 672 Object* scheduled_exception() { |
| 669 ASSERT(has_scheduled_exception()); | 673 ASSERT(has_scheduled_exception()); |
| 674 ASSERT(!thread_local_top_.scheduled_exception_->IsFailure()); |
| 670 return thread_local_top_.scheduled_exception_; | 675 return thread_local_top_.scheduled_exception_; |
| 671 } | 676 } |
| 672 bool has_scheduled_exception() { | 677 bool has_scheduled_exception() { |
| 678 ASSERT(!thread_local_top_.scheduled_exception_->IsFailure()); |
| 673 return thread_local_top_.scheduled_exception_ != heap_.the_hole_value(); | 679 return thread_local_top_.scheduled_exception_ != heap_.the_hole_value(); |
| 674 } | 680 } |
| 675 void clear_scheduled_exception() { | 681 void clear_scheduled_exception() { |
| 682 ASSERT(!thread_local_top_.scheduled_exception_->IsFailure()); |
| 676 thread_local_top_.scheduled_exception_ = heap_.the_hole_value(); | 683 thread_local_top_.scheduled_exception_ = heap_.the_hole_value(); |
| 677 } | 684 } |
| 678 | 685 |
| 679 bool IsExternallyCaught(); | 686 bool IsExternallyCaught(); |
| 680 | 687 |
| 681 bool is_catchable_by_javascript(MaybeObject* exception) { | 688 bool is_catchable_by_javascript(Object* exception) { |
| 682 return exception != heap()->termination_exception(); | 689 return exception != heap()->termination_exception(); |
| 683 } | 690 } |
| 684 | 691 |
| 685 // Serializer. | 692 // Serializer. |
| 686 void PushToPartialSnapshotCache(Object* obj); | 693 void PushToPartialSnapshotCache(Object* obj); |
| 687 | 694 |
| 688 // JS execution stack (see frames.h). | 695 // JS execution stack (see frames.h). |
| 689 static Address c_entry_fp(ThreadLocalTop* thread) { | 696 static Address c_entry_fp(ThreadLocalTop* thread) { |
| 690 return thread->c_entry_fp_; | 697 return thread->c_entry_fp_; |
| 691 } | 698 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 730 // handler the exception is scheduled to be rethrown when we return to running | 737 // handler the exception is scheduled to be rethrown when we return to running |
| 731 // JavaScript code. If an exception is scheduled true is returned. | 738 // JavaScript code. If an exception is scheduled true is returned. |
| 732 bool OptionalRescheduleException(bool is_bottom_call); | 739 bool OptionalRescheduleException(bool is_bottom_call); |
| 733 | 740 |
| 734 class ExceptionScope { | 741 class ExceptionScope { |
| 735 public: | 742 public: |
| 736 explicit ExceptionScope(Isolate* isolate) : | 743 explicit ExceptionScope(Isolate* isolate) : |
| 737 // Scope currently can only be used for regular exceptions, not | 744 // Scope currently can only be used for regular exceptions, not |
| 738 // failures like OOM or termination exception. | 745 // failures like OOM or termination exception. |
| 739 isolate_(isolate), | 746 isolate_(isolate), |
| 740 pending_exception_(isolate_->pending_exception()->ToObjectUnchecked(), | 747 pending_exception_(isolate_->pending_exception(), isolate_), |
| 741 isolate_), | |
| 742 catcher_(isolate_->catcher()) | 748 catcher_(isolate_->catcher()) |
| 743 { } | 749 { } |
| 744 | 750 |
| 745 ~ExceptionScope() { | 751 ~ExceptionScope() { |
| 746 isolate_->set_catcher(catcher_); | 752 isolate_->set_catcher(catcher_); |
| 747 isolate_->set_pending_exception(*pending_exception_); | 753 isolate_->set_pending_exception(*pending_exception_); |
| 748 } | 754 } |
| 749 | 755 |
| 750 private: | 756 private: |
| 751 Isolate* isolate_; | 757 Isolate* isolate_; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 812 template <typename T> | 818 template <typename T> |
| 813 MUST_USE_RESULT MaybeHandle<T> Throw(Handle<Object> exception, | 819 MUST_USE_RESULT MaybeHandle<T> Throw(Handle<Object> exception, |
| 814 MessageLocation* location = NULL) { | 820 MessageLocation* location = NULL) { |
| 815 Throw(*exception, location); | 821 Throw(*exception, location); |
| 816 return MaybeHandle<T>(); | 822 return MaybeHandle<T>(); |
| 817 } | 823 } |
| 818 | 824 |
| 819 // Re-throw an exception. This involves no error reporting since | 825 // Re-throw an exception. This involves no error reporting since |
| 820 // error reporting was handled when the exception was thrown | 826 // error reporting was handled when the exception was thrown |
| 821 // originally. | 827 // originally. |
| 822 Failure* ReThrow(MaybeObject* exception); | 828 Failure* ReThrow(Object* exception); |
| 823 void ScheduleThrow(Object* exception); | 829 void ScheduleThrow(Object* exception); |
| 824 // Re-set pending message, script and positions reported to the TryCatch | 830 // Re-set pending message, script and positions reported to the TryCatch |
| 825 // back to the TLS for re-use when rethrowing. | 831 // back to the TLS for re-use when rethrowing. |
| 826 void RestorePendingMessageFromTryCatch(v8::TryCatch* handler); | 832 void RestorePendingMessageFromTryCatch(v8::TryCatch* handler); |
| 827 void ReportPendingMessages(); | 833 void ReportPendingMessages(); |
| 828 // Return pending location if any or unfilled structure. | 834 // Return pending location if any or unfilled structure. |
| 829 MessageLocation GetMessageLocation(); | 835 MessageLocation GetMessageLocation(); |
| 830 Failure* ThrowIllegalOperation(); | 836 Failure* ThrowIllegalOperation(); |
| 831 Failure* ThrowInvalidStringLength(); | 837 Failure* ThrowInvalidStringLength(); |
| 832 | 838 |
| (...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1581 } | 1587 } |
| 1582 | 1588 |
| 1583 EmbeddedVector<char, 128> filename_; | 1589 EmbeddedVector<char, 128> filename_; |
| 1584 FILE* file_; | 1590 FILE* file_; |
| 1585 int scope_depth_; | 1591 int scope_depth_; |
| 1586 }; | 1592 }; |
| 1587 | 1593 |
| 1588 } } // namespace v8::internal | 1594 } } // namespace v8::internal |
| 1589 | 1595 |
| 1590 #endif // V8_ISOLATE_H_ | 1596 #endif // V8_ISOLATE_H_ |
| OLD | NEW |