hotspot/src/share/vm/gc_implementation/g1/g1MMUTracker.cpp
changeset 30579 5208524ce05c
parent 30576 463e71cefd8f
equal deleted inserted replaced
30314:3d55863a66ba 30579:5208524ce05c
     1 /*
     1 /*
     2  * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    74   }
    74   }
    75   return gc_time;
    75   return gc_time;
    76 }
    76 }
    77 
    77 
    78 void G1MMUTrackerQueue::add_pause(double start, double end, bool gc_thread) {
    78 void G1MMUTrackerQueue::add_pause(double start, double end, bool gc_thread) {
    79   double longest_allowed = longest_pause_internal(start);
       
    80   if (longest_allowed < 0.0)
       
    81     longest_allowed = 0.0;
       
    82   double duration = end - start;
    79   double duration = end - start;
    83 
    80 
    84   remove_expired_entries(end);
    81   remove_expired_entries(end);
    85   if (_no_entries == QueueLength) {
    82   if (_no_entries == QueueLength) {
    86     // OK, we've filled up the queue. There are a few ways
    83     // OK, we've filled up the queue. There are a few ways
   103   } else {
   100   } else {
   104     _head_index = trim_index(_head_index + 1);
   101     _head_index = trim_index(_head_index + 1);
   105     ++_no_entries;
   102     ++_no_entries;
   106   }
   103   }
   107   _array[_head_index] = G1MMUTrackerQueueElem(start, end);
   104   _array[_head_index] = G1MMUTrackerQueueElem(start, end);
   108 }
       
   109 
       
   110 // basically the _internal call does not remove expired entries
       
   111 // this is for trying things out in the future and a couple
       
   112 // of other places (debugging)
       
   113 
       
   114 double G1MMUTrackerQueue::longest_pause(double current_time) {
       
   115   if (_DISABLE_MMU)
       
   116     return _max_gc_time;
       
   117 
       
   118   MutexLockerEx x(MMUTracker_lock, Mutex::_no_safepoint_check_flag);
       
   119   remove_expired_entries(current_time);
       
   120 
       
   121   return longest_pause_internal(current_time);
       
   122 }
       
   123 
       
   124 double G1MMUTrackerQueue::longest_pause_internal(double current_time) {
       
   125   double target_time = _max_gc_time;
       
   126 
       
   127   while( 1 ) {
       
   128     double gc_time =
       
   129       calculate_gc_time(current_time + target_time);
       
   130     double diff = target_time + gc_time - _max_gc_time;
       
   131     if (!is_double_leq_0(diff)) {
       
   132       target_time -= diff;
       
   133       if (is_double_leq_0(target_time)) {
       
   134         target_time = -1.0;
       
   135         break;
       
   136       }
       
   137     } else {
       
   138       break;
       
   139     }
       
   140   }
       
   141 
       
   142   return target_time;
       
   143 }
   105 }
   144 
   106 
   145 // basically the _internal call does not remove expired entries
   107 // basically the _internal call does not remove expired entries
   146 // this is for trying things out in the future and a couple
   108 // this is for trying things out in the future and a couple
   147 // of other places (debugging)
   109 // of other places (debugging)