670 // "claim_token", if it is not already. Returns "true" iff the 671 // calling thread does the update, this indicates that the calling thread 672 // has claimed the thread in the current iteration. 673 bool claim_threads_do(bool is_par, uintx claim_token) { 674 if (!is_par) { 675 _threads_do_token = claim_token; 676 return true; 677 } else { 678 return claim_par_threads_do(claim_token); 679 } 680 } 681 682 uintx threads_do_token() const { return _threads_do_token; } 683 684 // jvmtiRedefineClasses support 685 void metadata_handles_do(void f(Metadata*)); 686 687 // Used by fast lock support 688 virtual bool is_lock_owned(address adr) const; 689 690 // Check if address is in the stack of the thread (not just for locks). 691 // Warning: the method can only be used on the running thread 692 bool is_in_stack(address adr) const; 693 // Check if address is in the usable part of the stack (excludes protected 694 // guard pages) 695 bool is_in_usable_stack(address adr) const; 696 697 // Sets this thread as starting thread. Returns failure if thread 698 // creation fails due to lack of memory, too many threads etc. 699 bool set_as_starting_thread(); 700 701 protected: 702 // OS data associated with the thread 703 OSThread* _osthread; // Platform-specific thread information 704 705 // Thread local resource area for temporary allocation within the VM 706 ResourceArea* _resource_area; 707 708 DEBUG_ONLY(ResourceMark* _current_resource_mark;) 709 710 // Thread local handle area for allocation of handles within the VM 711 HandleArea* _handle_area; 712 GrowableArray<Metadata*>* _metadata_handles; 713 714 // Support for stack overflow handling, get_thread, etc. 715 address _stack_base; 716 size_t _stack_size; 717 int _lgrp_id; 718 719 volatile void** polling_page_addr() { return &_polling_page; } 720 721 public: 722 // Stack overflow support 723 address stack_base() const { assert(_stack_base != NULL,"Sanity check"); return _stack_base; } 724 void set_stack_base(address base) { _stack_base = base; } 725 size_t stack_size() const { return _stack_size; } 726 void set_stack_size(size_t size) { _stack_size = size; } 727 address stack_end() const { return stack_base() - stack_size(); } 728 void record_stack_base_and_size(); 729 void register_thread_stack_with_NMT() NOT_NMT_RETURN; 730 731 bool on_local_stack(address adr) const { 732 // QQQ this has knowledge of direction, ought to be a stack method 733 return (_stack_base > adr && adr >= stack_end()); 734 } 735 736 int lgrp_id() const { return _lgrp_id; } 737 void set_lgrp_id(int value) { _lgrp_id = value; } 738 739 // Printing 740 void print_on(outputStream* st, bool print_extended_info) const; 741 virtual void print_on(outputStream* st) const { print_on(st, false); } 742 void print() const; 743 virtual void print_on_error(outputStream* st, char* buf, int buflen) const; 744 void print_value_on(outputStream* st) const; 745 746 // Debug-only code 747 #ifdef ASSERT 748 private: 749 // Deadlock detection support for Mutex locks. List of locks own by thread. 750 Mutex* _owned_locks; 751 // Mutex::set_owner_implementation is the only place where _owned_locks is modified, 752 // thus the friendship 753 friend class Mutex; 754 friend class Monitor; | 670 // "claim_token", if it is not already. Returns "true" iff the 671 // calling thread does the update, this indicates that the calling thread 672 // has claimed the thread in the current iteration. 673 bool claim_threads_do(bool is_par, uintx claim_token) { 674 if (!is_par) { 675 _threads_do_token = claim_token; 676 return true; 677 } else { 678 return claim_par_threads_do(claim_token); 679 } 680 } 681 682 uintx threads_do_token() const { return _threads_do_token; } 683 684 // jvmtiRedefineClasses support 685 void metadata_handles_do(void f(Metadata*)); 686 687 // Used by fast lock support 688 virtual bool is_lock_owned(address adr) const; 689 690 // Check if address is in the live stack of the thread (not just for locks). 691 // Warning: the method can only be used on the running thread. 692 bool is_in_stack(address adr) const; 693 694 // Check if address is in the usable part of the stack (excludes protected 695 // guard pages). Can be applied to any thread and is an approximation for 696 // using is_in_stack when the query has to happen from another thread. 697 bool is_in_usable_stack(address adr) const; 698 699 // Check if address in the stack mapped to this thread. Used mainly in 700 // error reporting (so has to include guard zone) and frame printing. 701 bool on_local_stack(address adr) const { 702 return (_stack_base > adr && adr >= stack_end()); 703 } 704 705 // Sets this thread as starting thread. Returns failure if thread 706 // creation fails due to lack of memory, too many threads etc. 707 bool set_as_starting_thread(); 708 709 protected: 710 // OS data associated with the thread 711 OSThread* _osthread; // Platform-specific thread information 712 713 // Thread local resource area for temporary allocation within the VM 714 ResourceArea* _resource_area; 715 716 DEBUG_ONLY(ResourceMark* _current_resource_mark;) 717 718 // Thread local handle area for allocation of handles within the VM 719 HandleArea* _handle_area; 720 GrowableArray<Metadata*>* _metadata_handles; 721 722 // Support for stack overflow handling, get_thread, etc. 723 address _stack_base; 724 size_t _stack_size; 725 int _lgrp_id; 726 727 volatile void** polling_page_addr() { return &_polling_page; } 728 729 public: 730 // Stack overflow support 731 address stack_base() const { assert(_stack_base != NULL,"Sanity check"); return _stack_base; } 732 void set_stack_base(address base) { _stack_base = base; } 733 size_t stack_size() const { return _stack_size; } 734 void set_stack_size(size_t size) { _stack_size = size; } 735 address stack_end() const { return stack_base() - stack_size(); } 736 void record_stack_base_and_size(); 737 void register_thread_stack_with_NMT() NOT_NMT_RETURN; 738 739 int lgrp_id() const { return _lgrp_id; } 740 void set_lgrp_id(int value) { _lgrp_id = value; } 741 742 // Printing 743 void print_on(outputStream* st, bool print_extended_info) const; 744 virtual void print_on(outputStream* st) const { print_on(st, false); } 745 void print() const; 746 virtual void print_on_error(outputStream* st, char* buf, int buflen) const; 747 void print_value_on(outputStream* st) const; 748 749 // Debug-only code 750 #ifdef ASSERT 751 private: 752 // Deadlock detection support for Mutex locks. List of locks own by thread. 753 Mutex* _owned_locks; 754 // Mutex::set_owner_implementation is the only place where _owned_locks is modified, 755 // thus the friendship 756 friend class Mutex; 757 friend class Monitor; |