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 #ifndef V8_ISOLATE_H_ | 5 #ifndef V8_ISOLATE_H_ |
6 #define V8_ISOLATE_H_ | 6 #define V8_ISOLATE_H_ |
7 | 7 |
8 #include <queue> | 8 #include <queue> |
9 #include "include/v8-debug.h" | 9 #include "include/v8-debug.h" |
10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 bool has_pending_message_; | 285 bool has_pending_message_; |
286 bool rethrowing_message_; | 286 bool rethrowing_message_; |
287 Object* pending_message_obj_; | 287 Object* pending_message_obj_; |
288 | 288 |
289 // Use a separate value for scheduled exceptions to preserve the | 289 // Use a separate value for scheduled exceptions to preserve the |
290 // invariants that hold about pending_exception. We may want to | 290 // invariants that hold about pending_exception. We may want to |
291 // unify them later. | 291 // unify them later. |
292 Object* scheduled_exception_; | 292 Object* scheduled_exception_; |
293 bool external_caught_exception_; | 293 bool external_caught_exception_; |
294 SaveContext* save_context_; | 294 SaveContext* save_context_; |
295 v8::TryCatch* catcher_; | |
296 | 295 |
297 // Stack. | 296 // Stack. |
298 Address c_entry_fp_; // the frame pointer of the top c entry frame | 297 Address c_entry_fp_; // the frame pointer of the top c entry frame |
299 Address handler_; // try-blocks are chained through the stack | 298 Address handler_; // try-blocks are chained through the stack |
300 Address c_function_; // C function that was called at c entry. | 299 Address c_function_; // C function that was called at c entry. |
301 | 300 |
302 // Throwing an exception may cause a Promise rejection. For this purpose | 301 // Throwing an exception may cause a Promise rejection. For this purpose |
303 // we keep track of a stack of nested promises and the corresponding | 302 // we keep track of a stack of nested promises and the corresponding |
304 // try-catch handlers. | 303 // try-catch handlers. |
305 PromiseOnStack* promise_on_stack_; | 304 PromiseOnStack* promise_on_stack_; |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 v8::TryCatch* try_catch_handler() { | 610 v8::TryCatch* try_catch_handler() { |
612 return thread_local_top_.try_catch_handler(); | 611 return thread_local_top_.try_catch_handler(); |
613 } | 612 } |
614 Address try_catch_handler_address() { | 613 Address try_catch_handler_address() { |
615 return thread_local_top_.try_catch_handler_address(); | 614 return thread_local_top_.try_catch_handler_address(); |
616 } | 615 } |
617 bool* external_caught_exception_address() { | 616 bool* external_caught_exception_address() { |
618 return &thread_local_top_.external_caught_exception_; | 617 return &thread_local_top_.external_caught_exception_; |
619 } | 618 } |
620 | 619 |
621 THREAD_LOCAL_TOP_ACCESSOR(v8::TryCatch*, catcher) | |
622 | |
623 THREAD_LOCAL_TOP_ADDRESS(Object*, scheduled_exception) | 620 THREAD_LOCAL_TOP_ADDRESS(Object*, scheduled_exception) |
624 | 621 |
625 Address pending_message_obj_address() { | 622 Address pending_message_obj_address() { |
626 return reinterpret_cast<Address>(&thread_local_top_.pending_message_obj_); | 623 return reinterpret_cast<Address>(&thread_local_top_.pending_message_obj_); |
627 } | 624 } |
628 | 625 |
629 Address has_pending_message_address() { | 626 Address has_pending_message_address() { |
630 return reinterpret_cast<Address>(&thread_local_top_.has_pending_message_); | 627 return reinterpret_cast<Address>(&thread_local_top_.has_pending_message_); |
631 } | 628 } |
632 | 629 |
633 Object* scheduled_exception() { | 630 Object* scheduled_exception() { |
634 DCHECK(has_scheduled_exception()); | 631 DCHECK(has_scheduled_exception()); |
635 DCHECK(!thread_local_top_.scheduled_exception_->IsException()); | 632 DCHECK(!thread_local_top_.scheduled_exception_->IsException()); |
636 return thread_local_top_.scheduled_exception_; | 633 return thread_local_top_.scheduled_exception_; |
637 } | 634 } |
638 bool has_scheduled_exception() { | 635 bool has_scheduled_exception() { |
639 DCHECK(!thread_local_top_.scheduled_exception_->IsException()); | 636 DCHECK(!thread_local_top_.scheduled_exception_->IsException()); |
640 return thread_local_top_.scheduled_exception_ != heap_.the_hole_value(); | 637 return thread_local_top_.scheduled_exception_ != heap_.the_hole_value(); |
641 } | 638 } |
642 void clear_scheduled_exception() { | 639 void clear_scheduled_exception() { |
643 DCHECK(!thread_local_top_.scheduled_exception_->IsException()); | 640 DCHECK(!thread_local_top_.scheduled_exception_->IsException()); |
644 thread_local_top_.scheduled_exception_ = heap_.the_hole_value(); | 641 thread_local_top_.scheduled_exception_ = heap_.the_hole_value(); |
645 } | 642 } |
646 | 643 |
647 bool HasExternalTryCatch(); | |
648 bool IsFinallyOnTop(); | 644 bool IsFinallyOnTop(); |
649 | 645 |
650 bool is_catchable_by_javascript(Object* exception) { | 646 bool is_catchable_by_javascript(Object* exception) { |
651 return exception != heap()->termination_exception(); | 647 return exception != heap()->termination_exception(); |
652 } | 648 } |
653 | 649 |
654 // JS execution stack (see frames.h). | 650 // JS execution stack (see frames.h). |
655 static Address c_entry_fp(ThreadLocalTop* thread) { | 651 static Address c_entry_fp(ThreadLocalTop* thread) { |
656 return thread->c_entry_fp_; | 652 return thread->c_entry_fp_; |
657 } | 653 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
701 // JavaScript code. If an exception is scheduled true is returned. | 697 // JavaScript code. If an exception is scheduled true is returned. |
702 bool OptionalRescheduleException(bool is_bottom_call); | 698 bool OptionalRescheduleException(bool is_bottom_call); |
703 | 699 |
704 // Push and pop a promise and the current try-catch handler. | 700 // Push and pop a promise and the current try-catch handler. |
705 void PushPromise(Handle<JSObject> promise); | 701 void PushPromise(Handle<JSObject> promise); |
706 void PopPromise(); | 702 void PopPromise(); |
707 Handle<Object> GetPromiseOnStackOnThrow(); | 703 Handle<Object> GetPromiseOnStackOnThrow(); |
708 | 704 |
709 class ExceptionScope { | 705 class ExceptionScope { |
710 public: | 706 public: |
711 explicit ExceptionScope(Isolate* isolate) : | 707 // Scope currently can only be used for regular exceptions, |
712 // Scope currently can only be used for regular exceptions, | 708 // not termination exception. |
713 // not termination exception. | 709 explicit ExceptionScope(Isolate* isolate) |
714 isolate_(isolate), | 710 : isolate_(isolate), |
715 pending_exception_(isolate_->pending_exception(), isolate_), | 711 pending_exception_(isolate_->pending_exception(), isolate_) {} |
716 catcher_(isolate_->catcher()) | |
717 { } | |
718 | 712 |
719 ~ExceptionScope() { | 713 ~ExceptionScope() { |
720 isolate_->set_catcher(catcher_); | |
721 isolate_->set_pending_exception(*pending_exception_); | 714 isolate_->set_pending_exception(*pending_exception_); |
722 } | 715 } |
723 | 716 |
724 private: | 717 private: |
725 Isolate* isolate_; | 718 Isolate* isolate_; |
726 Handle<Object> pending_exception_; | 719 Handle<Object> pending_exception_; |
727 v8::TryCatch* catcher_; | |
728 }; | 720 }; |
729 | 721 |
730 void SetCaptureStackTraceForUncaughtExceptions( | 722 void SetCaptureStackTraceForUncaughtExceptions( |
731 bool capture, | 723 bool capture, |
732 int frame_limit, | 724 int frame_limit, |
733 StackTrace::StackTraceOptions options); | 725 StackTrace::StackTraceOptions options); |
734 | 726 |
735 void PrintCurrentStackTrace(FILE* out); | 727 void PrintCurrentStackTrace(FILE* out); |
736 void PrintStack(StringStream* accumulator); | 728 void PrintStack(StringStream* accumulator); |
737 void PrintStack(FILE* out); | 729 void PrintStack(FILE* out); |
(...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1585 } | 1577 } |
1586 | 1578 |
1587 EmbeddedVector<char, 128> filename_; | 1579 EmbeddedVector<char, 128> filename_; |
1588 FILE* file_; | 1580 FILE* file_; |
1589 int scope_depth_; | 1581 int scope_depth_; |
1590 }; | 1582 }; |
1591 | 1583 |
1592 } } // namespace v8::internal | 1584 } } // namespace v8::internal |
1593 | 1585 |
1594 #endif // V8_ISOLATE_H_ | 1586 #endif // V8_ISOLATE_H_ |
OLD | NEW |