@@ -160,6 +160,11 @@ CallNode* PhaseMacroExpand::make_slow_call(CallNode *oldcall, const TypeFunc* sl
160160void PhaseMacroExpand::eliminate_gc_barrier (Node* p2x) {
161161 BarrierSetC2 *bs = BarrierSet::barrier_set ()->barrier_set_c2 ();
162162 bs->eliminate_gc_barrier (this , p2x);
163+ #ifndef PRODUCT
164+ if (PrintOptoStatistics) {
165+ Atomic::inc (&PhaseMacroExpand::_GC_barriers_removed_counter);
166+ }
167+ #endif
163168}
164169
165170// Search for a memory operation for the specified memory slice.
@@ -2339,6 +2344,7 @@ void PhaseMacroExpand::expand_subtypecheck_node(SubTypeCheckNode *check) {
23392344void PhaseMacroExpand::eliminate_macro_nodes () {
23402345 if (C->macro_count () == 0 )
23412346 return ;
2347+ NOT_PRODUCT (int membar_before = count_MemBar (C);)
23422348
23432349 // Before elimination may re-mark (change to Nested or NonEscObj)
23442350 // all associated (same box and obj) lock and unlock nodes.
@@ -2364,6 +2370,11 @@ void PhaseMacroExpand::eliminate_macro_nodes() {
23642370 DEBUG_ONLY (int old_macro_count = C->macro_count ();)
23652371 if (n->is_AbstractLock ()) {
23662372 success = eliminate_locking_node (n->as_AbstractLock ());
2373+ #ifndef PRODUCT
2374+ if (success && PrintOptoStatistics) {
2375+ Atomic::inc (&PhaseMacroExpand::_monitor_objects_removed_counter);
2376+ }
2377+ #endif
23672378 }
23682379 assert (success == (C->macro_count () < old_macro_count), " elimination reduces macro count" );
23692380 progress = progress || success;
@@ -2382,6 +2393,11 @@ void PhaseMacroExpand::eliminate_macro_nodes() {
23822393 case Node::Class_Allocate:
23832394 case Node::Class_AllocateArray:
23842395 success = eliminate_allocate_node (n->as_Allocate ());
2396+ #ifndef PRODUCT
2397+ if (success && PrintOptoStatistics) {
2398+ Atomic::inc (&PhaseMacroExpand::_objs_scalar_replaced_counter);
2399+ }
2400+ #endif
23852401 break ;
23862402 case Node::Class_CallStaticJava:
23872403 success = eliminate_boxing_node (n->as_CallStaticJava ());
@@ -2411,6 +2427,12 @@ void PhaseMacroExpand::eliminate_macro_nodes() {
24112427 progress = progress || success;
24122428 }
24132429 }
2430+ #ifndef PRODUCT
2431+ if (PrintOptoStatistics) {
2432+ int membar_after = count_MemBar (C);
2433+ Atomic::add (&PhaseMacroExpand::_memory_barriers_removed_counter, membar_before - membar_after);
2434+ }
2435+ #endif
24142436}
24152437
24162438// ------------------------------expand_macro_nodes----------------------
@@ -2599,3 +2621,38 @@ bool PhaseMacroExpand::expand_macro_nodes() {
25992621 _igvn.set_delay_transform (false );
26002622 return false ;
26012623}
2624+
2625+ #ifndef PRODUCT
2626+ int PhaseMacroExpand::_objs_scalar_replaced_counter = 0 ;
2627+ int PhaseMacroExpand::_monitor_objects_removed_counter = 0 ;
2628+ int PhaseMacroExpand::_GC_barriers_removed_counter = 0 ;
2629+ int PhaseMacroExpand::_memory_barriers_removed_counter = 0 ;
2630+
2631+ void PhaseMacroExpand::print_statistics () {
2632+ tty->print (" Objects scalar replaced = %d, " , Atomic::load (&_objs_scalar_replaced_counter));
2633+ tty->print (" Monitor objects removed = %d, " , Atomic::load (&_monitor_objects_removed_counter));
2634+ tty->print (" GC barriers removed = %d, " , Atomic::load (&_GC_barriers_removed_counter));
2635+ tty->print_cr (" Memory barriers removed = %d" , Atomic::load (&_memory_barriers_removed_counter));
2636+ }
2637+
2638+ int PhaseMacroExpand::count_MemBar (Compile *C) {
2639+ if (!PrintOptoStatistics) {
2640+ return 0 ;
2641+ }
2642+ Unique_Node_List ideal_nodes;
2643+ int total = 0 ;
2644+ ideal_nodes.map (C->live_nodes (), NULL );
2645+ ideal_nodes.push (C->root ());
2646+ for (uint next = 0 ; next < ideal_nodes.size (); ++next) {
2647+ Node* n = ideal_nodes.at (next);
2648+ if (n->is_MemBar ()) {
2649+ total++;
2650+ }
2651+ for (DUIterator_Fast imax, i = n->fast_outs (imax); i < imax; i++) {
2652+ Node* m = n->fast_out (i);
2653+ ideal_nodes.push (m);
2654+ }
2655+ }
2656+ return total;
2657+ }
2658+ #endif
0 commit comments