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 *
23 */
24
25 #include "precompiled.hpp"
26 #include "ci/ciConstant.hpp"
27 #include "ci/ciField.hpp"
28 #include "ci/ciMethod.hpp"
29 #include "ci/ciMethodData.hpp"
30 #include "ci/ciObjArrayKlass.hpp"
31 #include "ci/ciStreams.hpp"
32 #include "ci/ciTypeArrayKlass.hpp"
33 #include "ci/ciTypeFlow.hpp"
34 #include "compiler/compileLog.hpp"
35 #include "interpreter/bytecode.hpp"
36 #include "interpreter/bytecodes.hpp"
37 #include "memory/allocation.inline.hpp"
38 #include "opto/compile.hpp"
39 #include "opto/node.hpp"
40 #include "runtime/deoptimization.hpp"
41 #include "utilities/growableArray.hpp"
42
43 // ciTypeFlow::JsrSet
44 //
45 // A JsrSet represents some set of JsrRecords. This class
46 // is used to record a set of all jsr routines which we permit
47 // execution to return (ret) from.
48 //
49 // During abstract interpretation, JsrSets are used to determine
50 // whether two paths which reach a given block are unique, and
51 // should be cloned apart, or are compatible, and should merge
52 // together.
53
54 // ------------------------------------------------------------------
55 // ciTypeFlow::JsrSet::JsrSet
56 ciTypeFlow::JsrSet::JsrSet(Arena* arena, int default_len) {
57 if (arena != NULL) {
58 // Allocate growable array in Arena.
59 _set = new (arena) GrowableArray<JsrRecord*>(arena, default_len, 0, NULL);
2630 root_head->set_pre_order(0);
2631 root_head->set_post_order(0);
2632 root_tail->set_pre_order(max_jint);
2633 root_tail->set_post_order(max_jint);
2634 set_loop_tree_root(new (arena()) Loop(root_head, root_tail));
2635
2636 stk.push(start);
2637
2638 _next_pre_order = 0; // initialize pre_order counter
2639 _rpo_list = NULL;
2640 int next_po = 0; // initialize post_order counter
2641
2642 // Compute RPO and the control flow graph
2643 int size;
2644 while ((size = stk.length()) > 0) {
2645 Block* blk = stk.top(); // Leave node on stack
2646 if (!blk->is_visited()) {
2647 // forward arc in graph
2648 assert (!blk->has_pre_order(), "");
2649 blk->set_next_pre_order();
2650
2651 if (_next_pre_order >= (int)Compile::current()->max_node_limit() / 2) {
2652 // Too many basic blocks. Bail out.
2653 // This can happen when try/finally constructs are nested to depth N,
2654 // and there is O(2**N) cloning of jsr bodies. See bug 4697245!
2655 // "MaxNodeLimit / 2" is used because probably the parser will
2656 // generate at least twice that many nodes and bail out.
2657 record_failure("too many basic blocks");
2658 return;
2659 }
2660 if (do_flow) {
2661 flow_block(blk, temp_vector, temp_set);
2662 if (failing()) return; // Watch for bailouts.
2663 }
2664 } else if (!blk->is_post_visited()) {
2665 // cross or back arc
2666 for (SuccIter iter(blk); !iter.done(); iter.next()) {
2667 Block* succ = iter.succ();
2668 if (!succ->is_visited()) {
2669 stk.push(succ);
2670 }
2671 }
2672 if (stk.length() == size) {
2673 // There were no additional children, post visit node now
2674 stk.pop(); // Remove node from stack
2675
2676 build_loop_tree(blk);
2677 blk->set_post_order(next_po++); // Assign post order
2678 prepend_to_rpo_list(blk);
2679 assert(blk->is_post_visited(), "");
|
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 *
23 */
24
25 #include "precompiled.hpp"
26 #include "ci/ciConstant.hpp"
27 #include "ci/ciField.hpp"
28 #include "ci/ciMethod.hpp"
29 #include "ci/ciMethodData.hpp"
30 #include "ci/ciObjArrayKlass.hpp"
31 #include "ci/ciStreams.hpp"
32 #include "ci/ciTypeArrayKlass.hpp"
33 #include "ci/ciTypeFlow.hpp"
34 #include "compiler/compileLog.hpp"
35 #include "interpreter/bytecode.hpp"
36 #include "interpreter/bytecodes.hpp"
37 #include "memory/allocation.inline.hpp"
38 #ifdef COMPILER2
39 #include "opto/compile.hpp"
40 #include "opto/node.hpp"
41 #endif // COMPILER2
42 #include "runtime/deoptimization.hpp"
43 #include "utilities/growableArray.hpp"
44
45 // ciTypeFlow::JsrSet
46 //
47 // A JsrSet represents some set of JsrRecords. This class
48 // is used to record a set of all jsr routines which we permit
49 // execution to return (ret) from.
50 //
51 // During abstract interpretation, JsrSets are used to determine
52 // whether two paths which reach a given block are unique, and
53 // should be cloned apart, or are compatible, and should merge
54 // together.
55
56 // ------------------------------------------------------------------
57 // ciTypeFlow::JsrSet::JsrSet
58 ciTypeFlow::JsrSet::JsrSet(Arena* arena, int default_len) {
59 if (arena != NULL) {
60 // Allocate growable array in Arena.
61 _set = new (arena) GrowableArray<JsrRecord*>(arena, default_len, 0, NULL);
2632 root_head->set_pre_order(0);
2633 root_head->set_post_order(0);
2634 root_tail->set_pre_order(max_jint);
2635 root_tail->set_post_order(max_jint);
2636 set_loop_tree_root(new (arena()) Loop(root_head, root_tail));
2637
2638 stk.push(start);
2639
2640 _next_pre_order = 0; // initialize pre_order counter
2641 _rpo_list = NULL;
2642 int next_po = 0; // initialize post_order counter
2643
2644 // Compute RPO and the control flow graph
2645 int size;
2646 while ((size = stk.length()) > 0) {
2647 Block* blk = stk.top(); // Leave node on stack
2648 if (!blk->is_visited()) {
2649 // forward arc in graph
2650 assert (!blk->has_pre_order(), "");
2651 blk->set_next_pre_order();
2652 #ifdef COMPILER2
2653 if (_next_pre_order >= (int)Compile::current()->max_node_limit() / 2) {
2654 // Too many basic blocks. Bail out.
2655 // This can happen when try/finally constructs are nested to depth N,
2656 // and there is O(2**N) cloning of jsr bodies. See bug 4697245!
2657 // "MaxNodeLimit / 2" is used because probably the parser will
2658 // generate at least twice that many nodes and bail out.
2659 record_failure("too many basic blocks");
2660 return;
2661 }
2662 #endif
2663 if (do_flow) {
2664 flow_block(blk, temp_vector, temp_set);
2665 if (failing()) return; // Watch for bailouts.
2666 }
2667 } else if (!blk->is_post_visited()) {
2668 // cross or back arc
2669 for (SuccIter iter(blk); !iter.done(); iter.next()) {
2670 Block* succ = iter.succ();
2671 if (!succ->is_visited()) {
2672 stk.push(succ);
2673 }
2674 }
2675 if (stk.length() == size) {
2676 // There were no additional children, post visit node now
2677 stk.pop(); // Remove node from stack
2678
2679 build_loop_tree(blk);
2680 blk->set_post_order(next_po++); // Assign post order
2681 prepend_to_rpo_list(blk);
2682 assert(blk->is_post_visited(), "");
|