author | avoitylov |
Thu, 30 Aug 2018 16:33:14 -0400 | |
changeset 51599 | 3198179d97fa |
parent 51546 | b9f6a4427da9 |
child 53536 | 482109fae02b |
permissions | -rw-r--r-- |
51546 | 1 |
/* |
2 |
* Copyright (c) 2018, 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 |
*/ |
|
24 |
||
25 |
#include "precompiled.hpp" |
|
26 |
#include "classfile/systemDictionary.hpp" |
|
27 |
#include "gc/shared/weakProcessorPhases.hpp" |
|
28 |
#include "runtime/jniHandles.hpp" |
|
29 |
#include "utilities/debug.hpp" |
|
30 |
#include "utilities/macros.hpp" |
|
31 |
||
32 |
#if INCLUDE_JFR |
|
33 |
#include "jfr/jfr.hpp" |
|
34 |
#endif // INCLUDE_JFR |
|
35 |
||
36 |
#if INCLUDE_JVMTI |
|
37 |
#include "prims/jvmtiExport.hpp" |
|
38 |
#endif // INCLUDE_JVMTI |
|
39 |
||
40 |
WeakProcessorPhases::Phase WeakProcessorPhases::phase(uint value) { |
|
41 |
assert(value < phase_count, "Invalid phase value %u", value); |
|
42 |
return static_cast<Phase>(value); |
|
43 |
} |
|
44 |
||
45 |
uint WeakProcessorPhases::index(Phase phase) { |
|
46 |
uint value = static_cast<uint>(phase); |
|
47 |
assert(value < phase_count, "Invalid phase %u", value); |
|
48 |
return value; |
|
49 |
} |
|
50 |
||
51 |
uint WeakProcessorPhases::serial_index(Phase phase) { |
|
52 |
assert(is_serial(phase), "not serial phase %u", index(phase)); |
|
53 |
return index(phase) - serial_phase_start; |
|
54 |
} |
|
55 |
||
56 |
uint WeakProcessorPhases::oop_storage_index(Phase phase) { |
|
57 |
assert(is_oop_storage(phase), "not oop storage phase %u", index(phase)); |
|
58 |
return index(phase) - oop_storage_phase_start; |
|
59 |
} |
|
60 |
||
61 |
bool WeakProcessorPhases::is_serial(Phase phase) { |
|
51599
3198179d97fa
8210164: building Minimal VM fails with error: comparison of unsigned expression < 0 is always false [-Werror=type-limits]
avoitylov
parents:
51546
diff
changeset
|
62 |
// serial_phase_count is 0 if JFR and JVMTI are both not built, |
3198179d97fa
8210164: building Minimal VM fails with error: comparison of unsigned expression < 0 is always false [-Werror=type-limits]
avoitylov
parents:
51546
diff
changeset
|
63 |
// making this check with unsigned lhs redundant |
3198179d97fa
8210164: building Minimal VM fails with error: comparison of unsigned expression < 0 is always false [-Werror=type-limits]
avoitylov
parents:
51546
diff
changeset
|
64 |
#if INCLUDE_JVMTI || INCLUDE_JFR |
51546 | 65 |
return (index(phase) - serial_phase_start) < serial_phase_count; |
51599
3198179d97fa
8210164: building Minimal VM fails with error: comparison of unsigned expression < 0 is always false [-Werror=type-limits]
avoitylov
parents:
51546
diff
changeset
|
66 |
#else |
3198179d97fa
8210164: building Minimal VM fails with error: comparison of unsigned expression < 0 is always false [-Werror=type-limits]
avoitylov
parents:
51546
diff
changeset
|
67 |
STATIC_ASSERT(serial_phase_count == 0); |
3198179d97fa
8210164: building Minimal VM fails with error: comparison of unsigned expression < 0 is always false [-Werror=type-limits]
avoitylov
parents:
51546
diff
changeset
|
68 |
return false; |
3198179d97fa
8210164: building Minimal VM fails with error: comparison of unsigned expression < 0 is always false [-Werror=type-limits]
avoitylov
parents:
51546
diff
changeset
|
69 |
#endif |
51546 | 70 |
} |
71 |
||
72 |
bool WeakProcessorPhases::is_oop_storage(Phase phase) { |
|
73 |
return (index(phase) - oop_storage_phase_start) < oop_storage_phase_count; |
|
74 |
} |
|
75 |
||
76 |
const char* WeakProcessorPhases::description(Phase phase) { |
|
77 |
switch (phase) { |
|
78 |
JVMTI_ONLY(case jvmti: return "JVMTI weak processing";) |
|
79 |
JFR_ONLY(case jfr: return "JFR weak processing";) |
|
80 |
case jni: return "JNI weak processing"; |
|
81 |
case vm: return "VM weak processing"; |
|
82 |
default: |
|
83 |
ShouldNotReachHere(); |
|
84 |
return "Invalid weak processing phase"; |
|
85 |
} |
|
86 |
} |
|
87 |
||
88 |
WeakProcessorPhases::Processor WeakProcessorPhases::processor(Phase phase) { |
|
89 |
switch (phase) { |
|
90 |
JVMTI_ONLY(case jvmti: return &JvmtiExport::weak_oops_do;) |
|
91 |
JFR_ONLY(case jfr: return &Jfr::weak_oops_do;) |
|
92 |
default: |
|
93 |
ShouldNotReachHere(); |
|
94 |
return NULL; |
|
95 |
} |
|
96 |
} |
|
97 |
||
98 |
OopStorage* WeakProcessorPhases::oop_storage(Phase phase) { |
|
99 |
switch (phase) { |
|
100 |
case jni: return JNIHandles::weak_global_handles(); |
|
101 |
case vm: return SystemDictionary::vm_weak_oop_storage(); |
|
102 |
default: |
|
103 |
ShouldNotReachHere(); |
|
104 |
return NULL; |
|
105 |
} |
|
106 |
} |