Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell11
提交
fc73aa82
D
dragonwell11
项目概览
openanolis
/
dragonwell11
通知
7
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell11
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
fc73aa82
编写于
9月 12, 2016
作者:
S
sjohanss
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8114823: G1 doesn't honor request to disable class unloading
Reviewed-by: tschatzl, mgerdin
上级
f94e30d3
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
191 addition
and
19 deletion
+191
-19
hotspot/src/share/vm/gc/g1/g1MarkSweep.cpp
hotspot/src/share/vm/gc/g1/g1MarkSweep.cpp
+11
-4
hotspot/src/share/vm/gc/g1/g1RootProcessor.cpp
hotspot/src/share/vm/gc/g1/g1RootProcessor.cpp
+35
-10
hotspot/src/share/vm/gc/g1/g1RootProcessor.hpp
hotspot/src/share/vm/gc/g1/g1RootProcessor.hpp
+20
-0
hotspot/src/share/vm/runtime/arguments.cpp
hotspot/src/share/vm/runtime/arguments.cpp
+7
-5
hotspot/test/gc/class_unloading/TestClassUnloadingDisabled.java
...t/test/gc/class_unloading/TestClassUnloadingDisabled.java
+118
-0
未找到文件。
hotspot/src/share/vm/gc/g1/g1MarkSweep.cpp
浏览文件 @
fc73aa82
...
...
@@ -132,9 +132,16 @@ void G1MarkSweep::mark_sweep_phase1(bool& marked_for_unloading,
MarkingCodeBlobClosure
follow_code_closure
(
&
GenMarkSweep
::
follow_root_closure
,
!
CodeBlobToOopClosure
::
FixRelocations
);
{
G1RootProcessor
root_processor
(
g1h
,
1
);
root_processor
.
process_strong_roots
(
&
GenMarkSweep
::
follow_root_closure
,
&
GenMarkSweep
::
follow_cld_closure
,
&
follow_code_closure
);
if
(
ClassUnloading
)
{
root_processor
.
process_strong_roots
(
&
GenMarkSweep
::
follow_root_closure
,
&
GenMarkSweep
::
follow_cld_closure
,
&
follow_code_closure
);
}
else
{
root_processor
.
process_all_roots_no_string_table
(
&
GenMarkSweep
::
follow_root_closure
,
&
GenMarkSweep
::
follow_cld_closure
,
&
follow_code_closure
);
}
}
{
...
...
@@ -157,7 +164,7 @@ void G1MarkSweep::mark_sweep_phase1(bool& marked_for_unloading,
// This is the point where the entire marking should have completed.
assert
(
GenMarkSweep
::
_marking_stack
.
is_empty
(),
"Marking should have completed"
);
{
if
(
ClassUnloading
)
{
GCTraceTime
(
Debug
,
gc
,
phases
)
trace
(
"Class Unloading"
,
gc_timer
());
// Unload classes and purge the SystemDictionary.
...
...
hotspot/src/share/vm/gc/g1/g1RootProcessor.cpp
浏览文件 @
fc73aa82
...
...
@@ -83,6 +83,7 @@ void G1RootProcessor::evacuate_roots(G1EvacuationRootClosures* closures, uint wo
}
process_vm_roots
(
closures
,
phase_times
,
worker_i
);
process_string_table_roots
(
closures
,
phase_times
,
worker_i
);
{
// Now the CM ref_processor roots.
...
...
@@ -191,19 +192,34 @@ public:
void
G1RootProcessor
::
process_all_roots
(
OopClosure
*
oops
,
CLDClosure
*
clds
,
CodeBlobClosure
*
blobs
)
{
CodeBlobClosure
*
blobs
,
bool
process_string_table
)
{
AllRootsClosures
closures
(
oops
,
clds
);
process_java_roots
(
&
closures
,
NULL
,
0
);
process_vm_roots
(
&
closures
,
NULL
,
0
);
if
(
!
_process_strong_tasks
.
is_task_claimed
(
G1RP_PS_CodeCache_oops_do
)
)
{
CodeCache
::
blobs_do
(
blobs
);
if
(
process_string_table
)
{
process_string_table_roots
(
&
closures
,
NULL
,
0
);
}
process_code_cache_roots
(
blobs
,
NULL
,
0
);
_process_strong_tasks
.
all_tasks_completed
(
n_workers
());
}
void
G1RootProcessor
::
process_all_roots
(
OopClosure
*
oops
,
CLDClosure
*
clds
,
CodeBlobClosure
*
blobs
)
{
process_all_roots
(
oops
,
clds
,
blobs
,
true
);
}
void
G1RootProcessor
::
process_all_roots_no_string_table
(
OopClosure
*
oops
,
CLDClosure
*
clds
,
CodeBlobClosure
*
blobs
)
{
assert
(
!
ClassUnloading
,
"Should only be used when class unloading is disabled"
);
process_all_roots
(
oops
,
clds
,
blobs
,
false
);
}
void
G1RootProcessor
::
process_java_roots
(
G1RootClosures
*
closures
,
G1GCPhaseTimes
*
phase_times
,
uint
worker_i
)
{
...
...
@@ -280,14 +296,23 @@ void G1RootProcessor::process_vm_roots(G1RootClosures* closures,
SystemDictionary
::
roots_oops_do
(
strong_roots
,
weak_roots
);
}
}
}
{
G1GCParPhaseTimesTracker
x
(
phase_times
,
G1GCPhaseTimes
::
StringTableRoots
,
worker_i
);
// All threads execute the following. A specific chunk of buckets
// from the StringTable are the individual tasks.
if
(
weak_roots
!=
NULL
)
{
StringTable
::
possibly_parallel_oops_do
(
weak_roots
);
}
void
G1RootProcessor
::
process_string_table_roots
(
G1RootClosures
*
closures
,
G1GCPhaseTimes
*
phase_times
,
uint
worker_i
)
{
assert
(
closures
->
weak_oops
()
!=
NULL
,
"Should only be called when all roots are processed"
);
G1GCParPhaseTimesTracker
x
(
phase_times
,
G1GCPhaseTimes
::
StringTableRoots
,
worker_i
);
// All threads execute the following. A specific chunk of buckets
// from the StringTable are the individual tasks.
StringTable
::
possibly_parallel_oops_do
(
closures
->
weak_oops
());
}
void
G1RootProcessor
::
process_code_cache_roots
(
CodeBlobClosure
*
code_closure
,
G1GCPhaseTimes
*
phase_times
,
uint
worker_i
)
{
if
(
!
_process_strong_tasks
.
is_task_claimed
(
G1RP_PS_CodeCache_oops_do
))
{
CodeCache
::
blobs_do
(
code_closure
);
}
}
...
...
hotspot/src/share/vm/gc/g1/g1RootProcessor.hpp
浏览文件 @
fc73aa82
...
...
@@ -73,6 +73,11 @@ class G1RootProcessor : public StackObj {
void
worker_has_discovered_all_strong_classes
();
void
wait_until_all_strong_classes_discovered
();
void
process_all_roots
(
OopClosure
*
oops
,
CLDClosure
*
clds
,
CodeBlobClosure
*
blobs
,
bool
process_string_table
);
void
process_java_roots
(
G1RootClosures
*
closures
,
G1GCPhaseTimes
*
phase_times
,
uint
worker_i
);
...
...
@@ -81,6 +86,14 @@ class G1RootProcessor : public StackObj {
G1GCPhaseTimes
*
phase_times
,
uint
worker_i
);
void
process_string_table_roots
(
G1RootClosures
*
closures
,
G1GCPhaseTimes
*
phase_times
,
uint
worker_i
);
void
process_code_cache_roots
(
CodeBlobClosure
*
code_closure
,
G1GCPhaseTimes
*
phase_times
,
uint
worker_i
);
public:
G1RootProcessor
(
G1CollectedHeap
*
g1h
,
uint
n_workers
);
...
...
@@ -99,6 +112,13 @@ public:
CLDClosure
*
clds
,
CodeBlobClosure
*
blobs
);
// Apply oops, clds and blobs to strongly and weakly reachable roots in the system,
// the only thing different from process_all_roots is that we skip the string table
// to avoid keeping every string live when doing class unloading.
void
process_all_roots_no_string_table
(
OopClosure
*
oops
,
CLDClosure
*
clds
,
CodeBlobClosure
*
blobs
);
// Number of worker threads used by the root processor.
uint
n_workers
()
const
;
};
...
...
hotspot/src/share/vm/runtime/arguments.cpp
浏览文件 @
fc73aa82
...
...
@@ -1665,11 +1665,6 @@ void Arguments::set_cms_and_parnew_gc_flags() {
CompactibleFreeListSpaceLAB
::
modify_initialization
(
OldPLABSize
,
OldPLABWeight
);
}
if
(
!
ClassUnloading
)
{
FLAG_SET_CMDLINE
(
bool
,
CMSClassUnloadingEnabled
,
false
);
FLAG_SET_CMDLINE
(
bool
,
ExplicitGCInvokesConcurrentAndUnloadsClasses
,
false
);
}
log_trace
(
gc
)(
"MarkStackSize: %uk MarkStackSizeMax: %uk"
,
(
unsigned
int
)
(
MarkStackSize
/
K
),
(
uint
)
(
MarkStackSizeMax
/
K
));
}
#endif // INCLUDE_ALL_GCS
...
...
@@ -1997,6 +1992,13 @@ void Arguments::set_gc_specific_flags() {
// Keeping the heap 100% free is hard ;-) so limit it to 99%.
FLAG_SET_ERGO
(
uintx
,
MinHeapFreeRatio
,
99
);
}
// If class unloading is disabled, also disable concurrent class unloading.
if
(
!
ClassUnloading
)
{
FLAG_SET_CMDLINE
(
bool
,
CMSClassUnloadingEnabled
,
false
);
FLAG_SET_CMDLINE
(
bool
,
ClassUnloadingWithConcurrentMark
,
false
);
FLAG_SET_CMDLINE
(
bool
,
ExplicitGCInvokesConcurrentAndUnloadsClasses
,
false
);
}
#endif // INCLUDE_ALL_GCS
}
...
...
hotspot/test/gc/class_unloading/TestClassUnloadingDisabled.java
0 → 100644
浏览文件 @
fc73aa82
/*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reqserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @key gc
* @bug 8114823
* @requires vm.gc == null
* @requires vm.opt.ExplicitGCInvokesConcurrent != true
* @requires vm.opt.ClassUnloading != true
* @library /test/lib
* @modules java.base/jdk.internal.misc
* java.management
* @build sun.hotspot.WhiteBox
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
*
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
* -XX:-ClassUnloading -XX:+UseG1GC TestClassUnloadingDisabled
*
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
* -XX:-ClassUnloading -XX:+UseSerialGC TestClassUnloadingDisabled
*
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
* -XX:-ClassUnloading -XX:+UseParallelGC TestClassUnloadingDisabled
*
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
* -XX:-ClassUnloading -XX:+UseConcMarkSweepGC TestClassUnloadingDisabled
*/
import
java.io.File
;
import
java.io.IOException
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.nio.file.Paths
;
import
sun.hotspot.WhiteBox
;
import
static
jdk
.
test
.
lib
.
Asserts
.*;
public
class
TestClassUnloadingDisabled
{
public
static
void
main
(
String
args
[])
throws
Exception
{
final
WhiteBox
wb
=
WhiteBox
.
getWhiteBox
();
// Fetch the dir where the test class and the class
// to be loaded resides.
String
classDir
=
TestClassUnloadingDisabled
.
class
.
getProtectionDomain
().
getCodeSource
().
getLocation
().
getPath
();
String
className
=
"ClassToLoadUnload"
;
assertFalse
(
wb
.
isClassAlive
(
className
),
"Should not be loaded yet"
);
// The NoPDClassLoader handles loading classes in the test directory
// and loads them without a protection domain, which in some cases
// keeps the class live regardless of marking state.
NoPDClassLoader
nopd
=
new
NoPDClassLoader
(
classDir
);
nopd
.
loadClass
(
className
);
assertTrue
(
wb
.
isClassAlive
(
className
),
"Class should be loaded"
);
// Clear the class-loader, class and object references to make
// class unloading possible.
nopd
=
null
;
System
.
gc
();
assertTrue
(
wb
.
isClassAlive
(
className
),
"Class should not have ben unloaded"
);
}
}
class
NoPDClassLoader
extends
ClassLoader
{
String
path
;
NoPDClassLoader
(
String
path
)
{
this
.
path
=
path
;
}
public
Class
<?>
loadClass
(
String
name
)
throws
ClassNotFoundException
{
byte
[]
cls
=
null
;
File
f
=
new
File
(
path
,
name
+
".class"
);
// Delegate class loading if class not present in the given
// directory.
if
(!
f
.
exists
())
{
return
super
.
loadClass
(
name
);
}
try
{
Path
path
=
Paths
.
get
(
f
.
getAbsolutePath
());
cls
=
Files
.
readAllBytes
(
path
);
}
catch
(
IOException
e
)
{
throw
new
ClassNotFoundException
(
name
);
}
// Define class with no protection domain and resolve it.
return
defineClass
(
name
,
cls
,
0
,
cls
.
length
,
null
);
}
}
class
ClassToLoadUnload
{
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录