bool PSVirtualSpace::expand_by(size_t bytes, bool pre_touch) {
    assert(is_aligned(bytes), "arg not aligned");
    DEBUG_ONLY(PSVirtualSpaceVerifier this_verifier(this));

    if (uncommitted_size() < bytes) {
        return false;
    }

    char* const base_addr = committed_high_addr();
    bool result=os::commit_memory(_account,base_addr,bytes,alignment(),Modules::ParGC_PSVirtualSpace);
    if (result) {
        _committed_high_addr += bytes;
    }

    if (pre_touch || AlwaysPreTouch) {
        for (char* curr = base_addr;
                curr < _committed_high_addr;
                curr += os::vm_page_size()) {
            char tmp = *curr;
            *curr = 0;
        }
    }

    return result;
}
示例#2
0
size_t PSVirtualSpaceHighToLow::expand_into(PSVirtualSpace* other_space,
                                            size_t bytes) {
  assert(is_aligned(bytes), "arg not aligned");
  assert(grows_down(), "this space must grow down");
  assert(other_space->grows_up(), "other space must grow up");
  assert(reserved_low_addr() == other_space->reserved_high_addr(),
         "spaces not contiguous");
  assert(special() == other_space->special(), "one space is special in memory, the other is not");
  DEBUG_ONLY(PSVirtualSpaceVerifier this_verifier(this));
  DEBUG_ONLY(PSVirtualSpaceVerifier other_verifier(other_space));

  size_t bytes_needed = bytes;

  // First use the uncommitted region in this space.
  size_t tmp_bytes = MIN2(uncommitted_size(), bytes_needed);
  if (tmp_bytes > 0) {
    if (expand_by(tmp_bytes)) {
      bytes_needed -= tmp_bytes;
    } else {
      return 0;
    }
  }

  // Next take from the uncommitted region in the other space, and commit it.
  tmp_bytes = MIN2(other_space->uncommitted_size(), bytes_needed);
  if (tmp_bytes > 0) {
    char* const commit_base = committed_low_addr() - tmp_bytes;
    if (other_space->special() ||
        os::commit_memory(commit_base, tmp_bytes, alignment(), !ExecMem)) {
      // Reduce the reserved region in the other space.
      other_space->set_reserved(other_space->reserved_low_addr(),
                                other_space->reserved_high_addr() - tmp_bytes,
                                other_space->special());

      // Grow both reserved and committed in this space.
      _reserved_low_addr -= tmp_bytes;
      _committed_low_addr -= tmp_bytes;
      bytes_needed -= tmp_bytes;
    } else {
      return bytes - bytes_needed;
    }
  }

  // Finally take from the already committed region in the other space.
  tmp_bytes = bytes_needed;
  if (tmp_bytes > 0) {
    // Reduce both committed and reserved in the other space.
    other_space->set_committed(other_space->committed_low_addr(),
                               other_space->committed_high_addr() - tmp_bytes);
    other_space->set_reserved(other_space->reserved_low_addr(),
                              other_space->reserved_high_addr() - tmp_bytes,
                              other_space->special());

    // Grow both reserved and committed in this space.
    _reserved_low_addr -= tmp_bytes;
    _committed_low_addr -= tmp_bytes;
  }

  return bytes;
}
示例#3
0
void PSVirtualSpace::release() {
  DEBUG_ONLY(PSVirtualSpaceVerifier this_verifier(this));
  // This may not release memory it didn't reserve.
  // Use rs.release() to release the underlying memory instead.
  _reserved_low_addr = _reserved_high_addr = NULL;
  _committed_low_addr = _committed_high_addr = NULL;
  _special = false;
}
void PSVirtualSpace::release() {
    DEBUG_ONLY(PSVirtualSpaceVerifier this_verifier(this));
    if (reserved_low_addr() != NULL) {
        os::release_memory(reserved_low_addr(),reserved_size());
    }
    _reserved_low_addr = _reserved_high_addr = NULL;
    _committed_low_addr = _committed_high_addr = NULL;
}
bool PSVirtualSpaceHighToLow::shrink_by(size_t bytes) {
    assert(is_aligned(bytes), "arg not aligned");
    DEBUG_ONLY(PSVirtualSpaceVerifier this_verifier(this));

    if (committed_size() < bytes) {
        return false;
    }

    char* const base_addr = committed_low_addr();
    os::uncommit_memory(base_addr,bytes,Modules::ParGC_PSVirtualSpace);

    return true;
}
示例#6
0
bool PSVirtualSpaceHighToLow::shrink_by(size_t bytes) {
  assert(is_aligned(bytes), "arg not aligned");
  DEBUG_ONLY(PSVirtualSpaceVerifier this_verifier(this));

  if (committed_size() < bytes) {
    return false;
  }

  char* const base_addr = committed_low_addr();
  bool result = special() || os::uncommit_memory(base_addr, bytes);
  if (result) {
    _committed_low_addr += bytes;
  }

  return result;
}
bool PSVirtualSpace::expand_by(size_t bytes) {
  assert(is_aligned(bytes), "arg not aligned");
  DEBUG_ONLY(PSVirtualSpaceVerifier this_verifier(this));

  if (uncommitted_size() < bytes) {
    return false;
  }

  char* const base_addr = committed_high_addr();
  bool result = os::commit_memory(base_addr, bytes, alignment());
  if (result) {
    _committed_high_addr += bytes;
  }

  return result;
}
示例#8
0
bool PSVirtualSpaceHighToLow::expand_by(size_t bytes) {
  assert(is_aligned(bytes), "arg not aligned");
  DEBUG_ONLY(PSVirtualSpaceVerifier this_verifier(this));

  if (uncommitted_size() < bytes) {
    return false;
  }

  char* const base_addr = committed_low_addr() - bytes;
  bool result = special() ||
         os::commit_memory(base_addr, bytes, alignment(), !ExecMem);
  if (result) {
    _committed_low_addr -= bytes;
  }

  return result;
}