src/share/vm/memory/genRemSet.cpp

Mon, 29 Apr 2013 16:13:57 -0400

author
hseigel
date
Mon, 29 Apr 2013 16:13:57 -0400
changeset 4987
f258c5828eb8
parent 4037
da91efe96a93
child 5818
ab68fc0101ce
permissions
-rw-r--r--

8011773: Some tests on Interned String crashed JVM with OOM
Summary: Instead of terminating the VM, throw OutOfMemoryError exceptions.
Reviewed-by: coleenp, dholmes

     1 /*
     2  * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     8  *
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    12  * version 2 for more details (a copy is included in the LICENSE file that
    13  * accompanied this code).
    14  *
    15  * You should have received a copy of the GNU General Public License version
    16  * 2 along with this work; if not, write to the Free Software Foundation,
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    18  *
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    22  *
    23  */
    25 #include "precompiled.hpp"
    26 #include "classfile/classLoaderData.hpp"
    27 #include "memory/cardTableRS.hpp"
    28 #include "memory/genRemSet.hpp"
    30 // This kind of "BarrierSet" allows a "CollectedHeap" to detect and
    31 // enumerate ref fields that have been modified (since the last
    32 // enumeration.)
    34 uintx GenRemSet::max_alignment_constraint(Name nm) {
    35   switch (nm) {
    36   case GenRemSet::CardTable:
    37     return CardTableRS::ct_max_alignment_constraint();
    38   default:
    39     guarantee(false, "Unrecognized GenRemSet type.");
    40     return (0); // Make Windows compiler happy
    41   }
    42 }
    44 class HasAccumulatedModifiedOopsClosure : public KlassClosure {
    45   bool _found;
    46  public:
    47   HasAccumulatedModifiedOopsClosure() : _found(false) {}
    48   void do_klass(Klass* klass) {
    49     if (_found) {
    50       return;
    51     }
    53     if (klass->has_accumulated_modified_oops()) {
    54       _found = true;
    55     }
    56   }
    57   bool found() {
    58     return _found;
    59   }
    60 };
    62 bool KlassRemSet::mod_union_is_clear() {
    63   HasAccumulatedModifiedOopsClosure closure;
    64   ClassLoaderDataGraph::classes_do(&closure);
    66   return !closure.found();
    67 }
    70 class ClearKlassModUnionClosure : public KlassClosure {
    71  public:
    72   void do_klass(Klass* klass) {
    73     if (klass->has_accumulated_modified_oops()) {
    74       klass->clear_accumulated_modified_oops();
    75     }
    76   }
    77 };
    79 void KlassRemSet::clear_mod_union() {
    80   ClearKlassModUnionClosure closure;
    81   ClassLoaderDataGraph::classes_do(&closure);
    82 }

mercurial