Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell11
提交
f935eddd
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,发现更多精彩内容 >>
提交
f935eddd
编写于
12月 31, 2014
作者:
R
redestad
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8028357: Unnecessary allocation in AliasFileParser
Reviewed-by: jbachorik
上级
04070318
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
8 addition
and
191 deletion
+8
-191
jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/AliasFileParser.java
...classes/sun/jvmstat/perfdata/monitor/AliasFileParser.java
+2
-16
jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/CountedTimerTaskUtils.java
...s/sun/jvmstat/perfdata/monitor/CountedTimerTaskUtils.java
+2
-16
jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/v1_0/PerfDataBuffer.java
...ses/sun/jvmstat/perfdata/monitor/v1_0/PerfDataBuffer.java
+2
-47
jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/v2_0/PerfDataBuffer.java
...ses/sun/jvmstat/perfdata/monitor/v2_0/PerfDataBuffer.java
+2
-112
未找到文件。
jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/AliasFileParser.java
浏览文件 @
f935eddd
/*
* Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004,
2014,
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
...
...
@@ -42,7 +42,7 @@ import java.util.regex.*;
*/
public
class
AliasFileParser
{
private
static
final
String
ALIAS
=
"alias"
;
private
static
final
boolean
DEBUG
=
false
;
// 8028357 removed old, inefficient debug logging
// other variables
private
URL
inputfile
;
...
...
@@ -64,21 +64,12 @@ public class AliasFileParser {
}
}
private
void
logln
(
String
s
)
{
if
(
DEBUG
)
{
System
.
err
.
println
(
s
);
}
}
/**
* method to get the next token as a Token type
*/
private
void
nextToken
()
throws
IOException
{
st
.
nextToken
();
currentToken
=
new
Token
(
st
.
ttype
,
st
.
sval
);
logln
(
"Read token: type = "
+
currentToken
.
ttype
+
" string = "
+
currentToken
.
sval
);
}
/**
...
...
@@ -90,8 +81,6 @@ public class AliasFileParser {
if
((
currentToken
.
ttype
==
ttype
)
&&
(
currentToken
.
sval
.
compareTo
(
token
)
==
0
))
{
logln
(
"matched type: "
+
ttype
+
" and token = "
+
currentToken
.
sval
);
nextToken
();
}
else
{
throw
new
SyntaxException
(
st
.
lineno
());
...
...
@@ -105,7 +94,6 @@ public class AliasFileParser {
*/
private
void
match
(
int
ttype
)
throws
IOException
,
SyntaxException
{
if
(
currentToken
.
ttype
==
ttype
)
{
logln
(
"matched type: "
+
ttype
+
", token = "
+
currentToken
.
sval
);
nextToken
();
}
else
{
throw
new
SyntaxException
(
st
.
lineno
());
...
...
@@ -157,8 +145,6 @@ public class AliasFileParser {
}
while
((
currentToken
.
ttype
!=
StreamTokenizer
.
TT_EOF
)
&&
(
currentToken
.
sval
.
compareTo
(
ALIAS
)
!=
0
));
logln
(
"adding map entry for "
+
name
+
" values = "
+
aliases
);
map
.
put
(
name
,
aliases
);
}
}
...
...
jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/CountedTimerTaskUtils.java
浏览文件 @
f935eddd
/*
* Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004,
2014,
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
...
...
@@ -35,7 +35,7 @@ import java.util.*;
*/
public
class
CountedTimerTaskUtils
{
private
static
final
boolean
DEBUG
=
false
;
// 8028357 removed old, inefficient debug logging
/**
* Reschedule a CountedTimeTask at a different interval. Probably not
...
...
@@ -58,14 +58,6 @@ public class CountedTimerTaskUtils {
long
lastRun
=
oldTask
.
scheduledExecutionTime
();
long
expired
=
now
-
lastRun
;
if
(
DEBUG
)
{
System
.
err
.
println
(
"computing timer delay: "
+
" oldInterval = "
+
oldInterval
+
" newInterval = "
+
newInterval
+
" samples = "
+
oldTask
.
executionCount
()
+
" expired = "
+
expired
);
}
/*
* check if original task ever ran - if not, then lastRun is
* undefined and we simply set the delay to 0.
...
...
@@ -76,12 +68,6 @@ public class CountedTimerTaskUtils {
delay
=
remainder
>=
0
?
remainder
:
0
;
}
if
(
DEBUG
)
{
System
.
err
.
println
(
"rescheduling sampler task: interval = "
+
newInterval
+
" delay = "
+
delay
);
}
timer
.
schedule
(
newTask
,
delay
,
newInterval
);
}
}
jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/v1_0/PerfDataBuffer.java
浏览文件 @
f935eddd
...
...
@@ -44,7 +44,8 @@ import java.nio.*;
*/
public
class
PerfDataBuffer
extends
PerfDataBufferImpl
{
private
static
final
boolean
DEBUG
=
false
;
// 8028357 removed old, inefficient debug logging
private
static
final
int
syncWaitMs
=
Integer
.
getInteger
(
"sun.jvmstat.perdata.syncWaitMs"
,
5000
);
private
static
final
ArrayList
<
Monitor
>
EMPTY_LIST
=
new
ArrayList
<
Monitor
>(
0
);
...
...
@@ -268,18 +269,13 @@ public class PerfDataBuffer extends PerfDataBufferImpl {
* loop waiting for the ticks counter to be non zero. This is
* an indication that the jvm is initialized.
*/
log
(
"synchWithTarget: "
+
lvmid
+
" "
);
while
(
ticks
.
longValue
()
==
0
)
{
log
(
"."
);
try
{
Thread
.
sleep
(
20
);
}
catch
(
InterruptedException
e
)
{
}
if
(
System
.
currentTimeMillis
()
>
timeLimit
)
{
lognl
(
"failed: "
+
lvmid
);
throw
new
MonitorException
(
"Could Not Synchronize with target"
);
}
}
lognl
(
"success: "
+
lvmid
);
}
/**
...
...
@@ -291,24 +287,18 @@ public class PerfDataBuffer extends PerfDataBufferImpl {
throws
MonitorException
{
Monitor
monitor
=
null
;
log
(
"polling for: "
+
lvmid
+
","
+
name
+
" "
);
pollForEntry
=
nextEntry
;
while
((
monitor
=
map
.
get
(
name
))
==
null
)
{
log
(
"."
);
try
{
Thread
.
sleep
(
20
);
}
catch
(
InterruptedException
e
)
{
}
long
t
=
System
.
currentTimeMillis
();
if
((
t
>
timeLimit
)
||
(
overflow
.
intValue
()
>
0
))
{
lognl
(
"failed: "
+
lvmid
+
","
+
name
);
dumpAll
(
map
,
lvmid
);
throw
new
MonitorException
(
"Could not find expected counter"
);
}
getNewMonitors
(
map
);
}
lognl
(
"success: "
+
lvmid
+
","
+
name
);
return
monitor
;
}
...
...
@@ -481,8 +471,6 @@ public class PerfDataBuffer extends PerfDataBufferImpl {
// check for the end of the buffer
if
(
nextEntry
==
buffer
.
limit
())
{
lognl
(
"getNextMonitorEntry():"
+
" nextEntry == buffer.limit(): returning"
);
return
null
;
}
...
...
@@ -614,37 +602,4 @@ public class PerfDataBuffer extends PerfDataBufferImpl {
nextEntry
=
entryStart
+
entryLength
;
return
monitor
;
}
/**
* Method to dump debugging information
*/
private
void
dumpAll
(
Map
<
String
,
Monitor
>
map
,
int
lvmid
)
{
if
(
DEBUG
)
{
Set
<
String
>
keys
=
map
.
keySet
();
System
.
err
.
println
(
"Dump for "
+
lvmid
);
int
j
=
0
;
for
(
Iterator
<
String
>
i
=
keys
.
iterator
();
i
.
hasNext
();
j
++)
{
Monitor
monitor
=
map
.
get
(
i
.
next
());
System
.
err
.
println
(
j
+
"\t"
+
monitor
.
getName
()
+
"="
+
monitor
.
getValue
());
}
System
.
err
.
println
(
"nextEntry = "
+
nextEntry
+
" pollForEntry = "
+
pollForEntry
);
System
.
err
.
println
(
"Buffer info:"
);
System
.
err
.
println
(
"buffer = "
+
buffer
);
}
}
private
void
lognl
(
String
s
)
{
if
(
DEBUG
)
{
System
.
err
.
println
(
s
);
}
}
private
void
log
(
String
s
)
{
if
(
DEBUG
)
{
System
.
err
.
print
(
s
);
}
}
}
jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/v2_0/PerfDataBuffer.java
浏览文件 @
f935eddd
...
...
@@ -62,7 +62,8 @@ import java.nio.*;
*/
public
class
PerfDataBuffer
extends
PerfDataBufferImpl
{
private
static
final
boolean
DEBUG
=
false
;
// 8028357 removed old, inefficient debug logging
private
static
final
int
syncWaitMs
=
Integer
.
getInteger
(
"sun.jvmstat.perdata.syncWaitMs"
,
5000
);
private
static
final
ArrayList
<
Monitor
>
EMPTY_LIST
=
new
ArrayList
<>(
0
);
...
...
@@ -264,20 +265,15 @@ public class PerfDataBuffer extends PerfDataBufferImpl {
long
timeLimit
=
System
.
currentTimeMillis
()
+
syncWaitMs
;
// loop waiting for the accessible indicater to be non-zero
log
(
"synchWithTarget: "
+
lvmid
+
" "
);
while
(!
prologue
.
isAccessible
())
{
log
(
"."
);
// give the target jvm a chance to complete initializatoin
try
{
Thread
.
sleep
(
20
);
}
catch
(
InterruptedException
e
)
{
}
if
(
System
.
currentTimeMillis
()
>
timeLimit
)
{
logln
(
"failed: "
+
lvmid
);
throw
new
MonitorException
(
"Could not synchronize with target"
);
}
}
logln
(
"success: "
+
lvmid
);
}
/**
...
...
@@ -306,8 +302,6 @@ public class PerfDataBuffer extends PerfDataBufferImpl {
// check for end of the buffer
if
(
nextEntry
==
buffer
.
limit
())
{
logln
(
"getNextMonitorEntry():"
+
" nextEntry == buffer.limit(): returning"
);
return
null
;
}
...
...
@@ -346,9 +340,6 @@ public class PerfDataBuffer extends PerfDataBufferImpl {
byte
varByte
=
buffer
.
get
();
int
dataOffset
=
buffer
.
getInt
();
dump_entry_fixed
(
entryStart
,
nameOffset
,
vectorLength
,
typeCodeByte
,
flags
,
unitsByte
,
varByte
,
dataOffset
);
// convert common attributes to their object types
Units
units
=
Units
.
toUnits
(
unitsByte
);
Variability
variability
=
Variability
.
toVariability
(
varByte
);
...
...
@@ -439,8 +430,6 @@ public class PerfDataBuffer extends PerfDataBufferImpl {
// set the position to the start of the data item
buffer
.
position
(
entryStart
+
dataOffset
);
dump_entry_variable
(
name
,
buffer
,
dataSize
);
if
(
vectorLength
==
0
)
{
// create a scalar Monitor object
if
(
typeCode
==
TypeCode
.
LONG
)
{
...
...
@@ -514,103 +503,4 @@ public class PerfDataBuffer extends PerfDataBufferImpl {
nextEntry
=
entryStart
+
entryLength
;
return
monitor
;
}
/**
* Method to dump debugging information
*/
private
void
dumpAll
(
Map
<
String
,
Monitor
>
map
,
int
lvmid
)
{
if
(
DEBUG
)
{
Set
<
String
>
keys
=
map
.
keySet
();
System
.
err
.
println
(
"Dump for "
+
lvmid
);
int
j
=
0
;
for
(
Iterator
<
String
>
i
=
keys
.
iterator
();
i
.
hasNext
();
j
++)
{
Monitor
monitor
=
map
.
get
(
i
.
next
());
System
.
err
.
println
(
j
+
"\t"
+
monitor
.
getName
()
+
"="
+
monitor
.
getValue
());
}
System
.
err
.
println
(
"nextEntry = "
+
nextEntry
);
System
.
err
.
println
(
"Buffer info:"
);
System
.
err
.
println
(
"buffer = "
+
buffer
);
}
}
/**
* Method to dump the fixed portion of an entry.
*/
private
void
dump_entry_fixed
(
int
entry_start
,
int
nameOffset
,
int
vectorLength
,
byte
typeCodeByte
,
byte
flags
,
byte
unitsByte
,
byte
varByte
,
int
dataOffset
)
{
if
(
DEBUG
)
{
System
.
err
.
println
(
"Entry at offset: 0x"
+
Integer
.
toHexString
(
entry_start
));
System
.
err
.
println
(
"\tname_offset = 0x"
+
Integer
.
toHexString
(
nameOffset
));
System
.
err
.
println
(
"\tvector_length = 0x"
+
Integer
.
toHexString
(
vectorLength
));
System
.
err
.
println
(
"\tdata_type = 0x"
+
Integer
.
toHexString
(
typeCodeByte
));
System
.
err
.
println
(
"\tflags = 0x"
+
Integer
.
toHexString
(
flags
));
System
.
err
.
println
(
"\tdata_units = 0x"
+
Integer
.
toHexString
(
unitsByte
));
System
.
err
.
println
(
"\tdata_variability = 0x"
+
Integer
.
toHexString
(
varByte
));
System
.
err
.
println
(
"\tdata_offset = 0x"
+
Integer
.
toHexString
(
dataOffset
));
}
}
private
void
dump_entry_variable
(
String
name
,
ByteBuffer
bb
,
int
size
)
{
if
(
DEBUG
)
{
char
[]
toHex
=
new
char
[]
{
'0'
,
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
'8'
,
'9'
,
'a'
,
'b'
,
'c'
,
'd'
,
'e'
,
'f'
};
ByteBuffer
data
=
bb
.
slice
();
data
.
limit
(
size
);
System
.
err
.
println
(
"\tname = "
+
name
);
System
.
err
.
println
(
"\tdata = "
);
int
count
=
0
;
while
(
data
.
hasRemaining
())
{
byte
b
=
data
.
get
();
byte
high
=
(
byte
)((
b
>>
8
)
&
0x0f
);
byte
low
=
(
byte
)(
b
&
0x0f
);
if
(
count
%
16
==
0
)
{
System
.
err
.
print
(
"\t\t"
+
Integer
.
toHexString
(
count
/
16
)
+
": "
);
}
System
.
err
.
print
(
String
.
valueOf
(
toHex
[
high
])
+
String
.
valueOf
(
toHex
[
low
]));
count
++;
if
(
count
%
16
==
0
)
{
System
.
err
.
println
();
}
else
{
System
.
err
.
print
(
" "
);
}
}
if
(
count
%
16
!=
0
)
{
System
.
err
.
println
();
}
}
}
private
void
logln
(
String
s
)
{
if
(
DEBUG
)
{
System
.
err
.
println
(
s
);
}
}
private
void
log
(
String
s
)
{
if
(
DEBUG
)
{
System
.
err
.
print
(
s
);
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录