Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_hotspot
提交
eedeebde
D
dragonwell8_hotspot
项目概览
openanolis
/
dragonwell8_hotspot
通知
2
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_hotspot
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
eedeebde
编写于
9月 11, 2012
作者:
Z
zgu
浏览文件
操作
浏览文件
下载
差异文件
Merge
上级
c9bb8cb1
93294c84
变更
7
展开全部
隐藏空白更改
内联
并排
Showing
7 changed file
with
379 addition
and
366 deletion
+379
-366
src/share/vm/runtime/thread.cpp
src/share/vm/runtime/thread.cpp
+5
-6
src/share/vm/services/memPtr.cpp
src/share/vm/services/memPtr.cpp
+5
-5
src/share/vm/services/memPtrArray.hpp
src/share/vm/services/memPtrArray.hpp
+0
-4
src/share/vm/services/memSnapshot.cpp
src/share/vm/services/memSnapshot.cpp
+244
-270
src/share/vm/services/memSnapshot.hpp
src/share/vm/services/memSnapshot.hpp
+95
-75
src/share/vm/services/memTrackWorker.cpp
src/share/vm/services/memTrackWorker.cpp
+4
-1
src/share/vm/services/memTracker.hpp
src/share/vm/services/memTracker.hpp
+26
-5
未找到文件。
src/share/vm/runtime/thread.cpp
浏览文件 @
eedeebde
...
...
@@ -318,10 +318,9 @@ void Thread::record_stack_base_and_size() {
set_stack_size
(
os
::
current_stack_size
());
// record thread's native stack, stack grows downward
address
vm_base
=
_stack_base
-
_stack_size
;
MemTracker
::
record_virtual_memory_reserve
(
vm_base
,
_stack_size
,
CURRENT_PC
,
this
);
MemTracker
::
record_virtual_memory_type
(
vm_base
,
mtThreadStack
);
address
low_stack_addr
=
stack_base
()
-
stack_size
();
MemTracker
::
record_thread_stack
(
low_stack_addr
,
stack_size
(),
this
,
CURRENT_PC
);
}
...
...
@@ -329,8 +328,8 @@ Thread::~Thread() {
// Reclaim the objectmonitors from the omFreeList of the moribund thread.
ObjectSynchronizer
::
omFlush
(
this
)
;
MemTracker
::
record_virtual_memory_release
((
_stack_base
-
_stack_size
),
_stack_size
,
this
);
address
low_stack_addr
=
stack_base
()
-
stack_size
();
MemTracker
::
release_thread_stack
(
low_stack_addr
,
stack_size
()
,
this
);
// deallocate data structures
delete
resource_area
();
...
...
src/share/vm/services/memPtr.cpp
浏览文件 @
eedeebde
...
...
@@ -43,9 +43,9 @@ jint SequenceGenerator::next() {
bool
VMMemRegion
::
contains
(
const
VMMemRegion
*
mr
)
const
{
assert
(
base
()
!=
0
,
"
no base address
"
);
assert
(
base
()
!=
0
,
"
Sanity check
"
);
assert
(
size
()
!=
0
||
committed_size
()
!=
0
,
"
no range
"
);
"
Sanity check
"
);
address
base_addr
=
base
();
address
end_addr
=
base_addr
+
(
is_reserve_record
()
?
reserved_size
()
:
committed_size
());
...
...
@@ -61,14 +61,14 @@ bool VMMemRegion::contains(const VMMemRegion* mr) const {
return
(
mr
->
base
()
>=
base_addr
&&
(
mr
->
base
()
+
mr
->
committed_size
())
<=
end_addr
);
}
else
if
(
mr
->
is_type_tagging_record
())
{
assert
(
mr
->
base
()
!=
0
,
"no base
"
);
return
mr
->
base
()
==
base_addr
;
assert
(
mr
->
base
()
!=
NULL
,
"Sanity check
"
);
return
(
mr
->
base
()
>=
base_addr
&&
mr
->
base
()
<
end_addr
)
;
}
else
if
(
mr
->
is_release_record
())
{
assert
(
mr
->
base
()
!=
0
&&
mr
->
size
()
>
0
,
"bad record"
);
return
(
mr
->
base
()
==
base_addr
&&
mr
->
size
()
==
size
());
}
else
{
assert
(
false
,
"what happened?"
);
ShouldNotReachHere
(
);
return
false
;
}
}
src/share/vm/services/memPtrArray.hpp
浏览文件 @
eedeebde
...
...
@@ -84,11 +84,7 @@ class MemPointerArrayIterator VALUE_OBJ_CLASS_SPEC {
// implementation class
class
MemPointerArrayIteratorImpl
:
public
MemPointerArrayIterator
{
#ifdef ASSERT
protected:
#else
private:
#endif
MemPointerArray
*
_array
;
int
_pos
;
...
...
src/share/vm/services/memSnapshot.cpp
浏览文件 @
eedeebde
此差异已折叠。
点击以展开。
src/share/vm/services/memSnapshot.hpp
浏览文件 @
eedeebde
...
...
@@ -111,37 +111,31 @@ class VMMemPointerIterator : public MemPointerIterator {
MemPointerIterator
(
arr
)
{
}
// locate an exiting record that contains specified address, or
// locate an exi
s
ting record that contains specified address, or
// the record, where the record with specified address, should
// be inserted
// be inserted.
// virtual memory record array is sorted in address order, so
// binary search is performed
virtual
MemPointer
*
locate
(
address
addr
)
{
VMMemRegion
*
cur
=
(
VMMemRegion
*
)
current
();
VMMemRegion
*
next_p
;
while
(
cur
!=
NULL
)
{
if
(
cur
->
base
()
>
addr
)
{
return
cur
;
int
index_low
=
0
;
int
index_high
=
_array
->
length
();
int
index_mid
=
(
index_high
+
index_low
)
/
2
;
int
r
=
1
;
while
(
index_low
<
index_high
&&
(
r
=
compare
(
index_mid
,
addr
))
!=
0
)
{
if
(
r
>
0
)
{
index_high
=
index_mid
;
}
else
{
// find nearest existing range that has base address <= addr
next_p
=
(
VMMemRegion
*
)
peek_next
();
if
(
next_p
!=
NULL
&&
next_p
->
base
()
<=
addr
)
{
cur
=
(
VMMemRegion
*
)
next
();
continue
;
}
}
if
(
cur
->
is_reserve_record
()
&&
cur
->
base
()
<=
addr
&&
(
cur
->
base
()
+
cur
->
size
()
>
addr
))
{
return
cur
;
}
else
if
(
cur
->
is_commit_record
()
&&
cur
->
base
()
<=
addr
&&
(
cur
->
base
()
+
cur
->
committed_size
()
>
addr
))
{
return
cur
;
index_low
=
index_mid
;
}
cur
=
(
VMMemRegion
*
)
next
();
index_mid
=
(
index_high
+
index_low
)
/
2
;
}
if
(
r
==
0
)
{
// update current location
_pos
=
index_mid
;
return
_array
->
at
(
index_mid
);
}
else
{
return
NULL
;
}
return
NULL
;
}
#ifdef ASSERT
...
...
@@ -160,75 +154,99 @@ class VMMemPointerIterator : public MemPointerIterator {
(
p1
->
flags
()
&
MemPointerRecord
::
tag_masks
)
==
MemPointerRecord
::
tag_release
;
}
#endif
// compare if an address falls into a memory region,
// return 0, if the address falls into a memory region at specified index
// return 1, if memory region pointed by specified index is higher than the address
// return -1, if memory region pointed by specified index is lower than the address
int
compare
(
int
index
,
address
addr
)
const
{
VMMemRegion
*
r
=
(
VMMemRegion
*
)
_array
->
at
(
index
);
assert
(
r
->
is_reserve_record
(),
"Sanity check"
);
if
(
r
->
addr
()
>
addr
)
{
return
1
;
}
else
if
(
r
->
addr
()
+
r
->
reserved_size
()
<=
addr
)
{
return
-
1
;
}
else
{
return
0
;
}
}
};
class
StagingWalke
r
:
public
MemPointerArrayIterator
{
class
MallocRecordIterato
r
:
public
MemPointerArrayIterator
{
private:
MemPointerArrayIteratorImpl
_itr
;
bool
_is_vm_record
;
bool
_end_of_array
;
VMMemRegionEx
_vm_record
;
MemPointerRecordEx
_malloc_record
;
public:
StagingWalker
(
MemPointerArray
*
arr
)
:
_itr
(
arr
)
{
_end_of_array
=
false
;
next
();
MallocRecordIterator
(
MemPointerArray
*
arr
)
:
_itr
(
arr
)
{
}
// return the pointer at current position
MemPointer
*
current
()
const
{
if
(
_end_of_array
)
{
MemPointerRecord
*
cur
=
(
MemPointerRecord
*
)
_itr
.
current
();
assert
(
cur
==
NULL
||
!
cur
->
is_vm_pointer
(),
"seek error"
);
MemPointerRecord
*
next
=
(
MemPointerRecord
*
)
_itr
.
peek_next
();
if
(
next
==
NULL
||
next
->
addr
()
!=
cur
->
addr
())
{
return
cur
;
}
else
{
assert
(
!
cur
->
is_vm_pointer
(),
"Sanity check"
);
assert
(
cur
->
is_allocation_record
()
&&
next
->
is_deallocation_record
(),
"sorting order"
);
assert
(
cur
->
seq
()
!=
next
->
seq
(),
"Sanity check"
);
return
cur
->
seq
()
>
next
->
seq
()
?
cur
:
next
;
}
}
MemPointer
*
next
()
{
MemPointerRecord
*
cur
=
(
MemPointerRecord
*
)
_itr
.
current
();
assert
(
cur
==
NULL
||
!
cur
->
is_vm_pointer
(),
"Sanity check"
);
MemPointerRecord
*
next
=
(
MemPointerRecord
*
)
_itr
.
next
();
if
(
next
==
NULL
)
{
return
NULL
;
}
if
(
is_vm_record
())
{
return
(
MemPointer
*
)
&
_vm_record
;
}
else
{
return
(
MemPointer
*
)
&
_malloc_record
;
if
(
cur
->
addr
()
==
next
->
addr
())
{
next
=
(
MemPointerRecord
*
)
_itr
.
next
();
}
return
current
();
}
// return the next pointer and advance current position
MemPointer
*
next
();
MemPointer
*
peek_next
()
const
{
ShouldNotReachHere
();
return
NULL
;
}
MemPointer
*
peek_prev
()
const
{
ShouldNotReachHere
();
return
NULL
;
}
void
remove
()
{
ShouldNotReachHere
();
}
bool
insert
(
MemPointer
*
ptr
)
{
ShouldNotReachHere
();
return
false
;
}
bool
insert_after
(
MemPointer
*
ptr
)
{
ShouldNotReachHere
();
return
false
;
}
};
// type of 'current' record
bool
is_vm_record
()
const
{
return
_is_vm_record
;
}
class
StagingArea
:
public
_ValueObj
{
private:
MemPointerArray
*
_malloc_data
;
MemPointerArray
*
_vm_data
;
// return the next poinger without advancing current position
MemPointer
*
peek_next
()
const
{
assert
(
false
,
"not supported"
);
return
NULL
;
public:
StagingArea
()
:
_malloc_data
(
NULL
),
_vm_data
(
NULL
)
{
init
();
}
MemPointer
*
peek_prev
()
const
{
assert
(
false
,
"not supported"
);
return
NULL
;
}
// remove the pointer at current position
void
remove
()
{
assert
(
false
,
"not supported"
);
~
StagingArea
()
{
if
(
_malloc_data
!=
NULL
)
delete
_malloc_data
;
if
(
_vm_data
!=
NULL
)
delete
_vm_data
;
}
// insert the pointer at current position
bool
insert
(
MemPointer
*
ptr
)
{
assert
(
false
,
"not supported"
);
return
false
;
MallocRecordIterator
malloc_record_walker
()
{
return
MallocRecordIterator
(
malloc_data
());
}
bool
insert_after
(
MemPointer
*
ptr
)
{
assert
(
false
,
"not supported"
);
return
false
;
MemPointerArrayIteratorImpl
virtual_memory_record_walker
();
bool
init
();
void
clear
()
{
assert
(
_malloc_data
!=
NULL
&&
_vm_data
!=
NULL
,
"Just check"
);
_malloc_data
->
shrink
();
_malloc_data
->
clear
();
_vm_data
->
clear
();
}
private:
// consolidate all records referring to this vm region
bool
consolidate_vm_records
(
VMMemRegionEx
*
vm_rec
);
inline
MemPointerArray
*
malloc_data
()
{
return
_malloc_data
;
}
inline
MemPointerArray
*
vm_data
()
{
return
_vm_data
;
}
};
class
MemBaseline
;
class
MemSnapshot
:
public
CHeapObj
<
mtNMT
>
{
private:
// the following two arrays contain records of all known lived memory blocks
...
...
@@ -237,9 +255,7 @@ class MemSnapshot : public CHeapObj<mtNMT> {
// live virtual memory pointers
MemPointerArray
*
_vm_ptrs
;
// stagging a generation's data, before
// it can be prompted to snapshot
MemPointerArray
*
_staging_area
;
StagingArea
_staging_area
;
// the lock to protect this snapshot
Monitor
*
_lock
;
...
...
@@ -252,18 +268,19 @@ class MemSnapshot : public CHeapObj<mtNMT> {
virtual
~
MemSnapshot
();
// if we are running out of native memory
bool
out_of_memory
()
const
{
return
(
_alloc_ptrs
==
NULL
||
_staging_area
==
NULL
||
bool
out_of_memory
()
{
return
(
_alloc_ptrs
==
NULL
||
_staging_area
.
malloc_data
()
==
NULL
||
_staging_area
.
vm_data
()
==
NULL
||
_vm_ptrs
==
NULL
||
_lock
==
NULL
||
_alloc_ptrs
->
out_of_memory
()
||
_staging_area
->
out_of_memory
()
||
_vm_ptrs
->
out_of_memory
());
}
// merge a per-thread memory recorder into staging area
bool
merge
(
MemRecorder
*
rec
);
// promote staged data to snapshot
void
promote
();
bool
promote
();
void
wait
(
long
timeout
)
{
...
...
@@ -280,6 +297,9 @@ class MemSnapshot : public CHeapObj<mtNMT> {
private:
// copy pointer data from src to dest
void
copy_pointer
(
MemPointerRecord
*
dest
,
const
MemPointerRecord
*
src
);
bool
promote_malloc_records
(
MemPointerArrayIterator
*
itr
);
bool
promote_virtual_memory_records
(
MemPointerArrayIterator
*
itr
);
};
...
...
src/share/vm/services/memTrackWorker.cpp
浏览文件 @
eedeebde
...
...
@@ -118,7 +118,10 @@ void MemTrackWorker::run() {
_head
=
(
_head
+
1
)
%
MAX_GENERATIONS
;
}
// promote this generation data to snapshot
snapshot
->
promote
();
if
(
!
snapshot
->
promote
())
{
// failed to promote, means out of memory
MemTracker
::
shutdown
(
MemTracker
::
NMT_out_of_memory
);
}
}
else
{
snapshot
->
wait
(
1000
);
ThreadCritical
tc
;
...
...
src/share/vm/services/memTracker.hpp
浏览文件 @
eedeebde
...
...
@@ -39,7 +39,7 @@
#include "thread_solaris.inline.hpp"
#endif
#ifdef _DEBUG
_
#ifdef _DEBUG
#define DEBUG_CALLER_PC os::get_caller_pc(3)
#else
#define DEBUG_CALLER_PC 0
...
...
@@ -223,12 +223,33 @@ class MemTracker : AllStatic {
}
}
static
inline
void
record_thread_stack
(
address
addr
,
size_t
size
,
Thread
*
thr
,
address
pc
=
0
)
{
if
(
is_on
())
{
assert
(
size
>
0
&&
thr
!=
NULL
,
"Sanity check"
);
create_memory_record
(
addr
,
MemPointerRecord
::
virtual_memory_reserve_tag
()
|
mtThreadStack
,
size
,
pc
,
thr
);
create_memory_record
(
addr
,
MemPointerRecord
::
virtual_memory_commit_tag
()
|
mtThreadStack
,
size
,
pc
,
thr
);
}
}
static
inline
void
release_thread_stack
(
address
addr
,
size_t
size
,
Thread
*
thr
)
{
if
(
is_on
())
{
assert
(
size
>
0
&&
thr
!=
NULL
,
"Sanity check"
);
create_memory_record
(
addr
,
MemPointerRecord
::
virtual_memory_uncommit_tag
()
|
mtThreadStack
,
size
,
DEBUG_CALLER_PC
,
thr
);
create_memory_record
(
addr
,
MemPointerRecord
::
virtual_memory_release_tag
()
|
mtThreadStack
,
size
,
DEBUG_CALLER_PC
,
thr
);
}
}
// record a virtual memory 'commit' call
static
inline
void
record_virtual_memory_commit
(
address
addr
,
size_t
size
,
address
pc
=
0
,
Thread
*
thread
=
NULL
)
{
if
(
is_on
())
{
create_memory_record
(
addr
,
MemPointerRecord
::
virtual_memory_commit_tag
(),
size
,
pc
,
thread
);
size
,
DEBUG_CALLER_PC
,
thread
);
}
}
...
...
@@ -237,7 +258,7 @@ class MemTracker : AllStatic {
Thread
*
thread
=
NULL
)
{
if
(
is_on
())
{
create_memory_record
(
addr
,
MemPointerRecord
::
virtual_memory_uncommit_tag
(),
size
,
0
,
thread
);
size
,
DEBUG_CALLER_PC
,
thread
);
}
}
...
...
@@ -246,7 +267,7 @@ class MemTracker : AllStatic {
Thread
*
thread
=
NULL
)
{
if
(
is_on
())
{
create_memory_record
(
addr
,
MemPointerRecord
::
virtual_memory_release_tag
(),
size
,
0
,
thread
);
size
,
DEBUG_CALLER_PC
,
thread
);
}
}
...
...
@@ -257,7 +278,7 @@ class MemTracker : AllStatic {
assert
(
base
>
0
,
"wrong base address"
);
assert
((
flags
&
(
~
mt_masks
))
==
0
,
"memory type only"
);
create_memory_record
(
base
,
(
flags
|
MemPointerRecord
::
virtual_memory_type_tag
()),
0
,
0
,
thread
);
0
,
DEBUG_CALLER_PC
,
thread
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录