comparison src/share/vm/memory/referencePolicy.cpp @ 3992:d1bdeef3e3e2

7098282: G1: assert(interval >= 0) failed: Sanity check, referencePolicy.cpp: 76 Summary: There is a race between one thread successfully forwarding and copying the klass mirror for the SoftReference class (including the static master clock) and another thread attempting to use the master clock while attempting to discover a soft reference object. Maintain a shadow copy of the soft reference master clock and use the shadow during reference discovery and reference processing. Reviewed-by: tonyp, brutisso, ysr
author johnc
date Wed, 12 Oct 2011 10:25:51 -0700
parents f95d63e2154a
children
comparison
equal deleted inserted replaced
3991:3f24f946bc2d 3992:d1bdeef3e3e2
1 /* 1 /*
2 * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 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 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
39 assert(_max_interval >= 0,"Sanity check"); 39 assert(_max_interval >= 0,"Sanity check");
40 } 40 }
41 41
42 // The oop passed in is the SoftReference object, and not 42 // The oop passed in is the SoftReference object, and not
43 // the object the SoftReference points to. 43 // the object the SoftReference points to.
44 bool LRUCurrentHeapPolicy::should_clear_reference(oop p) { 44 bool LRUCurrentHeapPolicy::should_clear_reference(oop p,
45 jlong interval = java_lang_ref_SoftReference::clock() - java_lang_ref_SoftReference::timestamp(p); 45 jlong timestamp_clock) {
46 jlong interval = timestamp_clock - java_lang_ref_SoftReference::timestamp(p);
46 assert(interval >= 0, "Sanity check"); 47 assert(interval >= 0, "Sanity check");
47 48
48 // The interval will be zero if the ref was accessed since the last scavenge/gc. 49 // The interval will be zero if the ref was accessed since the last scavenge/gc.
49 if(interval <= _max_interval) { 50 if(interval <= _max_interval) {
50 return false; 51 return false;
69 assert(_max_interval >= 0,"Sanity check"); 70 assert(_max_interval >= 0,"Sanity check");
70 } 71 }
71 72
72 // The oop passed in is the SoftReference object, and not 73 // The oop passed in is the SoftReference object, and not
73 // the object the SoftReference points to. 74 // the object the SoftReference points to.
74 bool LRUMaxHeapPolicy::should_clear_reference(oop p) { 75 bool LRUMaxHeapPolicy::should_clear_reference(oop p,
75 jlong interval = java_lang_ref_SoftReference::clock() - java_lang_ref_SoftReference::timestamp(p); 76 jlong timestamp_clock) {
77 jlong interval = timestamp_clock - java_lang_ref_SoftReference::timestamp(p);
76 assert(interval >= 0, "Sanity check"); 78 assert(interval >= 0, "Sanity check");
77 79
78 // The interval will be zero if the ref was accessed since the last scavenge/gc. 80 // The interval will be zero if the ref was accessed since the last scavenge/gc.
79 if(interval <= _max_interval) { 81 if(interval <= _max_interval) {
80 return false; 82 return false;