hotspot/src/share/vm/gc_implementation/parNew/parOopClosures.hpp
author jcoomes
Thu, 11 Dec 2008 12:05:08 -0800
changeset 1668 8ec481b8f514
parent 360 21d113ecbf6a
child 5547 f4b087cbb361
permissions -rw-r--r--
6578152: fill_region_with_object has usability and safety issues Reviewed-by: apetrusenko, ysr
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 (c) 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
// Closures for ParNewGeneration
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
class ParScanThreadState;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
class ParNewGeneration;
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    29
typedef OopTaskQueueSet ObjToScanQueueSet;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
class ParallelTaskTerminator;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
class ParScanClosure: public OopsInGenClosure {
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    33
 protected:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
  ParScanThreadState* _par_scan_state;
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    35
  ParNewGeneration*   _g;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    36
  HeapWord*           _boundary;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    37
  template <class T> void inline par_do_barrier(T* p);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    38
  template <class T> void inline do_oop_work(T* p,
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    39
                                             bool gc_barrier,
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    40
                                             bool root_scan);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    41
 public:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
  ParScanClosure(ParNewGeneration* g, ParScanThreadState* par_scan_state);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
class ParScanWithBarrierClosure: public ParScanClosure {
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    46
 public:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  ParScanWithBarrierClosure(ParNewGeneration* g,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
                            ParScanThreadState* par_scan_state) :
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
    ParScanClosure(g, par_scan_state) {}
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    50
  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
    51
  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
    52
  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
    53
  inline void do_oop_nv(narrowOop* p);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
class ParScanWithoutBarrierClosure: public ParScanClosure {
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    57
 public:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  ParScanWithoutBarrierClosure(ParNewGeneration* g,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
                               ParScanThreadState* par_scan_state) :
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
    ParScanClosure(g, par_scan_state) {}
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    61
  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
    62
  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
    63
  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
    64
  inline void do_oop_nv(narrowOop* p);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
class ParRootScanWithBarrierTwoGensClosure: public ParScanClosure {
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    68
 public:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  ParRootScanWithBarrierTwoGensClosure(ParNewGeneration* g,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
                                       ParScanThreadState* par_scan_state) :
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
    ParScanClosure(g, par_scan_state) {}
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    72
  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
    73
  virtual void do_oop(narrowOop* p);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
class ParRootScanWithoutBarrierClosure: public ParScanClosure {
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    77
 public:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  ParRootScanWithoutBarrierClosure(ParNewGeneration* g,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
                                   ParScanThreadState* par_scan_state) :
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
    ParScanClosure(g, par_scan_state) {}
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    81
  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
    82
  virtual void do_oop(narrowOop* p);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
class ParScanWeakRefClosure: public ScanWeakRefClosure {
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    86
 protected:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  ParScanThreadState* _par_scan_state;
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    88
  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
    89
 public:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  ParScanWeakRefClosure(ParNewGeneration* g,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
                        ParScanThreadState* par_scan_state);
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    92
  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
    93
  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
    94
  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
    95
  inline void do_oop_nv(narrowOop* p);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
class ParEvacuateFollowersClosure: public VoidClosure {
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    99
 private:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  ParScanThreadState* _par_scan_state;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  ParScanThreadState* par_scan_state() { return _par_scan_state; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  // We want to preserve the specific types here (rather than "OopClosure")
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  // for later de-virtualization of do_oop calls.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  ParScanWithoutBarrierClosure* _to_space_closure;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  ParScanWithoutBarrierClosure* to_space_closure() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
    return _to_space_closure;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  ParRootScanWithoutBarrierClosure* _to_space_root_closure;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  ParRootScanWithoutBarrierClosure* to_space_root_closure() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
    return _to_space_root_closure;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  ParScanWithBarrierClosure* _old_gen_closure;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  ParScanWithBarrierClosure* old_gen_closure () {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
    return _old_gen_closure;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  ParRootScanWithBarrierTwoGensClosure* _old_gen_root_closure;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  ParRootScanWithBarrierTwoGensClosure* old_gen_root_closure () {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
    return _old_gen_root_closure;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  ParNewGeneration* _par_gen;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  ParNewGeneration* par_gen() { return _par_gen; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  ObjToScanQueueSet*  _task_queues;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  ObjToScanQueueSet*  task_queues() { return _task_queues; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  ParallelTaskTerminator* _terminator;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
  ParallelTaskTerminator* terminator() { return _terminator; }
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   131
 public:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  ParEvacuateFollowersClosure(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
    ParScanThreadState* par_scan_state_,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
    ParScanWithoutBarrierClosure* to_space_closure_,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
    ParScanWithBarrierClosure* old_gen_closure_,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
    ParRootScanWithoutBarrierClosure* to_space_root_closure_,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
    ParNewGeneration* par_gen_,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
    ParRootScanWithBarrierTwoGensClosure* old_gen_root_closure_,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
    ObjToScanQueueSet* task_queues_,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
    ParallelTaskTerminator* terminator_);
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   141
  virtual void do_void();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
};