@@ -119,38 +119,34 @@ class IntrinsicDescPair {
119
119
};
120
120
int Compile::intrinsic_insertion_index (ciMethod* m, bool is_virtual, bool & found) {
121
121
#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);
125
125
assert (cg1->method () != cg2->method ()
126
126
? cg1->method () < cg2->method ()
127
127
: cg1->is_virtual () < cg2->is_virtual (),
128
128
" compiler intrinsics list must stay sorted" );
129
129
}
130
130
#endif
131
131
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);
133
133
}
134
134
135
135
void 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 ();
140
136
bool found = false ;
141
137
int index = intrinsic_insertion_index (cg->method (), cg->is_virtual (), found);
142
138
assert (!found, " registering twice" );
143
- _intrinsics-> insert_before (index , cg);
139
+ _intrinsics. insert_before (index , cg);
144
140
assert (find_intrinsic (cg->method (), cg->is_virtual ()) == cg, " registration worked" );
145
141
}
146
142
147
143
CallGenerator* Compile::find_intrinsic (ciMethod* m, bool is_virtual) {
148
144
assert (m->is_loaded (), " don't try this on unloaded methods" );
149
- if (_intrinsics != NULL ) {
145
+ if (_intrinsics. length () > 0 ) {
150
146
bool found = false ;
151
147
int index = intrinsic_insertion_index (m, is_virtual, found);
152
148
if (found) {
153
- return _intrinsics-> at (index );
149
+ return _intrinsics. at (index );
154
150
}
155
151
}
156
152
// Lazily create intrinsics for intrinsic IDs well-known in the runtime.
@@ -168,9 +164,7 @@ CallGenerator* Compile::find_intrinsic(ciMethod* m, bool is_virtual) {
168
164
return NULL ;
169
165
}
170
166
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.
174
168
175
169
#ifndef PRODUCT
176
170
// statistics gathering...
@@ -352,6 +346,15 @@ void Compile::remove_useless_late_inlines(GrowableArray<CallGenerator*>* inlines
352
346
inlines->trunc_to (inlines->length ()-shift);
353
347
}
354
348
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
+
355
358
// Disconnect all useless nodes by disconnecting those at the boundary.
356
359
void Compile::remove_useless_nodes (Unique_Node_List &useful) {
357
360
uint next = 0 ;
@@ -366,7 +369,7 @@ void Compile::remove_useless_nodes(Unique_Node_List &useful) {
366
369
int max = n->outcnt ();
367
370
for (int j = 0 ; j < max; ++j) {
368
371
Node* child = n->raw_out (j);
369
- if (! useful.member (child)) {
372
+ if (!useful.member (child)) {
370
373
assert (!child->is_top () || child != top (),
371
374
" If top is cached in Compile object it is in useful list" );
372
375
// Only need to remove this out-edge to the useless node
@@ -379,34 +382,12 @@ void Compile::remove_useless_nodes(Unique_Node_List &useful) {
379
382
record_for_igvn (n->unique_out ());
380
383
}
381
384
}
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
+
410
391
BarrierSetC2* bs = BarrierSet::barrier_set ()->barrier_set_c2 ();
411
392
bs->eliminate_useless_gc_barriers (useful, this );
412
393
// clean up the late inline lists
@@ -533,6 +514,12 @@ Compile::Compile( ciEnv* ci_env, ciMethod* target, int osr_bci,
533
514
_directive(directive),
534
515
_log(ci_env->log ()),
535
516
_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),
536
523
_congraph(NULL ),
537
524
NOT_PRODUCT(_printer(NULL ) COMMA)
538
525
_dead_node_list(comp_arena()),
@@ -1015,13 +1002,6 @@ void Compile::Init(int aliaslevel) {
1015
1002
// A NULL adr_type hits in the cache right away. Preload the right answer.
1016
1003
probe_alias_cache (NULL )->_index = AliasIdxTop;
1017
1004
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 ();
1025
1005
#ifdef ASSERT
1026
1006
_type_verify_symmetry = true ;
1027
1007
_phase_optimize_finished = false ;
@@ -1794,8 +1774,8 @@ void Compile::cleanup_loop_predicates(PhaseIterGVN &igvn) {
1794
1774
1795
1775
void Compile::add_range_check_cast (Node* n) {
1796
1776
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);
1799
1779
}
1800
1780
1801
1781
// Remove all range check dependent CastIINodes.
@@ -1810,8 +1790,8 @@ void Compile::remove_range_check_casts(PhaseIterGVN &igvn) {
1810
1790
1811
1791
void Compile::add_opaque4_node (Node* n) {
1812
1792
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);
1815
1795
}
1816
1796
1817
1797
// Remove all Opaque4 nodes.
@@ -1988,9 +1968,9 @@ void Compile::inline_incrementally(PhaseIterGVN& igvn) {
1988
1968
1989
1969
1990
1970
bool Compile::optimize_loops (PhaseIterGVN& igvn, LoopOptsMode mode) {
1991
- if (_loop_opts_cnt > 0 ) {
1971
+ if (_loop_opts_cnt > 0 ) {
1992
1972
debug_only ( int cnt = 0 ; );
1993
- while (major_progress () && (_loop_opts_cnt > 0 )) {
1973
+ while (major_progress () && (_loop_opts_cnt > 0 )) {
1994
1974
TracePhase tp (" idealLoop" , &timers[_t_idealLoop]);
1995
1975
assert ( cnt++ < 40 , " infinite cycle in loop optimization" );
1996
1976
PhaseIdealLoop::optimize (igvn, mode);
@@ -2273,6 +2253,7 @@ void Compile::Optimize() {
2273
2253
}
2274
2254
2275
2255
DEBUG_ONLY ( _modified_nodes = NULL ; )
2256
+ assert (igvn._worklist .size () == 0 , " not empty" );
2276
2257
} // (End scope of igvn; run destructor if necessary for asserts.)
2277
2258
2278
2259
process_print_inlining ();
@@ -3683,7 +3664,7 @@ bool Compile::final_graph_reshaping() {
3683
3664
// be freely moved to the least frequent code path by gcm.
3684
3665
assert (OptimizeExpensiveOps || expensive_count () == 0 , " optimization off but list non empty?" );
3685
3666
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 );
3687
3668
}
3688
3669
3689
3670
Final_Reshape_Counts frc;
@@ -4335,45 +4316,45 @@ int Compile::cmp_expensive_nodes(Node** n1p, Node** n2p) {
4335
4316
4336
4317
void Compile::sort_expensive_nodes () {
4337
4318
if (!expensive_nodes_sorted ()) {
4338
- _expensive_nodes-> sort (cmp_expensive_nodes);
4319
+ _expensive_nodes. sort (cmp_expensive_nodes);
4339
4320
}
4340
4321
}
4341
4322
4342
4323
bool 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 ) {
4345
4326
return false ;
4346
4327
}
4347
4328
}
4348
4329
return true ;
4349
4330
}
4350
4331
4351
4332
bool Compile::should_optimize_expensive_nodes (PhaseIterGVN &igvn) {
4352
- if (_expensive_nodes-> length () == 0 ) {
4333
+ if (_expensive_nodes. length () == 0 ) {
4353
4334
return false ;
4354
4335
}
4355
4336
4356
4337
assert (OptimizeExpensiveOps, " optimization off?" );
4357
4338
4358
4339
// Take this opportunity to remove dead nodes from the list
4359
4340
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);
4362
4343
if (!n->is_unreachable (igvn)) {
4363
4344
assert (n->is_expensive (), " should be expensive" );
4364
- _expensive_nodes-> at_put (j, n);
4345
+ _expensive_nodes. at_put (j, n);
4365
4346
j++;
4366
4347
}
4367
4348
}
4368
- _expensive_nodes-> trunc_to (j);
4349
+ _expensive_nodes. trunc_to (j);
4369
4350
4370
4351
// Then sort the list so that similar nodes are next to each other
4371
4352
// and check for at least two nodes of identical kind with same data
4372
4353
// inputs.
4373
4354
sort_expensive_nodes ();
4374
4355
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 ) {
4377
4358
return true ;
4378
4359
}
4379
4360
}
@@ -4382,7 +4363,7 @@ bool Compile::should_optimize_expensive_nodes(PhaseIterGVN &igvn) {
4382
4363
}
4383
4364
4384
4365
void Compile::cleanup_expensive_nodes (PhaseIterGVN &igvn) {
4385
- if (_expensive_nodes-> length () == 0 ) {
4366
+ if (_expensive_nodes. length () == 0 ) {
4386
4367
return ;
4387
4368
}
4388
4369
@@ -4396,43 +4377,43 @@ void Compile::cleanup_expensive_nodes(PhaseIterGVN &igvn) {
4396
4377
int identical = 0 ;
4397
4378
int i = 0 ;
4398
4379
bool modified = false ;
4399
- for (; i < _expensive_nodes-> length ()-1 ; i++) {
4380
+ for (; i < _expensive_nodes. length ()-1 ; i++) {
4400
4381
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 ()) {
4402
4383
identical++;
4403
- _expensive_nodes-> at_put (j++, _expensive_nodes-> at (i));
4384
+ _expensive_nodes. at_put (j++, _expensive_nodes. at (i));
4404
4385
continue ;
4405
4386
}
4406
4387
if (identical > 0 ) {
4407
- _expensive_nodes-> at_put (j++, _expensive_nodes-> at (i));
4388
+ _expensive_nodes. at_put (j++, _expensive_nodes. at (i));
4408
4389
identical = 0 ;
4409
4390
} else {
4410
- Node* n = _expensive_nodes-> at (i);
4391
+ Node* n = _expensive_nodes. at (i);
4411
4392
igvn.replace_input_of (n, 0 , NULL );
4412
4393
igvn.hash_insert (n);
4413
4394
modified = true ;
4414
4395
}
4415
4396
}
4416
4397
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);
4420
4401
igvn.replace_input_of (n, 0 , NULL );
4421
4402
igvn.hash_insert (n);
4422
4403
modified = true ;
4423
4404
}
4424
- _expensive_nodes-> trunc_to (j);
4405
+ _expensive_nodes. trunc_to (j);
4425
4406
if (modified) {
4426
4407
igvn.optimize ();
4427
4408
}
4428
4409
}
4429
4410
4430
4411
void 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" );
4432
4413
assert (n->is_expensive (), " expensive nodes with non-null control here only" );
4433
4414
assert (!n->is_CFG () && !n->is_Mem (), " no cfg or memory nodes here" );
4434
4415
if (OptimizeExpensiveOps) {
4435
- _expensive_nodes-> append (n);
4416
+ _expensive_nodes. append (n);
4436
4417
} else {
4437
4418
// Clear control input and let IGVN optimize expensive nodes if
4438
4419
// OptimizeExpensiveOps is off.
@@ -4610,8 +4591,8 @@ void Compile::sort_macro_nodes() {
4610
4591
if (n->is_Allocate ()) {
4611
4592
if (i != allocates) {
4612
4593
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);
4615
4596
}
4616
4597
allocates++;
4617
4598
}
0 commit comments