Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_nashorn
提交
1cd60278
D
dragonwell8_nashorn
项目概览
openanolis
/
dragonwell8_nashorn
通知
2
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_nashorn
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
1cd60278
编写于
6月 05, 2013
作者:
H
hannesw
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8015350: Array.prototype.reduceRight issue with large length and index
Reviewed-by: attila, sundar, lagergren
上级
04fc0191
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
82 addition
and
27 deletion
+82
-27
src/jdk/nashorn/internal/objects/NativeArray.java
src/jdk/nashorn/internal/objects/NativeArray.java
+11
-11
src/jdk/nashorn/internal/runtime/arrays/ArrayIterator.java
src/jdk/nashorn/internal/runtime/arrays/ArrayIterator.java
+3
-3
src/jdk/nashorn/internal/runtime/arrays/ArrayLikeIterator.java
...dk/nashorn/internal/runtime/arrays/ArrayLikeIterator.java
+4
-4
src/jdk/nashorn/internal/runtime/arrays/EmptyArrayLikeIterator.java
...shorn/internal/runtime/arrays/EmptyArrayLikeIterator.java
+1
-1
src/jdk/nashorn/internal/runtime/arrays/IteratorAction.java
src/jdk/nashorn/internal/runtime/arrays/IteratorAction.java
+2
-2
src/jdk/nashorn/internal/runtime/arrays/MapIterator.java
src/jdk/nashorn/internal/runtime/arrays/MapIterator.java
+2
-2
src/jdk/nashorn/internal/runtime/arrays/ReverseArrayIterator.java
...nashorn/internal/runtime/arrays/ReverseArrayIterator.java
+2
-2
src/jdk/nashorn/internal/runtime/arrays/ReverseMapIterator.java
...k/nashorn/internal/runtime/arrays/ReverseMapIterator.java
+2
-2
test/script/basic/JDK-8015350.js
test/script/basic/JDK-8015350.js
+51
-0
test/script/basic/JDK-8015350.js.EXPECTED
test/script/basic/JDK-8015350.js.EXPECTED
+4
-0
未找到文件。
src/jdk/nashorn/internal/objects/NativeArray.java
浏览文件 @
1cd60278
...
...
@@ -75,7 +75,7 @@ public final class NativeArray extends ScriptObject {
private
static
final
MethodHandle
FILTER_CALLBACK_INVOKER
=
createIteratorCallbackInvoker
(
boolean
.
class
);
private
static
final
MethodHandle
REDUCE_CALLBACK_INVOKER
=
Bootstrap
.
createDynamicInvoker
(
"dyn:call"
,
Object
.
class
,
Object
.
class
,
Undefined
.
class
,
Object
.
class
,
Object
.
class
,
int
.
class
,
Object
.
class
);
Object
.
class
,
Undefined
.
class
,
Object
.
class
,
Object
.
class
,
long
.
class
,
Object
.
class
);
private
static
final
MethodHandle
CALL_CMP
=
Bootstrap
.
createDynamicInvoker
(
"dyn:call"
,
double
.
class
,
ScriptFunction
.
class
,
Object
.
class
,
Object
.
class
,
Object
.
class
);
...
...
@@ -1086,7 +1086,7 @@ public final class NativeArray extends ScriptObject {
private
static
boolean
applyEvery
(
final
Object
self
,
final
Object
callbackfn
,
final
Object
thisArg
)
{
return
new
IteratorAction
<
Boolean
>(
Global
.
toObject
(
self
),
callbackfn
,
thisArg
,
true
)
{
@Override
protected
boolean
forEach
(
final
Object
val
,
final
int
i
)
throws
Throwable
{
protected
boolean
forEach
(
final
Object
val
,
final
long
i
)
throws
Throwable
{
return
(
result
=
(
boolean
)
EVERY_CALLBACK_INVOKER
.
invokeExact
(
callbackfn
,
thisArg
,
val
,
i
,
self
));
}
}.
apply
();
...
...
@@ -1104,7 +1104,7 @@ public final class NativeArray extends ScriptObject {
public
static
Object
some
(
final
Object
self
,
final
Object
callbackfn
,
final
Object
thisArg
)
{
return
new
IteratorAction
<
Boolean
>(
Global
.
toObject
(
self
),
callbackfn
,
thisArg
,
false
)
{
@Override
protected
boolean
forEach
(
final
Object
val
,
final
int
i
)
throws
Throwable
{
protected
boolean
forEach
(
final
Object
val
,
final
long
i
)
throws
Throwable
{
return
!(
result
=
(
boolean
)
SOME_CALLBACK_INVOKER
.
invokeExact
(
callbackfn
,
thisArg
,
val
,
i
,
self
));
}
}.
apply
();
...
...
@@ -1122,7 +1122,7 @@ public final class NativeArray extends ScriptObject {
public
static
Object
forEach
(
final
Object
self
,
final
Object
callbackfn
,
final
Object
thisArg
)
{
return
new
IteratorAction
<
Object
>(
Global
.
toObject
(
self
),
callbackfn
,
thisArg
,
ScriptRuntime
.
UNDEFINED
)
{
@Override
protected
boolean
forEach
(
final
Object
val
,
final
int
i
)
throws
Throwable
{
protected
boolean
forEach
(
final
Object
val
,
final
long
i
)
throws
Throwable
{
FOREACH_CALLBACK_INVOKER
.
invokeExact
(
callbackfn
,
thisArg
,
val
,
i
,
self
);
return
true
;
}
...
...
@@ -1141,9 +1141,9 @@ public final class NativeArray extends ScriptObject {
public
static
Object
map
(
final
Object
self
,
final
Object
callbackfn
,
final
Object
thisArg
)
{
return
new
IteratorAction
<
NativeArray
>(
Global
.
toObject
(
self
),
callbackfn
,
thisArg
,
null
)
{
@Override
protected
boolean
forEach
(
final
Object
val
,
final
int
i
)
throws
Throwable
{
protected
boolean
forEach
(
final
Object
val
,
final
long
i
)
throws
Throwable
{
final
Object
r
=
MAP_CALLBACK_INVOKER
.
invokeExact
(
callbackfn
,
thisArg
,
val
,
i
,
self
);
result
.
defineOwnProperty
(
index
,
r
);
result
.
defineOwnProperty
(
(
int
)
index
,
r
);
return
true
;
}
...
...
@@ -1167,12 +1167,12 @@ public final class NativeArray extends ScriptObject {
@Function
(
attributes
=
Attribute
.
NOT_ENUMERABLE
,
arity
=
1
)
public
static
Object
filter
(
final
Object
self
,
final
Object
callbackfn
,
final
Object
thisArg
)
{
return
new
IteratorAction
<
NativeArray
>(
Global
.
toObject
(
self
),
callbackfn
,
thisArg
,
new
NativeArray
())
{
private
int
to
=
0
;
private
long
to
=
0
;
@Override
protected
boolean
forEach
(
final
Object
val
,
final
int
i
)
throws
Throwable
{
protected
boolean
forEach
(
final
Object
val
,
final
long
i
)
throws
Throwable
{
if
((
boolean
)
FILTER_CALLBACK_INVOKER
.
invokeExact
(
callbackfn
,
thisArg
,
val
,
i
,
self
))
{
result
.
defineOwnProperty
(
to
++
,
val
);
result
.
defineOwnProperty
(
(
int
)(
to
++)
,
val
);
}
return
true
;
}
...
...
@@ -1200,7 +1200,7 @@ public final class NativeArray extends ScriptObject {
//if initial value is ScriptRuntime.UNDEFINED - step forward once.
return
new
IteratorAction
<
Object
>(
Global
.
toObject
(
self
),
callbackfn
,
ScriptRuntime
.
UNDEFINED
,
initialValue
,
iter
)
{
@Override
protected
boolean
forEach
(
final
Object
val
,
final
int
i
)
throws
Throwable
{
protected
boolean
forEach
(
final
Object
val
,
final
long
i
)
throws
Throwable
{
// TODO: why can't I declare the second arg as Undefined.class?
result
=
REDUCE_CALLBACK_INVOKER
.
invokeExact
(
callbackfn
,
ScriptRuntime
.
UNDEFINED
,
result
,
val
,
i
,
self
);
return
true
;
...
...
@@ -1258,7 +1258,7 @@ public final class NativeArray extends ScriptObject {
private
static
MethodHandle
createIteratorCallbackInvoker
(
final
Class
<?>
rtype
)
{
return
Bootstrap
.
createDynamicInvoker
(
"dyn:call"
,
rtype
,
Object
.
class
,
Object
.
class
,
Object
.
class
,
int
.
class
,
Object
.
class
);
long
.
class
,
Object
.
class
);
}
}
src/jdk/nashorn/internal/runtime/arrays/ArrayIterator.java
浏览文件 @
1cd60278
...
...
@@ -36,7 +36,7 @@ public class ArrayIterator extends ArrayLikeIterator<Object> {
protected
final
ScriptObject
array
;
/** length of array */
protected
final
int
length
;
protected
final
long
length
;
/**
* Constructor
...
...
@@ -46,7 +46,7 @@ public class ArrayIterator extends ArrayLikeIterator<Object> {
protected
ArrayIterator
(
final
ScriptObject
array
,
final
boolean
includeUndefined
)
{
super
(
includeUndefined
);
this
.
array
=
array
;
this
.
length
=
(
int
)
array
.
getArray
().
length
();
this
.
length
=
array
.
getArray
().
length
();
}
/**
...
...
@@ -63,7 +63,7 @@ public class ArrayIterator extends ArrayLikeIterator<Object> {
}
@Override
public
int
getLength
()
{
public
long
getLength
()
{
return
length
;
}
...
...
src/jdk/nashorn/internal/runtime/arrays/ArrayLikeIterator.java
浏览文件 @
1cd60278
...
...
@@ -38,7 +38,7 @@ import jdk.nashorn.internal.runtime.ScriptObject;
abstract
public
class
ArrayLikeIterator
<
T
>
implements
Iterator
<
T
>
{
/** current element index in iteration */
protected
int
index
;
protected
long
index
;
/** should undefined elements be included in the iteration? */
protected
final
boolean
includeUndefined
;
...
...
@@ -65,7 +65,7 @@ abstract public class ArrayLikeIterator<T> implements Iterator<T> {
* Go the the next valid element index of the iterator
* @return next index
*/
protected
int
bumpIndex
()
{
protected
long
bumpIndex
()
{
return
index
++;
}
...
...
@@ -73,7 +73,7 @@ abstract public class ArrayLikeIterator<T> implements Iterator<T> {
* Return the next valid element index of the iterator
* @return next index
*/
public
int
nextIndex
()
{
public
long
nextIndex
()
{
return
index
;
}
...
...
@@ -86,7 +86,7 @@ abstract public class ArrayLikeIterator<T> implements Iterator<T> {
* Get the length of the iteration
* @return length
*/
public
abstract
int
getLength
();
public
abstract
long
getLength
();
/**
* ArrayLikeIterator factory
...
...
src/jdk/nashorn/internal/runtime/arrays/EmptyArrayLikeIterator.java
浏览文件 @
1cd60278
...
...
@@ -47,7 +47,7 @@ final class EmptyArrayLikeIterator extends ArrayLikeIterator<Object> {
}
@Override
public
int
getLength
()
{
public
long
getLength
()
{
return
0
;
}
}
src/jdk/nashorn/internal/runtime/arrays/IteratorAction.java
浏览文件 @
1cd60278
...
...
@@ -49,7 +49,7 @@ public abstract class IteratorAction<T> {
protected
T
result
;
/** Current array index of iterator */
protected
int
index
;
protected
long
index
;
/** Iterator object */
private
final
ArrayLikeIterator
<
Object
>
iter
;
...
...
@@ -134,6 +134,6 @@ public abstract class IteratorAction<T> {
*
* @throws Throwable if invocation throws an exception/error
*/
protected
abstract
boolean
forEach
(
final
Object
val
,
final
int
i
)
throws
Throwable
;
protected
abstract
boolean
forEach
(
final
Object
val
,
final
long
i
)
throws
Throwable
;
}
src/jdk/nashorn/internal/runtime/arrays/MapIterator.java
浏览文件 @
1cd60278
...
...
@@ -49,8 +49,8 @@ class MapIterator extends ArrayLikeIterator<Object> {
}
@Override
public
int
getLength
()
{
return
(
int
)
length
;
public
long
getLength
()
{
return
length
;
}
@Override
...
...
src/jdk/nashorn/internal/runtime/arrays/ReverseArrayIterator.java
浏览文件 @
1cd60278
...
...
@@ -39,7 +39,7 @@ public final class ReverseArrayIterator extends ArrayIterator {
*/
public
ReverseArrayIterator
(
final
ScriptObject
array
,
final
boolean
includeUndefined
)
{
super
(
array
,
includeUndefined
);
this
.
index
=
(
int
)
(
array
.
getArray
().
length
()
-
1
)
;
this
.
index
=
array
.
getArray
().
length
()
-
1
;
}
@Override
...
...
@@ -53,7 +53,7 @@ public final class ReverseArrayIterator extends ArrayIterator {
}
@Override
protected
int
bumpIndex
()
{
protected
long
bumpIndex
()
{
return
index
--;
}
}
src/jdk/nashorn/internal/runtime/arrays/ReverseMapIterator.java
浏览文件 @
1cd60278
...
...
@@ -35,7 +35,7 @@ final class ReverseMapIterator extends MapIterator {
ReverseMapIterator
(
final
ScriptObject
obj
,
final
boolean
includeUndefined
)
{
super
(
obj
,
includeUndefined
);
this
.
index
=
JSType
.
to
I
nt32
(
obj
.
getLength
())
-
1
;
this
.
index
=
JSType
.
to
Ui
nt32
(
obj
.
getLength
())
-
1
;
}
@Override
...
...
@@ -49,7 +49,7 @@ final class ReverseMapIterator extends MapIterator {
}
@Override
protected
int
bumpIndex
()
{
protected
long
bumpIndex
()
{
return
index
--;
}
}
test/script/basic/JDK-8015350.js
0 → 100644
浏览文件 @
1cd60278
/*
* 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-8015350: Array.prototype.reduceRight issue with large length and index
*
* @test
* @run
*/
function
reduce
(
obj
)
{
try
{
Array
.
prototype
.
reduceRight
.
call
(
obj
,
function
(
acc
,
v
,
i
,
o
){
print
(
v
+
i
);
throw
"
stop
"
;
},
0
);
}
catch
(
error
)
{
print
(
error
);
}
}
// array-like object
reduce
({
length
:
0xffffffff
,
0xfffffffe
:
"
index:
"
});
// actual sparse array
var
array
=
[];
array
[
0xfffffffe
]
=
"
index:
"
;
reduce
(
array
);
test/script/basic/JDK-8015350.js.EXPECTED
0 → 100644
浏览文件 @
1cd60278
index: 4294967294
stop
index: 4294967294
stop
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录