author | pliden |
Wed, 21 Feb 2018 07:50:33 +0100 | |
changeset 49031 | e4a0cc16b050 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
30764 | 2 |
* Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1623
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1623
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1623
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
26 |
#include "classfile/javaClasses.hpp" |
|
30764 | 27 |
#include "gc/shared/referencePolicy.hpp" |
7397 | 28 |
#include "memory/universe.hpp" |
29 |
#include "runtime/arguments.hpp" |
|
30 |
#include "runtime/globals.hpp" |
|
1 | 31 |
|
32 |
LRUCurrentHeapPolicy::LRUCurrentHeapPolicy() { |
|
1610
5dddd195cc86
6778647: snap(), snap_policy() should be renamed setup(), setup_policy()
ysr
parents:
1606
diff
changeset
|
33 |
setup(); |
1606
dcf9714addbe
6684579: SoftReference processing can be made more efficient
ysr
parents:
1
diff
changeset
|
34 |
} |
dcf9714addbe
6684579: SoftReference processing can be made more efficient
ysr
parents:
1
diff
changeset
|
35 |
|
dcf9714addbe
6684579: SoftReference processing can be made more efficient
ysr
parents:
1
diff
changeset
|
36 |
// Capture state (of-the-VM) information needed to evaluate the policy |
1610
5dddd195cc86
6778647: snap(), snap_policy() should be renamed setup(), setup_policy()
ysr
parents:
1606
diff
changeset
|
37 |
void LRUCurrentHeapPolicy::setup() { |
1 | 38 |
_max_interval = (Universe::get_heap_free_at_last_gc() / M) * SoftRefLRUPolicyMSPerMB; |
39 |
assert(_max_interval >= 0,"Sanity check"); |
|
40 |
} |
|
41 |
||
42 |
// The oop passed in is the SoftReference object, and not |
|
43 |
// the object the SoftReference points to. |
|
10683
4b5a5a507864
7098282: G1: assert(interval >= 0) failed: Sanity check, referencePolicy.cpp: 76
johnc
parents:
7397
diff
changeset
|
44 |
bool LRUCurrentHeapPolicy::should_clear_reference(oop p, |
4b5a5a507864
7098282: G1: assert(interval >= 0) failed: Sanity check, referencePolicy.cpp: 76
johnc
parents:
7397
diff
changeset
|
45 |
jlong timestamp_clock) { |
4b5a5a507864
7098282: G1: assert(interval >= 0) failed: Sanity check, referencePolicy.cpp: 76
johnc
parents:
7397
diff
changeset
|
46 |
jlong interval = timestamp_clock - java_lang_ref_SoftReference::timestamp(p); |
1 | 47 |
assert(interval >= 0, "Sanity check"); |
48 |
||
49 |
// The interval will be zero if the ref was accessed since the last scavenge/gc. |
|
50 |
if(interval <= _max_interval) { |
|
51 |
return false; |
|
52 |
} |
|
53 |
||
54 |
return true; |
|
55 |
} |
|
56 |
||
57 |
/////////////////////// MaxHeap ////////////////////// |
|
58 |
||
59 |
LRUMaxHeapPolicy::LRUMaxHeapPolicy() { |
|
1610
5dddd195cc86
6778647: snap(), snap_policy() should be renamed setup(), setup_policy()
ysr
parents:
1606
diff
changeset
|
60 |
setup(); |
1606
dcf9714addbe
6684579: SoftReference processing can be made more efficient
ysr
parents:
1
diff
changeset
|
61 |
} |
dcf9714addbe
6684579: SoftReference processing can be made more efficient
ysr
parents:
1
diff
changeset
|
62 |
|
dcf9714addbe
6684579: SoftReference processing can be made more efficient
ysr
parents:
1
diff
changeset
|
63 |
// Capture state (of-the-VM) information needed to evaluate the policy |
1610
5dddd195cc86
6778647: snap(), snap_policy() should be renamed setup(), setup_policy()
ysr
parents:
1606
diff
changeset
|
64 |
void LRUMaxHeapPolicy::setup() { |
1 | 65 |
size_t max_heap = MaxHeapSize; |
66 |
max_heap -= Universe::get_heap_used_at_last_gc(); |
|
67 |
max_heap /= M; |
|
68 |
||
69 |
_max_interval = max_heap * SoftRefLRUPolicyMSPerMB; |
|
70 |
assert(_max_interval >= 0,"Sanity check"); |
|
71 |
} |
|
72 |
||
73 |
// The oop passed in is the SoftReference object, and not |
|
74 |
// the object the SoftReference points to. |
|
10683
4b5a5a507864
7098282: G1: assert(interval >= 0) failed: Sanity check, referencePolicy.cpp: 76
johnc
parents:
7397
diff
changeset
|
75 |
bool LRUMaxHeapPolicy::should_clear_reference(oop p, |
4b5a5a507864
7098282: G1: assert(interval >= 0) failed: Sanity check, referencePolicy.cpp: 76
johnc
parents:
7397
diff
changeset
|
76 |
jlong timestamp_clock) { |
4b5a5a507864
7098282: G1: assert(interval >= 0) failed: Sanity check, referencePolicy.cpp: 76
johnc
parents:
7397
diff
changeset
|
77 |
jlong interval = timestamp_clock - java_lang_ref_SoftReference::timestamp(p); |
1 | 78 |
assert(interval >= 0, "Sanity check"); |
79 |
||
80 |
// The interval will be zero if the ref was accessed since the last scavenge/gc. |
|
81 |
if(interval <= _max_interval) { |
|
82 |
return false; |
|
83 |
} |
|
84 |
||
85 |
return true; |
|
86 |
} |