hotspot/src/share/vm/oops/oop.pcgc.inline.hpp
author johnc
Mon, 07 Jun 2010 17:46:04 -0700
changeset 5716 1947993a6161
parent 670 ddf3e9583f2f
child 5547 f4b087cbb361
permissions -rw-r--r--
6953058: G1: A bigapp crashes with SIGSEGV in compiled code Summary: In C2's G1 post write barrier, the loads of the buffer and index fields from the DirtyCardQueue structure may be moved across a safepoint. Use the current value of "control" in the C2 IR to limit how far these loads can move. Reviewed-by: never, iveresov, kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
670
ddf3e9583f2f 6719955: Update copyright year
xdono
parents: 360
diff changeset
     2
 * Copyright 2005-2008 Sun Microsystems, Inc.  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
 *
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
inline void oopDesc::update_contents(ParCompactionManager* cm) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
  // The klass field must be updated before anything else
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
  // can be done.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
  DEBUG_ONLY(klassOopDesc* original_klass = klass());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
  // Can the option to update and/or copy be moved up in the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
  // call chain to avoid calling into here?
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
  if (PSParallelCompact::should_update_klass(klass())) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
    update_header();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
    assert(klass()->is_klass(), "Not updated correctly");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
    assert(klass()->is_klass(), "Not updated");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
  Klass* new_klass = blueprint();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
  if (!new_klass->oop_is_typeArray()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
    // It might contain oops beyond the header, so take the virtual call.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
    new_klass->oop_update_pointers(cm, this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  // Else skip it.  The typeArrayKlass in the header never needs scavenging.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
inline void oopDesc::update_contents(ParCompactionManager* cm,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
                                     HeapWord* begin_limit,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
                                     HeapWord* end_limit) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  // The klass field must be updated before anything else
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  // can be done.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  debug_only(klassOopDesc* original_klass = klass());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  update_contents(cm, klass(), begin_limit, end_limit);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
inline void oopDesc::update_contents(ParCompactionManager* cm,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
                                     klassOop old_klass,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
                                     HeapWord* begin_limit,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
                                     HeapWord* end_limit) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  klassOop updated_klass =
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
    PSParallelCompact::summary_data().calc_new_klass(old_klass);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  // Needs to be boundary aware for the 64 bit case
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  // update_header();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  // The klass has moved.  Is the location of the klass
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  // within the limits?
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    70
  if ((((HeapWord*)&_metadata._klass) >= begin_limit) &&
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    71
      (((HeapWord*)&_metadata._klass) < end_limit)) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
    set_klass(updated_klass);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  Klass* klass = updated_klass->klass_part();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  if (!klass->oop_is_typeArray()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
    // It might contain oops beyond the header, so take the virtual call.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
    klass->oop_update_pointers(cm, this, begin_limit, end_limit);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  // Else skip it.  The typeArrayKlass in the header never needs scavenging.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
inline void oopDesc::follow_contents(ParCompactionManager* cm) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  assert (PSParallelCompact::mark_bitmap()->is_marked(this),
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
    "should be marked");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  blueprint()->oop_follow_contents(cm, this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
// Used by parallel old GC.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
inline void oopDesc::follow_header(ParCompactionManager* cm) {
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    92
  if (UseCompressedOops) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    93
    PSParallelCompact::mark_and_push(cm, compressed_klass_addr());
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    94
  } else {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    95
    PSParallelCompact::mark_and_push(cm, klass_addr());
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    96
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
inline oop oopDesc::forward_to_atomic(oop p) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  assert(ParNewGeneration::is_legal_forward_ptr(p),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
         "illegal forwarding pointer value.");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  markOop oldMark = mark();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  markOop forwardPtrMark = markOopDesc::encode_pointer_as_mark(p);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  markOop curMark;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  assert(forwardPtrMark->decode_pointer() == p, "encoding must be reversable");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  assert(sizeof(markOop) == sizeof(intptr_t), "CAS below requires this.");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  while (!is_forwarded()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
    curMark = (markOop)Atomic::cmpxchg_ptr(forwardPtrMark, &_mark, oldMark);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
    if (curMark == oldMark) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
      assert(is_forwarded(), "the CAS should have succeeded.");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
      return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
    oldMark = curMark;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  return forwardee();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
inline void oopDesc::update_header() {
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   121
  if (UseCompressedOops) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   122
    PSParallelCompact::adjust_pointer(compressed_klass_addr());
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   123
  } else {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   124
    PSParallelCompact::adjust_pointer(klass_addr());
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   125
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
inline void oopDesc::update_header(HeapWord* beg_addr, HeapWord* end_addr) {
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   129
  if (UseCompressedOops) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   130
    PSParallelCompact::adjust_pointer(compressed_klass_addr(),
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   131
                                      beg_addr, end_addr);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   132
  } else {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   133
    PSParallelCompact::adjust_pointer(klass_addr(), beg_addr, end_addr);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   134
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
}