| 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 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 int pending_message_start_pos_; | 251 int pending_message_start_pos_; |
| 252 int pending_message_end_pos_; | 252 int pending_message_end_pos_; |
| 253 // Use a separate value for scheduled exceptions to preserve the | 253 // Use a separate value for scheduled exceptions to preserve the |
| 254 // invariants that hold about pending_exception. We may want to | 254 // invariants that hold about pending_exception. We may want to |
| 255 // unify them later. | 255 // unify them later. |
| 256 MaybeObject* scheduled_exception_; | 256 MaybeObject* scheduled_exception_; |
| 257 bool external_caught_exception_; | 257 bool external_caught_exception_; |
| 258 SaveContext* save_context_; | 258 SaveContext* save_context_; |
| 259 v8::TryCatch* catcher_; | 259 v8::TryCatch* catcher_; |
| 260 | 260 |
| 261 // Fields for handling try-catch statements in optimized code. |
| 262 byte* optimized_handler_patch_buffer_; |
| 263 MaybeObject* optimized_pending_exception_; |
| 264 int optimized_handler_handler_index_; |
| 265 int optimized_handler_deopt_index_; |
| 266 int optimized_handler_frame_pc_offset_; |
| 267 |
| 261 // Stack. | 268 // Stack. |
| 262 Address c_entry_fp_; // the frame pointer of the top c entry frame | 269 Address c_entry_fp_; // the frame pointer of the top c entry frame |
| 263 Address handler_; // try-blocks are chained through the stack | 270 Address handler_; // try-blocks are chained through the stack |
| 264 | 271 |
| 265 #ifdef USE_SIMULATOR | 272 #ifdef USE_SIMULATOR |
| 266 #if defined(V8_TARGET_ARCH_ARM) || defined(V8_TARGET_ARCH_MIPS) | 273 #if defined(V8_TARGET_ARCH_ARM) || defined(V8_TARGET_ARCH_MIPS) |
| 267 Simulator* simulator_; | 274 Simulator* simulator_; |
| 268 #endif | 275 #endif |
| 269 #endif // USE_SIMULATOR | 276 #endif // USE_SIMULATOR |
| 270 | 277 |
| 271 Address js_entry_sp_; // the stack pointer of the bottom JS entry frame | 278 Address js_entry_sp_; // the stack pointer of the bottom JS entry frame |
| 272 Address external_callback_; // the external callback we're currently in | 279 Address external_callback_; // the external callback we're currently in |
| 273 StateTag current_vm_state_; | 280 StateTag current_vm_state_; |
| 274 | 281 |
| 275 // Generated code scratch locations. | 282 // Generated code scratch locations. |
| 276 int32_t formal_count_; | 283 int32_t formal_count_; |
| 277 | 284 |
| 278 // Call back function to report unsafe JS accesses. | 285 // Call back function to report unsafe JS accesses. |
| 279 v8::FailedAccessCheckCallback failed_access_check_callback_; | 286 v8::FailedAccessCheckCallback failed_access_check_callback_; |
| 280 | 287 |
| 281 // Head of the list of live LookupResults. | 288 // Head of the list of live LookupResults. |
| 282 LookupResult* top_lookup_result_; | 289 LookupResult* top_lookup_result_; |
| 283 | 290 |
| 284 // Whether out of memory exceptions should be ignored. | 291 // Whether out of memory exceptions should be ignored. |
| 285 bool ignore_out_of_memory_; | 292 bool ignore_out_of_memory_; |
| 286 | 293 |
| 294 int thread_id() { return thread_id_.ToInteger(); } |
| 295 |
| 287 private: | 296 private: |
| 288 void InitializeInternal(); | 297 void InitializeInternal(); |
| 289 | 298 |
| 290 Address try_catch_handler_address_; | 299 Address try_catch_handler_address_; |
| 291 }; | 300 }; |
| 292 | 301 |
| 293 | 302 |
| 294 class SystemThreadManager { | 303 class SystemThreadManager { |
| 295 public: | 304 public: |
| 296 enum ParallelSystemComponent { | 305 enum ParallelSystemComponent { |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 Address get_address_from_id(AddressId id); | 551 Address get_address_from_id(AddressId id); |
| 543 | 552 |
| 544 // Access to top context (where the current function object was created). | 553 // Access to top context (where the current function object was created). |
| 545 Context* context() { return thread_local_top_.context_; } | 554 Context* context() { return thread_local_top_.context_; } |
| 546 void set_context(Context* context) { | 555 void set_context(Context* context) { |
| 547 ASSERT(context == NULL || context->IsContext()); | 556 ASSERT(context == NULL || context->IsContext()); |
| 548 thread_local_top_.context_ = context; | 557 thread_local_top_.context_ = context; |
| 549 } | 558 } |
| 550 Context** context_address() { return &thread_local_top_.context_; } | 559 Context** context_address() { return &thread_local_top_.context_; } |
| 551 | 560 |
| 552 SaveContext* save_context() {return thread_local_top_.save_context_; } | 561 SaveContext* save_context() { return thread_local_top_.save_context_; } |
| 553 void set_save_context(SaveContext* save) { | 562 void set_save_context(SaveContext* save) { |
| 554 thread_local_top_.save_context_ = save; | 563 thread_local_top_.save_context_ = save; |
| 555 } | 564 } |
| 556 | 565 |
| 557 // Access to current thread id. | 566 // Access to current thread id. |
| 558 ThreadId thread_id() { return thread_local_top_.thread_id_; } | 567 ThreadId thread_id() { return thread_local_top_.thread_id_; } |
| 559 void set_thread_id(ThreadId id) { thread_local_top_.thread_id_ = id; } | 568 void set_thread_id(ThreadId id) { thread_local_top_.thread_id_ = id; } |
| 560 | 569 |
| 561 // Interface to pending exception. | 570 // Interface to pending exception. |
| 562 MaybeObject* pending_exception() { | 571 MaybeObject* pending_exception() { |
| 563 ASSERT(has_pending_exception()); | 572 ASSERT(has_pending_exception()); |
| 564 return thread_local_top_.pending_exception_; | 573 return thread_local_top_.pending_exception_; |
| 565 } | 574 } |
| 566 bool external_caught_exception() { | 575 bool external_caught_exception() { |
| 567 return thread_local_top_.external_caught_exception_; | 576 return thread_local_top_.external_caught_exception_; |
| 568 } | 577 } |
| 569 void set_external_caught_exception(bool value) { | 578 void set_external_caught_exception(bool value) { |
| 570 thread_local_top_.external_caught_exception_ = value; | 579 thread_local_top_.external_caught_exception_ = value; |
| 571 } | 580 } |
| 572 void set_pending_exception(MaybeObject* exception) { | 581 void set_pending_exception(MaybeObject* exception) { |
| 573 thread_local_top_.pending_exception_ = exception; | 582 thread_local_top_.pending_exception_ = exception; |
| 574 } | 583 } |
| 575 void clear_pending_exception() { | 584 void clear_pending_exception() { |
| 576 thread_local_top_.pending_exception_ = heap_.the_hole_value(); | 585 thread_local_top_.pending_exception_ = heap_.the_hole_value(); |
| 586 |
| 587 if (is_handling_optimized_catch_statement()) { |
| 588 ClearOptimizedHandlerByAPI(); |
| 589 } |
| 577 } | 590 } |
| 578 MaybeObject** pending_exception_address() { | 591 MaybeObject** pending_exception_address() { |
| 579 return &thread_local_top_.pending_exception_; | 592 return &thread_local_top_.pending_exception_; |
| 580 } | 593 } |
| 581 bool has_pending_exception() { | 594 bool has_pending_exception() { |
| 582 return !thread_local_top_.pending_exception_->IsTheHole(); | 595 return !thread_local_top_.pending_exception_->IsTheHole(); |
| 583 } | 596 } |
| 584 void clear_pending_message() { | 597 void clear_pending_message() { |
| 585 thread_local_top_.has_pending_message_ = false; | 598 thread_local_top_.has_pending_message_ = false; |
| 586 thread_local_top_.pending_message_obj_ = heap_.the_hole_value(); | 599 thread_local_top_.pending_message_obj_ = heap_.the_hole_value(); |
| 587 thread_local_top_.pending_message_script_ = NULL; | 600 thread_local_top_.pending_message_script_ = NULL; |
| 588 } | 601 } |
| 589 v8::TryCatch* try_catch_handler() { | 602 v8::TryCatch* try_catch_handler() { |
| 590 return thread_local_top_.TryCatchHandler(); | 603 return thread_local_top_.TryCatchHandler(); |
| 591 } | 604 } |
| 592 Address try_catch_handler_address() { | 605 Address try_catch_handler_address() { |
| 593 return thread_local_top_.try_catch_handler_address(); | 606 return thread_local_top_.try_catch_handler_address(); |
| 594 } | 607 } |
| 595 bool* external_caught_exception_address() { | 608 bool* external_caught_exception_address() { |
| 596 return &thread_local_top_.external_caught_exception_; | 609 return &thread_local_top_.external_caught_exception_; |
| 597 } | 610 } |
| 598 v8::TryCatch* catcher() { | 611 v8::TryCatch* catcher() { |
| 599 return thread_local_top_.catcher_; | 612 return thread_local_top_.catcher_; |
| 600 } | 613 } |
| 601 void set_catcher(v8::TryCatch* catcher) { | 614 void set_catcher(v8::TryCatch* catcher) { |
| 602 thread_local_top_.catcher_ = catcher; | 615 thread_local_top_.catcher_ = catcher; |
| 603 } | 616 } |
| 604 | 617 |
| 618 // Interface for supporting try-catch statements in optimized code. |
| 619 bool is_handling_optimized_catch_statement() { |
| 620 return thread_local_top_.optimized_handler_handler_index_ != -1; |
| 621 } |
| 622 byte* optimized_handler_patch_buffer() { |
| 623 return thread_local_top_.optimized_handler_patch_buffer_; |
| 624 } |
| 625 void set_optimized_handler_patch_buffer(Address patch_address, |
| 626 int patch_size) { |
| 627 ASSERT(thread_local_top_.optimized_handler_patch_buffer_ == NULL); |
| 628 thread_local_top_.optimized_handler_patch_buffer_ = new byte[patch_size]; |
| 629 memcpy(thread_local_top_.optimized_handler_patch_buffer_, |
| 630 patch_address, patch_size); |
| 631 } |
| 632 void clear_optimized_handler_patch_buffer() { |
| 633 ASSERT(thread_local_top_.optimized_handler_patch_buffer_ != NULL); |
| 634 delete[] thread_local_top_.optimized_handler_patch_buffer_; |
| 635 thread_local_top_.optimized_handler_patch_buffer_ = NULL; |
| 636 } |
| 637 MaybeObject* optimized_pending_exception() { |
| 638 return thread_local_top_.optimized_pending_exception_; |
| 639 } |
| 640 void set_optimized_pending_exception(MaybeObject* v) { |
| 641 thread_local_top_.optimized_pending_exception_ = v; |
| 642 } |
| 643 void clear_optimized_pending_exception() { |
| 644 thread_local_top_.optimized_pending_exception_ = NULL; |
| 645 } |
| 646 int optimized_handler_handler_index() { |
| 647 return thread_local_top_.optimized_handler_handler_index_; |
| 648 } |
| 649 void set_optimized_handler_handler_index(int v) { |
| 650 ASSERT(thread_local_top_.optimized_handler_handler_index_ == -1); |
| 651 thread_local_top_.optimized_handler_handler_index_ = v; |
| 652 } |
| 653 void clear_optimized_handler_handler_index() { |
| 654 ASSERT(thread_local_top_.optimized_handler_handler_index_ != -1); |
| 655 thread_local_top_.optimized_handler_handler_index_ = -1; |
| 656 } |
| 657 int optimized_handler_deopt_index() { |
| 658 return thread_local_top_.optimized_handler_deopt_index_; |
| 659 } |
| 660 void set_optimized_handler_deopt_index(int v) { |
| 661 ASSERT(thread_local_top_.optimized_handler_deopt_index_ == -1); |
| 662 thread_local_top_.optimized_handler_deopt_index_ = v; |
| 663 } |
| 664 void clear_optimized_handler_deopt_index() { |
| 665 ASSERT(thread_local_top_.optimized_handler_deopt_index_ != -1); |
| 666 thread_local_top_.optimized_handler_deopt_index_ = -1; |
| 667 } |
| 668 int optimized_handler_frame_pc_offset() { |
| 669 return thread_local_top_.optimized_handler_frame_pc_offset_; |
| 670 } |
| 671 void set_optimized_handler_frame_pc_offset(int v) { |
| 672 ASSERT(thread_local_top_.optimized_handler_frame_pc_offset_ == -1); |
| 673 thread_local_top_.optimized_handler_frame_pc_offset_ = v; |
| 674 } |
| 675 void clear_optimized_handler_frame_pc_offset() { |
| 676 ASSERT(thread_local_top_.optimized_handler_frame_pc_offset_ != -1); |
| 677 thread_local_top_.optimized_handler_frame_pc_offset_ = -1; |
| 678 } |
| 679 |
| 680 |
| 605 MaybeObject** scheduled_exception_address() { | 681 MaybeObject** scheduled_exception_address() { |
| 606 return &thread_local_top_.scheduled_exception_; | 682 return &thread_local_top_.scheduled_exception_; |
| 607 } | 683 } |
| 608 | 684 |
| 609 Address pending_message_obj_address() { | 685 Address pending_message_obj_address() { |
| 610 return reinterpret_cast<Address>(&thread_local_top_.pending_message_obj_); | 686 return reinterpret_cast<Address>(&thread_local_top_.pending_message_obj_); |
| 611 } | 687 } |
| 612 | 688 |
| 613 Address has_pending_message_address() { | 689 Address has_pending_message_address() { |
| 614 return reinterpret_cast<Address>(&thread_local_top_.has_pending_message_); | 690 return reinterpret_cast<Address>(&thread_local_top_.has_pending_message_); |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 768 Failure* ThrowIllegalOperation(); | 844 Failure* ThrowIllegalOperation(); |
| 769 | 845 |
| 770 // Promote a scheduled exception to pending. Asserts has_scheduled_exception. | 846 // Promote a scheduled exception to pending. Asserts has_scheduled_exception. |
| 771 Failure* PromoteScheduledException(); | 847 Failure* PromoteScheduledException(); |
| 772 void DoThrow(Object* exception, MessageLocation* location); | 848 void DoThrow(Object* exception, MessageLocation* location); |
| 773 // Checks if exception should be reported and finds out if it's | 849 // Checks if exception should be reported and finds out if it's |
| 774 // caught externally. | 850 // caught externally. |
| 775 bool ShouldReportException(bool* can_be_caught_externally, | 851 bool ShouldReportException(bool* can_be_caught_externally, |
| 776 bool catchable_by_javascript); | 852 bool catchable_by_javascript); |
| 777 | 853 |
| 854 // The temporary optimized handler state is used by the deoptimizer when |
| 855 // catching exceptions in optimized code. |
| 856 void PrepareForOptimizedHandler(); |
| 857 void ClearOptimizedHandlerByDeopt(Code* optimized_code); |
| 858 void ClearOptimizedHandlerByAPI(); |
| 859 |
| 778 // Attempts to compute the current source location, storing the | 860 // Attempts to compute the current source location, storing the |
| 779 // result in the target out parameter. | 861 // result in the target out parameter. |
| 780 void ComputeLocation(MessageLocation* target); | 862 void ComputeLocation(MessageLocation* target); |
| 781 | 863 |
| 782 // Override command line flag. | 864 // Override command line flag. |
| 783 void TraceException(bool flag); | 865 void TraceException(bool flag); |
| 784 | 866 |
| 785 // Out of resource exception helpers. | 867 // Out of resource exception helpers. |
| 786 Failure* StackOverflow(); | 868 Failure* StackOverflow(); |
| 787 Failure* TerminateExecution(); | 869 Failure* TerminateExecution(); |
| (...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1491 | 1573 |
| 1492 // Mark the native context with out of memory. | 1574 // Mark the native context with out of memory. |
| 1493 inline void Context::mark_out_of_memory() { | 1575 inline void Context::mark_out_of_memory() { |
| 1494 native_context()->set_out_of_memory(HEAP->true_value()); | 1576 native_context()->set_out_of_memory(HEAP->true_value()); |
| 1495 } | 1577 } |
| 1496 | 1578 |
| 1497 | 1579 |
| 1498 } } // namespace v8::internal | 1580 } } // namespace v8::internal |
| 1499 | 1581 |
| 1500 #endif // V8_ISOLATE_H_ | 1582 #endif // V8_ISOLATE_H_ |
| OLD | NEW |