1 /*
2 * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
60 // Keep a private copy of the caller_jvms:
61 _caller_jvms = new (C) JVMState(caller_jvms->method(), caller_tree->caller_jvms());
62 _caller_jvms->set_bci(caller_jvms->bci());
63 assert(!caller_jvms->should_reexecute(), "there should be no reexecute bytecode with inlining");
64 }
65 assert(_caller_jvms->same_calls_as(caller_jvms), "consistent JVMS");
66 assert((caller_tree == NULL ? 0 : caller_tree->stack_depth() + 1) == stack_depth(), "correct (redundant) depth parameter");
67 assert(caller_bci == this->caller_bci(), "correct (redundant) bci parameter");
68 // Update hierarchical counts, count_inline_bcs() and count_inlines()
69 InlineTree *caller = (InlineTree *)caller_tree;
70 for( ; caller != NULL; caller = ((InlineTree *)(caller->caller_tree())) ) {
71 caller->_count_inline_bcs += count_inline_bcs();
72 NOT_PRODUCT(caller->_count_inlines++;)
73 }
74 }
75
76 /**
77 * Return true when EA is ON and a java constructor is called or
78 * a super constructor is called from an inlined java constructor.
79 * Also return true for boxing methods.
80 */
81 static bool is_init_with_ea(ciMethod* callee_method,
82 ciMethod* caller_method, Compile* C) {
83 if (!C->do_escape_analysis() || !EliminateAllocations) {
84 return false; // EA is off
85 }
86 if (callee_method->is_initializer()) {
87 return true; // constuctor
88 }
89 if (caller_method->is_initializer() &&
90 caller_method != C->method() &&
91 caller_method->holder()->is_subclass_of(callee_method->holder())) {
92 return true; // super constructor is called from inlined constructor
93 }
94 if (C->eliminate_boxing() && callee_method->is_boxing_method()) {
95 return true;
96 }
97 return false;
98 }
99
100 /**
101 * Force inlining unboxing accessor.
102 */
103 static bool is_unboxing_method(ciMethod* callee_method, Compile* C) {
104 return C->eliminate_boxing() && callee_method->is_unboxing_method();
105 }
106
107 // positive filter: should callee be inlined?
108 bool InlineTree::should_inline(ciMethod* callee_method, ciMethod* caller_method,
109 int caller_bci, ciCallProfile& profile,
110 WarmCallInfo* wci_result) {
111 // Allows targeted inlining
112 if (C->directive()->should_inline(callee_method)) {
113 *wci_result = *(WarmCallInfo::always_hot());
114 if (C->print_inlining() && Verbose) {
115 CompileTask::print_inline_indent(inline_level());
|
1 /*
2 * Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
60 // Keep a private copy of the caller_jvms:
61 _caller_jvms = new (C) JVMState(caller_jvms->method(), caller_tree->caller_jvms());
62 _caller_jvms->set_bci(caller_jvms->bci());
63 assert(!caller_jvms->should_reexecute(), "there should be no reexecute bytecode with inlining");
64 }
65 assert(_caller_jvms->same_calls_as(caller_jvms), "consistent JVMS");
66 assert((caller_tree == NULL ? 0 : caller_tree->stack_depth() + 1) == stack_depth(), "correct (redundant) depth parameter");
67 assert(caller_bci == this->caller_bci(), "correct (redundant) bci parameter");
68 // Update hierarchical counts, count_inline_bcs() and count_inlines()
69 InlineTree *caller = (InlineTree *)caller_tree;
70 for( ; caller != NULL; caller = ((InlineTree *)(caller->caller_tree())) ) {
71 caller->_count_inline_bcs += count_inline_bcs();
72 NOT_PRODUCT(caller->_count_inlines++;)
73 }
74 }
75
76 /**
77 * Return true when EA is ON and a java constructor is called or
78 * a super constructor is called from an inlined java constructor.
79 * Also return true for boxing methods.
80 * Also return true for Iterable::iterator() invocation that is essential for forall-loops performance.
81 */
82 static bool is_init_with_ea(ciMethod* callee_method,
83 ciMethod* caller_method, Compile* C) {
84 if (!C->do_escape_analysis() || !EliminateAllocations) {
85 return false; // EA is off
86 }
87 if (callee_method->is_initializer()) {
88 return true; // constuctor
89 }
90 if (caller_method->is_initializer() &&
91 caller_method != C->method() &&
92 caller_method->holder()->is_subclass_of(callee_method->holder())) {
93 return true; // super constructor is called from inlined constructor
94 }
95 if (C->eliminate_boxing() && callee_method->is_boxing_method()) {
96 return true;
97 }
98 if (callee_method->name() == ciSymbol::iterator_name()) {
99 if (callee_method->signature()->return_type()->is_subtype_of(C->env()->Iterator_klass())) {
100 return true;
101 }
102 }
103 return false;
104 }
105
106 /**
107 * Force inlining unboxing accessor.
108 */
109 static bool is_unboxing_method(ciMethod* callee_method, Compile* C) {
110 return C->eliminate_boxing() && callee_method->is_unboxing_method();
111 }
112
113 // positive filter: should callee be inlined?
114 bool InlineTree::should_inline(ciMethod* callee_method, ciMethod* caller_method,
115 int caller_bci, ciCallProfile& profile,
116 WarmCallInfo* wci_result) {
117 // Allows targeted inlining
118 if (C->directive()->should_inline(callee_method)) {
119 *wci_result = *(WarmCallInfo::always_hot());
120 if (C->print_inlining() && Verbose) {
121 CompileTask::print_inline_indent(inline_level());
|