hotspot/src/share/vm/oops/instanceRefKlass.hpp
author ysr
Thu, 05 Jun 2008 15:57:56 -0700
changeset 1374 4c24294029a9
parent 1 489c9b5090e2
child 5547 f4b087cbb361
permissions -rw-r--r--
6711316: Open source the Garbage-First garbage collector Summary: First mercurial integration of the code for the Garbage-First garbage collector. Reviewed-by: apetrusenko, iveresov, jmasa, sgoldman, tonyp, 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 1997-2006 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
// An instanceRefKlass is a specialized instanceKlass for Java
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
// classes that are subclasses of java/lang/ref/Reference.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
// These classes are used to implement soft/weak/final/phantom
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
// references and finalization, and need special treatment by the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
// garbage collector.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
// During GC discovered reference objects are added (chained) to one
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
// of the four lists below, depending on the type of reference.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
// The linked occurs through the next field in class java/lang/ref/Reference.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
// Afterwards, the discovered references are processed in decreasing
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
// order of reachability. Reference objects eligible for notification
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
// are linked to the static pending_list in class java/lang/ref/Reference,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
// and the pending list lock object in the same class is notified.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
class instanceRefKlass: public instanceKlass {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
  // Type testing
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  bool oop_is_instanceRef() const             { return true; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  // Casting from klassOop
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  static instanceRefKlass* cast(klassOop k) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
    assert(k->klass_part()->oop_is_instanceRef(), "cast to instanceRefKlass");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
    return (instanceRefKlass*) k->klass_part();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  // allocation
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  DEFINE_ALLOCATE_PERMANENT(instanceRefKlass);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  // Garbage collection
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  int  oop_adjust_pointers(oop obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  void oop_follow_contents(oop obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  // Parallel Scavenge and Parallel Old
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  PARALLEL_GC_DECLS
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  int oop_oop_iterate(oop obj, OopClosure* blk) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
    return oop_oop_iterate_v(obj, blk);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  int oop_oop_iterate_m(oop obj, OopClosure* blk, MemRegion mr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
    return oop_oop_iterate_v_m(obj, blk, mr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
#define InstanceRefKlass_OOP_OOP_ITERATE_DECL(OopClosureType, nv_suffix)                \
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  int oop_oop_iterate##nv_suffix(oop obj, OopClosureType* blk);                         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  int oop_oop_iterate##nv_suffix##_m(oop obj, OopClosureType* blk, MemRegion mr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceRefKlass_OOP_OOP_ITERATE_DECL)
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    75
  ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceRefKlass_OOP_OOP_ITERATE_DECL)
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    76
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    77
#ifndef SERIALGC
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    78
#define InstanceRefKlass_OOP_OOP_ITERATE_BACKWARDS_DECL(OopClosureType, nv_suffix)      \
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    79
  int oop_oop_iterate_backwards##nv_suffix(oop obj, OopClosureType* blk);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    80
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    81
  ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceRefKlass_OOP_OOP_ITERATE_BACKWARDS_DECL)
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    82
  ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceRefKlass_OOP_OOP_ITERATE_BACKWARDS_DECL)
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    83
#endif // !SERIALGC
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  static void release_and_notify_pending_list_lock(BasicLock *pending_list_basic_lock);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  static void acquire_pending_list_lock(BasicLock *pending_list_basic_lock);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  // Update non-static oop maps so 'referent', 'nextPending' and
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  // 'discovered' will look like non-oops
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  static void update_nonstatic_oop_maps(klassOop k);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  // Verification
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  void oop_verify_on(oop obj, outputStream* st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
};