Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell11
提交
8a2e14fa
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,发现更多精彩内容 >>
提交
8a2e14fa
编写于
7月 04, 2014
作者:
S
sundar
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8044760: Avoid PropertyMap duplicate for global instances
Reviewed-by: attila, hannesw
上级
73c1f91e
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
53 addition
and
38 deletion
+53
-38
nashorn/src/jdk/nashorn/internal/objects/Global.java
nashorn/src/jdk/nashorn/internal/objects/Global.java
+1
-6
nashorn/src/jdk/nashorn/internal/objects/NativeDebug.java
nashorn/src/jdk/nashorn/internal/objects/NativeDebug.java
+0
-1
nashorn/src/jdk/nashorn/internal/runtime/PropertyMap.java
nashorn/src/jdk/nashorn/internal/runtime/PropertyMap.java
+0
-23
nashorn/src/jdk/nashorn/internal/runtime/ScriptObject.java
nashorn/src/jdk/nashorn/internal/runtime/ScriptObject.java
+52
-8
未找到文件。
nashorn/src/jdk/nashorn/internal/objects/Global.java
浏览文件 @
8a2e14fa
...
...
@@ -447,12 +447,7 @@ public final class Global extends ScriptObject implements Scope {
// null check on context
context
.
getClass
();
/*
* Duplicate global's map and use it. This way the initial Map filled
* by nasgen (referenced from static field in this class) is retained
* 'as is' (as that one is process wide singleton.
*/
return
$nasgenmap
$
.
duplicate
();
return
$nasgenmap
$
;
}
/**
...
...
nashorn/src/jdk/nashorn/internal/objects/NativeDebug.java
浏览文件 @
8a2e14fa
...
...
@@ -222,7 +222,6 @@ public final class NativeDebug extends ScriptObject {
out
.
println
(
"ScriptFunction allocations "
+
ScriptFunction
.
getAllocations
());
out
.
println
(
"PropertyMap count "
+
PropertyMap
.
getCount
());
out
.
println
(
"PropertyMap cloned "
+
PropertyMap
.
getClonedCount
());
out
.
println
(
"PropertyMap duplicated "
+
PropertyMap
.
getDuplicatedCount
());
out
.
println
(
"PropertyMap history hit "
+
PropertyMap
.
getHistoryHit
());
out
.
println
(
"PropertyMap proto invalidations "
+
PropertyMap
.
getProtoInvalidations
());
out
.
println
(
"PropertyMap proto history hit "
+
PropertyMap
.
getProtoHistoryHit
());
...
...
nashorn/src/jdk/nashorn/internal/runtime/PropertyMap.java
浏览文件 @
8a2e14fa
...
...
@@ -145,21 +145,6 @@ public final class PropertyMap implements Iterable<Object>, Serializable {
this
(
propertyMap
,
propertyMap
.
properties
);
}
/**
* Duplicates this PropertyMap instance. This is used to duplicate 'shared'
* maps {@link PropertyMap} used as process wide singletons. Shared maps are
* duplicated for every global scope object. That way listeners, proto and property
* histories are scoped within a global scope.
*
* @return Duplicated {@link PropertyMap}.
*/
public
PropertyMap
duplicate
()
{
if
(
Context
.
DEBUG
)
{
duplicatedCount
++;
}
return
new
PropertyMap
(
this
.
properties
,
this
.
className
,
0
,
0
,
0
,
containsArrayKeys
());
}
private
void
writeObject
(
final
ObjectOutputStream
out
)
throws
IOException
{
out
.
defaultWriteObject
();
out
.
writeObject
(
properties
.
getProperties
());
...
...
@@ -968,7 +953,6 @@ public final class PropertyMap implements Iterable<Object>, Serializable {
// counters updated only in debug mode
private
static
int
count
;
private
static
int
clonedCount
;
private
static
int
duplicatedCount
;
private
static
int
historyHit
;
private
static
int
protoInvalidations
;
private
static
int
protoHistoryHit
;
...
...
@@ -988,13 +972,6 @@ public final class PropertyMap implements Iterable<Object>, Serializable {
return
clonedCount
;
}
/**
* @return The number of maps that are duplicated.
*/
public
static
int
getDuplicatedCount
()
{
return
duplicatedCount
;
}
/**
* @return The number of times history was successfully used.
*/
...
...
nashorn/src/jdk/nashorn/internal/runtime/ScriptObject.java
浏览文件 @
8a2e14fa
...
...
@@ -160,7 +160,8 @@ public abstract class ScriptObject implements PropertyAccess {
static
final
MethodHandle
GLOBALFILTER
=
findOwnMH_S
(
"globalFilter"
,
Object
.
class
,
Object
.
class
);
private
static
final
MethodHandle
TRUNCATINGFILTER
=
findOwnMH_S
(
"truncatingFilter"
,
Object
[].
class
,
int
.
class
,
Object
[].
class
);
private
static
final
MethodHandle
KNOWNFUNCPROPGUARD
=
findOwnMH_S
(
"knownFunctionPropertyGuard"
,
boolean
.
class
,
Object
.
class
,
PropertyMap
.
class
,
MethodHandle
.
class
,
Object
.
class
,
ScriptFunction
.
class
);
private
static
final
MethodHandle
KNOWNFUNCPROPGUARDSELF
=
findOwnMH_S
(
"knownFunctionPropertyGuardSelf"
,
boolean
.
class
,
Object
.
class
,
PropertyMap
.
class
,
MethodHandle
.
class
,
ScriptFunction
.
class
);
private
static
final
MethodHandle
KNOWNFUNCPROPGUARDPROTO
=
findOwnMH_S
(
"knownFunctionPropertyGuardProto"
,
boolean
.
class
,
Object
.
class
,
PropertyMap
.
class
,
MethodHandle
.
class
,
int
.
class
,
ScriptFunction
.
class
);
private
static
final
ArrayList
<
MethodHandle
>
PROTO_FILTERS
=
new
ArrayList
<>();
...
...
@@ -2271,13 +2272,20 @@ public abstract class ScriptObject implements PropertyAccess {
if
(
scopeAccess
&&
func
.
isStrict
())
{
mh
=
bindTo
(
mh
,
UNDEFINED
);
}
return
new
GuardedInvocation
(
mh
,
//TODO this always does a scriptobject check
getKnownFunctionPropertyGuard
(
find
.
isSelf
()?
getKnownFunctionPropertyGuardSelf
(
getMap
(),
find
.
getGetter
(
Object
.
class
,
INVALID_PROGRAM_POINT
),
func
)
:
//TODO this always does a scriptobject check
getKnownFunctionPropertyGuardProto
(
getMap
(),
find
.
getGetter
(
Object
.
class
,
INVALID_PROGRAM_POINT
),
find
.
get
Owner
(),
find
.
get
ProtoChainLength
(),
func
),
getProtoSwitchPoint
(
NO_SUCH_PROPERTY_NAME
,
find
.
getOwner
()),
//TODO this doesn't need a ClassCastException as guard always checks script object
...
...
@@ -3595,15 +3603,51 @@ public abstract class ScriptObject implements PropertyAccess {
return
MH
.
findStatic
(
MethodHandles
.
lookup
(),
ScriptObject
.
class
,
name
,
MH
.
type
(
rtype
,
types
));
}
private
static
MethodHandle
getKnownFunctionPropertyGuard
(
final
PropertyMap
map
,
final
MethodHandle
getter
,
final
Object
where
,
final
ScriptFunction
func
)
{
return
MH
.
insertArguments
(
KNOWNFUNCPROPGUARD
,
1
,
map
,
getter
,
where
,
func
);
private
static
MethodHandle
getKnownFunctionPropertyGuard
Self
(
final
PropertyMap
map
,
final
MethodHandle
getter
,
final
ScriptFunction
func
)
{
return
MH
.
insertArguments
(
KNOWNFUNCPROPGUARD
SELF
,
1
,
map
,
getter
,
func
);
}
@SuppressWarnings
(
"unused"
)
private
static
boolean
knownFunctionPropertyGuard
(
final
Object
self
,
final
PropertyMap
map
,
final
MethodHandle
getter
,
final
Object
where
,
final
ScriptFunction
func
)
{
private
static
boolean
knownFunctionPropertyGuard
Self
(
final
Object
self
,
final
PropertyMap
map
,
final
MethodHandle
getter
,
final
ScriptFunction
func
)
{
if
(
self
instanceof
ScriptObject
&&
((
ScriptObject
)
self
).
getMap
()
==
map
)
{
try
{
return
getter
.
invokeExact
(
where
)
==
func
;
return
getter
.
invokeExact
(
self
)
==
func
;
}
catch
(
final
RuntimeException
|
Error
e
)
{
throw
e
;
}
catch
(
final
Throwable
t
)
{
throw
new
RuntimeException
(
t
);
}
}
return
false
;
}
private
static
MethodHandle
getKnownFunctionPropertyGuardProto
(
final
PropertyMap
map
,
final
MethodHandle
getter
,
final
int
depth
,
final
ScriptFunction
func
)
{
return
MH
.
insertArguments
(
KNOWNFUNCPROPGUARDPROTO
,
1
,
map
,
getter
,
depth
,
func
);
}
@SuppressWarnings
(
"unused"
)
private
static
ScriptObject
getProto
(
final
ScriptObject
self
,
final
int
depth
)
{
ScriptObject
proto
=
self
;
for
(
int
d
=
0
;
d
<
depth
;
d
++)
{
proto
=
proto
.
getProto
();
if
(
proto
==
null
)
{
return
null
;
}
}
return
proto
;
}
@SuppressWarnings
(
"unused"
)
private
static
boolean
knownFunctionPropertyGuardProto
(
final
Object
self
,
final
PropertyMap
map
,
final
MethodHandle
getter
,
final
int
depth
,
final
ScriptFunction
func
)
{
if
(
self
instanceof
ScriptObject
&&
((
ScriptObject
)
self
).
getMap
()
==
map
)
{
final
ScriptObject
proto
=
getProto
((
ScriptObject
)
self
,
depth
);
if
(
proto
==
null
)
{
return
false
;
}
try
{
return
getter
.
invokeExact
((
Object
)
proto
)
==
func
;
}
catch
(
final
RuntimeException
|
Error
e
)
{
throw
e
;
}
catch
(
final
Throwable
t
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录