hotspot/src/share/vm/gc/parallel/psPromotionLAB.hpp
author stefank
Tue, 04 Jul 2017 15:58:10 +0200
changeset 46619 a3919f5e8d2b
parent 46565 8dcbf532ea00
permissions -rw-r--r--
8178499: Remove _ptr_ and _size_ infixes from align functions Reviewed-by: rehn, tschatzl
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
30170
c73e90240913 8077414: PSPromotionLAB _state is unintialized
ecaspole
parents: 25905
diff changeset
     2
 * Copyright (c) 2002, 2015, 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
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30175
diff changeset
    25
#ifndef SHARE_VM_GC_PARALLEL_PSPROMOTIONLAB_HPP
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30175
diff changeset
    26
#define SHARE_VM_GC_PARALLEL_PSPROMOTIONLAB_HPP
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30175
diff changeset
    28
#include "gc/parallel/objectStartArray.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30175
diff changeset
    29
#include "gc/shared/collectedHeap.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
#include "memory/allocation.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    31
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
// PSPromotionLAB is a parallel scavenge promotion lab. This class acts very
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
// much like a MutableSpace. We couldn't embed a MutableSpace, though, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
// it has a considerable number of asserts and invariants that are violated.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
class ObjectStartArray;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 10676
diff changeset
    40
class PSPromotionLAB : public CHeapObj<mtGC> {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
 protected:
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    42
  static size_t filler_header_size;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
  enum LabState {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
    needs_flush,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
    flushed,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
    zero_size
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
  HeapWord* _top;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  HeapWord* _bottom;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  HeapWord* _end;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  LabState _state;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  void set_top(HeapWord* value)    { _top = value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  void set_bottom(HeapWord* value) { _bottom = value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  void set_end(HeapWord* value)    { _end = value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  // The shared initialize code invokes this.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  debug_only(virtual bool lab_is_valid(MemRegion lab) { return false; });
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
30170
c73e90240913 8077414: PSPromotionLAB _state is unintialized
ecaspole
parents: 25905
diff changeset
    62
  PSPromotionLAB() : _top(NULL), _bottom(NULL), _end(NULL), _state(zero_size) { }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  // Filling and flushing.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  void initialize(MemRegion lab);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  virtual void flush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  // Accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  HeapWord* bottom() const           { return _bottom; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  HeapWord* end() const              { return _end;    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  HeapWord* top() const              { return _top;    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  bool is_flushed()                  { return _state == flushed; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
10676
1e1510b8031a 7021322: assert(object_end <= top()) failed: Object crosses promotion LAB boundary
stefank
parents: 7397
diff changeset
    77
  bool unallocate_object(HeapWord* obj, size_t obj_size);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  // Returns a subregion containing all objects in this space.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  MemRegion used_region()            { return MemRegion(bottom(), top()); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 13963
diff changeset
    82
  // Boolean queries.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  bool is_empty() const              { return used() == 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  bool not_empty() const             { return used() > 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  bool contains(const void* p) const { return _bottom <= p && p < _end; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  // Size computations.  Sizes are in bytes.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  size_t capacity() const            { return byte_size(bottom(), end()); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  size_t used() const                { return byte_size(bottom(), top()); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  size_t free() const                { return byte_size(top(),    end()); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
class PSYoungPromotionLAB : public PSPromotionLAB {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  PSYoungPromotionLAB() { }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  // Not MT safe
25905
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents: 22551
diff changeset
    98
  inline HeapWord* allocate(size_t size);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
25905
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents: 22551
diff changeset
   100
  debug_only(virtual bool lab_is_valid(MemRegion lab);)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
class PSOldPromotionLAB : public PSPromotionLAB {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  ObjectStartArray* _start_array;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  PSOldPromotionLAB() : _start_array(NULL) { }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  PSOldPromotionLAB(ObjectStartArray* start_array) : _start_array(start_array) { }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  void set_start_array(ObjectStartArray* start_array) { _start_array = start_array; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  void flush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  // Not MT safe
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  HeapWord* allocate(size_t size) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
    // Cannot test for this now that we're doing promotion failures
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
    // assert(_state != flushed, "Sanity");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
    assert(_start_array != NULL, "Sanity");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
    HeapWord* obj = top();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
    HeapWord* new_top = obj + size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
    // The 'new_top>obj' check is needed to detect overflow of obj+size.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
    if (new_top > obj && new_top <= end()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
      set_top(new_top);
46619
a3919f5e8d2b 8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents: 46565
diff changeset
   125
      assert(is_object_aligned(obj) && is_object_aligned(new_top),
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
             "checking alignment");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
      _start_array->allocate_block(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
      return obj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
    return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
  debug_only(virtual bool lab_is_valid(MemRegion lab));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
};
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   136
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30175
diff changeset
   137
#endif // SHARE_VM_GC_PARALLEL_PSPROMOTIONLAB_HPP