hotspot/src/share/vm/memory/genOopClosures.hpp
author coleenp
Sun, 13 Apr 2008 17:43:42 -0400
changeset 360 21d113ecbf6a
parent 1 489c9b5090e2
child 670 ddf3e9583f2f
child 1374 4c24294029a9
permissions -rw-r--r--
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes Summary: Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
     2
 * Copyright 2001-2007 Sun Microsystems, Inc.  All Rights Reserved.
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
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    21
 * have any questions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
class Generation;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
class HeapWord;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
class CardTableRS;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
class CardTableModRefBS;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
class DefNewGeneration;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    31
template<class E> class GenericTaskQueue;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    32
typedef GenericTaskQueue<oop> OopTaskQueue;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    33
template<class E> class GenericTaskQueueSet;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    34
typedef GenericTaskQueueSet<oop> OopTaskQueueSet;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    35
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
// Closure for iterating roots from a particular generation
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
// Note: all classes deriving from this MUST call this do_barrier
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
// method at the end of their own do_oop method!
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
// Note: no do_oop defined, this is an abstract class.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
class OopsInGenClosure : public OopClosure {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
 private:
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    43
  Generation*  _orig_gen;     // generation originally set in ctor
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    44
  Generation*  _gen;          // generation being scanned
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
 protected:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  // Some subtypes need access.
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    48
  HeapWord*    _gen_boundary; // start of generation
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    49
  CardTableRS* _rs;           // remembered set
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  // For assertions
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  Generation* generation() { return _gen; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  CardTableRS* rs() { return _rs; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  // Derived classes that modify oops so that they might be old-to-young
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  // pointers must call the method below.
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    57
  template <class T> void do_barrier(T* p);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  OopsInGenClosure() : OopClosure(NULL),
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
    _orig_gen(NULL), _gen(NULL), _gen_boundary(NULL), _rs(NULL) {};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  OopsInGenClosure(Generation* gen);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  void set_generation(Generation* gen);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  void reset_generation() { _gen = _orig_gen; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  // Problem with static closures: must have _gen_boundary set at some point,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  // but cannot do this until after the heap is initialized.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  void set_orig_generation(Generation* gen) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
    _orig_gen = gen;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
    set_generation(gen);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  HeapWord* gen_boundary() { return _gen_boundary; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
// Closure for scanning DefNewGeneration.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
// This closure will perform barrier store calls for ALL
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
// pointers in scanned oops.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
class ScanClosure: public OopsInGenClosure {
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    83
 protected:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  DefNewGeneration* _g;
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    85
  HeapWord*         _boundary;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    86
  bool              _gc_barrier;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    87
  template <class T> inline void do_oop_work(T* p);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    88
 public:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  ScanClosure(DefNewGeneration* g, bool gc_barrier);
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    90
  virtual void do_oop(oop* p);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    91
  virtual void do_oop(narrowOop* p);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    92
  inline void do_oop_nv(oop* p);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    93
  inline void do_oop_nv(narrowOop* p);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  bool do_header() { return false; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  Prefetch::style prefetch_style() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
    return Prefetch::do_write;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
// Closure for scanning DefNewGeneration.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
// This closure only performs barrier store calls on
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
// pointers into the DefNewGeneration. This is less
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
// precise, but faster, than a ScanClosure
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
class FastScanClosure: public OopsInGenClosure {
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   106
 protected:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  DefNewGeneration* _g;
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   108
  HeapWord*         _boundary;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   109
  bool              _gc_barrier;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   110
  template <class T> inline void do_oop_work(T* p);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   111
 public:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  FastScanClosure(DefNewGeneration* g, bool gc_barrier);
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   113
  virtual void do_oop(oop* p);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   114
  virtual void do_oop(narrowOop* p);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   115
  inline void do_oop_nv(oop* p);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   116
  inline void do_oop_nv(narrowOop* p);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  bool do_header() { return false; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  Prefetch::style prefetch_style() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
    return Prefetch::do_write;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
class FilteringClosure: public OopClosure {
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   124
 private:
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   125
  HeapWord*   _boundary;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  OopClosure* _cl;
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   127
 protected:
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   128
  template <class T> inline void do_oop_work(T* p) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   129
    T heap_oop = oopDesc::load_heap_oop(p);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   130
    if (!oopDesc::is_null(heap_oop)) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   131
      oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   132
      if ((HeapWord*)obj < _boundary) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   133
        _cl->do_oop(p);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   134
      }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   135
    }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   136
  }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   137
 public:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  FilteringClosure(HeapWord* boundary, OopClosure* cl) :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
    OopClosure(cl->_ref_processor), _boundary(boundary),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
    _cl(cl) {}
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   141
  virtual void do_oop(oop* p);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   142
  virtual void do_oop(narrowOop* p);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   143
  inline void do_oop_nv(oop* p)       { FilteringClosure::do_oop_work(p); }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   144
  inline void do_oop_nv(narrowOop* p) { FilteringClosure::do_oop_work(p); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
  bool do_header() { return false; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
// Closure for scanning DefNewGeneration's weak references.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
// NOTE: very much like ScanClosure but not derived from
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
//  OopsInGenClosure -- weak references are processed all
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
//  at once, with no notion of which generation they were in.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
class ScanWeakRefClosure: public OopClosure {
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   153
 protected:
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   154
  DefNewGeneration* _g;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   155
  HeapWord*         _boundary;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   156
  template <class T> inline void do_oop_work(T* p);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   157
 public:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
  ScanWeakRefClosure(DefNewGeneration* g);
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   159
  virtual void do_oop(oop* p);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   160
  virtual void do_oop(narrowOop* p);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   161
  inline void do_oop_nv(oop* p);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   162
  inline void do_oop_nv(narrowOop* p);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
class VerifyOopClosure: public OopClosure {
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   166
 protected:
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   167
  template <class T> inline void do_oop_work(T* p) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   168
    oop obj = oopDesc::load_decode_heap_oop(p);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   169
    guarantee(obj->is_oop_or_null(), "invalid oop");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
  }
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   171
 public:
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   172
  virtual void do_oop(oop* p);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   173
  virtual void do_oop(narrowOop* p);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
  static VerifyOopClosure verify_oop;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
};