Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_hotspot
提交
cb8511d0
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看板
提交
cb8511d0
编写于
2月 15, 2012
作者:
F
fparain
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
7145243: Need additional specializations for argument parsing framework
Reviewed-by: acorn, fparain Contributed-by: nils.loodin@oracle.com
上级
89fd0b81
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
228 addition
and
18 deletion
+228
-18
src/share/vm/runtime/thread.cpp
src/share/vm/runtime/thread.cpp
+7
-5
src/share/vm/services/diagnosticArgument.cpp
src/share/vm/services/diagnosticArgument.cpp
+170
-9
src/share/vm/services/diagnosticArgument.hpp
src/share/vm/services/diagnosticArgument.hpp
+47
-1
src/share/vm/services/diagnosticFramework.cpp
src/share/vm/services/diagnosticFramework.cpp
+2
-2
src/share/vm/services/diagnosticFramework.hpp
src/share/vm/services/diagnosticFramework.hpp
+2
-1
未找到文件。
src/share/vm/runtime/thread.cpp
浏览文件 @
cb8511d0
...
...
@@ -3220,11 +3220,6 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) {
return
status
;
}
// Must be run after init_ft which initializes ft_enabled
if
(
TRACE_INITIALIZE
()
!=
JNI_OK
)
{
vm_exit_during_initialization
(
"Failed to initialize tracing backend"
);
}
// Should be done after the heap is fully created
main_thread
->
cache_global_variables
();
...
...
@@ -3366,6 +3361,7 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) {
initialize_class
(
vmSymbols
::
java_lang_ArithmeticException
(),
CHECK_0
);
initialize_class
(
vmSymbols
::
java_lang_StackOverflowError
(),
CHECK_0
);
initialize_class
(
vmSymbols
::
java_lang_IllegalMonitorStateException
(),
CHECK_0
);
initialize_class
(
vmSymbols
::
java_lang_IllegalArgumentException
(),
CHECK_0
);
}
else
{
warning
(
"java.lang.OutOfMemoryError has not been initialized"
);
warning
(
"java.lang.NullPointerException has not been initialized"
);
...
...
@@ -3373,6 +3369,7 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) {
warning
(
"java.lang.ArrayStoreException has not been initialized"
);
warning
(
"java.lang.ArithmeticException has not been initialized"
);
warning
(
"java.lang.StackOverflowError has not been initialized"
);
warning
(
"java.lang.IllegalArgumentException has not been initialized"
);
}
}
...
...
@@ -3402,6 +3399,11 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) {
quicken_jni_functions
();
// Must be run after init_ft which initializes ft_enabled
if
(
TRACE_INITIALIZE
()
!=
JNI_OK
)
{
vm_exit_during_initialization
(
"Failed to initialize tracing backend"
);
}
// Set flag that basic initialization has completed. Used by exceptions and various
// debug stuff, that does not work until all basic classes have been initialized.
set_init_completed
();
...
...
src/share/vm/services/diagnosticArgument.cpp
浏览文件 @
cb8511d0
...
...
@@ -28,9 +28,16 @@
#include "services/diagnosticArgument.hpp"
void
GenDCmdArgument
::
read_value
(
const
char
*
str
,
size_t
len
,
TRAPS
)
{
if
(
is_set
())
{
/* NOTE:Some argument types doesn't require a value,
* for instance boolean arguments: "enableFeatureX". is
* equivalent to "enableFeatureX=true". In these cases,
* str will be null. This is perfectly valid.
* All argument types must perform null checks on str.
*/
if
(
is_set
()
&&
!
allow_multiple
())
{
THROW_MSG
(
vmSymbols
::
java_lang_IllegalArgumentException
(),
"Duplicates in diagnostic command arguments"
);
"Duplicates in diagnostic command arguments
\n
"
);
}
parse_value
(
str
,
len
,
CHECK
);
set_is_set
(
true
);
...
...
@@ -38,9 +45,9 @@ void GenDCmdArgument::read_value(const char* str, size_t len, TRAPS) {
template
<
>
void
DCmdArgument
<
jlong
>::
parse_value
(
const
char
*
str
,
size_t
len
,
TRAPS
)
{
if
(
sscanf
(
str
,
INT64_FORMAT
,
&
_value
)
!=
1
)
{
if
(
str
==
NULL
||
sscanf
(
str
,
INT64_FORMAT
,
&
_value
)
!=
1
)
{
THROW_MSG
(
vmSymbols
::
java_lang_IllegalArgumentException
(),
"Integer parsing error in diagnostic command arguments"
);
"Integer parsing error in diagnostic command arguments
\n
"
);
}
}
...
...
@@ -89,13 +96,17 @@ template <> void DCmdArgument<bool>::destroy_value() { }
template
<
>
void
DCmdArgument
<
char
*>::
parse_value
(
const
char
*
str
,
size_t
len
,
TRAPS
)
{
if
(
str
==
NULL
)
{
_value
=
NULL
;
}
else
{
_value
=
NEW_C_HEAP_ARRAY
(
char
,
len
+
1
);
strncpy
(
_value
,
str
,
len
);
_value
[
len
]
=
0
;
}
}
template
<
>
void
DCmdArgument
<
char
*>::
init_value
(
TRAPS
)
{
if
(
has_default
())
{
if
(
has_default
()
&&
_default_string
!=
NULL
)
{
this
->
parse_value
(
_default_string
,
strlen
(
_default_string
),
THREAD
);
if
(
HAS_PENDING_EXCEPTION
)
{
fatal
(
"Default string must be parsable"
);
...
...
@@ -111,3 +122,153 @@ template <> void DCmdArgument<char*>::destroy_value() {
set_value
(
NULL
);
}
}
template
<
>
void
DCmdArgument
<
NanoTimeArgument
>::
parse_value
(
const
char
*
str
,
size_t
len
,
TRAPS
)
{
if
(
str
==
NULL
)
{
THROW_MSG
(
vmSymbols
::
java_lang_IllegalArgumentException
(),
"Integer parsing error nanotime value: syntax error"
);
}
int
argc
=
sscanf
(
str
,
INT64_FORMAT
,
&
_value
.
_time
);
if
(
argc
!=
1
)
{
THROW_MSG
(
vmSymbols
::
java_lang_IllegalArgumentException
(),
"Integer parsing error nanotime value: syntax error"
);
}
size_t
idx
=
0
;
while
(
idx
<
len
&&
isdigit
(
str
[
idx
]))
{
idx
++
;
}
if
(
idx
==
len
)
{
// only accept missing unit if the value is 0
if
(
_value
.
_time
!=
0
)
{
THROW_MSG
(
vmSymbols
::
java_lang_IllegalArgumentException
(),
"Integer parsing error nanotime value: unit required"
);
}
else
{
_value
.
_nanotime
=
0
;
strcpy
(
_value
.
_unit
,
"ns"
);
return
;
}
}
else
if
(
len
-
idx
>
2
)
{
THROW_MSG
(
vmSymbols
::
java_lang_IllegalArgumentException
(),
"Integer parsing error nanotime value: illegal unit"
);
}
else
{
strncpy
(
_value
.
_unit
,
&
str
[
idx
],
len
-
idx
);
/*Write an extra null termination. This is safe because _value._unit
* is declared as char[3], and length is checked to be not larger than
* two above. Also, this is necessary, since length might be 1, and the
* default value already in the string is ns, which is two chars.
*/
_value
.
_unit
[
len
-
idx
]
=
'\0'
;
}
if
(
strcmp
(
_value
.
_unit
,
"ns"
)
==
0
)
{
_value
.
_nanotime
=
_value
.
_time
;
}
else
if
(
strcmp
(
_value
.
_unit
,
"us"
)
==
0
)
{
_value
.
_nanotime
=
_value
.
_time
*
1000
;
}
else
if
(
strcmp
(
_value
.
_unit
,
"ms"
)
==
0
)
{
_value
.
_nanotime
=
_value
.
_time
*
1000
*
1000
;
}
else
if
(
strcmp
(
_value
.
_unit
,
"s"
)
==
0
)
{
_value
.
_nanotime
=
_value
.
_time
*
1000
*
1000
*
1000
;
}
else
if
(
strcmp
(
_value
.
_unit
,
"m"
)
==
0
)
{
_value
.
_nanotime
=
_value
.
_time
*
60
*
1000
*
1000
*
1000
;
}
else
if
(
strcmp
(
_value
.
_unit
,
"h"
)
==
0
)
{
_value
.
_nanotime
=
_value
.
_time
*
60
*
60
*
1000
*
1000
*
1000
;
}
else
if
(
strcmp
(
_value
.
_unit
,
"d"
)
==
0
)
{
_value
.
_nanotime
=
_value
.
_time
*
24
*
60
*
60
*
1000
*
1000
*
1000
;
}
else
{
THROW_MSG
(
vmSymbols
::
java_lang_IllegalArgumentException
(),
"Integer parsing error nanotime value: illegal unit"
);
}
}
template
<
>
void
DCmdArgument
<
NanoTimeArgument
>::
init_value
(
TRAPS
)
{
if
(
has_default
())
{
this
->
parse_value
(
_default_string
,
strlen
(
_default_string
),
THREAD
);
if
(
HAS_PENDING_EXCEPTION
)
{
fatal
(
"Default string must be parsable"
);
}
}
else
{
_value
.
_time
=
0
;
_value
.
_nanotime
=
0
;
strcmp
(
_value
.
_unit
,
"ns"
);
}
}
template
<
>
void
DCmdArgument
<
NanoTimeArgument
>::
destroy_value
()
{
}
// WARNING StringArrayArgument can only be used as an option, it cannot be
// used as an argument with the DCmdParser
template
<
>
void
DCmdArgument
<
StringArrayArgument
*>::
parse_value
(
const
char
*
str
,
size_t
len
,
TRAPS
)
{
_value
->
add
(
str
,
len
);
}
template
<
>
void
DCmdArgument
<
StringArrayArgument
*>::
init_value
(
TRAPS
)
{
_value
=
new
StringArrayArgument
();
_allow_multiple
=
true
;
if
(
has_default
())
{
fatal
(
"StringArrayArgument cannot have default value"
);
}
}
template
<
>
void
DCmdArgument
<
StringArrayArgument
*>::
destroy_value
()
{
if
(
_value
!=
NULL
)
{
delete
_value
;
set_value
(
NULL
);
}
}
template
<
>
void
DCmdArgument
<
MemorySizeArgument
>::
parse_value
(
const
char
*
str
,
size_t
len
,
TRAPS
)
{
if
(
str
==
NULL
)
{
THROW_MSG
(
vmSymbols
::
java_lang_IllegalArgumentException
(),
"Integer parsing error nanotime value: syntax error"
);
}
if
(
*
str
==
'-'
)
{
THROW_MSG
(
vmSymbols
::
java_lang_IllegalArgumentException
(),
"Parsing error memory size value: negative values not allowed"
);
}
int
res
=
sscanf
(
str
,
UINT64_FORMAT
"%c"
,
&
_value
.
_val
,
&
_value
.
_multiplier
);
if
(
res
==
2
)
{
switch
(
_value
.
_multiplier
)
{
case
'k'
:
case
'K'
:
_value
.
_size
=
_value
.
_val
*
1024
;
break
;
case
'm'
:
case
'M'
:
_value
.
_size
=
_value
.
_val
*
1024
*
1024
;
break
;
case
'g'
:
case
'G'
:
_value
.
_size
=
_value
.
_val
*
1024
*
1024
*
1024
;
break
;
default:
_value
.
_size
=
_value
.
_val
;
_value
.
_multiplier
=
' '
;
//default case should be to break with no error, since user
//can write size in bytes, or might have a delimiter and next arg
break
;
}
}
else
if
(
res
==
1
)
{
_value
.
_size
=
_value
.
_val
;
}
else
{
THROW_MSG
(
vmSymbols
::
java_lang_IllegalArgumentException
(),
"Parsing error memory size value: invalid value"
);
}
}
template
<
>
void
DCmdArgument
<
MemorySizeArgument
>::
init_value
(
TRAPS
)
{
if
(
has_default
())
{
this
->
parse_value
(
_default_string
,
strlen
(
_default_string
),
THREAD
);
if
(
HAS_PENDING_EXCEPTION
)
{
fatal
(
"Default string must be parsable"
);
}
}
else
{
_value
.
_size
=
0
;
_value
.
_val
=
0
;
_value
.
_multiplier
=
' '
;
}
}
template
<
>
void
DCmdArgument
<
MemorySizeArgument
>::
destroy_value
()
{
}
src/share/vm/services/diagnosticArgument.hpp
浏览文件 @
cb8511d0
/*
* Copyright (c) 201
1
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 201
2
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -31,6 +31,49 @@
#include "runtime/thread.hpp"
#include "utilities/exceptions.hpp"
class
StringArrayArgument
:
public
CHeapObj
{
private:
GrowableArray
<
char
*>*
_array
;
public:
StringArrayArgument
()
{
_array
=
new
(
ResourceObj
::
C_HEAP
)
GrowableArray
<
char
*>
(
32
,
true
);
assert
(
_array
!=
NULL
,
"Sanity check"
);
}
void
add
(
const
char
*
str
,
size_t
len
)
{
if
(
str
!=
NULL
)
{
char
*
ptr
=
NEW_C_HEAP_ARRAY
(
char
,
len
+
1
);
strncpy
(
ptr
,
str
,
len
);
ptr
[
len
]
=
0
;
_array
->
append
(
ptr
);
}
}
GrowableArray
<
char
*>*
array
()
{
return
_array
;
}
~
StringArrayArgument
()
{
for
(
int
i
=
0
;
i
<
_array
->
length
();
i
++
)
{
if
(
_array
->
at
(
i
)
!=
NULL
)
{
// Safety check
FREE_C_HEAP_ARRAY
(
char
,
_array
->
at
(
i
));
}
}
delete
_array
;
}
};
class
NanoTimeArgument
{
public:
jlong
_nanotime
;
jlong
_time
;
char
_unit
[
3
];
};
class
MemorySizeArgument
{
public:
u8
_size
;
u8
_val
;
char
_multiplier
;
};
class
GenDCmdArgument
:
public
ResourceObj
{
protected:
GenDCmdArgument
*
_next
;
...
...
@@ -40,6 +83,7 @@ protected:
const
char
*
_default_string
;
bool
_is_set
;
bool
_is_mandatory
;
bool
_allow_multiple
;
GenDCmdArgument
(
const
char
*
name
,
const
char
*
description
,
const
char
*
type
,
const
char
*
default_string
,
bool
mandatory
)
{
_name
=
name
;
...
...
@@ -48,6 +92,7 @@ protected:
_default_string
=
default_string
;
_is_mandatory
=
mandatory
;
_is_set
=
false
;
_allow_multiple
=
false
;
};
public:
const
char
*
name
()
{
return
_name
;
}
...
...
@@ -56,6 +101,7 @@ public:
const
char
*
default_string
()
{
return
_default_string
;
}
bool
is_set
()
{
return
_is_set
;
}
void
set_is_set
(
bool
b
)
{
_is_set
=
b
;
}
bool
allow_multiple
()
{
return
_allow_multiple
;
}
bool
is_mandatory
()
{
return
_is_mandatory
;
}
bool
has_value
()
{
return
_is_set
||
_default_string
!=
NULL
;
}
bool
has_default
()
{
return
_default_string
!=
NULL
;
}
...
...
src/share/vm/services/diagnosticFramework.cpp
浏览文件 @
cb8511d0
/*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011,
2012,
Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -61,7 +61,7 @@ CmdLine::CmdLine(const char* line, size_t len, bool no_command_name) {
bool
DCmdArgIter
::
next
(
TRAPS
)
{
if
(
_len
==
0
)
return
false
;
// skipping spaces
while
(
_cursor
<
_len
-
1
&&
isspace
(
_buffer
[
_cursor
])
)
{
while
(
_cursor
<
_len
-
1
&&
_buffer
[
_cursor
]
==
_delim
)
{
_cursor
++
;
}
// handling end of command line
...
...
src/share/vm/services/diagnosticFramework.hpp
浏览文件 @
cb8511d0
/*
* Copyright (c) 201
1
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 201
2
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -195,6 +195,7 @@ public:
DCmdParser
()
{
_options
=
NULL
;
_arguments_list
=
NULL
;
_delim
=
' '
;
}
void
add_dcmd_option
(
GenDCmdArgument
*
arg
);
void
add_dcmd_argument
(
GenDCmdArgument
*
arg
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录