src/share/vm/gc_implementation/g1/heapRegionSeq.inline.hpp

changeset 2963
c3f1170908be
parent 2314
f95d63e2154a
child 3713
720b6a76dd9d
     1.1 --- a/src/share/vm/gc_implementation/g1/heapRegionSeq.inline.hpp	Wed Jun 08 21:48:38 2011 -0400
     1.2 +++ b/src/share/vm/gc_implementation/g1/heapRegionSeq.inline.hpp	Fri Jun 10 13:16:40 2011 -0400
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -25,23 +25,42 @@
    1.11  #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGIONSEQ_INLINE_HPP
    1.12  #define SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGIONSEQ_INLINE_HPP
    1.13  
    1.14 +#include "gc_implementation/g1/heapRegion.hpp"
    1.15  #include "gc_implementation/g1/heapRegionSeq.hpp"
    1.16  
    1.17 -inline HeapRegion* HeapRegionSeq::addr_to_region(const void* addr) {
    1.18 -  assert(_seq_bottom != NULL, "bad _seq_bottom in addr_to_region");
    1.19 -  if ((char*) addr >= _seq_bottom) {
    1.20 -    size_t diff = (size_t) pointer_delta((HeapWord*) addr,
    1.21 -                                         (HeapWord*) _seq_bottom);
    1.22 -    int index = (int) (diff >> HeapRegion::LogOfHRGrainWords);
    1.23 -    assert(index >= 0, "invariant / paranoia");
    1.24 -    if (index < _regions.length()) {
    1.25 -      HeapRegion* hr = _regions.at(index);
    1.26 -      assert(hr->is_in_reserved(addr),
    1.27 -             "addr_to_region is wrong...");
    1.28 -      return hr;
    1.29 -    }
    1.30 +inline size_t HeapRegionSeq::addr_to_index_biased(HeapWord* addr) const {
    1.31 +  assert(_heap_bottom <= addr && addr < _heap_end,
    1.32 +         err_msg("addr: "PTR_FORMAT" bottom: "PTR_FORMAT" end: "PTR_FORMAT,
    1.33 +                 addr, _heap_bottom, _heap_end));
    1.34 +  size_t index = (size_t) addr >> _region_shift;
    1.35 +  return index;
    1.36 +}
    1.37 +
    1.38 +inline HeapRegion* HeapRegionSeq::addr_to_region_unsafe(HeapWord* addr) const {
    1.39 +  assert(_heap_bottom <= addr && addr < _heap_end,
    1.40 +         err_msg("addr: "PTR_FORMAT" bottom: "PTR_FORMAT" end: "PTR_FORMAT,
    1.41 +                 addr, _heap_bottom, _heap_end));
    1.42 +  size_t index_biased = addr_to_index_biased(addr);
    1.43 +  HeapRegion* hr = _regions_biased[index_biased];
    1.44 +  assert(hr != NULL, "invariant");
    1.45 +  return hr;
    1.46 +}
    1.47 +
    1.48 +inline HeapRegion* HeapRegionSeq::addr_to_region(HeapWord* addr) const {
    1.49 +  if (addr != NULL && addr < _heap_end) {
    1.50 +    assert(addr >= _heap_bottom,
    1.51 +          err_msg("addr: "PTR_FORMAT" bottom: "PTR_FORMAT, addr, _heap_bottom));
    1.52 +    return addr_to_region_unsafe(addr);
    1.53    }
    1.54    return NULL;
    1.55  }
    1.56  
    1.57 +inline HeapRegion* HeapRegionSeq::at(size_t index) const {
    1.58 +  assert(index < length(), "pre-condition");
    1.59 +  HeapRegion* hr = _regions[index];
    1.60 +  assert(hr != NULL, "sanity");
    1.61 +  assert(hr->hrs_index() == index, "sanity");
    1.62 +  return hr;
    1.63 +}
    1.64 +
    1.65  #endif // SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGIONSEQ_INLINE_HPP

mercurial