Exemplo n.º 1
0
size_t ParallelScavengeHeap::max_capacity() const {
  size_t estimated = reserved_region().byte_size();
  if (UseAdaptiveSizePolicy) {
    estimated -= _size_policy->max_survivor_size(young_gen()->max_size());
  } else {
    estimated -= young_gen()->to_space()->capacity_in_bytes();
  }
  return MAX2(estimated, capacity());
}
Exemplo n.º 2
0
jint ParallelScavengeHeap::initialize() {
  CollectedHeap::pre_initialize();

  const size_t heap_size = _collector_policy->max_heap_byte_size();

  ReservedSpace heap_rs = Universe::reserve_heap(heap_size, _collector_policy->heap_alignment());

  os::trace_page_sizes("Heap",
                       _collector_policy->min_heap_byte_size(),
                       heap_size,
                       generation_alignment(),
                       heap_rs.base(),
                       heap_rs.size());

  initialize_reserved_region((HeapWord*)heap_rs.base(), (HeapWord*)(heap_rs.base() + heap_rs.size()));

  CardTableExtension* const barrier_set = new CardTableExtension(reserved_region());
  barrier_set->initialize();
  set_barrier_set(barrier_set);

  // Make up the generations
  // Calculate the maximum size that a generation can grow.  This
  // includes growth into the other generation.  Note that the
  // parameter _max_gen_size is kept as the maximum
  // size of the generation as the boundaries currently stand.
  // _max_gen_size is still used as that value.
  double max_gc_pause_sec = ((double) MaxGCPauseMillis)/1000.0;
  double max_gc_minor_pause_sec = ((double) MaxGCMinorPauseMillis)/1000.0;

  _gens = new AdjoiningGenerations(heap_rs, _collector_policy, generation_alignment());

  _old_gen = _gens->old_gen();
  _young_gen = _gens->young_gen();

  const size_t eden_capacity = _young_gen->eden_space()->capacity_in_bytes();
  const size_t old_capacity = _old_gen->capacity_in_bytes();
  const size_t initial_promo_size = MIN2(eden_capacity, old_capacity);
  _size_policy =
    new PSAdaptiveSizePolicy(eden_capacity,
                             initial_promo_size,
                             young_gen()->to_space()->capacity_in_bytes(),
                             _collector_policy->gen_alignment(),
                             max_gc_pause_sec,
                             max_gc_minor_pause_sec,
                             GCTimeRatio
                             );

  assert(!UseAdaptiveGCBoundary ||
    (old_gen()->virtual_space()->high_boundary() ==
     young_gen()->virtual_space()->low_boundary()),
    "Boundaries must meet");
  // initialize the policy counters - 2 collectors, 3 generations
  _gc_policy_counters =
    new PSGCAdaptivePolicyCounters("ParScav:MSC", 2, 3, _size_policy);

  // Set up the GCTaskManager
  _gc_task_manager = GCTaskManager::create(ParallelGCThreads);

  if (UseParallelOldGC && !PSParallelCompact::initialize()) {
    return JNI_ENOMEM;
  }

  return JNI_OK;
}
Exemplo n.º 3
0
inline uint G1CollectedHeap::addr_to_region(HeapWord* addr) const {
  assert(is_in_reserved(addr),
         err_msg("Cannot calculate region index for address "PTR_FORMAT" that is outside of the heap ["PTR_FORMAT", "PTR_FORMAT")",
                 p2i(addr), p2i(reserved_region().start()), p2i(reserved_region().end())));
  return (uint)(pointer_delta(addr, reserved_region().start(), sizeof(uint8_t)) >> HeapRegion::LogOfHRGrainBytes);
}
Exemplo n.º 4
0
VirtualSpaceSummary CollectedHeap::create_heap_space_summary() {
  size_t capacity_in_words = capacity() / HeapWordSize;

  return VirtualSpaceSummary(
    reserved_region().start(), reserved_region().start() + capacity_in_words, reserved_region().end());
}
jint ParallelScavengeHeap::initialize() {
  CollectedHeap::pre_initialize();

  const size_t heap_size = _collector_policy->max_heap_byte_size();

  ReservedSpace heap_rs = Universe::reserve_heap(heap_size, _collector_policy->heap_alignment());

  os::trace_page_sizes("ps main", _collector_policy->min_heap_byte_size(),
                       heap_size, generation_alignment(),
                       heap_rs.base(),
                       heap_rs.size());

  initialize_reserved_region((HeapWord*)heap_rs.base(), (HeapWord*)(heap_rs.base() + heap_rs.size()));

  CardTableExtension* const barrier_set = new CardTableExtension(reserved_region());
  barrier_set->initialize();
  set_barrier_set(barrier_set);

  // Make up the generations
  // Calculate the maximum size that a generation can grow.  This
  // includes growth into the other generation.  Note that the
  // parameter _max_gen_size is kept as the maximum
  // size of the generation as the boundaries currently stand.
  // _max_gen_size is still used as that value.
  double max_gc_pause_sec = ((double) MaxGCPauseMillis)/1000.0;
  double max_gc_minor_pause_sec = ((double) MaxGCMinorPauseMillis)/1000.0;

  _gens = new AdjoiningGenerations(heap_rs, _collector_policy, generation_alignment());

  _old_gen = _gens->old_gen();
  _young_gen = _gens->young_gen();

  const size_t eden_capacity = _young_gen->eden_space()->capacity_in_bytes();
  const size_t old_capacity = _old_gen->capacity_in_bytes();
  const size_t initial_promo_size = MIN2(eden_capacity, old_capacity);
  _size_policy =
    new PSAdaptiveSizePolicy(eden_capacity,
                             initial_promo_size,
                             young_gen()->to_space()->capacity_in_bytes(),
                             _collector_policy->gen_alignment(),
                             max_gc_pause_sec,
                             max_gc_minor_pause_sec,
                             GCTimeRatio
                             );

  assert(!UseAdaptiveGCBoundary ||
    (old_gen()->virtual_space()->high_boundary() ==
     young_gen()->virtual_space()->low_boundary()),
    "Boundaries must meet");
  // initialize the policy counters - 2 collectors, 3 generations
  _gc_policy_counters =
    new PSGCAdaptivePolicyCounters("ParScav:MSC", 2, 3, _size_policy);

  // Set up the GCTaskManager
  _gc_task_manager = GCTaskManager::create(ParallelGCThreads);

  if (UseParallelOldGC && !PSParallelCompact::initialize()) {
    return JNI_ENOMEM;
  }

#ifdef PROFILE_OBJECT_INFO
  if (ProfileObjectInfo) {
    AllocPointInfoTable *apit = new AllocPointInfoTable(AllocPointInfoTable::apit_size);
    guarantee(!apit->allocation_failed(), "apm allocation failed");
    Universe::set_alloc_point_info_table(apit);

    PersistentObjectInfoTable *poit = new PersistentObjectInfoTable(
      PersistentObjectInfoTable::oit_size,
      _perm_gen->object_space()->used_region().start());
    guarantee(!poit->allocation_failed(), "poit allocation failed");
    Universe::set_persistent_object_info_table(poit);
  }
#endif
#ifdef PROFILE_OBJECT_ADDRESS_INFO
  if (ProfileObjectAddressInfo) {
    unsigned int oait_size = OAIT_SIZE;
    unsigned int kt_size = KLASS_TABLE_SIZE;

    KlassRecordTable *krt = new KlassRecordTable(kt_size);
    guarantee(!krt->allocation_failed(), "krt allocation failed");
    Universe::set_klass_record_table(krt);

    AllocPointInfoTable *apit = new AllocPointInfoTable(AllocPointInfoTable::apit_size);
    guarantee(!apit->allocation_failed(), "apit allocation failed");
    Universe::set_alloc_point_info_table(apit);

    ObjectAddressInfoTable *oait = new ObjectAddressInfoTable(oait_size, krt, apit);
    guarantee(!oait->allocation_failed(), "oait allocation failed");
    Universe::set_object_address_info_table(oait);
    ObjectAddressInfoTable *alt_oait = new ObjectAddressInfoTable(oait_size, krt, apit);
    guarantee(!oait->allocation_failed(), "oait allocation failed");
    Universe::set_alt_oait(alt_oait);
  }
#endif

  return JNI_OK;
}