1 /*
2 * Copyright (c) 2005, 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 *
1076 }
1077 if (_memproj_catchall != NULL) {
1078 _igvn.replace_node(_memproj_catchall, C->top());
1079 }
1080 if (_ioproj_fallthrough != NULL) {
1081 _igvn.replace_node(_ioproj_fallthrough, alloc->in(TypeFunc::I_O));
1082 }
1083 if (_ioproj_catchall != NULL) {
1084 _igvn.replace_node(_ioproj_catchall, C->top());
1085 }
1086 if (_catchallcatchproj != NULL) {
1087 _igvn.replace_node(_catchallcatchproj, C->top());
1088 }
1089 }
1090
1091 bool PhaseMacroExpand::eliminate_allocate_node(AllocateNode *alloc) {
1092 // Don't do scalar replacement if the frame can be popped by JVMTI:
1093 // if reallocation fails during deoptimization we'll pop all
1094 // interpreter frames for this compiled frame and that won't play
1095 // nice with JVMTI popframe.
1096 if (!EliminateAllocations || JvmtiExport::can_pop_frame() || !alloc->_is_non_escaping) {
1097 return false;
1098 }
1099 Node* klass = alloc->in(AllocateNode::KlassNode);
1100 const TypeKlassPtr* tklass = _igvn.type(klass)->is_klassptr();
1101 Node* res = alloc->result_cast();
1102 // Eliminate boxing allocations which are not used
1103 // regardless scalar replacable status.
1104 bool boxing_alloc = C->eliminate_boxing() &&
1105 tklass->klass()->is_instance_klass() &&
1106 tklass->klass()->as_instance_klass()->is_box_klass();
1107 if (!alloc->_is_scalar_replaceable && (!boxing_alloc || (res != NULL))) {
1108 return false;
1109 }
1110
1111 extract_call_projections(alloc);
1112
1113 GrowableArray <SafePointNode *> safepoints;
1114 if (!can_eliminate_allocation(alloc, safepoints)) {
1115 return false;
1116 }
|
1 /*
2 * Copyright (c) 2005, 2020, 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 *
1076 }
1077 if (_memproj_catchall != NULL) {
1078 _igvn.replace_node(_memproj_catchall, C->top());
1079 }
1080 if (_ioproj_fallthrough != NULL) {
1081 _igvn.replace_node(_ioproj_fallthrough, alloc->in(TypeFunc::I_O));
1082 }
1083 if (_ioproj_catchall != NULL) {
1084 _igvn.replace_node(_ioproj_catchall, C->top());
1085 }
1086 if (_catchallcatchproj != NULL) {
1087 _igvn.replace_node(_catchallcatchproj, C->top());
1088 }
1089 }
1090
1091 bool PhaseMacroExpand::eliminate_allocate_node(AllocateNode *alloc) {
1092 // Don't do scalar replacement if the frame can be popped by JVMTI:
1093 // if reallocation fails during deoptimization we'll pop all
1094 // interpreter frames for this compiled frame and that won't play
1095 // nice with JVMTI popframe.
1096 if (!EliminateAllocations || !alloc->_is_non_escaping) {
1097 return false;
1098 }
1099 Node* klass = alloc->in(AllocateNode::KlassNode);
1100 const TypeKlassPtr* tklass = _igvn.type(klass)->is_klassptr();
1101 Node* res = alloc->result_cast();
1102 // Eliminate boxing allocations which are not used
1103 // regardless scalar replacable status.
1104 bool boxing_alloc = C->eliminate_boxing() &&
1105 tklass->klass()->is_instance_klass() &&
1106 tklass->klass()->as_instance_klass()->is_box_klass();
1107 if (!alloc->_is_scalar_replaceable && (!boxing_alloc || (res != NULL))) {
1108 return false;
1109 }
1110
1111 extract_call_projections(alloc);
1112
1113 GrowableArray <SafePointNode *> safepoints;
1114 if (!can_eliminate_allocation(alloc, safepoints)) {
1115 return false;
1116 }
|