Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell11
提交
e1cacfed
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,发现更多精彩内容 >>
提交
e1cacfed
编写于
5月 22, 2013
作者:
H
hannesw
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8010804: Review long and integer usage conventions
Reviewed-by: jlaskey, sundar
上级
3bf9a5d4
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
150 addition
and
41 deletion
+150
-41
nashorn/src/jdk/nashorn/internal/codegen/FoldConstants.java
nashorn/src/jdk/nashorn/internal/codegen/FoldConstants.java
+2
-2
nashorn/src/jdk/nashorn/internal/objects/NativeArray.java
nashorn/src/jdk/nashorn/internal/objects/NativeArray.java
+9
-34
nashorn/src/jdk/nashorn/internal/objects/NativeDate.java
nashorn/src/jdk/nashorn/internal/objects/NativeDate.java
+1
-1
nashorn/src/jdk/nashorn/internal/runtime/JSType.java
nashorn/src/jdk/nashorn/internal/runtime/JSType.java
+10
-4
nashorn/test/script/basic/JDK-8010804.js
nashorn/test/script/basic/JDK-8010804.js
+86
-0
nashorn/test/script/basic/JDK-8010804.js.EXPECTED
nashorn/test/script/basic/JDK-8010804.js.EXPECTED
+42
-0
未找到文件。
nashorn/src/jdk/nashorn/internal/codegen/FoldConstants.java
浏览文件 @
e1cacfed
...
...
@@ -279,9 +279,9 @@ final class FoldConstants extends NodeVisitor {
isLong
&=
value
!=
0.0
&&
JSType
.
isRepresentableAsLong
(
value
);
if
(
isInteger
)
{
return
LiteralNode
.
newInstance
(
token
,
finish
,
JSType
.
toInt32
(
value
)
);
return
LiteralNode
.
newInstance
(
token
,
finish
,
(
int
)
value
);
}
else
if
(
isLong
)
{
return
LiteralNode
.
newInstance
(
token
,
finish
,
JSType
.
toLong
(
value
)
);
return
LiteralNode
.
newInstance
(
token
,
finish
,
(
long
)
value
);
}
return
LiteralNode
.
newInstance
(
token
,
finish
,
value
);
...
...
nashorn/src/jdk/nashorn/internal/objects/NativeArray.java
浏览文件 @
e1cacfed
...
...
@@ -754,25 +754,11 @@ public final class NativeArray extends ScriptObject {
final
Object
obj
=
Global
.
toObject
(
self
);
final
ScriptObject
sobj
=
(
ScriptObject
)
obj
;
final
long
len
=
JSType
.
toUint32
(
sobj
.
getLength
());
final
double
startNum
=
JSType
.
toNumber
(
start
);
final
long
relativeStartUint32
=
JSType
.
toUint32
(
startNum
);
final
long
relativeStart
=
JSType
.
toInteger
(
startNum
);
long
k
=
relativeStart
<
0
?
Math
.
max
(
len
+
relativeStart
,
0
)
:
Math
.
min
(
Math
.
max
(
relativeStartUint32
,
relativeStart
),
len
);
final
double
endNum
=
(
end
==
ScriptRuntime
.
UNDEFINED
)?
Double
.
NaN
:
JSType
.
toNumber
(
end
);
final
long
relativeEndUint32
=
(
end
==
ScriptRuntime
.
UNDEFINED
)?
len
:
JSType
.
toUint32
(
endNum
);
final
long
relativeEnd
=
(
end
==
ScriptRuntime
.
UNDEFINED
)?
len
:
JSType
.
toInteger
(
endNum
);
final
long
finale
=
relativeEnd
<
0
?
Math
.
max
(
len
+
relativeEnd
,
0
)
:
Math
.
min
(
Math
.
max
(
relativeEndUint32
,
relativeEnd
),
len
);
final
long
relativeStart
=
JSType
.
toLong
(
start
);
final
long
relativeEnd
=
(
end
==
ScriptRuntime
.
UNDEFINED
)
?
len
:
JSType
.
toLong
(
end
);
long
k
=
relativeStart
<
0
?
Math
.
max
(
len
+
relativeStart
,
0
)
:
Math
.
min
(
relativeStart
,
len
);
final
long
finale
=
relativeEnd
<
0
?
Math
.
max
(
len
+
relativeEnd
,
0
)
:
Math
.
min
(
relativeEnd
,
len
);
if
(
k
>=
finale
)
{
return
new
NativeArray
(
0
);
...
...
@@ -909,21 +895,10 @@ public final class NativeArray extends ScriptObject {
final
ScriptObject
sobj
=
(
ScriptObject
)
obj
;
final
boolean
strict
=
Global
.
isStrict
();
final
long
len
=
JSType
.
toUint32
(
sobj
.
getLength
());
final
double
startNum
=
JSType
.
toNumber
(
start
);
final
long
relativeStartUint32
=
JSType
.
toUint32
(
startNum
);
final
long
relativeStart
=
JSType
.
toInteger
(
startNum
);
//TODO: workaround overflow of relativeStart for start > Integer.MAX_VALUE
final
long
actualStart
=
relativeStart
<
0
?
Math
.
max
(
len
+
relativeStart
,
0
)
:
Math
.
min
(
Math
.
max
(
relativeStartUint32
,
relativeStart
),
len
);
final
long
actualDeleteCount
=
Math
.
min
(
Math
.
max
(
JSType
.
toInteger
(
deleteCount
),
0
),
len
-
actualStart
);
final
long
relativeStart
=
JSType
.
toLong
(
start
);
final
long
actualStart
=
relativeStart
<
0
?
Math
.
max
(
len
+
relativeStart
,
0
)
:
Math
.
min
(
relativeStart
,
len
);
final
long
actualDeleteCount
=
Math
.
min
(
Math
.
max
(
JSType
.
toLong
(
deleteCount
),
0
),
len
-
actualStart
);
final
NativeArray
array
=
new
NativeArray
(
actualDeleteCount
);
...
...
nashorn/src/jdk/nashorn/internal/objects/NativeDate.java
浏览文件 @
e1cacfed
...
...
@@ -770,7 +770,7 @@ public final class NativeDate extends ScriptObject {
nd
.
setTime
(
NaN
);
return
nd
.
getTime
();
}
int
yearInt
=
JSType
.
toInteger
(
yearNum
)
;
int
yearInt
=
(
int
)
yearNum
;
if
(
0
<=
yearInt
&&
yearInt
<=
99
)
{
yearInt
+=
1900
;
}
...
...
nashorn/src/jdk/nashorn/internal/runtime/JSType.java
浏览文件 @
e1cacfed
...
...
@@ -565,8 +565,11 @@ public enum JSType {
}
/**
* JavaScript compliant Object to integer conversion
* See ECMA 9.4 ToInteger
* JavaScript compliant Object to integer conversion. See ECMA 9.4 ToInteger
*
* <p>Note that this returns {@link java.lang.Integer#MAX_VALUE} or {@link java.lang.Integer#MIN_VALUE}
* for double values that exceed the int range, including positive and negative Infinity. It is the
* caller's responsibility to handle such values correctly.</p>
*
* @param obj an object
* @return an integer
...
...
@@ -576,8 +579,11 @@ public enum JSType {
}
/**
* JavaScript compliant Object to long conversion
* See ECMA 9.4 ToInteger
* JavaScript compliant Object to long conversion. See ECMA 9.4 ToInteger
*
* <p>Note that this returns {@link java.lang.Long#MAX_VALUE} or {@link java.lang.Long#MIN_VALUE}
* for double values that exceed the long range, including positive and negative Infinity. It is the
* caller's responsibility to handle such values correctly.</p>
*
* @param obj an object
* @return a long
...
...
nashorn/test/script/basic/JDK-8010804.js
0 → 100644
浏览文件 @
e1cacfed
/*
* Copyright (c) 2010, 2013, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* JDK-8010804: Review long and integer usage conventions
*
* @test
* @run
*/
var
x
=
[];
print
(
x
.
length
);
x
[
4294967294
]
=
1
;
print
(
x
.
length
);
x
[
4294967295
]
=
1
;
print
(
x
.
length
);
print
(
x
.
slice
(
4294967293
).
length
);
print
(
x
.
slice
(
4294967294
).
length
);
print
(
x
.
slice
(
4294967295
).
length
);
print
(
x
.
slice
(
4294967296
).
length
);
print
(
x
.
slice
(
-
4294967293
).
length
);
print
(
x
.
slice
(
-
4294967294
).
length
);
print
(
x
.
slice
(
-
4294967295
).
length
);
print
(
x
.
slice
(
-
4294967296
).
length
);
print
(
x
.
slice
(
0
,
4294967293
).
length
);
print
(
x
.
slice
(
0
,
4294967294
).
length
);
print
(
x
.
slice
(
0
,
4294967295
).
length
);
print
(
x
.
slice
(
0
,
4294967296
).
length
);
print
(
x
.
slice
(
0
,
-
4294967293
).
length
);
print
(
x
.
slice
(
0
,
-
4294967294
).
length
);
print
(
x
.
slice
(
0
,
-
4294967295
).
length
);
print
(
x
.
slice
(
0
,
-
4294967296
).
length
);
print
(
x
.
slice
(
9223371036854775807
).
length
);
print
(
x
.
slice
(
9223372036854775807
).
length
);
print
(
x
.
slice
(
9223373036854775807
).
length
);
print
(
x
.
slice
(
9223374036854775807
).
length
);
print
(
x
.
slice
(
-
9223371036854775807
).
length
);
print
(
x
.
slice
(
-
9223372036854775807
).
length
);
print
(
x
.
slice
(
-
9223373036854775807
).
length
);
print
(
x
.
slice
(
-
9223374036854775807
).
length
);
print
(
x
.
slice
(
-
9223371036854775807
,
1
).
length
);
print
(
x
.
slice
(
-
9223372036854775807
,
1
).
length
);
print
(
x
.
slice
(
-
9223373036854775807
,
1
).
length
);
print
(
x
.
slice
(
-
9223374036854775807
,
1
).
length
);
print
(
x
.
slice
(
-
9223371036854775807
,
-
1
).
length
);
print
(
x
.
slice
(
-
9223372036854775807
,
-
1
).
length
);
print
(
x
.
slice
(
-
9223373036854775807
,
-
1
).
length
);
print
(
x
.
slice
(
-
9223374036854775807
,
-
1
).
length
);
print
(
x
.
slice
(
Infinity
).
length
);
print
(
x
.
slice
(
Infinity
,
Infinity
).
length
);
print
(
x
.
slice
(
Infinity
,
-
Infinity
).
length
);
print
(
x
.
slice
(
-
Infinity
).
length
);
print
(
x
.
slice
(
-
Infinity
,
Infinity
).
length
);
print
(
x
.
slice
(
-
Infinity
,
-
Infinity
).
length
);
var
d
=
new
Date
();
d
.
setYear
(
Infinity
);
print
(
d
);
\ No newline at end of file
nashorn/test/script/basic/JDK-8010804.js.EXPECTED
0 → 100644
浏览文件 @
e1cacfed
0
4294967295
4294967295
2
1
0
0
4294967293
4294967294
4294967295
4294967295
4294967293
4294967294
4294967295
4294967295
2
1
0
0
0
0
0
0
4294967295
4294967295
4294967295
4294967295
1
1
1
1
4294967294
4294967294
4294967294
4294967294
0
0
0
4294967295
4294967295
0
Invalid Date
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录