hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionLAB.hpp
author jwilhelm
Thu, 23 Jan 2014 14:47:23 +0100
changeset 22551 9bf46d16dcc6
parent 13963 e5b53c306fb5
child 25905 04a3d83cc752
permissions -rw-r--r--
8025856: Fix typos in the GC code Summary: Fix about 440 typos in comments in the VM code Reviewed-by: mgerdin, tschatzl, coleenp, kmo, jcoomes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
13963
e5b53c306fb5 7197424: update copyright year to match last edit in jdk8 hotspot repository
mikael
parents: 13195
diff changeset
     2
 * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 670
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 670
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 670
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    25
#ifndef SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSPROMOTIONLAB_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#define SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSPROMOTIONLAB_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "gc_implementation/parallelScavenge/objectStartArray.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "memory/allocation.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
// PSPromotionLAB is a parallel scavenge promotion lab. This class acts very
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
// much like a MutableSpace. We couldn't embed a MutableSpace, though, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
// it has a considerable number of asserts and invariants that are violated.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
class ObjectStartArray;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 10676
diff changeset
    39
class PSPromotionLAB : public CHeapObj<mtGC> {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
 protected:
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    41
  static size_t filler_header_size;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
  enum LabState {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
    needs_flush,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
    flushed,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
    zero_size
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
  HeapWord* _top;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
  HeapWord* _bottom;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  HeapWord* _end;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  LabState _state;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  void set_top(HeapWord* value)    { _top = value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  void set_bottom(HeapWord* value) { _bottom = value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  void set_end(HeapWord* value)    { _end = value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  // The shared initialize code invokes this.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  debug_only(virtual bool lab_is_valid(MemRegion lab) { return false; });
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  PSPromotionLAB() : _top(NULL), _bottom(NULL), _end(NULL) { }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  // Filling and flushing.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  void initialize(MemRegion lab);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  virtual void flush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  // Accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  HeapWord* bottom() const           { return _bottom; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  HeapWord* end() const              { return _end;    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  HeapWord* top() const              { return _top;    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  bool is_flushed()                  { return _state == flushed; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
10676
1e1510b8031a 7021322: assert(object_end <= top()) failed: Object crosses promotion LAB boundary
stefank
parents: 7397
diff changeset
    76
  bool unallocate_object(HeapWord* obj, size_t obj_size);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  // Returns a subregion containing all objects in this space.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  MemRegion used_region()            { return MemRegion(bottom(), top()); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 13963
diff changeset
    81
  // Boolean queries.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  bool is_empty() const              { return used() == 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  bool not_empty() const             { return used() > 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  bool contains(const void* p) const { return _bottom <= p && p < _end; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  // Size computations.  Sizes are in bytes.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  size_t capacity() const            { return byte_size(bottom(), end()); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  size_t used() const                { return byte_size(bottom(), top()); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  size_t free() const                { return byte_size(top(),    end()); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
class PSYoungPromotionLAB : public PSPromotionLAB {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  PSYoungPromotionLAB() { }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  // Not MT safe
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  HeapWord* allocate(size_t size) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
    // Can't assert this, when young fills, we keep the LAB around, but flushed.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
    // assert(_state != flushed, "Sanity");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
    HeapWord* obj = top();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
    HeapWord* new_top = obj + size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
    // The 'new_top>obj' check is needed to detect overflow of obj+size.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
    if (new_top > obj && new_top <= end()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
      set_top(new_top);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
      assert(is_object_aligned((intptr_t)obj) && is_object_aligned((intptr_t)new_top),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
             "checking alignment");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
      return obj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
    return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  debug_only(virtual bool lab_is_valid(MemRegion lab));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
class PSOldPromotionLAB : public PSPromotionLAB {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  ObjectStartArray* _start_array;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  PSOldPromotionLAB() : _start_array(NULL) { }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  PSOldPromotionLAB(ObjectStartArray* start_array) : _start_array(start_array) { }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  void set_start_array(ObjectStartArray* start_array) { _start_array = start_array; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  void flush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  // Not MT safe
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  HeapWord* allocate(size_t size) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
    // Cannot test for this now that we're doing promotion failures
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
    // assert(_state != flushed, "Sanity");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
    assert(_start_array != NULL, "Sanity");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
    HeapWord* obj = top();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
    HeapWord* new_top = obj + size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
    // The 'new_top>obj' check is needed to detect overflow of obj+size.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
    if (new_top > obj && new_top <= end()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
      set_top(new_top);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
      assert(is_object_aligned((intptr_t)obj) && is_object_aligned((intptr_t)new_top),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
             "checking alignment");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
      _start_array->allocate_block(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
      return obj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
    return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  debug_only(virtual bool lab_is_valid(MemRegion lab));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
};
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   149
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   150
#endif // SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSPROMOTIONLAB_HPP