Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
34876602
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
34876602
编写于
9月 14, 2009
作者:
A
alanb
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6529758: JVMTI Waiters demo crashes. Double free.
Reviewed-by: ohair, tbell
上级
eed4dc6a
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
51 addition
and
36 deletion
+51
-36
src/share/demo/jvmti/waiters/Agent.cpp
src/share/demo/jvmti/waiters/Agent.cpp
+33
-35
src/share/demo/jvmti/waiters/Agent.hpp
src/share/demo/jvmti/waiters/Agent.hpp
+5
-1
src/share/demo/jvmti/waiters/Monitor.cpp
src/share/demo/jvmti/waiters/Monitor.cpp
+10
-0
src/share/demo/jvmti/waiters/Monitor.hpp
src/share/demo/jvmti/waiters/Monitor.hpp
+3
-0
未找到文件。
src/share/demo/jvmti/waiters/Agent.cpp
浏览文件 @
34876602
...
...
@@ -72,14 +72,6 @@ Agent::get_monitor(jvmtiEnv *jvmti, JNIEnv *env, jobject object)
{
jvmtiError
err
;
Monitor
*
m
;
/* We use tags to track these, the tag is the Monitor pointer */
err
=
jvmti
->
RawMonitorEnter
(
lock
);
{
check_jvmti_error
(
jvmti
,
err
,
"raw monitor enter"
);
/* The raw monitor enter/exit protects us from creating two
* instances for the same object.
*/
jlong
tag
;
m
=
NULL
;
...
...
@@ -90,18 +82,20 @@ Agent::get_monitor(jvmtiEnv *jvmti, JNIEnv *env, jobject object)
m
=
(
Monitor
*
)(
void
*
)(
ptrdiff_t
)
tag
;
if
(
m
==
NULL
)
{
m
=
new
Monitor
(
jvmti
,
env
,
object
);
/* Save monitor on list */
if
(
monitor_count
==
monitor_list_size
)
{
monitor_list_size
+=
monitor_list_grow_size
;
monitor_list
=
(
Monitor
**
)
realloc
((
void
*
)
monitor_list
,
(
monitor_list_size
)
*
(
int
)
sizeof
(
Monitor
*
));
}
monitor_list
[
monitor_count
]
=
m
;
m
->
set_slot
(
monitor_count
);
monitor_count
++
;
/*LINTED*/
tag
=
(
jlong
)(
ptrdiff_t
)(
void
*
)
m
;
err
=
jvmti
->
SetTag
(
object
,
tag
);
check_jvmti_error
(
jvmti
,
err
,
"set tag"
);
/* Save monitor on list */
monitor_list
=
(
Monitor
**
)
realloc
((
void
*
)
monitor_list
,
(
monitor_count
+
1
)
*
(
int
)
sizeof
(
Monitor
*
));
monitor_list
[
monitor_count
++
]
=
m
;
}
}
err
=
jvmti
->
RawMonitorExit
(
lock
);
check_jvmti_error
(
jvmti
,
err
,
"raw monitor exit"
);
return
m
;
}
...
...
@@ -112,12 +106,11 @@ Agent::Agent(jvmtiEnv *jvmti, JNIEnv *env, jthread thread)
stdout_message
(
"Agent created..
\n
"
);
stdout_message
(
"VMInit...
\n
"
);
/* Create a Monitor lock to use */
err
=
jvmti
->
CreateRawMonitor
(
"waiters Agent lock"
,
&
lock
);
check_jvmti_error
(
jvmti
,
err
,
"create raw monitor"
);
/* Start monitor list */
monitor_count
=
0
;
monitor_list
=
(
Monitor
**
)
malloc
((
int
)
sizeof
(
Monitor
*
));
monitor_list_size
=
initial_monitor_list_size
;
monitor_list
=
(
Monitor
**
)
malloc
(
monitor_list_size
*
(
int
)
sizeof
(
Monitor
*
));
}
Agent
::~
Agent
()
...
...
@@ -134,9 +127,6 @@ void Agent::vm_death(jvmtiEnv *jvmti, JNIEnv *env)
delete
monitor_list
[
i
];
}
free
(
monitor_list
);
/* Destroy the Monitor lock to use */
err
=
jvmti
->
DestroyRawMonitor
(
lock
);
check_jvmti_error
(
jvmti
,
err
,
"destroy raw monitor"
);
/* Print death message */
stdout_message
(
"VMDeath...
\n
"
);
}
...
...
@@ -218,5 +208,13 @@ void Agent::object_free(jvmtiEnv* jvmti, jlong tag)
Monitor
*
m
;
/*LINTED*/
m
=
(
Monitor
*
)(
ptrdiff_t
)
tag
;
if
(
monitor_count
>
1
)
{
/* Move the last element to this Monitor's slot */
int
slot
=
m
->
get_slot
();
Monitor
*
last
=
monitor_list
[
monitor_count
-
1
];
monitor_list
[
slot
]
=
last
;
last
->
set_slot
(
slot
);
}
monitor_count
--
;
delete
m
;
}
src/share/demo/jvmti/waiters/Agent.hpp
浏览文件 @
34876602
...
...
@@ -34,8 +34,12 @@
class
Agent
{
private:
jrawMonitorID
lock
;
enum
{
initial_monitor_list_size
=
64
,
monitor_list_grow_size
=
16
};
Monitor
**
monitor_list
;
unsigned
monitor_list_size
;
unsigned
monitor_count
;
Thread
*
get_thread
(
jvmtiEnv
*
jvmti
,
JNIEnv
*
env
,
jthread
thread
);
Monitor
*
get_monitor
(
jvmtiEnv
*
jvmti
,
JNIEnv
*
env
,
jobject
object
);
...
...
src/share/demo/jvmti/waiters/Monitor.cpp
浏览文件 @
34876602
...
...
@@ -73,6 +73,16 @@ Monitor::~Monitor()
name
,
contends
,
waits
,
timeouts
);
}
int
Monitor
::
get_slot
()
{
return
slot
;
}
void
Monitor
::
set_slot
(
int
aslot
)
{
slot
=
aslot
;
}
void
Monitor
::
contended
()
{
contends
++
;
...
...
src/share/demo/jvmti/waiters/Monitor.hpp
浏览文件 @
34876602
...
...
@@ -35,6 +35,7 @@ class Monitor {
private:
char
name
[
64
];
int
slot
;
unsigned
contends
;
unsigned
waits
;
unsigned
timeouts
;
...
...
@@ -42,6 +43,8 @@ class Monitor {
public:
Monitor
(
jvmtiEnv
*
jvmti
,
JNIEnv
*
env
,
jobject
object
);
~
Monitor
();
int
get_slot
();
void
set_slot
(
int
i
);
void
contended
();
void
waited
();
void
timeout
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录