Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_hotspot
提交
f317413f
D
dragonwell8_hotspot
项目概览
openanolis
/
dragonwell8_hotspot
通知
2
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_hotspot
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
f317413f
编写于
3月 16, 2012
作者:
J
jcoomes
浏览文件
操作
浏览文件
下载
差异文件
Merge
上级
86b977d9
33c403cd
变更
11
展开全部
隐藏空白更改
内联
并排
Showing
11 changed file
with
3203 addition
and
3003 deletion
+3203
-3003
src/share/vm/opto/bytecodeInfo.cpp
src/share/vm/opto/bytecodeInfo.cpp
+12
-12
src/share/vm/opto/c2_globals.hpp
src/share/vm/opto/c2_globals.hpp
+4
-1
src/share/vm/opto/callnode.cpp
src/share/vm/opto/callnode.cpp
+3
-9
src/share/vm/opto/callnode.hpp
src/share/vm/opto/callnode.hpp
+7
-1
src/share/vm/opto/compile.cpp
src/share/vm/opto/compile.cpp
+3
-3
src/share/vm/opto/escape.cpp
src/share/vm/opto/escape.cpp
+2773
-2796
src/share/vm/opto/escape.hpp
src/share/vm/opto/escape.hpp
+369
-163
src/share/vm/opto/phase.cpp
src/share/vm/opto/phase.cpp
+9
-4
src/share/vm/opto/phase.hpp
src/share/vm/opto/phase.hpp
+7
-2
src/share/vm/runtime/arguments.cpp
src/share/vm/runtime/arguments.cpp
+0
-9
src/share/vm/utilities/growableArray.hpp
src/share/vm/utilities/growableArray.hpp
+16
-3
未找到文件。
src/share/vm/opto/bytecodeInfo.cpp
浏览文件 @
f317413f
...
@@ -257,6 +257,18 @@ const char* InlineTree::should_not_inline(ciMethod *callee_method, ciMethod* cal
...
@@ -257,6 +257,18 @@ const char* InlineTree::should_not_inline(ciMethod *callee_method, ciMethod* cal
return
"exception method"
;
return
"exception method"
;
}
}
if
(
callee_method
->
should_not_inline
())
{
return
"disallowed by CompilerOracle"
;
}
if
(
UseStringCache
)
{
// Do not inline StringCache::profile() method used only at the beginning.
if
(
callee_method
->
name
()
==
ciSymbol
::
profile_name
()
&&
callee_method
->
holder
()
->
name
()
==
ciSymbol
::
java_lang_StringCache
())
{
return
"profiling method"
;
}
}
// use frequency-based objections only for non-trivial methods
// use frequency-based objections only for non-trivial methods
if
(
callee_method
->
code_size_for_inlining
()
<=
MaxTrivialSize
)
return
NULL
;
if
(
callee_method
->
code_size_for_inlining
()
<=
MaxTrivialSize
)
return
NULL
;
...
@@ -278,18 +290,6 @@ const char* InlineTree::should_not_inline(ciMethod *callee_method, ciMethod* cal
...
@@ -278,18 +290,6 @@ const char* InlineTree::should_not_inline(ciMethod *callee_method, ciMethod* cal
}
}
}
}
if
(
callee_method
->
should_not_inline
())
{
return
"disallowed by CompilerOracle"
;
}
if
(
UseStringCache
)
{
// Do not inline StringCache::profile() method used only at the beginning.
if
(
callee_method
->
name
()
==
ciSymbol
::
profile_name
()
&&
callee_method
->
holder
()
->
name
()
==
ciSymbol
::
java_lang_StringCache
())
{
return
"profiling method"
;
}
}
return
NULL
;
return
NULL
;
}
}
...
...
src/share/vm/opto/c2_globals.hpp
浏览文件 @
f317413f
/*
/*
* Copyright (c) 2000, 201
1
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 201
2
, 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
...
@@ -465,6 +465,9 @@
...
@@ -465,6 +465,9 @@
notproduct(bool, PrintOptimizePtrCompare, false, \
notproduct(bool, PrintOptimizePtrCompare, false, \
"Print information about optimized pointers compare") \
"Print information about optimized pointers compare") \
\
\
notproduct(bool, VerifyConnectionGraph , true, \
"Verify Connection Graph construction in Escape Analysis") \
\
product(bool, UseOptoBiasInlining, true, \
product(bool, UseOptoBiasInlining, true, \
"Generate biased locking code in C2 ideal graph") \
"Generate biased locking code in C2 ideal graph") \
\
\
...
...
src/share/vm/opto/callnode.cpp
浏览文件 @
f317413f
/*
/*
* Copyright (c) 1997, 201
0
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 201
2
, 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
...
@@ -1538,10 +1538,7 @@ Node *LockNode::Ideal(PhaseGVN *phase, bool can_reshape) {
...
@@ -1538,10 +1538,7 @@ Node *LockNode::Ideal(PhaseGVN *phase, bool can_reshape) {
// If we are locking an unescaped object, the lock/unlock is unnecessary
// If we are locking an unescaped object, the lock/unlock is unnecessary
//
//
ConnectionGraph
*
cgr
=
phase
->
C
->
congraph
();
ConnectionGraph
*
cgr
=
phase
->
C
->
congraph
();
PointsToNode
::
EscapeState
es
=
PointsToNode
::
GlobalEscape
;
if
(
cgr
!=
NULL
&&
cgr
->
not_global_escape
(
obj_node
()))
{
if
(
cgr
!=
NULL
)
es
=
cgr
->
escape_state
(
obj_node
());
if
(
es
!=
PointsToNode
::
UnknownEscape
&&
es
!=
PointsToNode
::
GlobalEscape
)
{
assert
(
!
is_eliminated
()
||
is_coarsened
(),
"sanity"
);
assert
(
!
is_eliminated
()
||
is_coarsened
(),
"sanity"
);
// The lock could be marked eliminated by lock coarsening
// The lock could be marked eliminated by lock coarsening
// code during first IGVN before EA. Replace coarsened flag
// code during first IGVN before EA. Replace coarsened flag
...
@@ -1680,10 +1677,7 @@ Node *UnlockNode::Ideal(PhaseGVN *phase, bool can_reshape) {
...
@@ -1680,10 +1677,7 @@ Node *UnlockNode::Ideal(PhaseGVN *phase, bool can_reshape) {
// If we are unlocking an unescaped object, the lock/unlock is unnecessary.
// If we are unlocking an unescaped object, the lock/unlock is unnecessary.
//
//
ConnectionGraph
*
cgr
=
phase
->
C
->
congraph
();
ConnectionGraph
*
cgr
=
phase
->
C
->
congraph
();
PointsToNode
::
EscapeState
es
=
PointsToNode
::
GlobalEscape
;
if
(
cgr
!=
NULL
&&
cgr
->
not_global_escape
(
obj_node
()))
{
if
(
cgr
!=
NULL
)
es
=
cgr
->
escape_state
(
obj_node
());
if
(
es
!=
PointsToNode
::
UnknownEscape
&&
es
!=
PointsToNode
::
GlobalEscape
)
{
assert
(
!
is_eliminated
()
||
is_coarsened
(),
"sanity"
);
assert
(
!
is_eliminated
()
||
is_coarsened
(),
"sanity"
);
// The lock could be marked eliminated by lock coarsening
// The lock could be marked eliminated by lock coarsening
// code during first IGVN before EA. Replace coarsened flag
// code during first IGVN before EA. Replace coarsened flag
...
...
src/share/vm/opto/callnode.hpp
浏览文件 @
f317413f
/*
/*
* Copyright (c) 1997, 201
1
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 201
2
, 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
...
@@ -546,6 +546,12 @@ public:
...
@@ -546,6 +546,12 @@ public:
// or result projection is there are several CheckCastPP
// or result projection is there are several CheckCastPP
// or returns NULL if there is no one.
// or returns NULL if there is no one.
Node
*
result_cast
();
Node
*
result_cast
();
// Does this node returns pointer?
bool
returns_pointer
()
const
{
const
TypeTuple
*
r
=
tf
()
->
range
();
return
(
r
->
cnt
()
>
TypeFunc
::
Parms
&&
r
->
field_at
(
TypeFunc
::
Parms
)
->
isa_ptr
());
}
// Collect all the interesting edges from a call for use in
// Collect all the interesting edges from a call for use in
// replacing the call by something else. Used by macro expansion
// replacing the call by something else. Used by macro expansion
...
...
src/share/vm/opto/compile.cpp
浏览文件 @
f317413f
/*
/*
* Copyright (c) 1997, 201
1
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 201
2
, 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
...
@@ -1707,7 +1707,6 @@ void Compile::Optimize() {
...
@@ -1707,7 +1707,6 @@ void Compile::Optimize() {
if
(
major_progress
())
print_method
(
"PhaseIdealLoop before EA"
,
2
);
if
(
major_progress
())
print_method
(
"PhaseIdealLoop before EA"
,
2
);
if
(
failing
())
return
;
if
(
failing
())
return
;
}
}
TracePhase
t2
(
"escapeAnalysis"
,
&
_t_escapeAnalysis
,
true
);
ConnectionGraph
::
do_analysis
(
this
,
&
igvn
);
ConnectionGraph
::
do_analysis
(
this
,
&
igvn
);
if
(
failing
())
return
;
if
(
failing
())
return
;
...
@@ -1719,6 +1718,7 @@ void Compile::Optimize() {
...
@@ -1719,6 +1718,7 @@ void Compile::Optimize() {
if
(
failing
())
return
;
if
(
failing
())
return
;
if
(
congraph
()
!=
NULL
&&
macro_count
()
>
0
)
{
if
(
congraph
()
!=
NULL
&&
macro_count
()
>
0
)
{
NOT_PRODUCT
(
TracePhase
t2
(
"macroEliminate"
,
&
_t_macroEliminate
,
TimeCompiler
);
)
PhaseMacroExpand
mexp
(
igvn
);
PhaseMacroExpand
mexp
(
igvn
);
mexp
.
eliminate_macro_nodes
();
mexp
.
eliminate_macro_nodes
();
igvn
.
set_delay_transform
(
false
);
igvn
.
set_delay_transform
(
false
);
...
@@ -1875,10 +1875,10 @@ void Compile::Code_Gen() {
...
@@ -1875,10 +1875,10 @@ void Compile::Code_Gen() {
cfg
.
Estimate_Block_Frequency
();
cfg
.
Estimate_Block_Frequency
();
cfg
.
GlobalCodeMotion
(
m
,
unique
(),
proj_list
);
cfg
.
GlobalCodeMotion
(
m
,
unique
(),
proj_list
);
if
(
failing
())
return
;
print_method
(
"Global code motion"
,
2
);
print_method
(
"Global code motion"
,
2
);
if
(
failing
())
return
;
NOT_PRODUCT
(
verify_graph_edges
();
)
NOT_PRODUCT
(
verify_graph_edges
();
)
debug_only
(
cfg
.
verify
();
)
debug_only
(
cfg
.
verify
();
)
...
...
src/share/vm/opto/escape.cpp
浏览文件 @
f317413f
此差异已折叠。
点击以展开。
src/share/vm/opto/escape.hpp
浏览文件 @
f317413f
此差异已折叠。
点击以展开。
src/share/vm/opto/phase.cpp
浏览文件 @
f317413f
/*
/*
* Copyright (c) 1997, 201
1
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 201
2
, 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
...
@@ -39,8 +39,9 @@ elapsedTimer Phase::_t_stubCompilation;
...
@@ -39,8 +39,9 @@ elapsedTimer Phase::_t_stubCompilation;
// The next timers used for LogCompilation
// The next timers used for LogCompilation
elapsedTimer
Phase
::
_t_parser
;
elapsedTimer
Phase
::
_t_parser
;
elapsedTimer
Phase
::
_t_escapeAnalysis
;
elapsedTimer
Phase
::
_t_optimizer
;
elapsedTimer
Phase
::
_t_optimizer
;
elapsedTimer
Phase
::
_t_escapeAnalysis
;
elapsedTimer
Phase
::
_t_connectionGraph
;
elapsedTimer
Phase
::
_t_idealLoop
;
elapsedTimer
Phase
::
_t_idealLoop
;
elapsedTimer
Phase
::
_t_ccp
;
elapsedTimer
Phase
::
_t_ccp
;
elapsedTimer
Phase
::
_t_matcher
;
elapsedTimer
Phase
::
_t_matcher
;
...
@@ -51,6 +52,7 @@ elapsedTimer Phase::_t_output;
...
@@ -51,6 +52,7 @@ elapsedTimer Phase::_t_output;
elapsedTimer
Phase
::
_t_graphReshaping
;
elapsedTimer
Phase
::
_t_graphReshaping
;
elapsedTimer
Phase
::
_t_scheduler
;
elapsedTimer
Phase
::
_t_scheduler
;
elapsedTimer
Phase
::
_t_blockOrdering
;
elapsedTimer
Phase
::
_t_blockOrdering
;
elapsedTimer
Phase
::
_t_macroEliminate
;
elapsedTimer
Phase
::
_t_macroExpand
;
elapsedTimer
Phase
::
_t_macroExpand
;
elapsedTimer
Phase
::
_t_peephole
;
elapsedTimer
Phase
::
_t_peephole
;
elapsedTimer
Phase
::
_t_codeGeneration
;
elapsedTimer
Phase
::
_t_codeGeneration
;
...
@@ -104,6 +106,8 @@ void Phase::print_timers() {
...
@@ -104,6 +106,8 @@ void Phase::print_timers() {
if
(
DoEscapeAnalysis
)
{
if
(
DoEscapeAnalysis
)
{
// EA is part of Optimizer.
// EA is part of Optimizer.
tty
->
print_cr
(
" escape analysis: %3.3f sec"
,
Phase
::
_t_escapeAnalysis
.
seconds
());
tty
->
print_cr
(
" escape analysis: %3.3f sec"
,
Phase
::
_t_escapeAnalysis
.
seconds
());
tty
->
print_cr
(
" connection graph: %3.3f sec"
,
Phase
::
_t_connectionGraph
.
seconds
());
tty
->
print_cr
(
" macroEliminate : %3.3f sec"
,
Phase
::
_t_macroEliminate
.
seconds
());
}
}
tty
->
print_cr
(
" iterGVN : %3.3f sec"
,
Phase
::
_t_iterGVN
.
seconds
());
tty
->
print_cr
(
" iterGVN : %3.3f sec"
,
Phase
::
_t_iterGVN
.
seconds
());
tty
->
print_cr
(
" idealLoop : %3.3f sec"
,
Phase
::
_t_idealLoop
.
seconds
());
tty
->
print_cr
(
" idealLoop : %3.3f sec"
,
Phase
::
_t_idealLoop
.
seconds
());
...
@@ -112,9 +116,10 @@ void Phase::print_timers() {
...
@@ -112,9 +116,10 @@ void Phase::print_timers() {
tty
->
print_cr
(
" iterGVN2 : %3.3f sec"
,
Phase
::
_t_iterGVN2
.
seconds
());
tty
->
print_cr
(
" iterGVN2 : %3.3f sec"
,
Phase
::
_t_iterGVN2
.
seconds
());
tty
->
print_cr
(
" macroExpand : %3.3f sec"
,
Phase
::
_t_macroExpand
.
seconds
());
tty
->
print_cr
(
" macroExpand : %3.3f sec"
,
Phase
::
_t_macroExpand
.
seconds
());
tty
->
print_cr
(
" graphReshape : %3.3f sec"
,
Phase
::
_t_graphReshaping
.
seconds
());
tty
->
print_cr
(
" graphReshape : %3.3f sec"
,
Phase
::
_t_graphReshaping
.
seconds
());
double
optimizer_subtotal
=
Phase
::
_t_iterGVN
.
seconds
()
+
double
optimizer_subtotal
=
Phase
::
_t_iterGVN
.
seconds
()
+
Phase
::
_t_iterGVN2
.
seconds
()
+
Phase
::
_t_escapeAnalysis
.
seconds
()
+
Phase
::
_t_macroEliminate
.
seconds
()
+
Phase
::
_t_idealLoop
.
seconds
()
+
Phase
::
_t_ccp
.
seconds
()
+
Phase
::
_t_idealLoop
.
seconds
()
+
Phase
::
_t_ccp
.
seconds
()
+
Phase
::
_t_graphReshaping
.
seconds
();
Phase
::
_t_
macroExpand
.
seconds
()
+
Phase
::
_t_
graphReshaping
.
seconds
();
double
percent_of_optimizer
=
((
optimizer_subtotal
==
0.0
)
?
0.0
:
(
optimizer_subtotal
/
Phase
::
_t_optimizer
.
seconds
()
*
100.0
));
double
percent_of_optimizer
=
((
optimizer_subtotal
==
0.0
)
?
0.0
:
(
optimizer_subtotal
/
Phase
::
_t_optimizer
.
seconds
()
*
100.0
));
tty
->
print_cr
(
" subtotal : %3.3f sec, %3.2f %%"
,
optimizer_subtotal
,
percent_of_optimizer
);
tty
->
print_cr
(
" subtotal : %3.3f sec, %3.2f %%"
,
optimizer_subtotal
,
percent_of_optimizer
);
}
}
...
...
src/share/vm/opto/phase.hpp
浏览文件 @
f317413f
/*
/*
* Copyright (c) 1997, 201
0
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 201
2
, 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
...
@@ -72,8 +72,12 @@ protected:
...
@@ -72,8 +72,12 @@ protected:
// The next timers used for LogCompilation
// The next timers used for LogCompilation
static
elapsedTimer
_t_parser
;
static
elapsedTimer
_t_parser
;
static
elapsedTimer
_t_escapeAnalysis
;
static
elapsedTimer
_t_optimizer
;
static
elapsedTimer
_t_optimizer
;
public:
// ConnectionGraph can't be Phase since it is used after EA done.
static
elapsedTimer
_t_escapeAnalysis
;
static
elapsedTimer
_t_connectionGraph
;
protected:
static
elapsedTimer
_t_idealLoop
;
static
elapsedTimer
_t_idealLoop
;
static
elapsedTimer
_t_ccp
;
static
elapsedTimer
_t_ccp
;
static
elapsedTimer
_t_matcher
;
static
elapsedTimer
_t_matcher
;
...
@@ -84,6 +88,7 @@ protected:
...
@@ -84,6 +88,7 @@ protected:
static
elapsedTimer
_t_graphReshaping
;
static
elapsedTimer
_t_graphReshaping
;
static
elapsedTimer
_t_scheduler
;
static
elapsedTimer
_t_scheduler
;
static
elapsedTimer
_t_blockOrdering
;
static
elapsedTimer
_t_blockOrdering
;
static
elapsedTimer
_t_macroEliminate
;
static
elapsedTimer
_t_macroExpand
;
static
elapsedTimer
_t_macroExpand
;
static
elapsedTimer
_t_peephole
;
static
elapsedTimer
_t_peephole
;
static
elapsedTimer
_t_codeGeneration
;
static
elapsedTimer
_t_codeGeneration
;
...
...
src/share/vm/runtime/arguments.cpp
浏览文件 @
f317413f
...
@@ -2523,15 +2523,6 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args,
...
@@ -2523,15 +2523,6 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args,
// was arrived at by experimenting with specjbb.
// was arrived at by experimenting with specjbb.
FLAG_SET_CMDLINE
(
uintx
,
OldPLABSize
,
8
*
K
);
// Note: this is in words
FLAG_SET_CMDLINE
(
uintx
,
OldPLABSize
,
8
*
K
);
// Note: this is in words
// CompilationPolicyChoice=0 causes the server compiler to adopt
// a more conservative which-method-do-I-compile policy when one
// of the counters maintained by the interpreter trips. The
// result is reduced startup time and improved specjbb and
// alacrity performance. Zero is the default, but we set it
// explicitly here in case the default changes.
// See runtime/compilationPolicy.*.
FLAG_SET_CMDLINE
(
intx
,
CompilationPolicyChoice
,
0
);
// Enable parallel GC and adaptive generation sizing
// Enable parallel GC and adaptive generation sizing
FLAG_SET_CMDLINE
(
bool
,
UseParallelGC
,
true
);
FLAG_SET_CMDLINE
(
bool
,
UseParallelGC
,
true
);
FLAG_SET_DEFAULT
(
ParallelGCThreads
,
FLAG_SET_DEFAULT
(
ParallelGCThreads
,
...
...
src/share/vm/utilities/growableArray.hpp
浏览文件 @
f317413f
/*
/*
* Copyright (c) 1997, 201
1
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 201
2
, 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
...
@@ -198,8 +198,11 @@ template<class E> class GrowableArray : public GenericGrowableArray {
...
@@ -198,8 +198,11 @@ template<class E> class GrowableArray : public GenericGrowableArray {
return
idx
;
return
idx
;
}
}
void
append_if_missing
(
const
E
&
elem
)
{
bool
append_if_missing
(
const
E
&
elem
)
{
if
(
!
contains
(
elem
))
append
(
elem
);
// Returns TRUE if elem is added.
bool
missed
=
!
contains
(
elem
);
if
(
missed
)
append
(
elem
);
return
missed
;
}
}
E
at
(
int
i
)
const
{
E
at
(
int
i
)
const
{
...
@@ -292,12 +295,22 @@ template<class E> class GrowableArray : public GenericGrowableArray {
...
@@ -292,12 +295,22 @@ template<class E> class GrowableArray : public GenericGrowableArray {
ShouldNotReachHere
();
ShouldNotReachHere
();
}
}
// The order is preserved.
void
remove_at
(
int
index
)
{
void
remove_at
(
int
index
)
{
assert
(
0
<=
index
&&
index
<
_len
,
"illegal index"
);
assert
(
0
<=
index
&&
index
<
_len
,
"illegal index"
);
for
(
int
j
=
index
+
1
;
j
<
_len
;
j
++
)
_data
[
j
-
1
]
=
_data
[
j
];
for
(
int
j
=
index
+
1
;
j
<
_len
;
j
++
)
_data
[
j
-
1
]
=
_data
[
j
];
_len
--
;
_len
--
;
}
}
// The order is changed.
void
delete_at
(
int
index
)
{
assert
(
0
<=
index
&&
index
<
_len
,
"illegal index"
);
if
(
index
<
--
_len
)
{
// Replace removed element with last one.
_data
[
index
]
=
_data
[
_len
];
}
}
// inserts the given element before the element at index i
// inserts the given element before the element at index i
void
insert_before
(
const
int
idx
,
const
E
&
elem
)
{
void
insert_before
(
const
int
idx
,
const
E
&
elem
)
{
check_nesting
();
check_nesting
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录