22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "compiler/compileLog.hpp"
27 #include "ci/bcEscapeAnalyzer.hpp"
28 #include "compiler/oopMap.hpp"
29 #include "opto/callGenerator.hpp"
30 #include "opto/callnode.hpp"
31 #include "opto/castnode.hpp"
32 #include "opto/convertnode.hpp"
33 #include "opto/escape.hpp"
34 #include "opto/locknode.hpp"
35 #include "opto/machnode.hpp"
36 #include "opto/matcher.hpp"
37 #include "opto/parse.hpp"
38 #include "opto/regalloc.hpp"
39 #include "opto/regmask.hpp"
40 #include "opto/rootnode.hpp"
41 #include "opto/runtime.hpp"
42
43 // Portions of code courtesy of Clifford Click
44
45 // Optimization - Graph Style
46
47 //=============================================================================
48 uint StartNode::size_of() const { return sizeof(*this); }
49 uint StartNode::cmp( const Node &n ) const
50 { return _domain == ((StartNode&)n)._domain; }
51 const Type *StartNode::bottom_type() const { return _domain; }
52 const Type* StartNode::Value(PhaseGVN* phase) const { return _domain; }
53 #ifndef PRODUCT
54 void StartNode::dump_spec(outputStream *st) const { st->print(" #"); _domain->dump_on(st);}
55 void StartNode::dump_compact_spec(outputStream *st) const { /* empty */ }
56 #endif
57
58 //------------------------------Ideal------------------------------------------
59 Node *StartNode::Ideal(PhaseGVN *phase, bool can_reshape){
60 return remove_dead_region(phase, can_reshape) ? this : NULL;
61 }
1121 set_prec(req(), n);
1122 }
1123 }
1124
1125
1126 //----------------------------next_exception-----------------------------------
1127 SafePointNode* SafePointNode::next_exception() const {
1128 if (len() == req()) {
1129 return NULL;
1130 } else {
1131 Node* n = in(req());
1132 assert(n == NULL || n->Opcode() == Op_SafePoint, "no other uses of prec edges");
1133 return (SafePointNode*) n;
1134 }
1135 }
1136
1137
1138 //------------------------------Ideal------------------------------------------
1139 // Skip over any collapsed Regions
1140 Node *SafePointNode::Ideal(PhaseGVN *phase, bool can_reshape) {
1141 return remove_dead_region(phase, can_reshape) ? this : NULL;
1142 }
1143
1144 //------------------------------Identity---------------------------------------
1145 // Remove obviously duplicate safepoints
1146 Node* SafePointNode::Identity(PhaseGVN* phase) {
1147
1148 // If you have back to back safepoints, remove one
1149 if( in(TypeFunc::Control)->is_SafePoint() )
1150 return in(TypeFunc::Control);
1151
1152 if( in(0)->is_Proj() ) {
1153 Node *n0 = in(0)->in(0);
1154 // Check if he is a call projection (except Leaf Call)
1155 if( n0->is_Catch() ) {
1156 n0 = n0->in(0)->in(0);
1157 assert( n0->is_Call(), "expect a call here" );
1158 }
1159 if( n0->is_Call() && n0->as_Call()->guaranteed_safepoint() ) {
1160 // Useless Safepoint, so remove it
1161 return in(TypeFunc::Control);
1360
1361 void AllocateNode::compute_MemBar_redundancy(ciMethod* initializer)
1362 {
1363 assert(initializer != NULL &&
1364 initializer->is_initializer() &&
1365 !initializer->is_static(),
1366 "unexpected initializer method");
1367 BCEscapeAnalyzer* analyzer = initializer->get_bcea();
1368 if (analyzer == NULL) {
1369 return;
1370 }
1371
1372 // Allocation node is first parameter in its initializer
1373 if (analyzer->is_arg_stack(0) || analyzer->is_arg_local(0)) {
1374 _is_allocation_MemBar_redundant = true;
1375 }
1376 }
1377
1378 //=============================================================================
1379 Node* AllocateArrayNode::Ideal(PhaseGVN *phase, bool can_reshape) {
1380 if (remove_dead_region(phase, can_reshape)) return this;
1381 // Don't bother trying to transform a dead node
1382 if (in(0) && in(0)->is_top()) return NULL;
1383
1384 const Type* type = phase->type(Ideal_length());
1385 if (type->isa_int() && type->is_int()->_hi < 0) {
1386 if (can_reshape) {
1387 PhaseIterGVN *igvn = phase->is_IterGVN();
1388 // Unreachable fall through path (negative array length),
1389 // the allocation can only throw so disconnect it.
1390 Node* proj = proj_out(TypeFunc::Control);
1391 Node* catchproj = NULL;
1392 if (proj != NULL) {
1393 for (DUIterator_Fast imax, i = proj->fast_outs(imax); i < imax; i++) {
1394 Node *cn = proj->fast_out(i);
1395 if (cn->is_Catch()) {
1396 catchproj = cn->as_Multi()->proj_out(CatchProjNode::fall_through_index);
1397 break;
1398 }
1399 }
1400 }
|
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "compiler/compileLog.hpp"
27 #include "ci/bcEscapeAnalyzer.hpp"
28 #include "compiler/oopMap.hpp"
29 #include "opto/callGenerator.hpp"
30 #include "opto/callnode.hpp"
31 #include "opto/castnode.hpp"
32 #include "opto/convertnode.hpp"
33 #include "opto/escape.hpp"
34 #include "opto/locknode.hpp"
35 #include "opto/machnode.hpp"
36 #include "opto/matcher.hpp"
37 #include "opto/parse.hpp"
38 #include "opto/regalloc.hpp"
39 #include "opto/regmask.hpp"
40 #include "opto/rootnode.hpp"
41 #include "opto/runtime.hpp"
42 #include "opto/valuetypenode.hpp"
43
44 // Portions of code courtesy of Clifford Click
45
46 // Optimization - Graph Style
47
48 //=============================================================================
49 uint StartNode::size_of() const { return sizeof(*this); }
50 uint StartNode::cmp( const Node &n ) const
51 { return _domain == ((StartNode&)n)._domain; }
52 const Type *StartNode::bottom_type() const { return _domain; }
53 const Type* StartNode::Value(PhaseGVN* phase) const { return _domain; }
54 #ifndef PRODUCT
55 void StartNode::dump_spec(outputStream *st) const { st->print(" #"); _domain->dump_on(st);}
56 void StartNode::dump_compact_spec(outputStream *st) const { /* empty */ }
57 #endif
58
59 //------------------------------Ideal------------------------------------------
60 Node *StartNode::Ideal(PhaseGVN *phase, bool can_reshape){
61 return remove_dead_region(phase, can_reshape) ? this : NULL;
62 }
1122 set_prec(req(), n);
1123 }
1124 }
1125
1126
1127 //----------------------------next_exception-----------------------------------
1128 SafePointNode* SafePointNode::next_exception() const {
1129 if (len() == req()) {
1130 return NULL;
1131 } else {
1132 Node* n = in(req());
1133 assert(n == NULL || n->Opcode() == Op_SafePoint, "no other uses of prec edges");
1134 return (SafePointNode*) n;
1135 }
1136 }
1137
1138
1139 //------------------------------Ideal------------------------------------------
1140 // Skip over any collapsed Regions
1141 Node *SafePointNode::Ideal(PhaseGVN *phase, bool can_reshape) {
1142 if (remove_dead_region(phase, can_reshape)) {
1143 return this;
1144 }
1145 if (jvms() != NULL) {
1146 bool progress = false;
1147 // A ValueTypeNode with a valid object input in the debug info?
1148 // Reference the object directly. Helps removal of useless value
1149 // type allocations with incremental inlining.
1150 for (uint i = jvms()->debug_start(); i < jvms()->debug_end(); i++) {
1151 Node *arg = in(i);
1152 if (arg->is_ValueType()) {
1153 ValueTypeNode* vt = arg->as_ValueType();
1154 Node* in_oop = vt->get_oop();
1155 const Type* oop_type = phase->type(in_oop);
1156 if (oop_type->meet(TypePtr::NULL_PTR) != oop_type) {
1157 set_req(i, in_oop);
1158 progress = true;
1159 }
1160 }
1161 }
1162 if (progress) {
1163 return this;
1164 }
1165 }
1166 return NULL;
1167 }
1168
1169 //------------------------------Identity---------------------------------------
1170 // Remove obviously duplicate safepoints
1171 Node* SafePointNode::Identity(PhaseGVN* phase) {
1172
1173 // If you have back to back safepoints, remove one
1174 if( in(TypeFunc::Control)->is_SafePoint() )
1175 return in(TypeFunc::Control);
1176
1177 if( in(0)->is_Proj() ) {
1178 Node *n0 = in(0)->in(0);
1179 // Check if he is a call projection (except Leaf Call)
1180 if( n0->is_Catch() ) {
1181 n0 = n0->in(0)->in(0);
1182 assert( n0->is_Call(), "expect a call here" );
1183 }
1184 if( n0->is_Call() && n0->as_Call()->guaranteed_safepoint() ) {
1185 // Useless Safepoint, so remove it
1186 return in(TypeFunc::Control);
1385
1386 void AllocateNode::compute_MemBar_redundancy(ciMethod* initializer)
1387 {
1388 assert(initializer != NULL &&
1389 initializer->is_initializer() &&
1390 !initializer->is_static(),
1391 "unexpected initializer method");
1392 BCEscapeAnalyzer* analyzer = initializer->get_bcea();
1393 if (analyzer == NULL) {
1394 return;
1395 }
1396
1397 // Allocation node is first parameter in its initializer
1398 if (analyzer->is_arg_stack(0) || analyzer->is_arg_local(0)) {
1399 _is_allocation_MemBar_redundant = true;
1400 }
1401 }
1402
1403 //=============================================================================
1404 Node* AllocateArrayNode::Ideal(PhaseGVN *phase, bool can_reshape) {
1405 Node* res = SafePointNode::Ideal(phase, can_reshape);
1406 if (res != NULL) {
1407 return res;
1408 }
1409 // Don't bother trying to transform a dead node
1410 if (in(0) && in(0)->is_top()) return NULL;
1411
1412 const Type* type = phase->type(Ideal_length());
1413 if (type->isa_int() && type->is_int()->_hi < 0) {
1414 if (can_reshape) {
1415 PhaseIterGVN *igvn = phase->is_IterGVN();
1416 // Unreachable fall through path (negative array length),
1417 // the allocation can only throw so disconnect it.
1418 Node* proj = proj_out(TypeFunc::Control);
1419 Node* catchproj = NULL;
1420 if (proj != NULL) {
1421 for (DUIterator_Fast imax, i = proj->fast_outs(imax); i < imax; i++) {
1422 Node *cn = proj->fast_out(i);
1423 if (cn->is_Catch()) {
1424 catchproj = cn->as_Multi()->proj_out(CatchProjNode::fall_through_index);
1425 break;
1426 }
1427 }
1428 }
|