33 #include "opto/graphKit.hpp" 34 #include "opto/subnode.hpp" 35 36 class BytecodeParseHistogram; 37 class InlineTree; 38 class Parse; 39 class SwitchRange; 40 41 42 //------------------------------InlineTree------------------------------------- 43 class InlineTree : public ResourceObj { 44 Compile* C; // cache 45 JVMState* _caller_jvms; // state of caller 46 ciMethod* _method; // method being called by the caller_jvms 47 InlineTree* _caller_tree; 48 uint _count_inline_bcs; // Accumulated count of inlined bytecodes 49 // Call-site count / interpreter invocation count, scaled recursively. 50 // Always between 0.0 and 1.0. Represents the percentage of the method's 51 // total execution time used at this call site. 52 const float _site_invoke_ratio; 53 const int _site_depth_adjust; 54 float compute_callee_frequency( int caller_bci ) const; 55 56 GrowableArray<InlineTree*> _subtrees; 57 friend class Compile; 58 59 protected: 60 InlineTree(Compile* C, 61 const InlineTree* caller_tree, 62 ciMethod* callee_method, 63 JVMState* caller_jvms, 64 int caller_bci, 65 float site_invoke_ratio, 66 int site_depth_adjust); 67 InlineTree *build_inline_tree_for_callee(ciMethod* callee_method, 68 JVMState* caller_jvms, 69 int caller_bci); 70 const char* try_to_inline(ciMethod* callee_method, ciMethod* caller_method, int caller_bci, ciCallProfile& profile, WarmCallInfo* wci_result); 71 const char* should_inline(ciMethod* callee_method, ciMethod* caller_method, int caller_bci, ciCallProfile& profile, WarmCallInfo* wci_result) const; 72 const char* should_not_inline(ciMethod* callee_method, ciMethod* caller_method, WarmCallInfo* wci_result) const; 73 void print_inlining(ciMethod *callee_method, int caller_bci, const char *failure_msg) const; 74 75 InlineTree *caller_tree() const { return _caller_tree; } 76 InlineTree* callee_at(int bci, ciMethod* m) const; 77 int inline_depth() const { return stack_depth() + _site_depth_adjust; } 78 int stack_depth() const { return _caller_jvms ? _caller_jvms->depth() : 0; } 79 80 public: 81 static InlineTree* build_inline_tree_root(); 82 static InlineTree* find_subtree_from_root(InlineTree* root, JVMState* jvms, ciMethod* callee, bool create_if_not_found = false); 83 84 // For temporary (stack-allocated, stateless) ilts: 85 InlineTree(Compile* c, ciMethod* callee_method, JVMState* caller_jvms, float site_invoke_ratio, int site_depth_adjust); 86 87 // InlineTree enum 88 enum InlineStyle { 89 Inline_do_not_inline = 0, // 90 Inline_cha_is_monomorphic = 1, // 91 Inline_type_profile_monomorphic = 2 // 92 }; 93 94 // See if it is OK to inline. 95 // The receiver is the inline tree for the caller. 96 // 97 // The result is a temperature indication. If it is hot or cold, 98 // inlining is immediate or undesirable. Otherwise, the info block 99 // returned is newly allocated and may be enqueued. 100 // 101 // If the method is inlinable, a new inline subtree is created on the fly, 102 // and may be accessed by find_subtree_from_root. 103 // The call_method is the dest_method for a special or static invocation. 104 // The call_method is an optimized virtual method candidate otherwise. 105 WarmCallInfo* ok_to_inline(ciMethod *call_method, JVMState* caller_jvms, ciCallProfile& profile, WarmCallInfo* wci); | 33 #include "opto/graphKit.hpp" 34 #include "opto/subnode.hpp" 35 36 class BytecodeParseHistogram; 37 class InlineTree; 38 class Parse; 39 class SwitchRange; 40 41 42 //------------------------------InlineTree------------------------------------- 43 class InlineTree : public ResourceObj { 44 Compile* C; // cache 45 JVMState* _caller_jvms; // state of caller 46 ciMethod* _method; // method being called by the caller_jvms 47 InlineTree* _caller_tree; 48 uint _count_inline_bcs; // Accumulated count of inlined bytecodes 49 // Call-site count / interpreter invocation count, scaled recursively. 50 // Always between 0.0 and 1.0. Represents the percentage of the method's 51 // total execution time used at this call site. 52 const float _site_invoke_ratio; 53 const int _max_inline_level; // the maximum inline level for this sub-tree (may be adjusted) 54 float compute_callee_frequency( int caller_bci ) const; 55 56 GrowableArray<InlineTree*> _subtrees; 57 friend class Compile; 58 59 protected: 60 InlineTree(Compile* C, 61 const InlineTree* caller_tree, 62 ciMethod* callee_method, 63 JVMState* caller_jvms, 64 int caller_bci, 65 float site_invoke_ratio, 66 int max_inline_level); 67 InlineTree *build_inline_tree_for_callee(ciMethod* callee_method, 68 JVMState* caller_jvms, 69 int caller_bci); 70 const char* try_to_inline(ciMethod* callee_method, ciMethod* caller_method, int caller_bci, ciCallProfile& profile, WarmCallInfo* wci_result); 71 const char* should_inline(ciMethod* callee_method, ciMethod* caller_method, int caller_bci, ciCallProfile& profile, WarmCallInfo* wci_result) const; 72 const char* should_not_inline(ciMethod* callee_method, ciMethod* caller_method, WarmCallInfo* wci_result) const; 73 void print_inlining(ciMethod *callee_method, int caller_bci, const char *failure_msg) const; 74 75 InlineTree *caller_tree() const { return _caller_tree; } 76 InlineTree* callee_at(int bci, ciMethod* m) const; 77 int inline_level() const { return stack_depth(); } 78 int stack_depth() const { return _caller_jvms ? _caller_jvms->depth() : 0; } 79 80 public: 81 static InlineTree* build_inline_tree_root(); 82 static InlineTree* find_subtree_from_root(InlineTree* root, JVMState* jvms, ciMethod* callee, bool create_if_not_found = false); 83 84 // For temporary (stack-allocated, stateless) ilts: 85 InlineTree(Compile* c, ciMethod* callee_method, JVMState* caller_jvms, float site_invoke_ratio, int max_inline_level); 86 87 // InlineTree enum 88 enum InlineStyle { 89 Inline_do_not_inline = 0, // 90 Inline_cha_is_monomorphic = 1, // 91 Inline_type_profile_monomorphic = 2 // 92 }; 93 94 // See if it is OK to inline. 95 // The receiver is the inline tree for the caller. 96 // 97 // The result is a temperature indication. If it is hot or cold, 98 // inlining is immediate or undesirable. Otherwise, the info block 99 // returned is newly allocated and may be enqueued. 100 // 101 // If the method is inlinable, a new inline subtree is created on the fly, 102 // and may be accessed by find_subtree_from_root. 103 // The call_method is the dest_method for a special or static invocation. 104 // The call_method is an optimized virtual method candidate otherwise. 105 WarmCallInfo* ok_to_inline(ciMethod *call_method, JVMState* caller_jvms, ciCallProfile& profile, WarmCallInfo* wci); |