Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
f80d6dc4
R
Rust
项目概览
int
/
Rust
接近 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f80d6dc4
编写于
6月 28, 2013
作者:
G
Graydon Hoare
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rustc: improve -Z trans-stats to report per-fn LLVM instruction counts and translation timing
上级
0c6fc46c
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
66 addition
and
28 deletion
+66
-28
src/librustc/middle/trans/base.rs
src/librustc/middle/trans/base.rs
+54
-11
src/librustc/middle/trans/build.rs
src/librustc/middle/trans/build.rs
+3
-0
src/librustc/middle/trans/common.rs
src/librustc/middle/trans/common.rs
+3
-1
src/librustc/middle/trans/context.rs
src/librustc/middle/trans/context.rs
+3
-7
src/librustc/middle/trans/glue.rs
src/librustc/middle/trans/glue.rs
+3
-9
未找到文件。
src/librustc/middle/trans/base.rs
浏览文件 @
f80d6dc4
...
...
@@ -72,6 +72,7 @@
use
std
::
vec
;
use
std
::
local_data
;
use
extra
::
time
;
use
extra
::
sort
;
use
syntax
::
ast
::
ident
;
use
syntax
::
ast_map
::{
path
,
path_elt_to_str
,
path_name
};
use
syntax
::
ast_util
::{
local_def
,
path_to_ident
};
...
...
@@ -141,6 +142,48 @@ fn fcx_has_nonzero_span(fcx: fn_ctxt) -> bool {
}
}
struct
StatRecorder
<
'self
>
{
ccx
:
@
mut
CrateContext
,
name
:
&
'self
str
,
start
:
u64
,
istart
:
uint
,
}
impl
<
'self
>
StatRecorder
<
'self
>
{
pub
fn
new
(
ccx
:
@
mut
CrateContext
,
name
:
&
'self
str
)
->
StatRecorder
<
'self
>
{
let
start
=
if
ccx
.sess
.trans_stats
()
{
time
::
precise_time_ns
()
}
else
{
0
};
let
istart
=
ccx
.stats.n_llvm_insns
;
StatRecorder
{
ccx
:
ccx
,
name
:
name
,
start
:
start
,
istart
:
istart
,
}
}
}
#[unsafe_destructor]
impl
<
'self
>
Drop
for
StatRecorder
<
'self
>
{
pub
fn
drop
(
&
self
)
{
if
self
.ccx.sess
.trans_stats
()
{
let
end
=
time
::
precise_time_ns
();
let
elapsed
=
((
end
-
self
.start
)
/
1_000_000
)
as
uint
;
let
iend
=
self
.ccx.stats.n_llvm_insns
;
self
.ccx.stats.fn_stats
.push
((
self
.name
.to_owned
(),
elapsed
,
iend
-
self
.istart
));
self
.ccx.stats.n_fns
+=
1
;
// Reset LLVM insn count to avoid compound costs.
self
.ccx.stats.n_llvm_insns
=
self
.istart
;
}
}
}
pub
fn
decl_fn
(
llmod
:
ModuleRef
,
name
:
&
str
,
cc
:
lib
::
llvm
::
CallConv
,
ty
:
Type
)
->
ValueRef
{
let
llfn
:
ValueRef
=
do
name
.as_c_str
|
buf
|
{
unsafe
{
...
...
@@ -1866,18 +1909,16 @@ pub fn trans_fn(ccx: @mut CrateContext,
param_substs
:
Option
<@
param_substs
>
,
id
:
ast
::
node_id
,
attrs
:
&
[
ast
::
attribute
])
{
let
do_time
=
ccx
.sess
.trans_stats
();
let
start
=
if
do_time
{
time
::
get_time
()
}
else
{
time
::
Timespec
::
new
(
0
,
0
)
}
;
let
the_path_str
=
path_str
(
ccx
.sess
,
path
);
let
_
s
=
StatRecorder
::
new
(
ccx
,
the_path_str
)
;
debug!
(
"trans_fn(self_arg=%?, param_substs=%s)"
,
self_arg
,
param_substs
.repr
(
ccx
.tcx
));
let
_
icx
=
push_ctxt
(
"trans_fn"
);
ccx
.stats.n_fns
+=
1
;
let
the_path_str
=
path_str
(
ccx
.sess
,
path
);
let
output_type
=
ty
::
ty_fn_ret
(
ty
::
node_id_to_type
(
ccx
.tcx
,
id
));
trans_closure
(
ccx
,
path
,
copy
path
,
decl
,
body
,
llfndecl
,
...
...
@@ -1893,10 +1934,6 @@ pub fn trans_fn(ccx: @mut CrateContext,
}
},
|
_
bcx
|
{
});
if
do_time
{
let
end
=
time
::
get_time
();
ccx
.log_fn_time
(
the_path_str
,
start
,
end
);
}
}
pub
fn
trans_enum_variant
(
ccx
:
@
mut
CrateContext
,
...
...
@@ -2961,8 +2998,14 @@ pub fn trans_crate(sess: session::Session,
io
::
println
(
fmt!
(
"n_monos: %u"
,
ccx
.stats.n_monos
));
io
::
println
(
fmt!
(
"n_inlines: %u"
,
ccx
.stats.n_inlines
));
io
::
println
(
fmt!
(
"n_closures: %u"
,
ccx
.stats.n_closures
));
io
::
println
(
"fn stats:"
);
do
sort
::
quick_sort
(
ccx
.stats.fn_stats
)
|
&
(
_
,
_
,
insns_a
),
&
(
_
,
_
,
insns_b
)|
{
insns_a
>
insns_b
}
for
ccx
.stats.fn_stats
.iter
()
.advance
|
&
(
name
,
ms
,
insns
)|
{
io
::
println
(
fmt!
(
"%u insns, %u ms, %s"
,
insns
,
ms
,
name
));
}
}
if
ccx
.sess
.count_llvm_insns
()
{
for
ccx
.stats.llvm_insns
.iter
()
.advance
|(
&
k
,
&
v
)|
{
io
::
println
(
fmt!
(
"%-7u %s"
,
v
,
k
));
...
...
src/librustc/middle/trans/build.rs
浏览文件 @
f80d6dc4
...
...
@@ -46,6 +46,9 @@ pub fn B(cx: block) -> BuilderRef {
}
pub
fn
count_insn
(
cx
:
block
,
category
:
&
str
)
{
if
cx
.ccx
()
.sess
.trans_stats
()
{
cx
.ccx
()
.stats.n_llvm_insns
+=
1
;
}
do
base
::
with_insn_ctxt
|
v
|
{
let
h
=
&
mut
cx
.ccx
()
.stats.llvm_insns
;
...
...
src/librustc/middle/trans/common.rs
浏览文件 @
f80d6dc4
...
...
@@ -96,8 +96,10 @@ pub struct Stats {
n_monos
:
uint
,
n_inlines
:
uint
,
n_closures
:
uint
,
n_llvm_insns
:
uint
,
llvm_insn_ctxt
:
~
[
~
str
],
llvm_insns
:
HashMap
<~
str
,
uint
>
,
fn_
times
:
~
[(
~
str
,
int
)]
// (ident, time
)
fn_
stats
:
~
[(
~
str
,
uint
,
uint
)]
// (ident, time-in-ms, llvm-instructions
)
}
pub
struct
BuilderRef_res
{
...
...
src/librustc/middle/trans/context.rs
浏览文件 @
f80d6dc4
...
...
@@ -210,8 +210,10 @@ pub fn new(sess: session::Session,
n_monos
:
0u
,
n_inlines
:
0u
,
n_closures
:
0u
,
n_llvm_insns
:
0u
,
llvm_insn_ctxt
:
~
[],
llvm_insns
:
HashMap
::
new
(),
fn_
time
s
:
~
[]
fn_
stat
s
:
~
[]
},
upcalls
:
upcall
::
declare_upcalls
(
targ_cfg
,
llmod
),
tydesc_type
:
tydesc_type
,
...
...
@@ -226,12 +228,6 @@ pub fn new(sess: session::Session,
}
}
}
pub
fn
log_fn_time
(
&
mut
self
,
name
:
~
str
,
start
:
time
::
Timespec
,
end
:
time
::
Timespec
)
{
let
elapsed
=
1000
*
((
end
.sec
-
start
.sec
)
as
int
)
+
((
end
.nsec
as
int
)
-
(
start
.nsec
as
int
))
/
1000000
;
self
.stats.fn_times
.push
((
name
,
elapsed
));
}
}
#[unsafe_destructor]
...
...
src/librustc/middle/trans/glue.rs
浏览文件 @
f80d6dc4
...
...
@@ -738,15 +738,9 @@ pub fn make_generic_glue(ccx: @mut CrateContext,
name
:
&
str
)
->
ValueRef
{
let
_
icx
=
push_ctxt
(
"make_generic_glue"
);
if
!
ccx
.sess
.trans_stats
()
{
return
make_generic_glue_inner
(
ccx
,
t
,
llfn
,
helper
);
}
let
start
=
time
::
get_time
();
let
llval
=
make_generic_glue_inner
(
ccx
,
t
,
llfn
,
helper
);
let
end
=
time
::
get_time
();
ccx
.log_fn_time
(
fmt!
(
"glue %s %s"
,
name
,
ty_to_short_str
(
ccx
.tcx
,
t
)),
start
,
end
);
return
llval
;
let
glue_name
=
fmt!
(
"glue %s %s"
,
name
,
ty_to_short_str
(
ccx
.tcx
,
t
));
let
_
s
=
StatRecorder
::
new
(
ccx
,
glue_name
);
make_generic_glue_inner
(
ccx
,
t
,
llfn
,
helper
)
}
pub
fn
emit_tydescs
(
ccx
:
&
mut
CrateContext
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录