src/share/vm/memory/referencePolicy.cpp

Thu, 24 Mar 2011 15:47:01 -0700

author
ysr
date
Thu, 24 Mar 2011 15:47:01 -0700
changeset 2710
5134fa1cfe63
parent 2314
f95d63e2154a
child 3188
d1bdeef3e3e2
permissions
-rw-r--r--

7029036: Card-table verification hangs with all framework collectors, except G1, even before the first GC
Summary: When verifying clean card ranges, use memory-range-bounded iteration over oops of objects overlapping that range, thus avoiding the otherwise quadratic worst-case cost of scanning large object arrays.
Reviewed-by: jmasa, jwilhelm, tonyp

duke@435 1 /*
stefank@2314 2 * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #include "precompiled.hpp"
stefank@2314 26 #include "classfile/javaClasses.hpp"
stefank@2314 27 #include "memory/referencePolicy.hpp"
stefank@2314 28 #include "memory/universe.hpp"
stefank@2314 29 #include "runtime/arguments.hpp"
stefank@2314 30 #include "runtime/globals.hpp"
duke@435 31
duke@435 32 LRUCurrentHeapPolicy::LRUCurrentHeapPolicy() {
ysr@892 33 setup();
ysr@888 34 }
ysr@888 35
ysr@888 36 // Capture state (of-the-VM) information needed to evaluate the policy
ysr@892 37 void LRUCurrentHeapPolicy::setup() {
duke@435 38 _max_interval = (Universe::get_heap_free_at_last_gc() / M) * SoftRefLRUPolicyMSPerMB;
duke@435 39 assert(_max_interval >= 0,"Sanity check");
duke@435 40 }
duke@435 41
duke@435 42 // The oop passed in is the SoftReference object, and not
duke@435 43 // the object the SoftReference points to.
duke@435 44 bool LRUCurrentHeapPolicy::should_clear_reference(oop p) {
duke@435 45 jlong interval = java_lang_ref_SoftReference::clock() - java_lang_ref_SoftReference::timestamp(p);
duke@435 46 assert(interval >= 0, "Sanity check");
duke@435 47
duke@435 48 // The interval will be zero if the ref was accessed since the last scavenge/gc.
duke@435 49 if(interval <= _max_interval) {
duke@435 50 return false;
duke@435 51 }
duke@435 52
duke@435 53 return true;
duke@435 54 }
duke@435 55
duke@435 56 /////////////////////// MaxHeap //////////////////////
duke@435 57
duke@435 58 LRUMaxHeapPolicy::LRUMaxHeapPolicy() {
ysr@892 59 setup();
ysr@888 60 }
ysr@888 61
ysr@888 62 // Capture state (of-the-VM) information needed to evaluate the policy
ysr@892 63 void LRUMaxHeapPolicy::setup() {
duke@435 64 size_t max_heap = MaxHeapSize;
duke@435 65 max_heap -= Universe::get_heap_used_at_last_gc();
duke@435 66 max_heap /= M;
duke@435 67
duke@435 68 _max_interval = max_heap * SoftRefLRUPolicyMSPerMB;
duke@435 69 assert(_max_interval >= 0,"Sanity check");
duke@435 70 }
duke@435 71
duke@435 72 // The oop passed in is the SoftReference object, and not
duke@435 73 // the object the SoftReference points to.
duke@435 74 bool LRUMaxHeapPolicy::should_clear_reference(oop p) {
duke@435 75 jlong interval = java_lang_ref_SoftReference::clock() - java_lang_ref_SoftReference::timestamp(p);
duke@435 76 assert(interval >= 0, "Sanity check");
duke@435 77
duke@435 78 // The interval will be zero if the ref was accessed since the last scavenge/gc.
duke@435 79 if(interval <= _max_interval) {
duke@435 80 return false;
duke@435 81 }
duke@435 82
duke@435 83 return true;
duke@435 84 }

mercurial