1 /*
2 * Copyright (c) 1997, 2016, 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 *
914 self = unvisited;
915 iterate_anti_dep = false;
916 idx = self->outcnt();
917 } // End recursion loop
918
919 return self;
920 }
921
922 //------------------------------ComputeLatenciesBackwards----------------------
923 // Compute the latency of all the instructions.
924 void PhaseCFG::compute_latencies_backwards(VectorSet &visited, Node_Stack &stack) {
925 #ifndef PRODUCT
926 if (trace_opto_pipelining())
927 tty->print("\n#---- ComputeLatenciesBackwards ----\n");
928 #endif
929
930 Node_Backward_Iterator iter((Node *)_root, visited, stack, *this);
931 Node *n;
932
933 // Walk over all the nodes from last to first
934 while (n = iter.next()) {
935 // Set the latency for the definitions of this instruction
936 partial_latency_of_defs(n);
937 }
938 } // end ComputeLatenciesBackwards
939
940 //------------------------------partial_latency_of_defs------------------------
941 // Compute the latency impact of this node on all defs. This computes
942 // a number that increases as we approach the beginning of the routine.
943 void PhaseCFG::partial_latency_of_defs(Node *n) {
944 // Set the latency for this instruction
945 #ifndef PRODUCT
946 if (trace_opto_pipelining()) {
947 tty->print("# latency_to_inputs: node_latency[%d] = %d for node", n->_idx, get_latency_for_node(n));
948 dump();
949 }
950 #endif
951
952 if (n->is_Proj()) {
953 n = n->in(0);
954 }
1189
1190 return least;
1191 }
1192
1193
1194 //------------------------------schedule_late-----------------------------------
1195 // Now schedule all codes as LATE as possible. This is the LCA in the
1196 // dominator tree of all USES of a value. Pick the block with the least
1197 // loop nesting depth that is lowest in the dominator tree.
1198 extern const char must_clone[];
1199 void PhaseCFG::schedule_late(VectorSet &visited, Node_Stack &stack) {
1200 #ifndef PRODUCT
1201 if (trace_opto_pipelining())
1202 tty->print("\n#---- schedule_late ----\n");
1203 #endif
1204
1205 Node_Backward_Iterator iter((Node *)_root, visited, stack, *this);
1206 Node *self;
1207
1208 // Walk over all the nodes from last to first
1209 while (self = iter.next()) {
1210 Block* early = get_block_for_node(self); // Earliest legal placement
1211
1212 if (self->is_top()) {
1213 // Top node goes in bb #2 with other constants.
1214 // It must be special-cased, because it has no out edges.
1215 early->add_inst(self);
1216 continue;
1217 }
1218
1219 // No uses, just terminate
1220 if (self->outcnt() == 0) {
1221 assert(self->is_MachProj(), "sanity");
1222 continue; // Must be a dead machine projection
1223 }
1224
1225 // If node is pinned in the block, then no scheduling can be done.
1226 if( self->pinned() ) // Pinned in block?
1227 continue;
1228
1229 MachNode* mach = self->is_Mach() ? self->as_Mach() : NULL;
1230 if (mach) {
1231 switch (mach->ideal_Opcode()) {
1232 case Op_CreateEx:
1233 // Don't move exception creation
1234 early->add_inst(self);
1235 continue;
1236 break;
1237 case Op_CheckCastPP:
1238 // Don't move CheckCastPP nodes away from their input, if the input
1239 // is a rawptr (5071820).
1240 Node *def = self->in(1);
1241 if (def != NULL && def->bottom_type()->base() == Type::RawPtr) {
1242 early->add_inst(self);
1243 #ifdef ASSERT
1244 _raw_oops.push(def);
1245 #endif
1246 continue;
1247 }
1248 break;
1249 }
1250 }
1251
1252 // Gather LCA of all uses
1253 Block *LCA = NULL;
1254 {
1255 for (DUIterator_Fast imax, i = self->fast_outs(imax); i < imax; i++) {
1256 // For all uses, find LCA
1257 Node* use = self->fast_out(i);
1258 LCA = raise_LCA_above_use(LCA, use, self, this);
1259 }
1260 } // (Hide defs of imax, i from rest of block.)
1261
1262 // Place temps in the block of their use. This isn't a
1263 // requirement for correctness but it reduces useless
1264 // interference between temps and other nodes.
1265 if (mach != NULL && mach->is_MachTemp()) {
1266 map_node_to_block(self, LCA);
1267 LCA->add_inst(self);
1268 continue;
1269 }
|
1 /*
2 * Copyright (c) 1997, 2017, 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 *
914 self = unvisited;
915 iterate_anti_dep = false;
916 idx = self->outcnt();
917 } // End recursion loop
918
919 return self;
920 }
921
922 //------------------------------ComputeLatenciesBackwards----------------------
923 // Compute the latency of all the instructions.
924 void PhaseCFG::compute_latencies_backwards(VectorSet &visited, Node_Stack &stack) {
925 #ifndef PRODUCT
926 if (trace_opto_pipelining())
927 tty->print("\n#---- ComputeLatenciesBackwards ----\n");
928 #endif
929
930 Node_Backward_Iterator iter((Node *)_root, visited, stack, *this);
931 Node *n;
932
933 // Walk over all the nodes from last to first
934 while ((n = iter.next())) {
935 // Set the latency for the definitions of this instruction
936 partial_latency_of_defs(n);
937 }
938 } // end ComputeLatenciesBackwards
939
940 //------------------------------partial_latency_of_defs------------------------
941 // Compute the latency impact of this node on all defs. This computes
942 // a number that increases as we approach the beginning of the routine.
943 void PhaseCFG::partial_latency_of_defs(Node *n) {
944 // Set the latency for this instruction
945 #ifndef PRODUCT
946 if (trace_opto_pipelining()) {
947 tty->print("# latency_to_inputs: node_latency[%d] = %d for node", n->_idx, get_latency_for_node(n));
948 dump();
949 }
950 #endif
951
952 if (n->is_Proj()) {
953 n = n->in(0);
954 }
1189
1190 return least;
1191 }
1192
1193
1194 //------------------------------schedule_late-----------------------------------
1195 // Now schedule all codes as LATE as possible. This is the LCA in the
1196 // dominator tree of all USES of a value. Pick the block with the least
1197 // loop nesting depth that is lowest in the dominator tree.
1198 extern const char must_clone[];
1199 void PhaseCFG::schedule_late(VectorSet &visited, Node_Stack &stack) {
1200 #ifndef PRODUCT
1201 if (trace_opto_pipelining())
1202 tty->print("\n#---- schedule_late ----\n");
1203 #endif
1204
1205 Node_Backward_Iterator iter((Node *)_root, visited, stack, *this);
1206 Node *self;
1207
1208 // Walk over all the nodes from last to first
1209 while ((self = iter.next())) {
1210 Block* early = get_block_for_node(self); // Earliest legal placement
1211
1212 if (self->is_top()) {
1213 // Top node goes in bb #2 with other constants.
1214 // It must be special-cased, because it has no out edges.
1215 early->add_inst(self);
1216 continue;
1217 }
1218
1219 // No uses, just terminate
1220 if (self->outcnt() == 0) {
1221 assert(self->is_MachProj(), "sanity");
1222 continue; // Must be a dead machine projection
1223 }
1224
1225 // If node is pinned in the block, then no scheduling can be done.
1226 if( self->pinned() ) // Pinned in block?
1227 continue;
1228
1229 MachNode* mach = self->is_Mach() ? self->as_Mach() : NULL;
1230 if (mach) {
1231 switch (mach->ideal_Opcode()) {
1232 case Op_CreateEx:
1233 // Don't move exception creation
1234 early->add_inst(self);
1235 continue;
1236 break;
1237 case Op_CheckCastPP: {
1238 // Don't move CheckCastPP nodes away from their input, if the input
1239 // is a rawptr (5071820).
1240 Node *def = self->in(1);
1241 if (def != NULL && def->bottom_type()->base() == Type::RawPtr) {
1242 early->add_inst(self);
1243 #ifdef ASSERT
1244 _raw_oops.push(def);
1245 #endif
1246 continue;
1247 }
1248 break;
1249 }
1250 default:
1251 break;
1252 }
1253 }
1254
1255 // Gather LCA of all uses
1256 Block *LCA = NULL;
1257 {
1258 for (DUIterator_Fast imax, i = self->fast_outs(imax); i < imax; i++) {
1259 // For all uses, find LCA
1260 Node* use = self->fast_out(i);
1261 LCA = raise_LCA_above_use(LCA, use, self, this);
1262 }
1263 } // (Hide defs of imax, i from rest of block.)
1264
1265 // Place temps in the block of their use. This isn't a
1266 // requirement for correctness but it reduces useless
1267 // interference between temps and other nodes.
1268 if (mach != NULL && mach->is_MachTemp()) {
1269 map_node_to_block(self, LCA);
1270 LCA->add_inst(self);
1271 continue;
1272 }
|