Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_langtools
提交
c09a480e
D
dragonwell8_langtools
项目概览
openanolis
/
dragonwell8_langtools
通知
0
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_langtools
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
c09a480e
编写于
4月 26, 2013
作者:
V
vromero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8008562: javac, a refactoring to Bits is necessary in order to provide a change history
Reviewed-by: mcimadamore
上级
6cd68e0d
变更
3
展开全部
隐藏空白更改
内联
并排
Showing
3 changed file
with
364 addition
and
179 deletion
+364
-179
src/share/classes/com/sun/tools/javac/comp/Flow.java
src/share/classes/com/sun/tools/javac/comp/Flow.java
+167
-152
src/share/classes/com/sun/tools/javac/jvm/Code.java
src/share/classes/com/sun/tools/javac/jvm/Code.java
+3
-3
src/share/classes/com/sun/tools/javac/util/Bits.java
src/share/classes/com/sun/tools/javac/util/Bits.java
+194
-24
未找到文件。
src/share/classes/com/sun/tools/javac/comp/Flow.java
浏览文件 @
c09a480e
此差异已折叠。
点击以展开。
src/share/classes/com/sun/tools/javac/jvm/Code.java
浏览文件 @
c09a480e
...
@@ -1647,7 +1647,7 @@ public class Code {
...
@@ -1647,7 +1647,7 @@ public class Code {
State
dup
()
{
State
dup
()
{
try
{
try
{
State
state
=
(
State
)
super
.
clone
();
State
state
=
(
State
)
super
.
clone
();
state
.
defined
=
defined
.
dup
(
);
state
.
defined
=
new
Bits
(
defined
);
state
.
stack
=
stack
.
clone
();
state
.
stack
=
stack
.
clone
();
if
(
locks
!=
null
)
state
.
locks
=
locks
.
clone
();
if
(
locks
!=
null
)
state
.
locks
=
locks
.
clone
();
if
(
debugCode
)
{
if
(
debugCode
)
{
...
@@ -1775,7 +1775,7 @@ public class Code {
...
@@ -1775,7 +1775,7 @@ public class Code {
}
}
State
join
(
State
other
)
{
State
join
(
State
other
)
{
defined
=
defined
.
andSet
(
other
.
defined
);
defined
.
andSet
(
other
.
defined
);
Assert
.
check
(
stacksize
==
other
.
stacksize
Assert
.
check
(
stacksize
==
other
.
stacksize
&&
nlocks
==
other
.
nlocks
);
&&
nlocks
==
other
.
nlocks
);
for
(
int
i
=
0
;
i
<
stacksize
;
)
{
for
(
int
i
=
0
;
i
<
stacksize
;
)
{
...
@@ -1887,7 +1887,7 @@ public class Code {
...
@@ -1887,7 +1887,7 @@ public class Code {
/** Set the current variable defined state. */
/** Set the current variable defined state. */
public
void
setDefined
(
Bits
newDefined
)
{
public
void
setDefined
(
Bits
newDefined
)
{
if
(
alive
&&
newDefined
!=
state
.
defined
)
{
if
(
alive
&&
newDefined
!=
state
.
defined
)
{
Bits
diff
=
state
.
defined
.
dup
(
).
xorSet
(
newDefined
);
Bits
diff
=
new
Bits
(
state
.
defined
).
xorSet
(
newDefined
);
for
(
int
adr
=
diff
.
nextBit
(
0
);
for
(
int
adr
=
diff
.
nextBit
(
0
);
adr
>=
0
;
adr
>=
0
;
adr
=
diff
.
nextBit
(
adr
+
1
))
{
adr
=
diff
.
nextBit
(
adr
+
1
))
{
...
...
src/share/classes/com/sun/tools/javac/util/Bits.java
浏览文件 @
c09a480e
/*
/*
* Copyright (c) 1999, 201
2
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 201
3
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -27,6 +27,8 @@ package com.sun.tools.javac.util;
...
@@ -27,6 +27,8 @@ package com.sun.tools.javac.util;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
static
com
.
sun
.
tools
.
javac
.
util
.
Bits
.
BitsOpKind
.*;
/** A class for extensible, mutable bit sets.
/** A class for extensible, mutable bit sets.
*
*
* <p><b>This is NOT part of any supported API.
* <p><b>This is NOT part of any supported API.
...
@@ -36,31 +38,114 @@ import java.util.Arrays;
...
@@ -36,31 +38,114 @@ import java.util.Arrays;
*/
*/
public
class
Bits
{
public
class
Bits
{
public
enum
BitsOpKind
{
INIT
,
CLEAR
,
INCL_BIT
,
EXCL_BIT
,
ASSIGN
,
AND_SET
,
OR_SET
,
DIFF_SET
,
XOR_SET
,
INCL_RANGE
,
EXCL_RANGE
,
}
// ____________ reset _________
// / UNKNOWN \ <-------- / UNINIT \
// \____________/ | \_________/
// | | |
// |assign | | any
// | ___________ |
// ------> / NORMAL \ <----
// \___________/ |
// | |
// | |
// -----------
// any
private
enum
BitsState
{
/* A Bits instance is in UNKNOWN state if it has been explicitly reset.
* It is possible to get to this state from any other by calling the
* reset method. An instance in the UNKNOWN state can pass to the
* NORMAL state after being assigned another Bits instance.
*/
UNKNOWN
,
/* A Bits instance is in UNINIT when it is created with the default
* constructor but it isn't explicitly reset. The main objective of this
* internal state is to save some memory.
*/
UNINIT
,
/* The normal state is reached after creating a Bits instance from an
* existing one or after applying any operation to an instance on UNINIT
* or NORMAL state. From this state a bits instance can pass to the
* UNKNOWN state by calling the reset method.
*/
NORMAL
;
static
BitsState
getState
(
int
[]
someBits
,
boolean
reset
)
{
if
(
reset
)
{
return
UNKNOWN
;
}
else
{
if
(
someBits
!=
unassignedBits
)
{
return
NORMAL
;
}
else
{
return
UNINIT
;
}
}
}
}
private
final
static
int
wordlen
=
32
;
private
final
static
int
wordlen
=
32
;
private
final
static
int
wordshift
=
5
;
private
final
static
int
wordshift
=
5
;
private
final
static
int
wordmask
=
wordlen
-
1
;
private
final
static
int
wordmask
=
wordlen
-
1
;
private
int
[]
bits
;
public
int
[]
bits
=
null
;
// This field will store last version of bits after every change.
public
int
[]
oldBits
=
null
;
public
BitsOpKind
lastOperation
=
null
;
private
static
final
int
[]
unassignedBits
=
new
int
[
0
];
private
BitsState
currentState
;
/** Construct an initially empty set.
/** Construct an initially empty set.
*/
*/
public
Bits
()
{
public
Bits
()
{
this
(
new
int
[
1
]);
this
(
false
);
}
public
Bits
(
Bits
someBits
)
{
this
(
someBits
.
dup
().
bits
,
BitsState
.
getState
(
someBits
.
bits
,
false
));
}
public
Bits
(
boolean
reset
)
{
this
(
unassignedBits
,
BitsState
.
getState
(
unassignedBits
,
reset
));
}
}
/** Construct a set consisting initially of given bit vector.
/** Construct a set consisting initially of given bit vector.
*/
*/
p
ublic
Bits
(
int
[]
bits
)
{
p
rivate
Bits
(
int
[]
bits
,
BitsState
initState
)
{
this
.
bits
=
bits
;
this
.
bits
=
bits
;
this
.
currentState
=
initState
;
switch
(
initState
)
{
case
UNKNOWN:
reset
();
//this will also set current state;
break
;
case
NORMAL:
Assert
.
check
(
bits
!=
unassignedBits
);
lastOperation
=
INIT
;
break
;
}
}
}
/** Construct a set consisting initially of given range.
/** This method will be called after any operation that causes a change to
* the bits. Subclasses can thus override it in order to extract information
* from the changes produced to the bits by the given operation.
*/
*/
public
Bits
(
int
start
,
int
limit
)
{
public
void
changed
()
{}
this
();
inclRange
(
start
,
limit
);
}
private
void
sizeTo
(
int
len
)
{
private
void
sizeTo
(
int
len
)
{
if
(
bits
.
length
<
len
)
{
if
(
bits
.
length
<
len
)
{
...
@@ -71,57 +156,110 @@ public class Bits {
...
@@ -71,57 +156,110 @@ public class Bits {
/** This set = {}.
/** This set = {}.
*/
*/
public
void
clear
()
{
public
void
clear
()
{
Assert
.
check
(
currentState
!=
BitsState
.
UNKNOWN
);
oldBits
=
bits
;
lastOperation
=
CLEAR
;
for
(
int
i
=
0
;
i
<
bits
.
length
;
i
++)
bits
[
i
]
=
0
;
for
(
int
i
=
0
;
i
<
bits
.
length
;
i
++)
bits
[
i
]
=
0
;
changed
();
currentState
=
BitsState
.
NORMAL
;
}
public
void
reset
()
{
bits
=
null
;
oldBits
=
null
;
currentState
=
BitsState
.
UNKNOWN
;
}
public
boolean
isReset
()
{
return
currentState
==
BitsState
.
UNKNOWN
;
}
public
Bits
assign
(
Bits
someBits
)
{
lastOperation
=
ASSIGN
;
oldBits
=
bits
;
bits
=
someBits
.
dup
().
bits
;
changed
();
currentState
=
BitsState
.
NORMAL
;
return
this
;
}
}
/** Return a copy of this set.
/** Return a copy of this set.
*/
*/
public
Bits
dup
()
{
private
Bits
dup
()
{
int
[]
newbits
=
new
int
[
bits
.
length
];
Assert
.
check
(
currentState
!=
BitsState
.
UNKNOWN
);
System
.
arraycopy
(
bits
,
0
,
newbits
,
0
,
bits
.
length
);
Bits
tmp
=
new
Bits
();
return
new
Bits
(
newbits
);
if
(
currentState
!=
BitsState
.
NORMAL
)
{
tmp
.
bits
=
bits
;
}
else
{
tmp
.
bits
=
new
int
[
bits
.
length
];
System
.
arraycopy
(
bits
,
0
,
tmp
.
bits
,
0
,
bits
.
length
);
}
currentState
=
BitsState
.
NORMAL
;
return
tmp
;
}
}
/** Include x in this set.
/** Include x in this set.
*/
*/
public
void
incl
(
int
x
)
{
public
void
incl
(
int
x
)
{
Assert
.
check
(
currentState
!=
BitsState
.
UNKNOWN
);
Assert
.
check
(
x
>=
0
);
Assert
.
check
(
x
>=
0
);
oldBits
=
bits
;
lastOperation
=
INCL_BIT
;
sizeTo
((
x
>>>
wordshift
)
+
1
);
sizeTo
((
x
>>>
wordshift
)
+
1
);
bits
[
x
>>>
wordshift
]
=
bits
[
x
>>>
wordshift
]
|
bits
[
x
>>>
wordshift
]
=
bits
[
x
>>>
wordshift
]
|
(
1
<<
(
x
&
wordmask
));
(
1
<<
(
x
&
wordmask
));
changed
();
currentState
=
BitsState
.
NORMAL
;
}
}
/** Include [start..limit) in this set.
/** Include [start..limit) in this set.
*/
*/
public
void
inclRange
(
int
start
,
int
limit
)
{
public
void
inclRange
(
int
start
,
int
limit
)
{
Assert
.
check
(
currentState
!=
BitsState
.
UNKNOWN
);
oldBits
=
bits
;
lastOperation
=
INCL_RANGE
;
sizeTo
((
limit
>>>
wordshift
)
+
1
);
sizeTo
((
limit
>>>
wordshift
)
+
1
);
for
(
int
x
=
start
;
x
<
limit
;
x
++)
for
(
int
x
=
start
;
x
<
limit
;
x
++)
{
bits
[
x
>>>
wordshift
]
=
bits
[
x
>>>
wordshift
]
|
bits
[
x
>>>
wordshift
]
=
bits
[
x
>>>
wordshift
]
|
(
1
<<
(
x
&
wordmask
));
(
1
<<
(
x
&
wordmask
));
}
changed
();
currentState
=
BitsState
.
NORMAL
;
}
}
/** Exclude [start...end] from this set.
/** Exclude [start...end] from this set.
*/
*/
public
void
excludeFrom
(
int
start
)
{
public
void
excludeFrom
(
int
start
)
{
Assert
.
check
(
currentState
!=
BitsState
.
UNKNOWN
);
oldBits
=
bits
;
lastOperation
=
EXCL_RANGE
;
Bits
temp
=
new
Bits
();
Bits
temp
=
new
Bits
();
temp
.
sizeTo
(
bits
.
length
);
temp
.
sizeTo
(
bits
.
length
);
temp
.
inclRange
(
0
,
start
);
temp
.
inclRange
(
0
,
start
);
andSet
(
temp
);
internalAndSet
(
temp
);
changed
();
currentState
=
BitsState
.
NORMAL
;
}
}
/** Exclude x from this set.
/** Exclude x from this set.
*/
*/
public
void
excl
(
int
x
)
{
public
void
excl
(
int
x
)
{
Assert
.
check
(
currentState
!=
BitsState
.
UNKNOWN
);
Assert
.
check
(
x
>=
0
);
Assert
.
check
(
x
>=
0
);
oldBits
=
bits
;
lastOperation
=
EXCL_BIT
;
sizeTo
((
x
>>>
wordshift
)
+
1
);
sizeTo
((
x
>>>
wordshift
)
+
1
);
bits
[
x
>>>
wordshift
]
=
bits
[
x
>>>
wordshift
]
&
bits
[
x
>>>
wordshift
]
=
bits
[
x
>>>
wordshift
]
&
~(
1
<<
(
x
&
wordmask
));
~(
1
<<
(
x
&
wordmask
));
changed
();
currentState
=
BitsState
.
NORMAL
;
}
}
/** Is x an element of this set?
/** Is x an element of this set?
*/
*/
public
boolean
isMember
(
int
x
)
{
public
boolean
isMember
(
int
x
)
{
Assert
.
check
(
currentState
!=
BitsState
.
UNKNOWN
);
return
return
0
<=
x
&&
x
<
(
bits
.
length
<<
wordshift
)
&&
0
<=
x
&&
x
<
(
bits
.
length
<<
wordshift
)
&&
(
bits
[
x
>>>
wordshift
]
&
(
1
<<
(
x
&
wordmask
)))
!=
0
;
(
bits
[
x
>>>
wordshift
]
&
(
1
<<
(
x
&
wordmask
)))
!=
0
;
...
@@ -130,38 +268,66 @@ public class Bits {
...
@@ -130,38 +268,66 @@ public class Bits {
/** {@literal this set = this set & xs}.
/** {@literal this set = this set & xs}.
*/
*/
public
Bits
andSet
(
Bits
xs
)
{
public
Bits
andSet
(
Bits
xs
)
{
Assert
.
check
(
currentState
!=
BitsState
.
UNKNOWN
);
oldBits
=
bits
;
lastOperation
=
AND_SET
;
internalAndSet
(
xs
);
changed
();
currentState
=
BitsState
.
NORMAL
;
return
this
;
}
private
void
internalAndSet
(
Bits
xs
)
{
Assert
.
check
(
currentState
!=
BitsState
.
UNKNOWN
);
sizeTo
(
xs
.
bits
.
length
);
sizeTo
(
xs
.
bits
.
length
);
for
(
int
i
=
0
;
i
<
xs
.
bits
.
length
;
i
++)
for
(
int
i
=
0
;
i
<
xs
.
bits
.
length
;
i
++)
{
bits
[
i
]
=
bits
[
i
]
&
xs
.
bits
[
i
];
bits
[
i
]
=
bits
[
i
]
&
xs
.
bits
[
i
];
return
this
;
}
}
}
/** this set = this set | xs.
/** this set = this set | xs.
*/
*/
public
Bits
orSet
(
Bits
xs
)
{
public
Bits
orSet
(
Bits
xs
)
{
Assert
.
check
(
currentState
!=
BitsState
.
UNKNOWN
);
oldBits
=
bits
;
lastOperation
=
OR_SET
;
sizeTo
(
xs
.
bits
.
length
);
sizeTo
(
xs
.
bits
.
length
);
for
(
int
i
=
0
;
i
<
xs
.
bits
.
length
;
i
++)
for
(
int
i
=
0
;
i
<
xs
.
bits
.
length
;
i
++)
{
bits
[
i
]
=
bits
[
i
]
|
xs
.
bits
[
i
];
bits
[
i
]
=
bits
[
i
]
|
xs
.
bits
[
i
];
}
changed
();
currentState
=
BitsState
.
NORMAL
;
return
this
;
return
this
;
}
}
/** this set = this set \ xs.
/** this set = this set \ xs.
*/
*/
public
Bits
diffSet
(
Bits
xs
)
{
public
Bits
diffSet
(
Bits
xs
)
{
Assert
.
check
(
currentState
!=
BitsState
.
UNKNOWN
);
oldBits
=
bits
;
lastOperation
=
DIFF_SET
;
for
(
int
i
=
0
;
i
<
bits
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
bits
.
length
;
i
++)
{
if
(
i
<
xs
.
bits
.
length
)
{
if
(
i
<
xs
.
bits
.
length
)
{
bits
[
i
]
=
bits
[
i
]
&
~
xs
.
bits
[
i
];
bits
[
i
]
=
bits
[
i
]
&
~
xs
.
bits
[
i
];
}
}
}
}
changed
();
currentState
=
BitsState
.
NORMAL
;
return
this
;
return
this
;
}
}
/** this set = this set ^ xs.
/** this set = this set ^ xs.
*/
*/
public
Bits
xorSet
(
Bits
xs
)
{
public
Bits
xorSet
(
Bits
xs
)
{
Assert
.
check
(
currentState
!=
BitsState
.
UNKNOWN
);
oldBits
=
bits
;
lastOperation
=
XOR_SET
;
sizeTo
(
xs
.
bits
.
length
);
sizeTo
(
xs
.
bits
.
length
);
for
(
int
i
=
0
;
i
<
xs
.
bits
.
length
;
i
++)
for
(
int
i
=
0
;
i
<
xs
.
bits
.
length
;
i
++)
{
bits
[
i
]
=
bits
[
i
]
^
xs
.
bits
[
i
];
bits
[
i
]
=
bits
[
i
]
^
xs
.
bits
[
i
];
}
changed
();
currentState
=
BitsState
.
NORMAL
;
return
this
;
return
this
;
}
}
...
@@ -187,6 +353,7 @@ public class Bits {
...
@@ -187,6 +353,7 @@ public class Bits {
* }</pre>
* }</pre>
*/
*/
public
int
nextBit
(
int
x
)
{
public
int
nextBit
(
int
x
)
{
Assert
.
check
(
currentState
!=
BitsState
.
UNKNOWN
);
int
windex
=
x
>>>
wordshift
;
int
windex
=
x
>>>
wordshift
;
if
(
windex
>=
bits
.
length
)
return
-
1
;
if
(
windex
>=
bits
.
length
)
return
-
1
;
int
word
=
bits
[
windex
]
&
~((
1
<<
(
x
&
wordmask
))-
1
);
int
word
=
bits
[
windex
]
&
~((
1
<<
(
x
&
wordmask
))-
1
);
...
@@ -202,17 +369,20 @@ public class Bits {
...
@@ -202,17 +369,20 @@ public class Bits {
/** a string representation of this set.
/** a string representation of this set.
*/
*/
public
String
toString
()
{
public
String
toString
()
{
char
[]
digits
=
new
char
[
bits
.
length
*
wordlen
];
if
(
bits
.
length
>
0
)
{
for
(
int
i
=
0
;
i
<
bits
.
length
*
wordlen
;
i
++)
char
[]
digits
=
new
char
[
bits
.
length
*
wordlen
];
digits
[
i
]
=
isMember
(
i
)
?
'1'
:
'0'
;
for
(
int
i
=
0
;
i
<
bits
.
length
*
wordlen
;
i
++)
return
new
String
(
digits
);
digits
[
i
]
=
isMember
(
i
)
?
'1'
:
'0'
;
return
new
String
(
digits
);
}
else
{
return
"[]"
;
}
}
}
/** Test Bits.nextBit(int). */
/** Test Bits.nextBit(int). */
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
java
.
util
.
Random
r
=
new
java
.
util
.
Random
();
java
.
util
.
Random
r
=
new
java
.
util
.
Random
();
Bits
bits
=
new
Bits
();
Bits
bits
=
new
Bits
();
int
dupCount
=
0
;
for
(
int
i
=
0
;
i
<
125
;
i
++)
{
for
(
int
i
=
0
;
i
<
125
;
i
++)
{
int
k
;
int
k
;
do
{
do
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录