@@ -119,38 +119,34 @@ class IntrinsicDescPair {
119119};
120120int Compile::intrinsic_insertion_index (ciMethod* m, bool is_virtual, bool & found) {
121121#ifdef ASSERT
122- for (int i = 1 ; i < _intrinsics-> length (); i++) {
123- CallGenerator* cg1 = _intrinsics-> at (i-1 );
124- CallGenerator* cg2 = _intrinsics-> at (i);
122+ for (int i = 1 ; i < _intrinsics. length (); i++) {
123+ CallGenerator* cg1 = _intrinsics. at (i-1 );
124+ CallGenerator* cg2 = _intrinsics. at (i);
125125 assert (cg1->method () != cg2->method ()
126126 ? cg1->method () < cg2->method ()
127127 : cg1->is_virtual () < cg2->is_virtual (),
128128 " compiler intrinsics list must stay sorted" );
129129 }
130130#endif
131131 IntrinsicDescPair pair (m, is_virtual);
132- return _intrinsics-> find_sorted <IntrinsicDescPair*, IntrinsicDescPair::compare>(&pair, found);
132+ return _intrinsics. find_sorted <IntrinsicDescPair*, IntrinsicDescPair::compare>(&pair, found);
133133}
134134
135135void Compile::register_intrinsic (CallGenerator* cg) {
136- if (_intrinsics == NULL ) {
137- _intrinsics = new (comp_arena ())GrowableArray<CallGenerator*>(comp_arena (), 60 , 0 , NULL );
138- }
139- int len = _intrinsics->length ();
140136 bool found = false ;
141137 int index = intrinsic_insertion_index (cg->method (), cg->is_virtual (), found);
142138 assert (!found, " registering twice" );
143- _intrinsics-> insert_before (index, cg);
139+ _intrinsics. insert_before (index, cg);
144140 assert (find_intrinsic (cg->method (), cg->is_virtual ()) == cg, " registration worked" );
145141}
146142
147143CallGenerator* Compile::find_intrinsic (ciMethod* m, bool is_virtual) {
148144 assert (m->is_loaded (), " don't try this on unloaded methods" );
149- if (_intrinsics != NULL ) {
145+ if (_intrinsics. length () > 0 ) {
150146 bool found = false ;
151147 int index = intrinsic_insertion_index (m, is_virtual, found);
152148 if (found) {
153- return _intrinsics-> at (index);
149+ return _intrinsics. at (index);
154150 }
155151 }
156152 // Lazily create intrinsics for intrinsic IDs well-known in the runtime.
@@ -168,9 +164,7 @@ CallGenerator* Compile::find_intrinsic(ciMethod* m, bool is_virtual) {
168164 return NULL ;
169165}
170166
171- // Compile:: register_library_intrinsics and make_vm_intrinsic are defined
172- // in library_call.cpp.
173-
167+ // Compile::make_vm_intrinsic is defined in library_call.cpp.
174168
175169#ifndef PRODUCT
176170// statistics gathering...
@@ -352,6 +346,15 @@ void Compile::remove_useless_late_inlines(GrowableArray<CallGenerator*>* inlines
352346 inlines->trunc_to (inlines->length ()-shift);
353347}
354348
349+ void Compile::remove_useless_nodes (GrowableArray<Node*>& node_list, Unique_Node_List& useful) {
350+ for (int i = node_list.length () - 1 ; i >= 0 ; i--) {
351+ Node* n = node_list.at (i);
352+ if (!useful.member (n)) {
353+ node_list.remove_if_existing (n);
354+ }
355+ }
356+ }
357+
355358// Disconnect all useless nodes by disconnecting those at the boundary.
356359void Compile::remove_useless_nodes (Unique_Node_List &useful) {
357360 uint next = 0 ;
@@ -366,7 +369,7 @@ void Compile::remove_useless_nodes(Unique_Node_List &useful) {
366369 int max = n->outcnt ();
367370 for (int j = 0 ; j < max; ++j) {
368371 Node* child = n->raw_out (j);
369- if (! useful.member (child)) {
372+ if (!useful.member (child)) {
370373 assert (!child->is_top () || child != top (),
371374 " If top is cached in Compile object it is in useful list" );
372375 // Only need to remove this out-edge to the useless node
@@ -379,34 +382,12 @@ void Compile::remove_useless_nodes(Unique_Node_List &useful) {
379382 record_for_igvn (n->unique_out ());
380383 }
381384 }
382- // Remove useless macro and predicate opaq nodes
383- for (int i = C->macro_count ()-1 ; i >= 0 ; i--) {
384- Node* n = C->macro_node (i);
385- if (!useful.member (n)) {
386- remove_macro_node (n);
387- }
388- }
389- // Remove useless CastII nodes with range check dependency
390- for (int i = range_check_cast_count () - 1 ; i >= 0 ; i--) {
391- Node* cast = range_check_cast_node (i);
392- if (!useful.member (cast)) {
393- remove_range_check_cast (cast);
394- }
395- }
396- // Remove useless expensive nodes
397- for (int i = C->expensive_count ()-1 ; i >= 0 ; i--) {
398- Node* n = C->expensive_node (i);
399- if (!useful.member (n)) {
400- remove_expensive_node (n);
401- }
402- }
403- // Remove useless Opaque4 nodes
404- for (int i = opaque4_count () - 1 ; i >= 0 ; i--) {
405- Node* opaq = opaque4_node (i);
406- if (!useful.member (opaq)) {
407- remove_opaque4_node (opaq);
408- }
409- }
385+
386+ remove_useless_nodes (_macro_nodes, useful); // remove useless macro and predicate opaq nodes
387+ remove_useless_nodes (_expensive_nodes, useful); // remove useless expensive nodes
388+ remove_useless_nodes (_range_check_casts, useful); // remove useless CastII nodes with range check dependency
389+ remove_useless_nodes (_opaque4_nodes, useful); // remove useless Opaque4 nodes
390+
410391 BarrierSetC2* bs = BarrierSet::barrier_set ()->barrier_set_c2 ();
411392 bs->eliminate_useless_gc_barriers (useful, this );
412393 // clean up the late inline lists
@@ -533,6 +514,12 @@ Compile::Compile( ciEnv* ci_env, ciMethod* target, int osr_bci,
533514 _directive(directive),
534515 _log(ci_env->log ()),
535516 _failure_reason(NULL ),
517+ _intrinsics (comp_arena(), 0, 0, NULL),
518+ _macro_nodes (comp_arena(), 8, 0, NULL),
519+ _predicate_opaqs (comp_arena(), 8, 0, NULL),
520+ _expensive_nodes (comp_arena(), 8, 0, NULL),
521+ _range_check_casts (comp_arena(), 8, 0, NULL),
522+ _opaque4_nodes (comp_arena(), 8, 0, NULL),
536523 _congraph(NULL ),
537524 NOT_PRODUCT(_printer(NULL ) COMMA)
538525 _dead_node_list(comp_arena()),
@@ -1015,13 +1002,6 @@ void Compile::Init(int aliaslevel) {
10151002 // A NULL adr_type hits in the cache right away. Preload the right answer.
10161003 probe_alias_cache (NULL )->_index = AliasIdxTop;
10171004
1018- _intrinsics = NULL ;
1019- _macro_nodes = new (comp_arena ()) GrowableArray<Node*>(comp_arena (), 8 , 0 , NULL );
1020- _predicate_opaqs = new (comp_arena ()) GrowableArray<Node*>(comp_arena (), 8 , 0 , NULL );
1021- _expensive_nodes = new (comp_arena ()) GrowableArray<Node*>(comp_arena (), 8 , 0 , NULL );
1022- _range_check_casts = new (comp_arena ()) GrowableArray<Node*>(comp_arena (), 8 , 0 , NULL );
1023- _opaque4_nodes = new (comp_arena ()) GrowableArray<Node*>(comp_arena (), 8 , 0 , NULL );
1024- register_library_intrinsics ();
10251005#ifdef ASSERT
10261006 _type_verify_symmetry = true ;
10271007 _phase_optimize_finished = false ;
@@ -1794,8 +1774,8 @@ void Compile::cleanup_loop_predicates(PhaseIterGVN &igvn) {
17941774
17951775void Compile::add_range_check_cast (Node* n) {
17961776 assert (n->isa_CastII ()->has_range_check (), " CastII should have range check dependency" );
1797- assert (!_range_check_casts-> contains (n), " duplicate entry in range check casts" );
1798- _range_check_casts-> append (n);
1777+ assert (!_range_check_casts. contains (n), " duplicate entry in range check casts" );
1778+ _range_check_casts. append (n);
17991779}
18001780
18011781// Remove all range check dependent CastIINodes.
@@ -1810,8 +1790,8 @@ void Compile::remove_range_check_casts(PhaseIterGVN &igvn) {
18101790
18111791void Compile::add_opaque4_node (Node* n) {
18121792 assert (n->Opcode () == Op_Opaque4, " Opaque4 only" );
1813- assert (!_opaque4_nodes-> contains (n), " duplicate entry in Opaque4 list" );
1814- _opaque4_nodes-> append (n);
1793+ assert (!_opaque4_nodes. contains (n), " duplicate entry in Opaque4 list" );
1794+ _opaque4_nodes. append (n);
18151795}
18161796
18171797// Remove all Opaque4 nodes.
@@ -1988,9 +1968,9 @@ void Compile::inline_incrementally(PhaseIterGVN& igvn) {
19881968
19891969
19901970bool Compile::optimize_loops (PhaseIterGVN& igvn, LoopOptsMode mode) {
1991- if (_loop_opts_cnt > 0 ) {
1971+ if (_loop_opts_cnt > 0 ) {
19921972 debug_only ( int cnt = 0 ; );
1993- while (major_progress () && (_loop_opts_cnt > 0 )) {
1973+ while (major_progress () && (_loop_opts_cnt > 0 )) {
19941974 TracePhase tp (" idealLoop" , &timers[_t_idealLoop]);
19951975 assert ( cnt++ < 40 , " infinite cycle in loop optimization" );
19961976 PhaseIdealLoop::optimize (igvn, mode);
@@ -2273,6 +2253,7 @@ void Compile::Optimize() {
22732253 }
22742254
22752255 DEBUG_ONLY ( _modified_nodes = NULL ; )
2256+ assert (igvn._worklist .size () == 0 , " not empty" );
22762257 } // (End scope of igvn; run destructor if necessary for asserts.)
22772258
22782259 process_print_inlining ();
@@ -3683,7 +3664,7 @@ bool Compile::final_graph_reshaping() {
36833664 // be freely moved to the least frequent code path by gcm.
36843665 assert (OptimizeExpensiveOps || expensive_count () == 0 , " optimization off but list non empty?" );
36853666 for (int i = 0 ; i < expensive_count (); i++) {
3686- _expensive_nodes-> at (i)->set_req (0 , NULL );
3667+ _expensive_nodes. at (i)->set_req (0 , NULL );
36873668 }
36883669
36893670 Final_Reshape_Counts frc;
@@ -4335,45 +4316,45 @@ int Compile::cmp_expensive_nodes(Node** n1p, Node** n2p) {
43354316
43364317void Compile::sort_expensive_nodes () {
43374318 if (!expensive_nodes_sorted ()) {
4338- _expensive_nodes-> sort (cmp_expensive_nodes);
4319+ _expensive_nodes. sort (cmp_expensive_nodes);
43394320 }
43404321}
43414322
43424323bool Compile::expensive_nodes_sorted () const {
4343- for (int i = 1 ; i < _expensive_nodes-> length (); i++) {
4344- if (cmp_expensive_nodes (_expensive_nodes-> adr_at (i), _expensive_nodes-> adr_at (i-1 )) < 0 ) {
4324+ for (int i = 1 ; i < _expensive_nodes. length (); i++) {
4325+ if (cmp_expensive_nodes (_expensive_nodes. adr_at (i), _expensive_nodes. adr_at (i-1 )) < 0 ) {
43454326 return false ;
43464327 }
43474328 }
43484329 return true ;
43494330}
43504331
43514332bool Compile::should_optimize_expensive_nodes (PhaseIterGVN &igvn) {
4352- if (_expensive_nodes-> length () == 0 ) {
4333+ if (_expensive_nodes. length () == 0 ) {
43534334 return false ;
43544335 }
43554336
43564337 assert (OptimizeExpensiveOps, " optimization off?" );
43574338
43584339 // Take this opportunity to remove dead nodes from the list
43594340 int j = 0 ;
4360- for (int i = 0 ; i < _expensive_nodes-> length (); i++) {
4361- Node* n = _expensive_nodes-> at (i);
4341+ for (int i = 0 ; i < _expensive_nodes. length (); i++) {
4342+ Node* n = _expensive_nodes. at (i);
43624343 if (!n->is_unreachable (igvn)) {
43634344 assert (n->is_expensive (), " should be expensive" );
4364- _expensive_nodes-> at_put (j, n);
4345+ _expensive_nodes. at_put (j, n);
43654346 j++;
43664347 }
43674348 }
4368- _expensive_nodes-> trunc_to (j);
4349+ _expensive_nodes. trunc_to (j);
43694350
43704351 // Then sort the list so that similar nodes are next to each other
43714352 // and check for at least two nodes of identical kind with same data
43724353 // inputs.
43734354 sort_expensive_nodes ();
43744355
4375- for (int i = 0 ; i < _expensive_nodes-> length ()-1 ; i++) {
4376- if (cmp_expensive_nodes (_expensive_nodes-> adr_at (i), _expensive_nodes-> adr_at (i+1 )) == 0 ) {
4356+ for (int i = 0 ; i < _expensive_nodes. length ()-1 ; i++) {
4357+ if (cmp_expensive_nodes (_expensive_nodes. adr_at (i), _expensive_nodes. adr_at (i+1 )) == 0 ) {
43774358 return true ;
43784359 }
43794360 }
@@ -4382,7 +4363,7 @@ bool Compile::should_optimize_expensive_nodes(PhaseIterGVN &igvn) {
43824363}
43834364
43844365void Compile::cleanup_expensive_nodes (PhaseIterGVN &igvn) {
4385- if (_expensive_nodes-> length () == 0 ) {
4366+ if (_expensive_nodes. length () == 0 ) {
43864367 return ;
43874368 }
43884369
@@ -4396,43 +4377,43 @@ void Compile::cleanup_expensive_nodes(PhaseIterGVN &igvn) {
43964377 int identical = 0 ;
43974378 int i = 0 ;
43984379 bool modified = false ;
4399- for (; i < _expensive_nodes-> length ()-1 ; i++) {
4380+ for (; i < _expensive_nodes. length ()-1 ; i++) {
44004381 assert (j <= i, " can't write beyond current index" );
4401- if (_expensive_nodes-> at (i)->Opcode () == _expensive_nodes-> at (i+1 )->Opcode ()) {
4382+ if (_expensive_nodes. at (i)->Opcode () == _expensive_nodes. at (i+1 )->Opcode ()) {
44024383 identical++;
4403- _expensive_nodes-> at_put (j++, _expensive_nodes-> at (i));
4384+ _expensive_nodes. at_put (j++, _expensive_nodes. at (i));
44044385 continue ;
44054386 }
44064387 if (identical > 0 ) {
4407- _expensive_nodes-> at_put (j++, _expensive_nodes-> at (i));
4388+ _expensive_nodes. at_put (j++, _expensive_nodes. at (i));
44084389 identical = 0 ;
44094390 } else {
4410- Node* n = _expensive_nodes-> at (i);
4391+ Node* n = _expensive_nodes. at (i);
44114392 igvn.replace_input_of (n, 0 , NULL );
44124393 igvn.hash_insert (n);
44134394 modified = true ;
44144395 }
44154396 }
44164397 if (identical > 0 ) {
4417- _expensive_nodes-> at_put (j++, _expensive_nodes-> at (i));
4418- } else if (_expensive_nodes-> length () >= 1 ) {
4419- Node* n = _expensive_nodes-> at (i);
4398+ _expensive_nodes. at_put (j++, _expensive_nodes. at (i));
4399+ } else if (_expensive_nodes. length () >= 1 ) {
4400+ Node* n = _expensive_nodes. at (i);
44204401 igvn.replace_input_of (n, 0 , NULL );
44214402 igvn.hash_insert (n);
44224403 modified = true ;
44234404 }
4424- _expensive_nodes-> trunc_to (j);
4405+ _expensive_nodes. trunc_to (j);
44254406 if (modified) {
44264407 igvn.optimize ();
44274408 }
44284409}
44294410
44304411void Compile::add_expensive_node (Node * n) {
4431- assert (!_expensive_nodes-> contains (n), " duplicate entry in expensive list" );
4412+ assert (!_expensive_nodes. contains (n), " duplicate entry in expensive list" );
44324413 assert (n->is_expensive (), " expensive nodes with non-null control here only" );
44334414 assert (!n->is_CFG () && !n->is_Mem (), " no cfg or memory nodes here" );
44344415 if (OptimizeExpensiveOps) {
4435- _expensive_nodes-> append (n);
4416+ _expensive_nodes. append (n);
44364417 } else {
44374418 // Clear control input and let IGVN optimize expensive nodes if
44384419 // OptimizeExpensiveOps is off.
@@ -4610,8 +4591,8 @@ void Compile::sort_macro_nodes() {
46104591 if (n->is_Allocate ()) {
46114592 if (i != allocates) {
46124593 Node* tmp = macro_node (allocates);
4613- _macro_nodes-> at_put (allocates, n);
4614- _macro_nodes-> at_put (i, tmp);
4594+ _macro_nodes. at_put (allocates, n);
4595+ _macro_nodes. at_put (i, tmp);
46154596 }
46164597 allocates++;
46174598 }
0 commit comments