Mercurial > hg > truffle
comparison src/share/vm/opto/compile.cpp @ 7212:291ffc492eb6
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Fri, 14 Dec 2012 14:35:13 +0100 |
parents | cd3d6a6b95d9 |
children | ad5dd04754ee |
comparison
equal
deleted
inserted
replaced
7163:2ed8d74e5984 | 7212:291ffc492eb6 |
---|---|
21 * questions. | 21 * questions. |
22 * | 22 * |
23 */ | 23 */ |
24 | 24 |
25 #include "precompiled.hpp" | 25 #include "precompiled.hpp" |
26 #include "asm/assembler.hpp" | 26 #include "asm/macroAssembler.hpp" |
27 #include "asm/macroAssembler.inline.hpp" | |
27 #include "classfile/systemDictionary.hpp" | 28 #include "classfile/systemDictionary.hpp" |
28 #include "code/exceptionHandlerTable.hpp" | 29 #include "code/exceptionHandlerTable.hpp" |
29 #include "code/nmethod.hpp" | 30 #include "code/nmethod.hpp" |
30 #include "compiler/compileLog.hpp" | 31 #include "compiler/compileLog.hpp" |
32 #include "compiler/disassembler.hpp" | |
31 #include "compiler/oopMap.hpp" | 33 #include "compiler/oopMap.hpp" |
32 #include "opto/addnode.hpp" | 34 #include "opto/addnode.hpp" |
33 #include "opto/block.hpp" | 35 #include "opto/block.hpp" |
34 #include "opto/c2compiler.hpp" | 36 #include "opto/c2compiler.hpp" |
35 #include "opto/callGenerator.hpp" | 37 #include "opto/callGenerator.hpp" |
314 i -= uses_found; // we deleted 1 or more copies of this edge | 316 i -= uses_found; // we deleted 1 or more copies of this edge |
315 } | 317 } |
316 } | 318 } |
317 | 319 |
318 | 320 |
319 | 321 static inline bool not_a_node(const Node* n) { |
322 if (n == NULL) return true; | |
323 if (((intptr_t)n & 1) != 0) return true; // uninitialized, etc. | |
324 if (*(address*)n == badAddress) return true; // kill by Node::destruct | |
325 return false; | |
326 } | |
320 | 327 |
321 // Identify all nodes that are reachable from below, useful. | 328 // Identify all nodes that are reachable from below, useful. |
322 // Use breadth-first pass that records state in a Unique_Node_List, | 329 // Use breadth-first pass that records state in a Unique_Node_List, |
323 // recursive traversal is slower. | 330 // recursive traversal is slower. |
324 void Compile::identify_useful_nodes(Unique_Node_List &useful) { | 331 void Compile::identify_useful_nodes(Unique_Node_List &useful) { |
335 assert( next < unique(), "Unique useful nodes < total nodes"); | 342 assert( next < unique(), "Unique useful nodes < total nodes"); |
336 Node *n = useful.at(next); | 343 Node *n = useful.at(next); |
337 uint max = n->len(); | 344 uint max = n->len(); |
338 for( uint i = 0; i < max; ++i ) { | 345 for( uint i = 0; i < max; ++i ) { |
339 Node *m = n->in(i); | 346 Node *m = n->in(i); |
340 if( m == NULL ) continue; | 347 if (not_a_node(m)) continue; |
341 useful.push(m); | 348 useful.push(m); |
349 } | |
350 } | |
351 } | |
352 | |
353 // Update dead_node_list with any missing dead nodes using useful | |
354 // list. Consider all non-useful nodes to be useless i.e., dead nodes. | |
355 void Compile::update_dead_node_list(Unique_Node_List &useful) { | |
356 uint max_idx = unique(); | |
357 VectorSet& useful_node_set = useful.member_set(); | |
358 | |
359 for (uint node_idx = 0; node_idx < max_idx; node_idx++) { | |
360 // If node with index node_idx is not in useful set, | |
361 // mark it as dead in dead node list. | |
362 if (! useful_node_set.test(node_idx) ) { | |
363 record_dead_node(node_idx); | |
342 } | 364 } |
343 } | 365 } |
344 } | 366 } |
345 | 367 |
346 // Disconnect all useless nodes by disconnecting those at the boundary. | 368 // Disconnect all useless nodes by disconnecting those at the boundary. |
580 _node_bundling_base(NULL), | 602 _node_bundling_base(NULL), |
581 _java_calls(0), | 603 _java_calls(0), |
582 _inner_loops(0), | 604 _inner_loops(0), |
583 _scratch_const_size(-1), | 605 _scratch_const_size(-1), |
584 _in_scratch_emit_size(false), | 606 _in_scratch_emit_size(false), |
607 _dead_node_list(comp_arena()), | |
608 _dead_node_count(0), | |
585 #ifndef PRODUCT | 609 #ifndef PRODUCT |
586 _trace_opto_output(TraceOptoOutput || method()->has_option("TraceOptoOutput")), | 610 _trace_opto_output(TraceOptoOutput || method()->has_option("TraceOptoOutput")), |
587 _printer(IdealGraphPrinter::printer()), | 611 _printer(IdealGraphPrinter::printer()), |
588 #endif | 612 #endif |
589 _congraph(NULL) { | 613 _congraph(NULL) { |
871 _inner_loops(0), | 895 _inner_loops(0), |
872 #ifndef PRODUCT | 896 #ifndef PRODUCT |
873 _trace_opto_output(TraceOptoOutput), | 897 _trace_opto_output(TraceOptoOutput), |
874 _printer(NULL), | 898 _printer(NULL), |
875 #endif | 899 #endif |
900 _dead_node_list(comp_arena()), | |
901 _dead_node_count(0), | |
876 _congraph(NULL) { | 902 _congraph(NULL) { |
877 C = this; | 903 C = this; |
878 | 904 |
879 #ifndef PRODUCT | 905 #ifndef PRODUCT |
880 TraceTime t1(NULL, &_t_totalCompilation, TimeCompiler, false); | 906 TraceTime t1(NULL, &_t_totalCompilation, TimeCompiler, false); |
1066 // their _out arrays. | 1092 // their _out arrays. |
1067 if (_top != NULL) _top->setup_is_top(); | 1093 if (_top != NULL) _top->setup_is_top(); |
1068 if (old_top != NULL) old_top->setup_is_top(); | 1094 if (old_top != NULL) old_top->setup_is_top(); |
1069 assert(_top == NULL || top()->is_top(), ""); | 1095 assert(_top == NULL || top()->is_top(), ""); |
1070 } | 1096 } |
1097 | |
1098 #ifdef ASSERT | |
1099 uint Compile::count_live_nodes_by_graph_walk() { | |
1100 Unique_Node_List useful(comp_arena()); | |
1101 // Get useful node list by walking the graph. | |
1102 identify_useful_nodes(useful); | |
1103 return useful.size(); | |
1104 } | |
1105 | |
1106 void Compile::print_missing_nodes() { | |
1107 | |
1108 // Return if CompileLog is NULL and PrintIdealNodeCount is false. | |
1109 if ((_log == NULL) && (! PrintIdealNodeCount)) { | |
1110 return; | |
1111 } | |
1112 | |
1113 // This is an expensive function. It is executed only when the user | |
1114 // specifies VerifyIdealNodeCount option or otherwise knows the | |
1115 // additional work that needs to be done to identify reachable nodes | |
1116 // by walking the flow graph and find the missing ones using | |
1117 // _dead_node_list. | |
1118 | |
1119 Unique_Node_List useful(comp_arena()); | |
1120 // Get useful node list by walking the graph. | |
1121 identify_useful_nodes(useful); | |
1122 | |
1123 uint l_nodes = C->live_nodes(); | |
1124 uint l_nodes_by_walk = useful.size(); | |
1125 | |
1126 if (l_nodes != l_nodes_by_walk) { | |
1127 if (_log != NULL) { | |
1128 _log->begin_head("mismatched_nodes count='%d'", abs((int) (l_nodes - l_nodes_by_walk))); | |
1129 _log->stamp(); | |
1130 _log->end_head(); | |
1131 } | |
1132 VectorSet& useful_member_set = useful.member_set(); | |
1133 int last_idx = l_nodes_by_walk; | |
1134 for (int i = 0; i < last_idx; i++) { | |
1135 if (useful_member_set.test(i)) { | |
1136 if (_dead_node_list.test(i)) { | |
1137 if (_log != NULL) { | |
1138 _log->elem("mismatched_node_info node_idx='%d' type='both live and dead'", i); | |
1139 } | |
1140 if (PrintIdealNodeCount) { | |
1141 // Print the log message to tty | |
1142 tty->print_cr("mismatched_node idx='%d' both live and dead'", i); | |
1143 useful.at(i)->dump(); | |
1144 } | |
1145 } | |
1146 } | |
1147 else if (! _dead_node_list.test(i)) { | |
1148 if (_log != NULL) { | |
1149 _log->elem("mismatched_node_info node_idx='%d' type='neither live nor dead'", i); | |
1150 } | |
1151 if (PrintIdealNodeCount) { | |
1152 // Print the log message to tty | |
1153 tty->print_cr("mismatched_node idx='%d' type='neither live nor dead'", i); | |
1154 } | |
1155 } | |
1156 } | |
1157 if (_log != NULL) { | |
1158 _log->tail("mismatched_nodes"); | |
1159 } | |
1160 } | |
1161 } | |
1162 #endif | |
1071 | 1163 |
1072 #ifndef PRODUCT | 1164 #ifndef PRODUCT |
1073 void Compile::verify_top(Node* tn) const { | 1165 void Compile::verify_top(Node* tn) const { |
1074 if (tn != NULL) { | 1166 if (tn != NULL) { |
1075 assert(tn->is_Con(), "top node must be a constant"); | 1167 assert(tn->is_Con(), "top node must be a constant"); |
2085 // Note that OffsetBot and OffsetTop are very negative. | 2177 // Note that OffsetBot and OffsetTop are very negative. |
2086 } | 2178 } |
2087 | 2179 |
2088 // Eliminate trivially redundant StoreCMs and accumulate their | 2180 // Eliminate trivially redundant StoreCMs and accumulate their |
2089 // precedence edges. | 2181 // precedence edges. |
2090 static void eliminate_redundant_card_marks(Node* n) { | 2182 void Compile::eliminate_redundant_card_marks(Node* n) { |
2091 assert(n->Opcode() == Op_StoreCM, "expected StoreCM"); | 2183 assert(n->Opcode() == Op_StoreCM, "expected StoreCM"); |
2092 if (n->in(MemNode::Address)->outcnt() > 1) { | 2184 if (n->in(MemNode::Address)->outcnt() > 1) { |
2093 // There are multiple users of the same address so it might be | 2185 // There are multiple users of the same address so it might be |
2094 // possible to eliminate some of the StoreCMs | 2186 // possible to eliminate some of the StoreCMs |
2095 Node* mem = n->in(MemNode::Memory); | 2187 Node* mem = n->in(MemNode::Memory); |
2120 done = true; | 2212 done = true; |
2121 } | 2213 } |
2122 // Eliminate the previous StoreCM | 2214 // Eliminate the previous StoreCM |
2123 prev->set_req(MemNode::Memory, mem->in(MemNode::Memory)); | 2215 prev->set_req(MemNode::Memory, mem->in(MemNode::Memory)); |
2124 assert(mem->outcnt() == 0, "should be dead"); | 2216 assert(mem->outcnt() == 0, "should be dead"); |
2125 mem->disconnect_inputs(NULL); | 2217 mem->disconnect_inputs(NULL, this); |
2126 } else { | 2218 } else { |
2127 prev = mem; | 2219 prev = mem; |
2128 } | 2220 } |
2129 mem = prev->in(MemNode::Memory); | 2221 mem = prev->in(MemNode::Memory); |
2130 } | 2222 } |
2131 } | 2223 } |
2132 } | 2224 } |
2133 | 2225 |
2134 //------------------------------final_graph_reshaping_impl---------------------- | 2226 //------------------------------final_graph_reshaping_impl---------------------- |
2135 // Implement items 1-5 from final_graph_reshaping below. | 2227 // Implement items 1-5 from final_graph_reshaping below. |
2136 static void final_graph_reshaping_impl( Node *n, Final_Reshape_Counts &frc ) { | 2228 void Compile::final_graph_reshaping_impl( Node *n, Final_Reshape_Counts &frc) { |
2137 | 2229 |
2138 if ( n->outcnt() == 0 ) return; // dead node | 2230 if ( n->outcnt() == 0 ) return; // dead node |
2139 uint nop = n->Opcode(); | 2231 uint nop = n->Opcode(); |
2140 | 2232 |
2141 // Check for 2-input instruction with "last use" on right input. | 2233 // Check for 2-input instruction with "last use" on right input. |
2161 } | 2253 } |
2162 } | 2254 } |
2163 | 2255 |
2164 #ifdef ASSERT | 2256 #ifdef ASSERT |
2165 if( n->is_Mem() ) { | 2257 if( n->is_Mem() ) { |
2166 Compile* C = Compile::current(); | 2258 int alias_idx = get_alias_index(n->as_Mem()->adr_type()); |
2167 int alias_idx = C->get_alias_index(n->as_Mem()->adr_type()); | |
2168 assert( n->in(0) != NULL || alias_idx != Compile::AliasIdxRaw || | 2259 assert( n->in(0) != NULL || alias_idx != Compile::AliasIdxRaw || |
2169 // oop will be recorded in oop map if load crosses safepoint | 2260 // oop will be recorded in oop map if load crosses safepoint |
2170 n->is_Load() && (n->as_Load()->bottom_type()->isa_oopptr() || | 2261 n->is_Load() && (n->as_Load()->bottom_type()->isa_oopptr() || |
2171 LoadNode::is_immutable_value(n->in(MemNode::Address))), | 2262 LoadNode::is_immutable_value(n->in(MemNode::Address))), |
2172 "raw memory operations should have control edge"); | 2263 "raw memory operations should have control edge"); |
2211 case Op_CmpD3: | 2302 case Op_CmpD3: |
2212 frc.inc_double_count(); | 2303 frc.inc_double_count(); |
2213 break; | 2304 break; |
2214 case Op_Opaque1: // Remove Opaque Nodes before matching | 2305 case Op_Opaque1: // Remove Opaque Nodes before matching |
2215 case Op_Opaque2: // Remove Opaque Nodes before matching | 2306 case Op_Opaque2: // Remove Opaque Nodes before matching |
2216 n->subsume_by(n->in(1)); | 2307 n->subsume_by(n->in(1), this); |
2217 break; | 2308 break; |
2218 case Op_CallStaticJava: | 2309 case Op_CallStaticJava: |
2219 case Op_CallJava: | 2310 case Op_CallJava: |
2220 case Op_CallDynamicJava: | 2311 case Op_CallDynamicJava: |
2221 frc.inc_java_call_count(); // Count java call site; | 2312 frc.inc_java_call_count(); // Count java call site; |
2335 Node* nn = NULL; | 2426 Node* nn = NULL; |
2336 | 2427 |
2337 int op = t->isa_oopptr() ? Op_ConN : Op_ConNKlass; | 2428 int op = t->isa_oopptr() ? Op_ConN : Op_ConNKlass; |
2338 | 2429 |
2339 // Look for existing ConN node of the same exact type. | 2430 // Look for existing ConN node of the same exact type. |
2340 Compile* C = Compile::current(); | 2431 Node* r = root(); |
2341 Node* r = C->root(); | |
2342 uint cnt = r->outcnt(); | 2432 uint cnt = r->outcnt(); |
2343 for (uint i = 0; i < cnt; i++) { | 2433 for (uint i = 0; i < cnt; i++) { |
2344 Node* m = r->raw_out(i); | 2434 Node* m = r->raw_out(i); |
2345 if (m!= NULL && m->Opcode() == op && | 2435 if (m!= NULL && m->Opcode() == op && |
2346 m->bottom_type()->make_ptr() == t) { | 2436 m->bottom_type()->make_ptr() == t) { |
2350 } | 2440 } |
2351 if (nn != NULL) { | 2441 if (nn != NULL) { |
2352 // Decode a narrow oop to match address | 2442 // Decode a narrow oop to match address |
2353 // [R12 + narrow_oop_reg<<3 + offset] | 2443 // [R12 + narrow_oop_reg<<3 + offset] |
2354 if (t->isa_oopptr()) { | 2444 if (t->isa_oopptr()) { |
2355 nn = new (C) DecodeNNode(nn, t); | 2445 nn = new (this) DecodeNNode(nn, t); |
2356 } else { | 2446 } else { |
2357 nn = new (C) DecodeNKlassNode(nn, t); | 2447 nn = new (this) DecodeNKlassNode(nn, t); |
2358 } | 2448 } |
2359 n->set_req(AddPNode::Base, nn); | 2449 n->set_req(AddPNode::Base, nn); |
2360 n->set_req(AddPNode::Address, nn); | 2450 n->set_req(AddPNode::Address, nn); |
2361 if (addp->outcnt() == 0) { | 2451 if (addp->outcnt() == 0) { |
2362 addp->disconnect_inputs(NULL); | 2452 addp->disconnect_inputs(NULL, this); |
2363 } | 2453 } |
2364 } | 2454 } |
2365 } | 2455 } |
2366 } | 2456 } |
2367 #endif | 2457 #endif |
2369 } | 2459 } |
2370 | 2460 |
2371 #ifdef _LP64 | 2461 #ifdef _LP64 |
2372 case Op_CastPP: | 2462 case Op_CastPP: |
2373 if (n->in(1)->is_DecodeN() && Matcher::gen_narrow_oop_implicit_null_checks()) { | 2463 if (n->in(1)->is_DecodeN() && Matcher::gen_narrow_oop_implicit_null_checks()) { |
2374 Compile* C = Compile::current(); | |
2375 Node* in1 = n->in(1); | 2464 Node* in1 = n->in(1); |
2376 const Type* t = n->bottom_type(); | 2465 const Type* t = n->bottom_type(); |
2377 Node* new_in1 = in1->clone(); | 2466 Node* new_in1 = in1->clone(); |
2378 new_in1->as_DecodeN()->set_type(t); | 2467 new_in1->as_DecodeN()->set_type(t); |
2379 | 2468 |
2398 // corresponds to use it as value in implicit_null_check(). | 2487 // corresponds to use it as value in implicit_null_check(). |
2399 // | 2488 // |
2400 new_in1->set_req(0, n->in(0)); | 2489 new_in1->set_req(0, n->in(0)); |
2401 } | 2490 } |
2402 | 2491 |
2403 n->subsume_by(new_in1); | 2492 n->subsume_by(new_in1, this); |
2404 if (in1->outcnt() == 0) { | 2493 if (in1->outcnt() == 0) { |
2405 in1->disconnect_inputs(NULL); | 2494 in1->disconnect_inputs(NULL, this); |
2406 } | 2495 } |
2407 } | 2496 } |
2408 break; | 2497 break; |
2409 | 2498 |
2410 case Op_CmpP: | 2499 case Op_CmpP: |
2417 in2 = in1; | 2506 in2 = in1; |
2418 in1 = n->in(2); | 2507 in1 = n->in(2); |
2419 } | 2508 } |
2420 assert(in1->is_DecodeNarrowPtr(), "sanity"); | 2509 assert(in1->is_DecodeNarrowPtr(), "sanity"); |
2421 | 2510 |
2422 Compile* C = Compile::current(); | |
2423 Node* new_in2 = NULL; | 2511 Node* new_in2 = NULL; |
2424 if (in2->is_DecodeNarrowPtr()) { | 2512 if (in2->is_DecodeNarrowPtr()) { |
2425 assert(in2->Opcode() == in1->Opcode(), "must be same node type"); | 2513 assert(in2->Opcode() == in1->Opcode(), "must be same node type"); |
2426 new_in2 = in2->in(1); | 2514 new_in2 = in2->in(1); |
2427 } else if (in2->Opcode() == Op_ConP) { | 2515 } else if (in2->Opcode() == Op_ConP) { |
2430 assert(in1->is_DecodeN(), "compare klass to null?"); | 2518 assert(in1->is_DecodeN(), "compare klass to null?"); |
2431 // Don't convert CmpP null check into CmpN if compressed | 2519 // Don't convert CmpP null check into CmpN if compressed |
2432 // oops implicit null check is not generated. | 2520 // oops implicit null check is not generated. |
2433 // This will allow to generate normal oop implicit null check. | 2521 // This will allow to generate normal oop implicit null check. |
2434 if (Matcher::gen_narrow_oop_implicit_null_checks()) | 2522 if (Matcher::gen_narrow_oop_implicit_null_checks()) |
2435 new_in2 = ConNode::make(C, TypeNarrowOop::NULL_PTR); | 2523 new_in2 = ConNode::make(this, TypeNarrowOop::NULL_PTR); |
2436 // | 2524 // |
2437 // This transformation together with CastPP transformation above | 2525 // This transformation together with CastPP transformation above |
2438 // will generated code for implicit NULL checks for compressed oops. | 2526 // will generated code for implicit NULL checks for compressed oops. |
2439 // | 2527 // |
2440 // The original code after Optimize() | 2528 // The original code after Optimize() |
2469 // decode_not_null narrow_oop_reg, base_reg | 2557 // decode_not_null narrow_oop_reg, base_reg |
2470 // Load [base_reg + offset], val_reg | 2558 // Load [base_reg + offset], val_reg |
2471 // NullCheck base_reg | 2559 // NullCheck base_reg |
2472 // | 2560 // |
2473 } else if (t->isa_oopptr()) { | 2561 } else if (t->isa_oopptr()) { |
2474 new_in2 = ConNode::make(C, t->make_narrowoop()); | 2562 new_in2 = ConNode::make(this, t->make_narrowoop()); |
2475 } else if (t->isa_klassptr()) { | 2563 } else if (t->isa_klassptr()) { |
2476 new_in2 = ConNode::make(C, t->make_narrowklass()); | 2564 new_in2 = ConNode::make(this, t->make_narrowklass()); |
2477 } | 2565 } |
2478 } | 2566 } |
2479 if (new_in2 != NULL) { | 2567 if (new_in2 != NULL) { |
2480 Node* cmpN = new (C) CmpNNode(in1->in(1), new_in2); | 2568 Node* cmpN = new (this) CmpNNode(in1->in(1), new_in2); |
2481 n->subsume_by( cmpN ); | 2569 n->subsume_by(cmpN, this); |
2482 if (in1->outcnt() == 0) { | 2570 if (in1->outcnt() == 0) { |
2483 in1->disconnect_inputs(NULL); | 2571 in1->disconnect_inputs(NULL, this); |
2484 } | 2572 } |
2485 if (in2->outcnt() == 0) { | 2573 if (in2->outcnt() == 0) { |
2486 in2->disconnect_inputs(NULL); | 2574 in2->disconnect_inputs(NULL, this); |
2487 } | 2575 } |
2488 } | 2576 } |
2489 } | 2577 } |
2490 break; | 2578 break; |
2491 | 2579 |
2499 | 2587 |
2500 case Op_EncodeP: | 2588 case Op_EncodeP: |
2501 case Op_EncodePKlass: { | 2589 case Op_EncodePKlass: { |
2502 Node* in1 = n->in(1); | 2590 Node* in1 = n->in(1); |
2503 if (in1->is_DecodeNarrowPtr()) { | 2591 if (in1->is_DecodeNarrowPtr()) { |
2504 n->subsume_by(in1->in(1)); | 2592 n->subsume_by(in1->in(1), this); |
2505 } else if (in1->Opcode() == Op_ConP) { | 2593 } else if (in1->Opcode() == Op_ConP) { |
2506 Compile* C = Compile::current(); | |
2507 const Type* t = in1->bottom_type(); | 2594 const Type* t = in1->bottom_type(); |
2508 if (t == TypePtr::NULL_PTR) { | 2595 if (t == TypePtr::NULL_PTR) { |
2509 assert(t->isa_oopptr(), "null klass?"); | 2596 assert(t->isa_oopptr(), "null klass?"); |
2510 n->subsume_by(ConNode::make(C, TypeNarrowOop::NULL_PTR)); | 2597 n->subsume_by(ConNode::make(this, TypeNarrowOop::NULL_PTR), this); |
2511 } else if (t->isa_oopptr()) { | 2598 } else if (t->isa_oopptr()) { |
2512 n->subsume_by(ConNode::make(C, t->make_narrowoop())); | 2599 n->subsume_by(ConNode::make(this, t->make_narrowoop()), this); |
2513 } else if (t->isa_klassptr()) { | 2600 } else if (t->isa_klassptr()) { |
2514 n->subsume_by(ConNode::make(C, t->make_narrowklass())); | 2601 n->subsume_by(ConNode::make(this, t->make_narrowklass()), this); |
2515 } | 2602 } |
2516 } | 2603 } |
2517 if (in1->outcnt() == 0) { | 2604 if (in1->outcnt() == 0) { |
2518 in1->disconnect_inputs(NULL); | 2605 in1->disconnect_inputs(NULL, this); |
2519 } | 2606 } |
2520 break; | 2607 break; |
2521 } | 2608 } |
2522 | 2609 |
2523 case Op_Proj: { | 2610 case Op_Proj: { |
2536 proj = use; | 2623 proj = use; |
2537 break; | 2624 break; |
2538 } | 2625 } |
2539 } | 2626 } |
2540 assert(proj != NULL, "must be found"); | 2627 assert(proj != NULL, "must be found"); |
2541 p->subsume_by(proj); | 2628 p->subsume_by(proj, this); |
2542 } | 2629 } |
2543 } | 2630 } |
2544 break; | 2631 break; |
2545 } | 2632 } |
2546 | 2633 |
2556 assert(m != NULL, ""); | 2643 assert(m != NULL, ""); |
2557 if (unique_in != m) | 2644 if (unique_in != m) |
2558 unique_in = NULL; | 2645 unique_in = NULL; |
2559 } | 2646 } |
2560 if (unique_in != NULL) { | 2647 if (unique_in != NULL) { |
2561 n->subsume_by(unique_in); | 2648 n->subsume_by(unique_in, this); |
2562 } | 2649 } |
2563 } | 2650 } |
2564 break; | 2651 break; |
2565 | 2652 |
2566 #endif | 2653 #endif |
2569 if (UseDivMod) { | 2656 if (UseDivMod) { |
2570 // Check if a%b and a/b both exist | 2657 // Check if a%b and a/b both exist |
2571 Node* d = n->find_similar(Op_DivI); | 2658 Node* d = n->find_similar(Op_DivI); |
2572 if (d) { | 2659 if (d) { |
2573 // Replace them with a fused divmod if supported | 2660 // Replace them with a fused divmod if supported |
2574 Compile* C = Compile::current(); | |
2575 if (Matcher::has_match_rule(Op_DivModI)) { | 2661 if (Matcher::has_match_rule(Op_DivModI)) { |
2576 DivModINode* divmod = DivModINode::make(C, n); | 2662 DivModINode* divmod = DivModINode::make(this, n); |
2577 d->subsume_by(divmod->div_proj()); | 2663 d->subsume_by(divmod->div_proj(), this); |
2578 n->subsume_by(divmod->mod_proj()); | 2664 n->subsume_by(divmod->mod_proj(), this); |
2579 } else { | 2665 } else { |
2580 // replace a%b with a-((a/b)*b) | 2666 // replace a%b with a-((a/b)*b) |
2581 Node* mult = new (C) MulINode(d, d->in(2)); | 2667 Node* mult = new (this) MulINode(d, d->in(2)); |
2582 Node* sub = new (C) SubINode(d->in(1), mult); | 2668 Node* sub = new (this) SubINode(d->in(1), mult); |
2583 n->subsume_by( sub ); | 2669 n->subsume_by(sub, this); |
2584 } | 2670 } |
2585 } | 2671 } |
2586 } | 2672 } |
2587 break; | 2673 break; |
2588 | 2674 |
2590 if (UseDivMod) { | 2676 if (UseDivMod) { |
2591 // Check if a%b and a/b both exist | 2677 // Check if a%b and a/b both exist |
2592 Node* d = n->find_similar(Op_DivL); | 2678 Node* d = n->find_similar(Op_DivL); |
2593 if (d) { | 2679 if (d) { |
2594 // Replace them with a fused divmod if supported | 2680 // Replace them with a fused divmod if supported |
2595 Compile* C = Compile::current(); | |
2596 if (Matcher::has_match_rule(Op_DivModL)) { | 2681 if (Matcher::has_match_rule(Op_DivModL)) { |
2597 DivModLNode* divmod = DivModLNode::make(C, n); | 2682 DivModLNode* divmod = DivModLNode::make(this, n); |
2598 d->subsume_by(divmod->div_proj()); | 2683 d->subsume_by(divmod->div_proj(), this); |
2599 n->subsume_by(divmod->mod_proj()); | 2684 n->subsume_by(divmod->mod_proj(), this); |
2600 } else { | 2685 } else { |
2601 // replace a%b with a-((a/b)*b) | 2686 // replace a%b with a-((a/b)*b) |
2602 Node* mult = new (C) MulLNode(d, d->in(2)); | 2687 Node* mult = new (this) MulLNode(d, d->in(2)); |
2603 Node* sub = new (C) SubLNode(d->in(1), mult); | 2688 Node* sub = new (this) SubLNode(d->in(1), mult); |
2604 n->subsume_by( sub ); | 2689 n->subsume_by(sub, this); |
2605 } | 2690 } |
2606 } | 2691 } |
2607 } | 2692 } |
2608 break; | 2693 break; |
2609 | 2694 |
2618 case Op_PackL: | 2703 case Op_PackL: |
2619 case Op_PackD: | 2704 case Op_PackD: |
2620 if (n->req()-1 > 2) { | 2705 if (n->req()-1 > 2) { |
2621 // Replace many operand PackNodes with a binary tree for matching | 2706 // Replace many operand PackNodes with a binary tree for matching |
2622 PackNode* p = (PackNode*) n; | 2707 PackNode* p = (PackNode*) n; |
2623 Node* btp = p->binary_tree_pack(Compile::current(), 1, n->req()); | 2708 Node* btp = p->binary_tree_pack(this, 1, n->req()); |
2624 n->subsume_by(btp); | 2709 n->subsume_by(btp, this); |
2625 } | 2710 } |
2626 break; | 2711 break; |
2627 case Op_Loop: | 2712 case Op_Loop: |
2628 case Op_CountedLoop: | 2713 case Op_CountedLoop: |
2629 if (n->as_Loop()->is_inner_loop()) { | 2714 if (n->as_Loop()->is_inner_loop()) { |
2643 juint mask = (n->bottom_type() == TypeInt::INT) ? (BitsPerInt - 1) : (BitsPerLong - 1); | 2728 juint mask = (n->bottom_type() == TypeInt::INT) ? (BitsPerInt - 1) : (BitsPerLong - 1); |
2644 const TypeInt* t = in2->find_int_type(); | 2729 const TypeInt* t = in2->find_int_type(); |
2645 if (t != NULL && t->is_con()) { | 2730 if (t != NULL && t->is_con()) { |
2646 juint shift = t->get_con(); | 2731 juint shift = t->get_con(); |
2647 if (shift > mask) { // Unsigned cmp | 2732 if (shift > mask) { // Unsigned cmp |
2648 Compile* C = Compile::current(); | 2733 n->set_req(2, ConNode::make(this, TypeInt::make(shift & mask))); |
2649 n->set_req(2, ConNode::make(C, TypeInt::make(shift & mask))); | |
2650 } | 2734 } |
2651 } else { | 2735 } else { |
2652 if (t == NULL || t->_lo < 0 || t->_hi > (int)mask) { | 2736 if (t == NULL || t->_lo < 0 || t->_hi > (int)mask) { |
2653 Compile* C = Compile::current(); | 2737 Node* shift = new (this) AndINode(in2, ConNode::make(this, TypeInt::make(mask))); |
2654 Node* shift = new (C) AndINode(in2, ConNode::make(C, TypeInt::make(mask))); | |
2655 n->set_req(2, shift); | 2738 n->set_req(2, shift); |
2656 } | 2739 } |
2657 } | 2740 } |
2658 if (in2->outcnt() == 0) { // Remove dead node | 2741 if (in2->outcnt() == 0) { // Remove dead node |
2659 in2->disconnect_inputs(NULL); | 2742 in2->disconnect_inputs(NULL, this); |
2660 } | 2743 } |
2661 } | 2744 } |
2662 break; | 2745 break; |
2663 default: | 2746 default: |
2664 assert( !n->is_Call(), "" ); | 2747 assert( !n->is_Call(), "" ); |
2672 } | 2755 } |
2673 | 2756 |
2674 //------------------------------final_graph_reshaping_walk--------------------- | 2757 //------------------------------final_graph_reshaping_walk--------------------- |
2675 // Replacing Opaque nodes with their input in final_graph_reshaping_impl(), | 2758 // Replacing Opaque nodes with their input in final_graph_reshaping_impl(), |
2676 // requires that the walk visits a node's inputs before visiting the node. | 2759 // requires that the walk visits a node's inputs before visiting the node. |
2677 static void final_graph_reshaping_walk( Node_Stack &nstack, Node *root, Final_Reshape_Counts &frc ) { | 2760 void Compile::final_graph_reshaping_walk( Node_Stack &nstack, Node *root, Final_Reshape_Counts &frc ) { |
2678 ResourceArea *area = Thread::current()->resource_area(); | 2761 ResourceArea *area = Thread::current()->resource_area(); |
2679 Unique_Node_List sfpt(area); | 2762 Unique_Node_List sfpt(area); |
2680 | 2763 |
2681 frc._visited.set(root->_idx); // first, mark node as visited | 2764 frc._visited.set(root->_idx); // first, mark node as visited |
2682 uint cnt = root->req(); | 2765 uint cnt = root->req(); |
2739 } | 2822 } |
2740 if (safe_to_skip) { | 2823 if (safe_to_skip) { |
2741 n->set_req(j, in->in(1)); | 2824 n->set_req(j, in->in(1)); |
2742 } | 2825 } |
2743 if (in->outcnt() == 0) { | 2826 if (in->outcnt() == 0) { |
2744 in->disconnect_inputs(NULL); | 2827 in->disconnect_inputs(NULL, this); |
2745 } | 2828 } |
2746 } | 2829 } |
2747 } | 2830 } |
2748 } | 2831 } |
2749 } | 2832 } |
3012 } | 3095 } |
3013 _root = NULL; // flush the graph, too | 3096 _root = NULL; // flush the graph, too |
3014 } | 3097 } |
3015 | 3098 |
3016 Compile::TracePhase::TracePhase(const char* name, elapsedTimer* accumulator, bool dolog) | 3099 Compile::TracePhase::TracePhase(const char* name, elapsedTimer* accumulator, bool dolog) |
3017 : TraceTime(NULL, accumulator, false NOT_PRODUCT( || TimeCompiler ), false) | 3100 : TraceTime(NULL, accumulator, false NOT_PRODUCT( || TimeCompiler ), false), |
3101 _phase_name(name), _dolog(dolog) | |
3018 { | 3102 { |
3019 if (dolog) { | 3103 if (dolog) { |
3020 C = Compile::current(); | 3104 C = Compile::current(); |
3021 _log = C->log(); | 3105 _log = C->log(); |
3022 } else { | 3106 } else { |
3023 C = NULL; | 3107 C = NULL; |
3024 _log = NULL; | 3108 _log = NULL; |
3025 } | 3109 } |
3026 if (_log != NULL) { | 3110 if (_log != NULL) { |
3027 _log->begin_head("phase name='%s' nodes='%d'", name, C->unique()); | 3111 _log->begin_head("phase name='%s' nodes='%d' live='%d'", _phase_name, C->unique(), C->live_nodes()); |
3028 _log->stamp(); | 3112 _log->stamp(); |
3029 _log->end_head(); | 3113 _log->end_head(); |
3030 } | 3114 } |
3031 } | 3115 } |
3032 | 3116 |
3033 Compile::TracePhase::~TracePhase() { | 3117 Compile::TracePhase::~TracePhase() { |
3118 | |
3119 C = Compile::current(); | |
3120 if (_dolog) { | |
3121 _log = C->log(); | |
3122 } else { | |
3123 _log = NULL; | |
3124 } | |
3125 | |
3126 #ifdef ASSERT | |
3127 if (PrintIdealNodeCount) { | |
3128 tty->print_cr("phase name='%s' nodes='%d' live='%d' live_graph_walk='%d'", | |
3129 _phase_name, C->unique(), C->live_nodes(), C->count_live_nodes_by_graph_walk()); | |
3130 } | |
3131 | |
3132 if (VerifyIdealNodeCount) { | |
3133 Compile::current()->print_missing_nodes(); | |
3134 } | |
3135 #endif | |
3136 | |
3034 if (_log != NULL) { | 3137 if (_log != NULL) { |
3035 _log->done("phase nodes='%d'", C->unique()); | 3138 _log->done("phase name='%s' nodes='%d' live='%d'", _phase_name, C->unique(), C->live_nodes()); |
3036 } | 3139 } |
3037 } | 3140 } |
3038 | 3141 |
3039 //============================================================================= | 3142 //============================================================================= |
3040 // Two Constant's are equal when the type and the value are equal. | 3143 // Two Constant's are equal when the type and the value are equal. |