3810 } else { 3811 // The coast is clear. 3812 return false; 3813 } 3814 } 3815 3816 // Compute when not to trap. Used by matching trap based nodes and 3817 // NullCheck optimization. 3818 void Compile::set_allowed_deopt_reasons() { 3819 _allowed_reasons = 0; 3820 if (is_method_compilation()) { 3821 for (int rs = (int)Deoptimization::Reason_none+1; rs < Compile::trapHistLength; rs++) { 3822 assert(rs < BitsPerInt, "recode bit map"); 3823 if (!too_many_traps((Deoptimization::DeoptReason) rs)) { 3824 _allowed_reasons |= nth_bit(rs); 3825 } 3826 } 3827 } 3828 } 3829 3830 bool Compile::is_compiling_clinit_for(ciKlass* k) { 3831 ciMethod* root = method(); // the root method of compilation 3832 return root->is_static_initializer() && root->holder() == k; // access in the context of clinit 3833 } 3834 3835 #ifndef PRODUCT 3836 //------------------------------verify_graph_edges--------------------------- 3837 // Walk the Graph and verify that there is a one-to-one correspondence 3838 // between Use-Def edges and Def-Use edges in the graph. 3839 void Compile::verify_graph_edges(bool no_dead_code) { 3840 if (VerifyGraphEdges) { 3841 ResourceArea *area = Thread::current()->resource_area(); 3842 Unique_Node_List visited(area); 3843 // Call recursive graph walk to check edges 3844 _root->verify_edges(visited); 3845 if (no_dead_code) { 3846 // Now make sure that no visited node is used by an unvisited node. 3847 bool dead_nodes = false; 3848 Unique_Node_List checked(area); 3849 while (visited.size() > 0) { 3850 Node* n = visited.pop(); 3851 checked.push(n); 3852 for (uint i = 0; i < n->outcnt(); i++) { | 3810 } else { 3811 // The coast is clear. 3812 return false; 3813 } 3814 } 3815 3816 // Compute when not to trap. Used by matching trap based nodes and 3817 // NullCheck optimization. 3818 void Compile::set_allowed_deopt_reasons() { 3819 _allowed_reasons = 0; 3820 if (is_method_compilation()) { 3821 for (int rs = (int)Deoptimization::Reason_none+1; rs < Compile::trapHistLength; rs++) { 3822 assert(rs < BitsPerInt, "recode bit map"); 3823 if (!too_many_traps((Deoptimization::DeoptReason) rs)) { 3824 _allowed_reasons |= nth_bit(rs); 3825 } 3826 } 3827 } 3828 } 3829 3830 bool Compile::needs_clinit_barrier(ciMethod* method, ciMethod* accessing_method) { 3831 return method->is_static() && needs_clinit_barrier(method->holder(), accessing_method); 3832 } 3833 3834 bool Compile::needs_clinit_barrier(ciField* field, ciMethod* accessing_method) { 3835 return field->is_static() && needs_clinit_barrier(field->holder(), accessing_method); 3836 } 3837 3838 bool Compile::needs_clinit_barrier(ciInstanceKlass* holder, ciMethod* accessing_method) { 3839 if (holder->is_initialized()) { 3840 return false; 3841 } 3842 if (holder->is_being_initialized()) { 3843 if (accessing_method->holder() == holder) { 3844 // Access inside a class. The barrier can be elided when access happens in <clinit>, 3845 // <init>, or a static method. In all those cases, there was an initialization 3846 // barrier on the holder klass passed. 3847 if (accessing_method->is_static_initializer() || 3848 accessing_method->is_object_initializer() || 3849 accessing_method->is_static()) { 3850 return false; 3851 } 3852 } else if (accessing_method->holder()->is_subclass_of(holder)) { 3853 // Access from a subclass. The barrier can be elided only when access happens in <clinit>. 3854 // In case of <init> or a static method, the barrier is on the subclass is not enough: 3855 // child class can become fully initialized while its parent class is still being initialized. 3856 if (accessing_method->is_static_initializer()) { 3857 return false; 3858 } 3859 } 3860 ciMethod* root = method(); // the root method of compilation 3861 if (root != accessing_method) { 3862 return needs_clinit_barrier(holder, root); // check access in the context of compilation root 3863 } 3864 } 3865 return true; 3866 } 3867 3868 #ifndef PRODUCT 3869 //------------------------------verify_graph_edges--------------------------- 3870 // Walk the Graph and verify that there is a one-to-one correspondence 3871 // between Use-Def edges and Def-Use edges in the graph. 3872 void Compile::verify_graph_edges(bool no_dead_code) { 3873 if (VerifyGraphEdges) { 3874 ResourceArea *area = Thread::current()->resource_area(); 3875 Unique_Node_List visited(area); 3876 // Call recursive graph walk to check edges 3877 _root->verify_edges(visited); 3878 if (no_dead_code) { 3879 // Now make sure that no visited node is used by an unvisited node. 3880 bool dead_nodes = false; 3881 Unique_Node_List checked(area); 3882 while (visited.size() > 0) { 3883 Node* n = visited.pop(); 3884 checked.push(n); 3885 for (uint i = 0; i < n->outcnt(); i++) { |